:root {
  --bg: #f7f7f8; --surface: #ffffff; --surface-2: #f2f3f5; --hover: #f5f6f8;
  --text: #16181d; --text-2: #5b616e; --text-3: #8a909c;
  --line: #e6e8ec; --line-2: #d5d8de;
  --accent: #0866ff; --accent-weak: #e8f0ff; --accent-text: #0a58d6;
  --star: #e8a400; --ok: #1a9e5c; --warn: #d98a00; --bad: #d93a3a;
  --bar-track: #eceef1; --bar: #0866ff;
  --shadow: 0 1px 2px rgba(16,24,40,.04), 0 1px 3px rgba(16,24,40,.06);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.14), 0 2px 6px rgba(16,24,40,.08);
  --r: 10px; --r-sm: 7px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1012; --surface: #17181b; --surface-2: #1f2125; --hover: #1d1f23;
    --text: #ececef; --text-2: #a4a8b2; --text-3: #737884;
    --line: #26282d; --line-2: #33363c;
    --accent: #3a86ff; --accent-weak: #172338; --accent-text: #6ea6ff;
    --star: #f2b62e; --ok: #34c27a; --warn: #f0a63a; --bad: #f06464;
    --bar-track: #26282d; --bar: #3a86ff;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 12px 32px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased;
  background: var(--bg); color: var(--text);
}
button, input, select { font: inherit; color: inherit; }
svg { flex: none; }
.num { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }
.muted { color: var(--text-2); }
.err { color: var(--bad); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--hover); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.input, .select {
  height: 32px; padding: 0 10px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: var(--r-sm); font-size: 13px; min-width: 0;
}
.input:focus, .select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.select { padding-right: 26px; appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='none' stroke='%238a909c' stroke-width='1.5'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 9px center; }
.search { position: relative; flex: 1; min-width: 120px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search .input { width: 100%; padding-left: 32px; }
.search kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
kbd { font: 11px ui-monospace, monospace; color: var(--text-3); border: 1px solid var(--line-2); border-radius: 4px; padding: 0 5px; background: var(--surface-2); }

.seg { display: inline-flex; background: var(--surface-2); border-radius: var(--r-sm); padding: 2px; gap: 2px; }
.seg button { height: 28px; padding: 0 10px; border: 0; border-radius: 5px; background: none; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

input[type=checkbox] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; height: 56px; display: flex; align-items: center; gap: 16px;
  padding: 0 20px; background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 15px; letter-spacing: -.01em; white-space: nowrap; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; color: #fff; }
.topbar .spacer { flex: 1; }
.conn { display: inline-flex; align-items: center; gap: 8px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 20%, transparent); }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 220px minmax(0, 1fr) 320px; gap: 20px; padding: 20px; max-width: 1560px; margin: 0 auto; align-items: start; }
.app.no-nav { grid-template-columns: minmax(0, 1fr) 320px; }

/* category nav */
.nav { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 1px; }
.nav .label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 0 10px 8px; }
.nav button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 34px; padding: 0 10px;
  border: 0; background: none; border-radius: var(--r-sm); font-size: 13.5px; color: var(--text-2); cursor: pointer; text-align: left;
}
.nav button:hover { background: var(--surface-2); color: var(--text); }
.nav button.on { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.nav button .n { font-size: 12px; color: var(--text-3); font-weight: 400; }
.nav button .synced { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); margin-left: auto; margin-right: 6px; }

/* panel */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); min-width: 0; }
.panel-head { padding: 18px 20px 0; }
.title-row { display: flex; align-items: flex-start; gap: 12px; }
.title-row h1 { font-size: 20px; line-height: 1.25; font-weight: 650; letter-spacing: -.015em; margin: 0; }
.title-row p { margin: 3px 0 0; font-size: 13px; color: var(--text-2); }
.title-row .actions { margin-left: auto; display: flex; gap: 8px; }

.tabs { display: flex; gap: 20px; margin-top: 14px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative; height: 38px; padding: 0; border: 0; background: none; font-size: 13.5px; font-weight: 500;
  color: var(--text-2); cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--text); }
.tabs button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }
.tabs button .n { color: var(--text-3); font-weight: 400; margin-left: 4px; font-size: 12px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 20px; border-bottom: 1px solid var(--line); }

.progress { height: 2px; background: transparent; overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }

.notice {
  display: flex; align-items: center; gap: 12px; margin: 14px 20px 0; padding: 10px 12px;
  background: var(--accent-weak); border-radius: var(--r-sm); font-size: 13px; color: var(--text);
}
.notice .btn { margin-left: auto; height: 28px; }

/* ---------- list ---------- */
.list-head, .row {
  display: grid; grid-template-columns: 18px 30px minmax(0, 1fr) 170px 18px; gap: 12px; align-items: center; padding: 0 20px;
}
.list-head { height: 34px; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--text-3); border-bottom: 1px solid var(--line); }
.list-head .r { text-align: right; }
.group {
  position: sticky; top: 56px; z-index: 2; display: flex; align-items: baseline; gap: 8px; padding: 14px 20px 6px;
  background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--text); border-bottom: 1px solid var(--line);
}
.group .n { color: var(--text-3); font-weight: 400; }
.group .note { margin-left: auto; font-weight: 400; color: var(--text-3); font-size: 12px; text-align: right; }
.row { min-height: 50px; padding-top: 7px; padding-bottom: 7px; border-bottom: 1px solid var(--line); cursor: pointer; transition: background .08s; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--hover); }
.row.sel { background: var(--accent-weak); }
.rank { font-size: 12px; color: var(--text-3); text-align: right; }
.rank.top { color: var(--accent-text); font-weight: 600; }
.name { min-width: 0; }
.name .t { display: flex; align-items: center; gap: 6px; font-weight: 500; }
.name .t span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name .s { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.star { color: var(--star); }
.pill { font-size: 11px; font-weight: 500; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.pill.hid { background: color-mix(in srgb, #8b5cf6 14%, transparent); color: #8b5cf6; }
.aud { text-align: right; font-size: 13px; }
.aud .na { color: var(--text-3); }
.bar { height: 4px; border-radius: 2px; background: var(--bar-track); margin-top: 6px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--bar); border-radius: 2px; margin-left: auto; }
.st { width: 8px; height: 8px; border-radius: 50%; justify-self: center; background: var(--line-2); }
.st.exact { background: var(--ok); } .st.approx { background: var(--warn); } .st.none, .st.error { background: transparent; box-shadow: inset 0 0 0 1.5px var(--bad); }
.empty { padding: 48px 20px; text-align: center; color: var(--text-2); }
.empty b { display: block; color: var(--text); margin-bottom: 4px; }

/* ---------- tray ---------- */
.tray { position: sticky; top: 76px; display: flex; flex-direction: column; max-height: calc(100vh - 96px); }
.tray-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.tray-head h2 { font-size: 14px; font-weight: 600; margin: 0; }
.count { min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--surface-2); font-size: 12px; font-weight: 600; display: inline-grid; place-items: center; }
.count.on { background: var(--accent); color: #fff; }
.tray-head .btn { margin-left: auto; height: 26px; padding: 0 8px; font-size: 12px; }
.sel-list { flex: 1; overflow: auto; padding: 0 8px; min-height: 60px; }
.sel-item { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 8px; border-radius: var(--r-sm); font-size: 13px; }
.sel-item:hover { background: var(--hover); }
.sel-item span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sel-item small { color: var(--text-3); }
.sel-item button { border: 0; background: none; color: var(--text-3); cursor: pointer; padding: 4px; border-radius: 4px; display: grid; opacity: 0; }
.sel-item:hover button { opacity: 1; }
.sel-item button:hover { color: var(--bad); background: var(--surface-2); }
.sel-empty { padding: 18px 8px; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.tray-foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.copy-group { display: flex; }
.copy-group .btn.primary { flex: 1; justify-content: center; height: 38px; border-radius: var(--r-sm) 0 0 var(--r-sm); font-size: 14px; }
.copy-group .btn.more { height: 38px; width: 36px; justify-content: center; padding: 0; border-radius: 0 var(--r-sm) var(--r-sm) 0; border-left: 1px solid color-mix(in srgb, #fff 30%, var(--accent)); background: var(--accent); border-color: var(--accent); color: #fff; }
.menu { position: relative; }
.menu-pop {
  position: absolute; right: 0; bottom: calc(100% + 6px); min-width: 210px; padding: 4px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg); z-index: 30;
}
.menu-pop button { display: flex; width: 100%; align-items: center; gap: 8px; height: 34px; padding: 0 10px; border: 0; background: none; border-radius: 6px; font-size: 13px; cursor: pointer; text-align: left; }
.menu-pop button:hover { background: var(--surface-2); }
.menu-pop small { margin-left: auto; color: var(--text-3); }
.hint { font-size: 12px; color: var(--text-3); margin: 10px 0 0; line-height: 1.5; }
.sets { border-top: 1px solid var(--line); padding: 12px 16px 14px; }
.sets summary { font-size: 13px; font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.sets summary::-webkit-details-marker { display: none; }
.sets .save { display: flex; gap: 6px; margin-top: 10px; }
.sets .save .input { flex: 1; }
.set-row { display: flex; align-items: center; gap: 6px; height: 32px; font-size: 13px; }
.set-row span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.set-row span:hover { color: var(--accent-text); }
.mobile-bar { display: none; }

/* ---------- search view ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 14px 20px 0; }
.chip { height: 28px; padding: 0 11px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface); font-size: 12.5px; cursor: pointer; }
.chip:hover { border-color: var(--text-3); }
.chip.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.sub-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); padding: 16px 20px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); cursor: pointer; white-space: nowrap; }

/* ---------- dialog / toast ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 32px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(10,12,16,.45); }
.dlg { padding: 22px; }
.dlg h3 { margin: 0 0 4px; font-size: 16px; }
.dlg p { margin: 0 0 16px; font-size: 13px; color: var(--text-2); line-height: 1.55; }
.dlg ol { margin: 0 0 16px; padding-left: 18px; font-size: 13px; color: var(--text-2); line-height: 1.7; }
.dlg a { color: var(--accent-text); }
.dlg .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 12.5px; font-weight: 500; }
.dlg .field .input { width: 100%; height: 36px; }
.dlg .foot { display: flex; justify-content: flex-end; gap: 8px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 12px); opacity: 0; pointer-events: none;
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-radius: 9px; background: var(--text); color: var(--surface);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); transition: opacity .18s, transform .18s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app, .app.no-nav { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 96px; gap: 12px; }
  .nav { position: static; flex-direction: row; overflow-x: auto; scrollbar-width: none; gap: 4px; }
  .nav .label { display: none; }
  .nav button { width: auto; flex: none; border: 1px solid var(--line); background: var(--surface); }
  .nav button .n, .nav button .synced { display: none; }
  .tray { position: fixed; left: 0; right: 0; bottom: 0; top: auto; max-height: 75vh; border-radius: 14px 14px 0 0; box-shadow: var(--shadow-lg); z-index: 25; transform: translateY(calc(100% - 64px)); transition: transform .22s; }
  .tray.open { transform: none; }
  .tray .tray-head, .tray .sel-list, .tray .sets { display: none; }
  .tray.open .tray-head, .tray.open .sel-list, .tray.open .sets { display: flex; }
  .tray.open .sel-list, .tray.open .sets { display: block; }
  .mobile-bar { display: flex; align-items: center; gap: 10px; height: 64px; padding: 0 16px; flex: none; }
  .tray.open .mobile-bar { display: none; }
  .mobile-bar .btn.primary { margin-left: auto; height: 38px; }
  .tray:not(.open) .tray-foot { display: none; }
  .group { top: 56px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 12px; gap: 10px; }
  .brand span { display: none; }
  .panel-head { padding: 16px 14px 0; }
  .title-row { flex-wrap: wrap; }
  .title-row .actions { margin-left: 0; width: 100%; }
  .title-row .actions .btn { flex: 1; justify-content: center; }
  .toolbar { padding: 10px 14px; }
  .toolbar .search { flex-basis: 100%; }
  .toolbar .select { flex: 1; }
  .toolbar .seg { order: 3; width: 100%; overflow-x: auto; }
  .toolbar .seg button { flex: 1; }
  .list-head { display: none; }
  .row { grid-template-columns: 18px minmax(0, 1fr) 92px 10px; padding: 7px 14px; gap: 10px; }
  .row .rank { display: none; }
  .group { padding: 12px 14px 6px; }
  .group .note { display: none; }
  .notice { margin: 12px 14px 0; flex-wrap: wrap; }
  .chips, .sub-label { padding-left: 14px; padding-right: 14px; }
}
.mobile-only { display: none; }
@media (max-width: 1180px) { .mobile-only { display: inline-flex; } }

/* =================== v3 additions =================== */
a { color: inherit; }
.small { font-size: 12.5px; }
.strong { font-weight: 600; }
.push { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bt { border-top: 1px solid var(--line); }
.pb { padding-bottom: 16px; }
.small-title { font-size: 13.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.w-sm { max-width: 200px; }
.ok-text { color: var(--ok); } .danger-text { color: var(--bad) !important; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn.icon.sm { width: 28px; padding: 0; }
.btn.block { width: 100%; justify-content: center; height: 40px; font-size: 14px; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
a.btn { text-decoration: none; }
.toolbar.foot { border-top: 1px solid var(--line); border-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 12.5px; font-weight: 500; }
.field .input, .field .select { width: 100%; height: 38px; font-size: 14px; }
.field textarea.input { height: auto; padding: 9px 10px; line-height: 1.5; resize: vertical; }
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: -4px 0 10px; }
.toast.bad { background: var(--bad); color: #fff; }

/* top bar extras */
.brand { text-decoration: none; }
.crumb { font-size: 13px; font-weight: 600; color: var(--text-2); padding-left: 14px; border-left: 1px solid var(--line-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--text); color: var(--surface); font-size: 12px; font-weight: 600; cursor: pointer; display: inline-grid; place-items: center; flex: none; }
.avatar.sm { width: 28px; height: 28px; font-size: 11.5px; background: var(--surface-2); color: var(--text-2); cursor: default; }
.menu-pop.down { top: calc(100% + 6px); bottom: auto; right: 0; }
.menu-pop a { display: flex; align-items: center; height: 34px; padding: 0 10px; border-radius: 6px; font-size: 13px; text-decoration: none; }
.menu-pop a:hover { background: var(--surface-2); }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-head small { color: var(--text-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.menu.inline { display: inline-block; }
.banner { background: color-mix(in srgb, var(--warn) 14%, var(--surface)); border-bottom: 1px solid color-mix(in srgb, var(--warn) 30%, var(--line)); padding: 9px 20px; font-size: 13px; text-align: center; }
.banner a { color: var(--accent-text); font-weight: 600; }
.skeleton { height: 240px; margin: 16px 20px; border-radius: 8px; background: linear-gradient(90deg, var(--surface-2), var(--hover), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }

/* audiences */
.chips.bt { padding-top: 14px; padding-bottom: 2px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; padding: 16px 20px 20px; }
.pcard { text-align: left; display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); cursor: pointer; transition: border-color .12s, box-shadow .12s, transform .12s; }
.pcard:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.pc-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.pcard p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pc-tags, .tagline { display: flex; flex-wrap: wrap; gap: 4px; }
.pc-tags span, .tagline span { font-size: 11px; padding: 2px 7px; border-radius: 4px; background: var(--surface-2); color: var(--text-2); }
.tagline { margin-top: 10px; align-items: center; font-size: 12px; color: var(--text-3); gap: 6px; }
.pc-foot { margin-top: auto; padding-top: 8px; border-top: 1px solid var(--line); }
.pc-foot b { color: var(--text); }
.btn.back { margin: -4px 0 10px -10px; }
.list-head.bt { margin-top: 0; }

/* auth */
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 380px; }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 21px; letter-spacing: -.015em; margin: 14px 0 6px; }
.auth-brand p { margin: 0; color: var(--text-2); font-size: 13.5px; line-height: 1.5; }
.mark.lg { width: 40px; height: 40px; border-radius: 11px; margin: 0 auto; background: var(--accent); color: #fff; display: grid; place-items: center; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 22px; }
.seg.full { display: flex; margin-bottom: 18px; }
.seg.full button { flex: 1; }
.auth-foot { text-align: center; font-size: 12.5px; margin-top: 16px; }
.done b { display: block; font-size: 15px; margin-bottom: 6px; }
.done p { margin: 0; line-height: 1.55; font-size: 13.5px; }

/* admin */
.app.no-tray { grid-template-columns: 220px minmax(0, 1fr); padding-bottom: 96px; }
.nav button .n:empty { display: none; }
.nav button .n { background: var(--warn); color: #fff; border-radius: 9px; padding: 0 6px; font-weight: 600; font-size: 11px; }
.app:not(.admin) .nav button .n { background: none; color: var(--text-3); padding: 0; font-weight: 400; font-size: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat { padding: 16px 20px; display: flex; flex-direction: column; gap: 2px; }
.stat + .stat { border-left: 1px solid var(--line); }
.stat span { font-size: 12px; color: var(--text-2); font-weight: 500; }
.stat b { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.stat b.ok { color: var(--ok); } .stat b.bad { color: var(--bad); }
.stat small { font-size: 12px; color: var(--text-3); }
.section { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section h3 { margin: 0 0 4px; font-size: 14px; }
.section p { margin: 0 0 12px; font-size: 13px; line-height: 1.55; max-width: 640px; }
.row-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.meter { height: 6px; border-radius: 3px; background: var(--bar-track); overflow: hidden; margin-bottom: 10px; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .4s; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; color: var(--text-3); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table th:first-child, .table td:first-child { padding-left: 20px; }
.table th:last-child, .table td:last-child { padding-right: 20px; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--hover); }
.table .r { text-align: right; }
.user { display: flex; align-items: center; gap: 10px; }
.user b { font-weight: 500; display: block; }
.user small { color: var(--text-3); font-size: 12px; }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 13%, transparent); color: var(--bad); }
.pill.acc { background: var(--accent-weak); color: var(--accent-text); }
.menu-pop.right { right: 0; left: auto; }
.menu-pop button.danger-text:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }

.form { padding: 0 20px; }
.form-row { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.form-label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; }
.form-label span { color: var(--text-2); font-size: 12.5px; line-height: 1.5; }
.form-ctl { display: flex; flex-direction: column; gap: 8px; justify-content: center; }
.form-ctl .input { height: 36px; width: 100%; max-width: 460px; }
.form-foot { display: flex; align-items: center; gap: 10px; padding: 16px 0 20px; flex-wrap: wrap; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; width: fit-content; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i { width: 34px; height: 20px; border-radius: 10px; background: var(--line-2); position: relative; transition: background .15s; flex: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.switch input:checked + i { background: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }

.editor { padding: 18px 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.ed-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ed-grid .field { margin: 0; }
.ed-card { border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg); }
.ed-head { display: flex; gap: 6px; align-items: center; }
.ed-head .grow { flex: 1; font-weight: 600; }
.ed-card textarea { width: 100%; height: auto; padding: 8px 10px; line-height: 1.55; resize: vertical; }
.ed-card .input { width: 100%; }
.ed-card .ed-head .input { width: auto; }
.tag-picks { display: flex; flex-wrap: wrap; gap: 6px; font-weight: 400; }
.tp { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: 14px; font-size: 12.5px; cursor: pointer; background: var(--surface); }
.tp:has(input:checked) { border-color: var(--accent); background: var(--accent-weak); color: var(--accent-text); }
.tp input { width: 13px; height: 13px; }
.editor > .btn { align-self: flex-start; }
.savebar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(900px, calc(100vw - 24px)); display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px 10px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 30; font-size: 13px; }
.savebar.is-dirty { border-color: var(--accent); }
.savebar.is-dirty > span { font-weight: 600; }
.savebar label.btn { cursor: pointer; }

@media (max-width: 1180px) {
  .app.no-tray { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--line); }
}
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; gap: 10px; }
  .ed-grid { grid-template-columns: 1fr; }
  .cards { padding: 14px; grid-template-columns: 1fr; }
  .crumb, .topbar > a.btn { display: none; }
  .savebar > span { width: 100%; }
  .savebar .push { margin-left: 0; }
  #locale { display: none; }
}
body:has(.savebar:not(.hide)) .toast { bottom: 84px; }
.list-head.bt { border-top: 1px solid var(--line); }

/* Claude / MCP page */
.newkey { margin-top: 12px; padding: 12px; border: 1px solid var(--accent); background: var(--accent-weak); border-radius: var(--r); }
.nk-head { font-size: 13px; margin-bottom: 8px; }
.codeline { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); min-width: 0; }
.newkey .codeline { background: var(--surface); }
.codeline code { flex: 1; font: 12.5px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; padding: 4px 0; }
.howto { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.howto > div { min-width: 0; border: 1px solid var(--line); border-radius: var(--r); padding: 14px; }
.howto b { font-size: 13.5px; }
.howto ol { margin: 8px 0 10px; padding-left: 18px; font-size: 13px; color: var(--text-2); line-height: 1.6; }
.note-line { margin: 12px 0 0 !important; }
.examples { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); line-height: 1.8; }
.table.flush th:first-child, .table.flush td:first-child { padding-left: 0; }
.table.flush th:last-child, .table.flush td:last-child { padding-right: 0; }
.table td.wrap { white-space: normal; min-width: 240px; }
@media (max-width: 900px) { .howto { grid-template-columns: 1fr; } }
.menu-head { text-align: left; align-items: flex-start; }
.menu-head small { margin-left: 0; }
