:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #14171f; --muted: #667085; --line: #e4e7ec;
  --accent: #2f5bea; --accent-ink: #ffffff; --ok: #12805c; --warn: #b54708; --bad: #c4320a;
  --chip: #eef2ff; --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.06);
}
@media (prefers-color-scheme: dark) {
  :root { --bg:#0f1115; --panel:#171a21; --ink:#e7e9ee; --muted:#98a2b3; --line:#2a2f3a; --chip:#1f2640; --shadow:none; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 Inter, system-ui, sans-serif; }
a { color: var(--accent); text-decoration: none; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; word-break: break-all; }

.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 16px; padding: 0 8px 14px; }
.brand span { color: var(--accent); }
.side a { color: var(--ink); padding: 8px 10px; border-radius: 8px; display: flex; justify-content: space-between; }
.side a.on, .side a:hover { background: var(--chip); }
.side .grow { flex: 1; }
.side select { width: 100%; margin-bottom: 12px; }
main { padding: 28px 32px; max-width: 1100px; width: 100%; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 28px 0 10px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.stack { display: grid; gap: 12px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--chip); }

label { display: grid; gap: 6px; font-weight: 500; font-size: 13.5px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }

.btn { font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 14px; border-radius: 8px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--chip); }
.pill.ok { color: var(--ok); } .pill.warn { color: var(--warn); } .pill.bad { color: var(--bad); }
.stats { display: flex; gap: 18px; flex-wrap: wrap; }
.stat b { display: block; font-size: 20px; }

.urlbox { display: flex; gap: 8px; align-items: center; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.urlbox .mono { flex: 1; }
.login { width: 100%; max-width: 380px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 500; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; padding: 10px 16px; border-right: none; border-bottom: 1px solid var(--line); }
  .side .grow, .brand { display: none; }
  main { padding: 18px 16px; }
  .grid2 { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
}

/* Tags page */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 4px; }
.tabs a { padding: 8px 12px; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.sections { display: grid; gap: 12px; }
.section { display: grid; gap: 8px; }
.tagrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tagrow .tname { flex: 1; min-width: 180px; }
.tagrow.sub { margin-left: 32px; }
.tagrow.cand > span:first-child { flex: 1; min-width: 180px; color: var(--muted); padding: 6px 2px; }
.tagrow .full { flex-basis: 100%; font-size: 11.5px; padding-left: 2px; }
.tagrow select { width: auto; }
.icon { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--muted); width: 34px; height: 34px; border-radius: 50%; cursor: pointer; }
.icon:hover { color: var(--ink); }
.icon.danger:hover, .btn.danger { color: #fff; background: var(--bad); border-color: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { width: 100%; max-width: 560px; max-height: 85vh; overflow: auto; }
.preview { max-height: 320px; overflow: auto; font-family: ui-monospace, Menlo, monospace; font-size: 12px; display: grid; gap: 6px; background: var(--bg); padding: 10px; border-radius: 8px; }

/* Tags page v2 (20 Oct): compact, TagGenie-like */
.tagtable th, .tagtable td { padding: 6px 10px; font-size: 13px; }
.gbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.gbar #gname { font-weight: 700; font-size: 15px; width: 300px; padding: 6px 10px; }
.sections { gap: 10px; }
.section { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 14px; align-items: start; }
.seclabel { display: grid; gap: 8px; justify-items: start; font-size: 13px; }
.seclabel .btn.small { font-size: 12px; padding: 3px 9px; }
.secbody { display: grid; gap: 6px; }
.tagrow { gap: 5px; }
.tagrow .tname { padding: 5px 9px; font-size: 13.5px; min-width: 160px; }
.tagrow.sub { margin-left: 28px; }
.tagrow.cand > span:first-child { font-size: 13.5px; padding: 4px 2px; }
.tagrow .btn.small { font-size: 12px; padding: 3px 9px; }
.icon { width: 28px; height: 28px; font-size: 12.5px; }
.tagrow .full { font-size: 11px; }
@media (max-width: 760px) { .section { grid-template-columns: 1fr; } }

.dlist { display: grid; gap: 4px; max-height: 220px; overflow: auto; }
.dlist a { padding: 4px 6px; border-radius: 6px; }
.dlist a:hover { background: var(--chip); }
.modal .btn[data-v] { width: 100%; }
.dlist a.on { background: var(--chip); font-weight: 600; }
