:root {
  color-scheme: dark;
  --bg0: #1e1b4b;
  --bg1: #312e81;
  --bg2: #4c1d95;
  --panel: rgba(255, 255, 255, 0.07);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --line: rgba(255, 255, 255, 0.16);
  --text: #ede9fe;
  --muted: #c4b5fd;
  --accent: #7c3aed;
  --accent-hi: #8b5cf6;
  --green: #22c55e;
  --red: #f87171;
  --radius: 16px;
}
* { box-sizing: border-box; margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
  background: linear-gradient(160deg, var(--bg0) 0%, var(--bg1) 55%, var(--bg2) 130%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100dvh;
  padding: 0 14px 40px;
}
/* The hidden attribute must beat component display rules (flex/grid) —
   the lock view toggles whole regions with it. Same lesson as .editor. */
[hidden] { display: none !important; }
a { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
code { background: rgba(0,0,0,.35); padding: 1px 6px; border-radius: 6px; font-size: .85em; }

/* --- header --- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 2px;
  background: linear-gradient(160deg, rgba(30,27,75,.92), rgba(49,46,129,.92));
  backdrop-filter: blur(8px);
}
.brand { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; margin-right: auto; }
.brand-mark { font-size: 26px; }
.tabs { display: flex; gap: 6px; align-items: center; }
.tab {
  /* One identical box for every header nav item — the <button> tabs and the
     <a> Extension link alike — so they share height, padding and vertical
     centering instead of the link drifting out of line. */
  display: inline-flex; align-items: center; justify-content: center;
  height: 36px; padding: 0 14px; line-height: 1; white-space: nowrap;
  background: transparent; border: 1px solid transparent; border-radius: 999px;
  font-weight: 600; cursor: pointer; text-decoration: none; color: var(--muted);
}
.tab.active { background: var(--panel-strong); color: var(--text); border-color: var(--line); }
.acting { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); font-weight: 600; }
.acting select { height: 36px; padding-top: 0; padding-bottom: 0; }
select {
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 9px; color: var(--text); max-width: 100%;
}
select option, select optgroup { color: #111; }

main { max-width: 1080px; margin: 0 auto; }
h2 { margin: 26px 0 8px; font-size: 20px; }
.muted { color: var(--muted); line-height: 1.5; max-width: 65ch; }

/* --- people --- */
.people-row { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 4px; }
/* The Lists-view people row is for VIEWING (browsing someone's lists); the
   Settings "You are…" chips are the ACTING identity. The caption plus the
   ghost style below keep the two rows from reading as the same control. */
.row-caption {
  margin: 18px 0 0; font-size: 12px; font-weight: 800;
  letter-spacing: .07em; text-transform: uppercase; color: var(--muted);
}
.row-caption .note { letter-spacing: 0; text-transform: none; font-weight: 600; opacity: .8; }
#view-lists .people-row { margin-top: 8px; }
#people-row .person-chip { background: transparent; }
#people-row .person-chip.selected { background: var(--panel); }
.person-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--panel); border: 2px solid var(--line); border-radius: 999px;
  padding: 8px 15px 8px 10px; font-weight: 700; cursor: pointer; font-size: 15px;
}
.person-chip .avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 15px; background: rgba(0,0,0,.3);
}
.person-chip.selected { border-color: var(--pc, var(--accent-hi)); background: var(--panel-strong); }

/* --- lists --- */
.lists-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.list-pills { display: flex; gap: 7px; flex-wrap: wrap; }
.list-pill {
  background: transparent; border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 7px 13px; font-weight: 600; cursor: pointer;
}
.list-pill.open { background: var(--accent); border-color: var(--accent); color: #fff; }
.list-pill .cnt { opacity: .75; font-size: .85em; margin-left: 4px; }
.new-list { display: flex; gap: 6px; margin-left: auto; }
.new-list input {
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 170px;
}
.list-manage { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; font-size: 14px; color: var(--muted); min-height: 20px; }
.list-manage .lm-name { font-weight: 700; color: var(--text); }

/* --- buttons --- */
.btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: 12px;
  padding: 9px 16px; font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:active { background: var(--accent-hi); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 11px; border-radius: 10px; font-size: 13px; }
.btn.danger { border-color: rgba(248,113,113,.5); color: #fecaca; }
.btn:disabled { opacity: .55; cursor: wait; }

/* --- add form --- */
.add-form {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px;
}
.add-row { display: flex; gap: 9px; }
.add-row.sub { margin-top: 10px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
#add-url {
  flex: 1; min-width: 0; background: rgba(0,0,0,.35); border: 1px solid var(--line);
  border-radius: 12px; padding: 11px 12px; font-size: 16px;
}
.hint { font-size: 13px; }

/* --- items --- */
.items-grid {
  display: grid; gap: 14px; margin-top: 18px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
@media (max-width: 560px) {
  .items-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
  .brand { font-size: 21px; }
}
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
}
.card .thumb {
  aspect-ratio: 4 / 3; background: rgba(0,0,0,.3); display: grid; place-items: center;
  font-size: 44px; overflow: hidden;
}
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 7px; flex: 1; }
.card h3 { font-size: 15px; line-height: 1.35; font-weight: 700; }
.card h3 a { color: var(--text); text-decoration: none; }
.title-clamp {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
  background: rgba(0,0,0,.35); border: 1px solid var(--line); color: var(--muted);
}
.prices { font-size: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.prices .now { font-weight: 800; font-size: 16px; }
.prices .was { color: var(--muted); }
.badge-drop {
  background: rgba(34,197,94,.18); border: 1px solid rgba(34,197,94,.55); color: #bbf7d0;
  font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px;
}
.badge-up {
  background: rgba(248,113,113,.14); border: 1px solid rgba(248,113,113,.45); color: #fecaca;
  font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px;
}
.card .note { font-size: 13.5px; color: var(--muted); line-height: 1.4; }
.card .meta { font-size: 12px; color: var(--muted); margin-top: auto; }
.card .actions { display: flex; gap: 6px; margin-top: 9px; }
.card .actions .spacer { flex: 1; }
.icon-btn {
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 9px;
  padding: 6px 10px; cursor: pointer; font-size: 13px; font-weight: 600; text-decoration: none; color: var(--text);
}
.editor { display: flex; flex-direction: column; gap: 8px; width: 100%; }
/* The hidden attribute must win over the flex display above — without
   this, every editor renders open (the original "giant edit panel" bug). */
.editor[hidden] { display: none; }
.editor input, .editor select {
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 9px; padding: 8px 9px; width: 100%;
}
.editor label { font-size: 12px; color: var(--muted); font-weight: 700; display: block; margin-bottom: 3px; }
.editor .actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* --- items toolbar + view toggle (polish pass) --- */
.items-toolbar { display: flex; align-items: center; gap: 10px; margin-top: 16px; min-height: 34px; }
.items-toolbar .hint { flex: 1; color: var(--muted); font-size: 13px; }
.view-toggle {
  display: inline-flex; gap: 2px; padding: 3px;
  background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 999px;
}
.vt-btn {
  background: transparent; border: 0; border-radius: 999px; padding: 6px 13px;
  font-weight: 700; font-size: 13.5px; color: var(--muted); cursor: pointer;
}
.vt-btn.active { background: var(--accent); color: #fff; }

/* --- list view rows (polish pass) --- */
.items-grid.mode-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex; align-items: center; gap: 11px; flex-wrap: wrap;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 8px 11px;
}
.row-thumb {
  width: 46px; height: 46px; flex: none; border-radius: 9px; overflow: hidden;
  background: rgba(0,0,0,.3); display: grid; place-items: center; font-size: 22px;
}
.row-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.row-title {
  color: var(--text); text-decoration: none; font-weight: 700; font-size: 14.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-price { display: flex; gap: 7px; align-items: center; font-size: 14px; white-space: nowrap; }
.row-price .now { font-weight: 800; font-size: 15px; }
.row-price .was { color: var(--muted); }
.row-actions { display: flex; gap: 6px; }
.item-row .editor { flex-basis: 100%; }
@media (max-width: 560px) {
  .row-thumb { width: 40px; height: 40px; font-size: 19px; }
  .row-actions .icon-btn { padding: 6px 8px; font-size: 12.5px; }
}

.empty {
  margin-top: 18px; border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 28px 18px; text-align: center; color: var(--muted); line-height: 1.55;
}
.empty .big { font-size: 38px; display: block; margin-bottom: 8px; }

.foot { text-align: center; color: var(--muted); font-size: 12.5px; margin-top: 36px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #171233; border: 1px solid var(--line); color: var(--text);
  padding: 11px 17px; border-radius: 12px; font-weight: 600; font-size: 14.5px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); z-index: 50; max-width: min(92vw, 520px); text-align: center;
}
.toast.error { border-color: rgba(248,113,113,.6); color: #fecaca; }

/* --- settings: extension connect codes --- */
.ext-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.ext-row > .person-chip { flex: none; }
.ext-row-label { color: var(--muted); font-size: 13.5px; flex: 1 1 160px; min-width: 0; }
.ext-row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.ext-row-btns .btn { white-space: nowrap; }
/* Mid widths and down: the two buttons take their own row under chip + label
   instead of squeezing against (or off) the right edge. */
@media (max-width: 900px) {
  .ext-row-btns { flex-basis: 100%; margin-left: 0; }
}
@media (max-width: 560px) {
  .ext-row-btns .btn { flex: 1 1 100%; white-space: normal; }
}
.ext-token-box {
  margin-top: 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; line-height: 1.55;
}
.ext-token-row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.ext-token-row input {
  flex: 1; min-width: 0; background: rgba(0,0,0,.35); border: 1px solid var(--line);
  border-radius: 10px; padding: 9px 11px; color: var(--text);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px;
}

/* --- phase 4: alerts, alternates, notifications --- */
.badge {
  display: inline-grid; place-items: center; min-width: 19px; height: 19px;
  padding: 0 5px; margin-left: 6px; border-radius: 999px; vertical-align: 2px;
  background: var(--green); color: #052e12; font-size: 11.5px; font-weight: 800;
}
.badge[hidden] { display: none; }
.alerts-head { display: flex; align-items: center; gap: 10px; margin-top: 26px; }
.alerts-head h2 { margin: 0; flex: 1; }
.alerts-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.alert-row {
  display: flex; gap: 12px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 11px 13px;
}
.alert-row.unseen { border-color: rgba(34,197,94,.55); background: rgba(34,197,94,.07); }
.alert-row.seen { opacity: .72; }
.alert-thumb {
  width: 56px; height: 56px; flex: none; border-radius: 10px; overflow: hidden;
  background: rgba(0,0,0,.3); display: grid; place-items: center; font-size: 26px;
}
.alert-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.alert-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.alert-body h3 { font-size: 14.5px; line-height: 1.35; }
.alert-body h3 a { color: var(--text); text-decoration: none; }
.alert-body .meta { font-size: 12px; color: var(--muted); }
.alts { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.alts .alt { color: var(--muted); text-decoration: none; border-bottom: 1px dotted rgba(255,255,255,.35); white-space: nowrap; }
.alts .alt:hover { color: var(--text); }
.alts .alt-sep { opacity: .6; }
.switch-row { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-top: 6px; cursor: pointer; }
.switch-row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--accent); cursor: pointer; }
.switch-row input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .5; }

/* --- v0.7.0: adult-list lock --- */
.lock-badge { font-size: 12px; margin-left: 2px; }
.lock-panel {
  margin-top: 16px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px 18px; text-align: center;
}
.lock-panel .lock-emoji { font-size: 40px; }
.lock-panel h3 { margin: 8px 0 6px; font-size: 19px; }
.lock-panel .muted { margin: 0 auto; }
.lock-form { display: flex; gap: 9px; justify-content: center; margin-top: 14px; flex-wrap: wrap; }
.lock-form input {
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 12px;
  padding: 11px 12px; font-size: 16px; min-width: 0; width: 260px; max-width: 100%;
}
.lock-error { color: #fecaca; font-weight: 600; margin-top: 10px; font-size: 14px; }
.lock-set-form { display: flex; flex-direction: column; gap: 9px; margin-top: 12px; max-width: 420px; }
.lock-set-form label { font-size: 12px; color: var(--muted); font-weight: 700; display: block; margin-bottom: 3px; }
.lock-set-form input {
  background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; width: 100%;
}
.lock-set-form .actions { display: flex; gap: 6px; }
