:root {
  /* shared tokens */
  --cyan: #2ee6a6;
  --cyan-dim: rgba(46, 230, 166, 0.14);
  --amber: #ffb020;
  --amber-dim: rgba(255, 176, 32, 0.14);
  --rose: #ff5d7a;
  --blue: #5b8cff;
  --blue-dim: rgba(91, 140, 255, 0.14);
  --aihaotan: #2ee6a6;
  --priceai: #5b8cff;
  --radius: 16px;
  --radius-sm: 10px;
  --font: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --display: "Syne", "IBM Plex Sans", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --primary-btn-text: #062317;
  --stock-ok: #7decc0;
  --stock-oos: #ff8aa0;

  /* Midnight (default dark) */
  --ink: #0b1220;
  --ink-2: #121a2b;
  --panel: rgba(18, 26, 43, 0.82);
  --panel-solid: #141d30;
  --line: rgba(148, 163, 184, 0.16);
  --text: #e8eef9;
  --muted: #8b9bb8;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  --topbar-bg: rgba(11, 18, 32, 0.78);
  --surface-soft: rgba(255, 255, 255, 0.03);
  --surface-hover: rgba(255, 255, 255, 0.06);
  --seg-bg: rgba(0, 0, 0, 0.2);
  --seg-active-bg: rgba(255, 255, 255, 0.08);
  --brand-mark-from: #1a2740;
  --brand-mark-to: #0f1728;
  --min-card-from: #152036;
  --min-card-to: #0f1828;
  --grid-line: rgba(91, 140, 255, 0.05);
  --glow-a: rgba(46, 230, 166, 0.18);
  --glow-b: rgba(91, 140, 255, 0.16);
  --glow-c: rgba(255, 176, 32, 0.08);
  --nav-active-fg: #062317;
  --input-bg: rgba(255, 255, 255, 0.03);
  --table-bg: rgba(15, 22, 36, 0.82);
  --table-head: rgba(255, 255, 255, 0.03);
  --table-row-hover: rgba(255, 255, 255, 0.035);
  --table-row-min: rgba(46, 230, 166, 0.08);
  --search-bg: rgba(20, 29, 48, 0.92);
  --search-inset: inset 0 1px 0 rgba(255,255,255,0.04);
  --field-bg: rgba(0, 0, 0, 0.25);
  --placeholder: #5f6f8c;
  --code-bg: rgba(255,255,255,0.05);
  color-scheme: dark;
}

html[data-theme="daylight"] {
  --ink: #f3f6fb;
  --ink-2: #e8eef8;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --line: rgba(15, 23, 42, 0.1);
  --text: #0f172a;
  --muted: #5b6b86;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
  --topbar-bg: rgba(243, 246, 251, 0.86);
  --surface-soft: rgba(15, 23, 42, 0.03);
  --surface-hover: rgba(15, 23, 42, 0.06);
  --seg-bg: rgba(15, 23, 42, 0.05);
  --seg-active-bg: #ffffff;
  --brand-mark-from: #e8f7f1;
  --brand-mark-to: #dce8fb;
  --min-card-from: #ffffff;
  --min-card-to: #f4f8ff;
  --grid-line: rgba(91, 140, 255, 0.08);
  --glow-a: rgba(46, 230, 166, 0.12);
  --glow-b: rgba(91, 140, 255, 0.1);
  --glow-c: rgba(255, 176, 32, 0.08);
  --nav-active-fg: #062317;
  --input-bg: rgba(255, 255, 255, 0.92);
  --table-bg: #ffffff;
  --table-head: #f4f7fb;
  --table-row-hover: rgba(15, 159, 110, 0.06);
  --table-row-min: rgba(15, 159, 110, 0.08);
  --search-bg: #ffffff;
  --search-inset: inset 0 1px 0 rgba(15, 23, 42, 0.02);
  --field-bg: #f4f7fb;
  --placeholder: #8a97ad;
  --code-bg: rgba(15, 23, 42, 0.05);
  --cyan: #0f9f6e;
  --cyan-dim: rgba(15, 159, 110, 0.12);
  --amber: #c47d00;
  --amber-dim: rgba(196, 125, 0, 0.12);
  --blue: #3b6ef5;
  --blue-dim: rgba(59, 110, 245, 0.12);
  --aihaotan: #0f9f6e;
  --priceai: #3b6ef5;
  --stock-ok: #0f9f6e;
  --stock-oos: #d64560;
  --rose: #d64560;
  color-scheme: light;
}

html[data-theme="midnight"] {
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Ensure HTML hidden attribute always wins over display rules */
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; }

.bg-grid {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, #000 20%, transparent 75%);
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 50% 40% at 15% -10%, var(--glow-a), transparent 55%),
    radial-gradient(ellipse 40% 35% at 90% 10%, var(--glow-b), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, var(--glow-c), transparent 55%);
}

.topbar, .shell, .toast-wrap, .loading-bar { position: relative; z-index: 1; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 1rem;
  padding: 0.85rem 1.5rem;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(145deg, var(--brand-mark-from), var(--brand-mark-to));
  border: 1px solid var(--line);
  display: grid; place-items: center; position: relative;
}
.radar-ring {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid rgba(46, 230, 166, 0.35);
  box-shadow: 0 0 0 4px rgba(46, 230, 166, 0.08);
  animation: pulse-ring 2.4s ease-out infinite;
}
.radar-dot {
  position: absolute; width: 7px; height: 7px; border-radius: 50%;
  background: var(--cyan); box-shadow: 0 0 12px var(--cyan);
}
@keyframes pulse-ring {
  0% { transform: scale(0.85); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
.brand-title {
  font-family: var(--display); font-weight: 800; letter-spacing: -0.03em;
  font-size: 1.05rem;
}
.brand-sub { font-size: 0.72rem; color: var(--muted); }

.nav { display: flex; gap: 0.35rem; margin-left: 1rem; }
.nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0.45rem 0.9rem; border-radius: 999px;
  color: var(--muted); font-weight: 500; font-size: 0.9rem;
  transition: 0.15s ease;
  text-decoration: none; border: 0; background: transparent; cursor: pointer;
}
.nav-btn:hover { color: var(--text); background: var(--surface-soft); }
.nav-btn.active {
  color: var(--nav-active-fg); background: var(--cyan); font-weight: 600;
}

.top-status {
  margin-left: 0.5rem; display: flex; align-items: center; gap: 0.45rem;
  font-size: 0.8rem; color: var(--muted);
  padding: 0.35rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(255,255,255,0.02);
}
.top-status .dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan);
}
.top-status.busy .dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: blink 1s infinite; }
.top-status.err .dot { background: var(--rose); box-shadow: 0 0 8px var(--rose); }
@keyframes blink { 50% { opacity: 0.35; } }

.shell {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.75rem 0 4rem;
}

.view { display: none; }
.view.active { display: block; animation: fade-in 0.28s ease; }
@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

h1 {
  font-family: var(--display); font-weight: 800;
  letter-spacing: -0.035em; font-size: clamp(1.7rem, 3.5vw, 2.35rem);
  margin: 0 0 0.5rem; line-height: 1.15;
}
h1 em {
  font-style: normal;
  background: linear-gradient(120deg, var(--cyan), #7cf0c8 40%, var(--amber));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
h2 { margin: 0 0 0.35rem; font-size: 1.1rem; font-weight: 600; }
.lede { color: var(--muted); margin: 0 0 1.25rem; max-width: 52ch; }
.muted { color: var(--muted); font-size: 0.88rem; }
.panel-head {
  display: flex; flex-wrap: wrap; gap: 1rem;
  justify-content: space-between; align-items: flex-start;
  margin-bottom: 1.25rem;
}

.search-bar {
  display: flex; gap: 0.65rem; flex-wrap: wrap;
  margin-bottom: 0.9rem;
}
.search-input-wrap {
  flex: 1 1 280px;
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0 1rem;
  min-height: 52px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--search-bg);
  box-shadow: var(--search-inset);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.search-input-wrap:focus-within {
  border-color: rgba(46, 230, 166, 0.55);
  box-shadow: 0 0 0 4px rgba(46, 230, 166, 0.12);
}
.search-input-wrap svg { color: var(--muted); flex-shrink: 0; }
.search-input-wrap input {
  flex: 1; border: 0; outline: 0; background: transparent;
  min-width: 0; font-size: 1rem; color: var(--text);
}
.search-input-wrap input::placeholder { color: var(--placeholder); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 42px; padding: 0 1.05rem; border-radius: 999px;
  font-weight: 600; font-size: 0.92rem;
  border: 1px solid transparent;
  transition: 0.15s ease;
}
.btn.primary {
  background: linear-gradient(135deg, #2ee6a6, #1fcf93);
  color: var(--primary-btn-text);
  box-shadow: 0 8px 24px rgba(46, 230, 166, 0.22);
}
.btn.primary:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn.ghost {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--text);
}
.btn.ghost:hover { border-color: rgba(148,163,184,0.35); background: var(--surface-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none !important; }

.hot-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-bottom: 0.9rem; }
.hot-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip {
  padding: 0.28rem 0.7rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-soft);
  font-size: 0.82rem; color: var(--muted);
  transition: 0.15s;
}
.chip:hover { color: var(--text); border-color: rgba(46,230,166,0.4); background: var(--cyan-dim); }

.filters {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center;
  margin-bottom: 1.25rem;
}
.check {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.88rem; color: var(--muted); cursor: pointer;
}
.check input { accent-color: var(--cyan); width: 15px; height: 15px; }
.filter-seg {
  display: inline-flex; padding: 3px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--seg-bg);
}
.seg {
  padding: 0.35rem 0.75rem; border-radius: 999px;
  font-size: 0.82rem; color: var(--muted); font-weight: 500;
}
.seg.active { background: var(--seg-active-bg); color: var(--text); }

.min-board {
  display: grid;
  grid-template-columns: 1.15fr 1fr 1fr;
  gap: 0.9rem;
  margin-bottom: 1rem;
  align-items: stretch;
}
@media (max-width: 860px) {
  .min-board { grid-template-columns: 1fr; }
}

.card, .min-card, .source-card, .watch-card, .settings-card {
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.min-card {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 1rem 1.1rem 0.9rem;
  position: relative;
  overflow: hidden;
  min-height: 220px;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}
.min-card:hover {
  border-color: rgba(46, 230, 166, 0.3);
  transform: translateY(-1px);
}
.min-card.global {
  background:
    radial-gradient(circle at 100% 0%, rgba(46,230,166,0.16), transparent 48%),
    linear-gradient(160deg, var(--min-card-from), var(--min-card-to));
  border-color: rgba(46, 230, 166, 0.32);
  box-shadow: 0 16px 40px rgba(46, 230, 166, 0.08), var(--shadow);
}
.min-card.is-empty { opacity: 0.78; }
.min-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  min-height: 1.45rem;
}
.min-card .label {
  font-size: 0.7rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--muted);
  margin: 0;
}
.min-card .badge {
  position: static;
  flex-shrink: 0;
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--cyan-dim);
  color: var(--cyan);
  border: 1px solid rgba(46,230,166,0.32);
}
.min-card-price-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.6rem;
}
.min-card .price {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(1.7rem, 3.5vw, 2.25rem);
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--amber);
}
.min-card.global .price {
  color: var(--cyan);
  text-shadow: 0 0 28px rgba(46,230,166,0.2);
}
x

.stock-chip {
  display: inline-flex;
  align-items: center;
  max-width: 48%;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 650;
  color: var(--cyan);
  background: var(--cyan-dim);
  border: 1px solid rgba(46, 230, 166, 0.22);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stock-chip.oos {
  color: var(--rose);
  background: rgba(255, 93, 122, 0.1);
  border-color: rgba(255, 93, 122, 0.22);
}

.min-card-body {
  display: grid;
  gap: 0.25rem;
  flex: 1;
  min-height: 3.2rem;
}

.min-card-foot { margin-top: auto; padding-top: 0.7rem; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 0.65rem; }

.shop-line { display: inline-flex; align-items: center; gap: 0.4rem; min-width: 0; flex: 1; color: var(--muted); font-size: 0.8rem; }

.min-card .source-line { font-size: 0.72rem; font-weight: 650; color: var(--muted); }
.shop-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 0 3px var(--cyan-dim); flex-shrink: 0; }
.shop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }

.min-card .title-line {
  margin: 0; font-size: 0.88rem; font-weight: 550; line-height: 1.4; color: var(--text);
  max-height: 2.6em; overflow: hidden;
}
.buy-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.25rem; flex-shrink: 0;
  min-height: 32px; padding: 0 0.85rem; border-radius: 999px; font-size: 0.82rem; font-weight: 700;
  text-decoration: none; border: 1px solid rgba(46, 230, 166, 0.28); background: var(--cyan-dim);
  color: var(--cyan); transition: 0.15s ease; margin-left: auto;
}

.buy-btn:hover { border-color: rgba(46, 230, 166, 0.5); background: rgba(46, 230, 166, 0.18); transform: translateY(-1px); }
.buy-btn.primary {
  background: linear-gradient(135deg, #2ee6a6, #1fcf93); color: var(--primary-btn-text);
  border-color: transparent; box-shadow: 0 8px 18px rgba(46, 230, 166, 0.2);
}
.buy-btn.primary:hover { filter: brightness(1.04); }
.buy-btn.disabled {
  opacity: 0.5; cursor: not-allowed; color: var(--muted); pointer-events: none;
  border-color: var(--line); background: var(--field-bg); box-shadow: none;
}

html[data-theme="daylight"] .min-card.global {
  box-shadow: 0 14px 34px rgba(15, 159, 110, 0.08), var(--shadow);
  border-color: rgba(15, 159, 110, 0.28);
}
html[data-theme="daylight"] .buy-btn.primary { box-shadow: 0 8px 18px rgba(15, 159, 110, 0.16); }
html[data-theme="daylight"] .min-card:hover { box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08); }

.source-cards {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem;
  margin-bottom: 1.4rem;
}
@media (max-width: 700px) { .source-cards { grid-template-columns: 1fr; } }
.source-card { padding: 1rem 1.1rem; }
.source-card .head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.55rem;
}
.source-card .name { font-weight: 600; }
.source-card .ok { color: var(--cyan); font-size: 0.78rem; }
.source-card .bad { color: var(--rose); font-size: 0.78rem; }
.source-card .stats {
  display: flex; gap: 1rem; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.85rem; color: var(--muted);
}
.source-card .stats strong { color: var(--text); font-weight: 600; }

.tag {
  display: inline-flex; align-items: center;
  padding: 0.12rem 0.45rem; border-radius: 6px;
  font-size: 0.72rem; font-weight: 600;
}
.tag.aihaotan { background: var(--cyan-dim); color: var(--aihaotan); }
.tag.priceai { background: var(--blue-dim); color: var(--priceai); }
.tag.stock { background: rgba(46,230,166,0.1); color: var(--stock-ok); }
.tag.oos { background: rgba(255,93,122,0.12); color: var(--stock-oos); }
.tag.lowest {
  background: var(--amber-dim); color: var(--amber);
  border: 1px solid rgba(255,176,32,0.35);
}

.toolbar {
  display: flex; flex-wrap: wrap; gap: 0.75rem;
  justify-content: space-between; align-items: flex-end;
  margin-bottom: 0.75rem;
}
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }

.table-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  background: var(--table-bg);
  box-shadow: var(--shadow);
}
table.offers {
  width: 100%; border-collapse: collapse; min-width: 720px;
  background: transparent;
  color: var(--text);
}
table.offers th, table.offers td {
  padding: 0.75rem 0.9rem; text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  background: transparent;
}
table.offers th {
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 600;
  background: var(--table-head);
  position: sticky; top: 0;
  z-index: 1;
}
table.offers tr:last-child td { border-bottom: 0; }
table.offers tr:hover td { background: var(--table-row-hover); }
table.offers tr.is-min td { background: var(--table-row-min); }
table.offers .num { text-align: right; font-family: var(--mono); white-space: nowrap; }
table.offers .price-cell { font-weight: 600; color: var(--amber); font-size: 1rem; }
table.offers .title { font-weight: 500; max-width: 320px; }
table.offers .shop { color: var(--muted); font-size: 0.86rem; margin-top: 0.15rem; }
table.offers .link-btn {
  color: var(--cyan); font-size: 0.85rem; font-weight: 600;
  text-decoration: none;
}
table.offers .link-btn:hover { text-decoration: underline; }

.disclaimer {
  margin-top: 1rem; font-size: 0.78rem; color: var(--muted);
}

.empty-state {
  display: grid; place-items: center;
  min-height: 280px; padding: 2rem 0;
}
.empty-state.compact { min-height: 180px; }
.empty-card {
  text-align: center; max-width: 360px;
  padding: 2rem 1.5rem;
  border: 1px dashed rgba(148,163,184,0.25);
  border-radius: var(--radius);
  background: var(--field-bg);
}
.empty-icon {
  font-size: 2rem; color: var(--cyan); margin-bottom: 0.5rem;
  opacity: 0.85;
}
.empty-card h3 { margin: 0 0 0.4rem; font-family: var(--display); }
.empty-card p { margin: 0; color: var(--muted); font-size: 0.92rem; }
.linkish {
  color: var(--cyan); font-weight: 600; text-decoration: underline;
  text-underline-offset: 3px;
}

.watch-form.card, .card { padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem;
}
.form-grid .span2 { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: auto; }
}
label > span:not(.switch-copy):not(.switch-control):not(.switch-ui):not(.check-ui) {
  display: block; font-size: 0.78rem; color: var(--muted);
  margin-bottom: 0.35rem;
}
label.field > .field-label,
.field > .field-label {
  display: block;
  margin-bottom: 0;
}
label input:not([type="checkbox"]):not([type="radio"]),
.settings-card input:not([type="checkbox"]):not([type="radio"]),
.inline-field input:not([type="checkbox"]):not([type="radio"]),
.field input {
  width: 100%; min-height: 40px;
  padding: 0 0.8rem; border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--field-bg); outline: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
label input:not([type="checkbox"]):not([type="radio"]):focus,
.settings-card input:not([type="checkbox"]):not([type="radio"]):focus,
.field input:focus {
  border-color: rgba(46,230,166,0.5);
  box-shadow: 0 0 0 3px rgba(46,230,166,0.1);
}
.form-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem;
  margin-top: 0.95rem;
}
.grow { flex: 1; }

.watch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 0.85rem;
}
.watch-card { padding: 1.1rem 1.15rem; display: flex; flex-direction: column; gap: 0.65rem; }
.watch-card .kw {
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  letter-spacing: -0.02em;
}
.watch-card .price-row {
  display: flex; align-items: baseline; gap: 0.5rem; flex-wrap: wrap;
}
.watch-card .big-price {
  font-family: var(--mono); font-size: 1.7rem; font-weight: 600; color: var(--cyan);
}
.watch-card .target { font-size: 0.85rem; color: var(--muted); }
.watch-card .info { font-size: 0.86rem; color: var(--muted); }
.watch-card .info .t {
  color: var(--text); display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; margin-top: 0.2rem;
}
.watch-card .actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid color-mix(in srgb, var(--line) 88%, transparent);
}
.watch-card .actions.admin-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.watch-card .actions .btn,
.watch-card .actions a.btn {
  width: 100%;
  min-width: 0;
  min-height: 36px;
  padding: 0 0.55rem;
  justify-content: center;
  text-align: center;
  margin-left: 0;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 650;
  white-space: nowrap;
}
.watch-card .actions .buy-btn {
  margin-left: 0;
  min-height: 36px;
  padding: 0 0.55rem;
  font-size: 0.82rem;
}
.watch-card .actions .danger-soft {
  color: #f87171;
  border-color: color-mix(in srgb, #f87171 32%, var(--line));
  background: color-mix(in srgb, #f87171 8%, var(--surface-soft));
}
.watch-card .actions .danger-soft:hover {
  border-color: color-mix(in srgb, #f87171 50%, var(--line));
  background: color-mix(in srgb, #f87171 14%, var(--surface-soft));
}
html[data-theme="daylight"] .watch-card .actions .danger-soft {
  color: #dc2626;
  border-color: color-mix(in srgb, #dc2626 28%, var(--line));
  background: color-mix(in srgb, #dc2626 7%, var(--surface-soft));
}
.watch-card.disabled { opacity: 0.55; }

.settings-stack { display: grid; gap: 0.9rem; }
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.85fr);
  gap: 0.9rem;
  align-items: start;
}
@media (max-width: 920px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-side { display: grid; gap: 0.9rem; }
.settings-card {
  padding: 1.15rem 1.2rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}
.section-head.compact { margin-bottom: 0.15rem; }
.section-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: -0.02em; }
.section-head h3 { margin: 0; font-size: 0.95rem; font-weight: 650; }
.section-kicker {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cyan);
  margin-bottom: 0.18rem;
}
.section-block {
  display: grid;
  gap: 0.7rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem 0.75rem;
}
.field-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .field-grid { grid-template-columns: 1fr; }
  .field-grid .span-2 { grid-column: auto; }
}
.field { display: grid; gap: 0.32rem; min-width: 0; }
.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.field-with-unit {
  position: relative;
  display: flex;
  align-items: center;
}
.field-with-unit input { padding-right: 2.2rem; }
.field-with-unit .unit {
  position: absolute;
  right: 0.75rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  pointer-events: none;
}
.help-fold {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field-bg);
  padding: 0.15rem 0.85rem;
}
.help-fold summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.55rem 0;
  user-select: none;
}
.help-fold summary::-webkit-details-marker { display: none; }
.help-fold summary::after {
  content: "▾";
  float: right;
  color: var(--muted);
  font-size: 0.7rem;
}
.help-fold[open] summary::after { content: "▴"; }
.help-fold .steps { padding-bottom: 0.65rem; }
.steps {
  margin: 0; padding-left: 1.15rem; color: var(--muted); font-size: 0.84rem;
  line-height: 1.55;
}
.steps li + li { margin-top: 0.25rem; }
.steps code, .about-value code {
  font-family: var(--mono); font-size: 0.78rem;
  background: var(--code-bg); padding: 0.08rem 0.32rem; border-radius: 5px;
}
.pill {
  display: inline-flex; align-items: center;
  padding: 0.22rem 0.62rem; border-radius: 999px;
  font-size: 0.74rem; font-weight: 650;
  background: var(--field-bg); color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.pill.soft { background: var(--surface-soft); }
.pill.ok { background: var(--cyan-dim); color: var(--cyan); border-color: rgba(46,230,166,0.3); }
.pill.warn { background: var(--amber-dim); color: var(--amber); border-color: rgba(255,176,32,0.28); }

/* Switch rows (replaces giant native checkboxes) */
.switch-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.85rem;
  padding: 0.72rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.switch-row:hover { border-color: rgba(46, 230, 166, 0.3); }
.switch-copy {
  display: grid;
  gap: 0.12rem;
  min-width: 0;
}
.switch-copy strong {
  font-size: 0.88rem;
  font-weight: 650;
  color: var(--text);
}
.switch-copy small {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.35;
}
.switch-control {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}
.switch-control input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 2;
}
.switch-ui {
  display: block;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: rgba(139, 155, 184, 0.35);
  border: 1px solid var(--line);
  position: relative;
  transition: 0.18s ease;
  pointer-events: none;
}
.switch-ui::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.18);
  transition: transform 0.18s ease;
}
.switch-control input:checked + .switch-ui {
  background: var(--cyan);
  border-color: transparent;
}
.switch-control input:checked + .switch-ui::after {
  transform: translateX(18px);
}
.switch-row:has(input:focus-visible) {
  box-shadow: 0 0 0 3px rgba(46,230,166,0.14);
}
.sticky-actions {
  margin-top: 0.15rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--line);
}
.settings-hint { margin: 0; min-height: 1.2em; }
.about-grid { display: grid; gap: 0.55rem; }
.about-item {
  display: grid;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
}
.about-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.about-value {
  font-size: 0.86rem;
  color: var(--text);
  line-height: 1.4;
}
.health-panel { display: grid; gap: 0.55rem; }
.health-loading, .health-error {
  padding: 0.85rem;
  border-radius: 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.86rem;
}
.health-error { color: var(--rose); }
.health-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
.health-metric {
  padding: 0.7rem 0.75rem;
  border-radius: 10px;
  background: var(--field-bg);
  border: 1px solid var(--line);
  display: grid;
  gap: 0.18rem;
}
.health-metric .hm-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.health-metric .hm-value {
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--text);
}
.health-metric .hm-value.ok { color: var(--cyan); }
.health-metric .hm-value.bad { color: var(--rose); }
.health {
  margin-top: 0.5rem; padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--field-bg); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 0.82rem; color: var(--muted);
  white-space: pre-wrap;
}


.toast-wrap {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 50;
  display: flex; flex-direction: column; gap: 0.5rem;
  width: min(360px, calc(100% - 2rem));
}
.toast {
  padding: 0.8rem 1rem; border-radius: 12px;
  background: #1a2438; border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: 0.9rem;
  animation: toast-in 0.22s ease;
}
.toast.ok { border-color: rgba(46,230,166,0.35); }
.toast.err { border-color: rgba(255,93,122,0.4); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.loading-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 60;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--amber), transparent);
  background-size: 200% 100%;
  animation: load 1s linear infinite;
}
@keyframes load {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .top-status { margin-left: 0; }
}

/* --- v2: filters, charts, inline edit --- */
.filters.advanced {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.inline-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: min(220px, 100%);
  flex: 1;
}
.inline-field span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 500;
}
.inline-field input {
  background: var(--field-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
  outline: none;
  color: var(--text);
}
.inline-field input:focus {
  border-color: rgba(46,230,166,0.45);
  box-shadow: 0 0 0 3px rgba(46,230,166,0.1);
}

.tag.soft {
  background: var(--surface-hover);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 0.72rem;
}
.shop.tags { margin-top: 0.25rem; display: flex; flex-wrap: wrap; gap: 0.25rem; }

.chart-block {
  margin-top: 0.15rem;
  padding: 0.55rem 0.45rem 0.35rem;
  border-radius: var(--radius-sm);
  background: var(--field-bg);
  border: 1px solid var(--line);
}
.chart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  padding: 0 0.2rem;
}
.chart-meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.range-seg {
  display: inline-flex;
  gap: 0.2rem;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.12rem;
}
.range-seg .seg {
  padding: 0.18rem 0.55rem;
  font-size: 0.72rem;
  border-radius: 999px;
  color: var(--muted);
}
.range-seg .seg.active {
  background: var(--cyan-dim);
  color: var(--cyan);
  font-weight: 600;
}
canvas.spark {
  display: block;
  width: 100%;
  height: 72px;
}

.edit-block {
  margin-top: 0.15rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(91,140,255,0.06);
  border: 1px solid rgba(91,140,255,0.2);
}
.form-grid.compact {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}
@media (max-width: 480px) {
  .form-grid.compact { grid-template-columns: 1fr; }
}
.form-actions.tight { margin-top: 0.55rem; }


/* ========== Theme toggle (single button) ========== */
.theme-menu {
  position: relative;
  margin-left: auto;
}
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 34px;
  padding: 0.3rem 0.7rem 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 1px 0 rgba(255,255,255,0.03);
  transition: 0.15s ease;
}
.theme-toggle:hover {
  border-color: rgba(46, 230, 166, 0.4);
  background: var(--surface-hover);
}
.theme-toggle[aria-expanded="true"] {
  border-color: rgba(46, 230, 166, 0.55);
  box-shadow: 0 0 0 3px rgba(46, 230, 166, 0.12);
}
.theme-toggle-ico {
  width: 1.25rem;
  height: 1.25rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--cyan-dim);
  color: var(--cyan);
  font-size: 0.78rem;
  line-height: 1;
}
.theme-toggle-caret {
  color: var(--muted);
  font-size: 0.65rem;
  transform: translateY(1px);
}
.theme-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 40;
  min-width: 220px;
  padding: 0.35rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel-solid);
  box-shadow: var(--shadow);
  display: grid;
  gap: 0.2rem;
}
.theme-dropdown[hidden] { display: none !important; }
.theme-opt {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.6rem;
  border-radius: 10px;
  color: var(--text);
  transition: 0.12s ease;
}
.theme-opt:hover { background: var(--surface-soft); }
.theme-opt.active {
  background: var(--cyan-dim);
  box-shadow: inset 0 0 0 1px rgba(46, 230, 166, 0.25);
}
.theme-opt .opt-ico {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--seg-bg);
  color: var(--cyan);
  font-size: 0.9rem;
  flex-shrink: 0;
}
.theme-opt .opt-text {
  display: grid;
  gap: 0.08rem;
  min-width: 0;
}
.theme-opt .opt-text strong {
  font-size: 0.86rem;
  font-weight: 650;
}
.theme-opt .opt-text small {
  color: var(--muted);
  font-size: 0.72rem;
}

/* ========== Settings appearance strip ========== */
.appearance-card {
  padding: 1rem 1.15rem 1.05rem;
  display: grid;
  gap: 0.75rem;
}
.theme-seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}
@media (max-width: 780px) {
  .theme-seg { grid-template-columns: 1fr; }
}
.theme-seg-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 0.7rem;
  text-align: left;
  padding: 0.65rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s, transform 0.15s;
  min-height: 64px;
}
.theme-seg-item:hover {
  border-color: rgba(46, 230, 166, 0.32);
  transform: translateY(-1px);
}
.theme-seg-item.active {
  border-color: rgba(46, 230, 166, 0.5);
  background: var(--cyan-dim);
  box-shadow: 0 0 0 1px rgba(46, 230, 166, 0.1);
}
.theme-seg-item .theme-preview {
  width: 56px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  background:
    linear-gradient(120deg, #0b1220 0 36%, #f3f6fb 36% 64%, #2ee6a6 64% 100%);
}
.theme-seg-item .theme-preview.daylight {
  background:
    linear-gradient(120deg, #eef3fa 0 42%, #ffffff 42% 68%, #0f9f6e 68% 100%);
}
.theme-seg-item .theme-preview.midnight {
  background:
    linear-gradient(120deg, #0b1220 0 45%, #141d30 45% 70%, #2ee6a6 70% 100%);
}
.theme-seg-item .t-copy { min-width: 0; }
.theme-seg-item .t-name {
  font-weight: 700;
  font-size: 0.88rem;
  margin-bottom: 0.1rem;
  letter-spacing: -0.01em;
}
.theme-seg-item .t-desc {
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.35;
}


/* daylight field polish */
html[data-theme="daylight"] .search-input-wrap {
  background: var(--search-bg);
  border-color: rgba(15, 23, 42, 0.12);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
html[data-theme="daylight"] .search-input-wrap:focus-within {
  border-color: rgba(15, 159, 110, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 159, 110, 0.12);
}
html[data-theme="daylight"] .btn.ghost {
  background: var(--panel-solid);
}
html[data-theme="daylight"] .chip,
html[data-theme="daylight"] .filter-seg {
  background: var(--field-bg);
}
html[data-theme="daylight"] .min-card.global {
  border-color: rgba(15, 159, 110, 0.28);
}
html[data-theme="daylight"] .theme-toggle {
  background: #fff;
}
html[data-theme="daylight"] .theme-dropdown {
  background: #fff;
}


/* ========== Auth gate / login vault ========== */
/* Guest mode */
body.auth-locked .topbar,
body.auth-locked .shell {
  pointer-events: none;
  user-select: none;
  filter: blur(2px);
}
body.auth-locked .auth-gate {
  pointer-events: auto;
  user-select: auto;
  filter: none;
}
body.guest-mode .topbar,
body.guest-mode .shell,
body.auth-ready .topbar,
body.auth-ready .shell,
body.auth-ready .toast-wrap {
  visibility: visible;
  pointer-events: auto;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: clamp(16px, 3vw, 36px);
  background:
    radial-gradient(980px 520px at 12% 8%, var(--glow-a), transparent 58%),
    radial-gradient(860px 480px at 92% 12%, var(--glow-b), transparent 52%),
    radial-gradient(720px 420px at 50% 110%, var(--glow-c), transparent 58%),
    linear-gradient(165deg, var(--ink) 0%, var(--ink-2) 55%, var(--ink) 100%);
  overflow: auto;
}

.auth-gate[hidden] {
  display: none !important;
}

.auth-ambient {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.auth-gridline {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(circle at 50% 45%, #000 20%, transparent 72%);
  opacity: 0.7;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.45;
}

.auth-orb-a {
  width: 280px;
  height: 280px;
  left: 8%;
  top: 18%;
  background: var(--glow-a);
}

.auth-orb-b {
  width: 320px;
  height: 320px;
  right: 6%;
  bottom: 10%;
  background: var(--glow-b);
}

.auth-orbit {
  position: absolute;
  left: 50%;
  top: 48%;
  border: 1px solid color-mix(in srgb, var(--cyan) 24%, transparent);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.4;
}

.auth-orbit-a {
  width: min(78vw, 640px);
  height: min(78vw, 640px);
  animation: auth-spin 36s linear infinite;
  border-style: dashed;
}

.auth-orbit-b {
  width: min(52vw, 420px);
  height: min(52vw, 420px);
  border-color: color-mix(in srgb, var(--blue) 26%, transparent);
  animation: auth-spin 22s linear infinite reverse;
}

.auth-scan {
  position: absolute;
  left: 50%;
  top: 48%;
  width: min(78vw, 640px);
  height: min(78vw, 640px);
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: conic-gradient(
    from 200deg,
    transparent 0deg,
    color-mix(in srgb, var(--cyan) 18%, transparent) 42deg,
    transparent 88deg
  );
  animation: auth-spin 9s linear infinite;
  opacity: 0.5;
  mask-image: radial-gradient(circle, transparent 44%, #000 45%, #000 50%, transparent 51%);
}

@keyframes auth-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(14px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .auth-orbit-a,
  .auth-orbit-b,
  .auth-scan {
    animation: none;
  }
  .auth-frame {
    animation: none !important;
  }
}

.auth-frame {
  position: relative;
  width: min(980px, 100%);
  display: grid;
  gap: 16px;
  animation: auth-rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.auth-frame-centered {
  width: min(440px, 100%);
  justify-items: stretch;
  margin: 0 auto;
}

.auth-card-centered {
  padding: clamp(28px, 4vw, 36px);
  display: flex;
  flex-direction: column;
  border-radius: 22px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 2.5%, transparent), transparent 28%),
    var(--panel);
  box-shadow:
    var(--shadow),
    0 0 0 1px color-mix(in srgb, #fff 4%, transparent) inset;
  backdrop-filter: blur(20px);
  position: relative;
  overflow: hidden;
  min-height: auto;
}

.auth-card-centered::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--blue), transparent);
  opacity: 0.9;
}

html[data-theme="daylight"] .auth-card-centered {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), #fff);
}


.auth-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px;
}

.auth-brand-mini {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-mark {
  width: 40px;
  height: 40px;
}

.auth-theme-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
}

.auth-panel {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: min(560px, calc(100vh - 120px));
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-solid) 88%, transparent);
  box-shadow:
    var(--shadow),
    0 0 0 1px color-mix(in srgb, #fff 4%, transparent) inset;
  backdrop-filter: blur(20px);
}

.auth-side {
  position: relative;
  padding: clamp(28px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  gap: 18px;
  background:
    linear-gradient(160deg, color-mix(in srgb, var(--cyan) 10%, transparent), transparent 42%),
    linear-gradient(20deg, color-mix(in srgb, var(--blue) 12%, transparent), transparent 48%),
    var(--panel-solid);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.auth-side::after {
  content: "";
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border: 1px dashed color-mix(in srgb, var(--cyan) 30%, transparent);
  opacity: 0.55;
}

.auth-side-badge {
  align-self: flex-start;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--cyan);
  border: 1px solid color-mix(in srgb, var(--cyan) 35%, transparent);
  background: color-mix(in srgb, var(--cyan) 10%, transparent);
  border-radius: 999px;
  padding: 6px 10px;
}

.auth-side-title {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.55rem, 2.6vw, 2.05rem);
  line-height: 1.18;
  letter-spacing: -0.03em;
  font-weight: 800;
  color: var(--text);
}

.auth-side-title em {
  font-style: normal;
  background: linear-gradient(90deg, var(--cyan), var(--blue));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-side-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.95rem;
  max-width: 36ch;
}

.auth-trust {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.auth-trust li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-soft) 88%, transparent);
}

.auth-trust-ico {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--cyan) 22%, transparent);
}

.auth-trust strong {
  display: block;
  font-size: 13px;
  color: var(--text);
  font-weight: 650;
}

.auth-trust small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.auth-side-foot {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.02em;
}

.auth-main {
  padding: clamp(28px, 4vw, 40px);
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, color-mix(in srgb, #fff 2.5%, transparent), transparent 28%),
    var(--panel);
  position: relative;
}

.auth-main-head {
  margin-bottom: 22px;
}

.auth-kicker {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
  font-weight: 700;
  margin-bottom: 10px;
}

.auth-title {
  font-family: var(--display);
  font-size: clamp(1.55rem, 2.3vw, 1.9rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  margin: 0 0 8px;
  color: var(--text);
}

.auth-lede {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  font-size: 0.95rem;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-field .field-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auth-field input {
  height: 46px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--field-bg);
  color: var(--text);
  padding: 0 14px;
  width: 100%;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.auth-field input:hover {
  border-color: color-mix(in srgb, var(--blue) 35%, var(--line));
}

.auth-field input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--cyan) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 16%, transparent);
  background: color-mix(in srgb, var(--field-bg) 80%, var(--panel-solid));
}

.auth-input-wrap {
  position: relative;
}

.auth-pass-wrap input {
  padding-right: 48px;
}

.auth-eye {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.auth-eye:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.auth-eye[aria-pressed="true"] {
  color: var(--cyan);
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
  height: 48px;
  border-radius: 12px;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 10px 24px color-mix(in srgb, var(--cyan) 18%, transparent);
}

.auth-submit:disabled {
  opacity: 0.7;
  cursor: wait;
}

.auth-btn-arrow {
  font-size: 16px;
  transition: transform 0.18s ease;
}

.auth-submit:hover .auth-btn-arrow {
  transform: translateX(3px);
}

.auth-footnote {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.auth-footnote code {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--code-bg);
}

.auth-foot-row {
  margin-top: 2px;
}

.auth-error {
  margin: 14px 0 0;
  padding: 11px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--rose) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--rose) 34%, transparent);
  color: var(--rose);
  font-size: 13px;
  line-height: 1.45;
}

.auth-secure-bar {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.auth-dot {
  opacity: 0.5;
}

html[data-theme="daylight"] .auth-panel {
  background: color-mix(in srgb, #fff 94%, var(--ink-2));
}

html[data-theme="daylight"] .auth-side {
  background:
    linear-gradient(160deg, rgba(46, 230, 166, 0.1), transparent 42%),
    linear-gradient(20deg, rgba(91, 140, 255, 0.1), transparent 48%),
    #f7fafc;
}

html[data-theme="daylight"] .auth-main {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), #fff);
}

html[data-theme="daylight"] .auth-field input {
  background: #fff;
}

@media (max-width: 860px) {
  .auth-panel {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .auth-side {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 14px;
    padding-bottom: 22px;
  }

  .auth-side-copy {
    max-width: none;
  }

  .auth-trust {
    grid-template-columns: 1fr;
  }

  .auth-side-foot {
    margin-top: 4px;
  }

  .auth-main {
    padding-top: 24px;
  }
}

@media (max-width: 520px) {
  .auth-gate {
    padding: 12px;
    place-items: stretch;
  }

  .auth-frame {
    width: 100%;
  }

  .auth-topbar {
    padding: 2px 2px 0;
  }

  .auth-panel {
    border-radius: 18px;
  }

  .auth-side-title {
    font-size: 1.4rem;
  }

  .auth-trust li {
    padding: 10px;
  }
}


.auth-frame-centered .auth-topbar {
  padding: 0 2px;
}

.auth-frame-centered .auth-main-head {
  text-align: left;
  margin-bottom: 20px;
}

.auth-frame-centered .auth-secure-bar {
  justify-content: flex-start;
}

@media (max-width: 520px) {
  .auth-frame-centered {
    width: 100%;
  }

  .auth-card-centered {
    border-radius: 18px;
    padding: 22px 18px 18px;
  }
}

/* user menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 4px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--nav-active-fg);
  background: linear-gradient(135deg, var(--cyan), var(--blue));
}

.user-meta {
  display: grid;
  line-height: 1.15;
}

.user-meta strong {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.user-meta small {
  font-size: 10px;
  color: var(--muted);
}

.user-logout {
  height: 34px;
  padding: 0 12px;
  font-size: 12px;
}

/* security settings */
.security-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.security-stat {
  border: 1px solid var(--line);
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: grid;
  gap: 4px;
}

.ss-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ss-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.card-inset {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

@media (max-width: 720px) {
  .security-grid {
    grid-template-columns: 1fr;
  }
  .user-meta small {
    display: none;
  }
  .auth-card {
    padding: 22px 18px 18px;
  }
}

/* ========== Topbar / logo polish (guest + admin) ========== */
.topbar{display:flex;align-items:center;gap:14px;padding:12px 18px;position:sticky;top:0;z-index:40;backdrop-filter:blur(16px) saturate(1.2);background:var(--topbar-bg);border-bottom:1px solid var(--line);} 
.brand{display:flex;align-items:center;gap:12px;text-decoration:none;color:inherit;min-width:0;margin-right:4px;}
.brand-mark{width:42px;height:42px;border-radius:14px;display:grid;place-items:center;background:transparent;flex:0 0 auto;box-shadow:none;}
.brand-logo{width:40px;height:40px;display:block;}
.brand-title{font-family:var(--display);font-weight:800;font-size:1.12rem;letter-spacing:-0.03em;line-height:1.1;color:var(--text);}
.brand-title span{background:linear-gradient(100deg,var(--cyan),var(--blue));-webkit-background-clip:text;background-clip:text;color:transparent;}
.brand-sub{margin-top:2px;font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:220px;}
.nav{display:flex;align-items:center;gap:4px;padding:4px;border-radius:999px;background:var(--seg-bg);border:1px solid var(--line);} 
.nav-btn{border:0;background:transparent;color:var(--muted);font:inherit;font-size:13px;font-weight:600;padding:8px 14px;border-radius:999px;cursor:pointer;}
.nav-btn:hover{color:var(--text);background:var(--surface-hover);}
.nav-btn.active{background:linear-gradient(135deg,#2ee6a6,#49d9b0);color:var(--nav-active-fg);box-shadow:0 6px 16px rgba(46,230,166,.22);}
.topbar-actions{margin-left:auto;display:flex;align-items:center;gap:8px;}
.icon-btn{width:38px;height:38px;border-radius:12px;border:1px solid var(--line);background:var(--surface-soft);color:var(--text);display:inline-grid;place-items:center;cursor:pointer;}
.icon-btn:hover{background:var(--surface-hover);color:var(--cyan);}
.gear-btn svg{display:block;transition:transform .25s ease;}
.gear-btn:hover svg{transform:rotate(28deg);}
.guest-banner{display:flex;align-items:center;gap:12px;margin:0 0 14px;padding:12px 14px;border-radius:14px;border:1px solid rgba(91,140,255,.25);background:linear-gradient(100deg,rgba(46,230,166,.08),rgba(91,140,255,.08));}
.guest-banner[hidden]{display:none!important;}
.guest-banner-ico{width:34px;height:34px;border-radius:10px;display:grid;place-items:center;color:var(--cyan);background:rgba(46,230,166,.12);border:1px solid rgba(46,230,166,.24);flex:0 0 auto;}
.guest-banner-copy{display:grid;gap:2px;min-width:0;flex:1;}
.guest-banner-copy strong{font-size:13px;color:var(--text);}
.guest-banner-copy span{font-size:12px;color:var(--muted);line-height:1.45;}
.guest-login-cta{height:36px;padding:0 14px;border-radius:999px;flex:0 0 auto;white-space:nowrap;}
@media (max-width:900px){.brand-sub{display:none}.theme-toggle-label,.theme-toggle-caret{display:none}.user-meta{display:none}}
@media (max-width:720px){.topbar{flex-wrap:wrap;gap:10px}.nav{order:3;width:100%;justify-content:space-between}.nav-btn{flex:1;text-align:center}.topbar-actions{margin-left:auto}.guest-banner{flex-wrap:wrap}.guest-login-cta{width:100%}}

.guest-watch-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 36px 20px;
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: var(--surface-soft);
}
.guest-watch-empty h3 { margin: 10px 0 6px; font-size: 1.05rem; }
.guest-watch-empty .btn { margin-top: 12px; }
.guest-watch-empty .empty-ico { font-size: 22px; color: var(--cyan); opacity: .85; }

/* Guest watch board */
.watch-card.guest-card {
  position: relative;
}
.watch-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.watch-badge {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
}
.watch-badge.readonly {
  color: var(--blue);
  border-color: color-mix(in srgb, var(--blue) 30%, var(--line));
  background: color-mix(in srgb, var(--blue) 10%, transparent);
}
.watch-badge.paused {
  color: var(--amber);
  border-color: color-mix(in srgb, var(--amber) 30%, var(--line));
  background: color-mix(in srgb, var(--amber) 10%, transparent);
}
.actions.guest-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}
.actions.guest-actions .buy-btn,
.actions.guest-actions .action-btn {
  width: 100%;
  margin-left: 0;
  justify-content: center;
  text-align: center;
}
.guest-watch-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 22px;
  border-radius: 18px;
  border: 1px dashed var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--cyan) 6%, transparent), transparent 55%),
    var(--surface-soft);
}
.guest-watch-empty h3 { margin: 10px 0 6px; font-size: 1.08rem; }
.guest-watch-empty .btn { margin-top: 14px; }
.guest-watch-empty .empty-ico { font-size: 22px; color: var(--cyan); }
#watchAdminToolbar[hidden] { display: none !important; }


/* Compact watch page head */
.watch-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.watch-panel-head h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.7rem);
}
.watch-panel-head .toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.watch-panel-head .toolbar-actions .btn {
  height: 38px;
  border-radius: 999px;
  padding: 0 16px;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .watch-panel-head {
    flex-direction: column;
    align-items: stretch;
  }
  .watch-panel-head .toolbar-actions {
    width: 100%;
  }
  .watch-panel-head .toolbar-actions .btn {
    flex: 1;
  }
}
