:root {
  --bg: #000000;
  --bg-2: #000000;
  --surface: rgba(0, 0, 0, 0.35);
  --surface-2: rgba(80, 140, 255, 0.10);
  --surface-3: rgba(80, 140, 255, 0.16);
  --line: rgba(120, 170, 255, 0.14);
  --line-2: rgba(150, 190, 255, 0.22);
  --text: #ffffff;
  --text-dim: #c5d4f5;
  --muted: #7a90c2;
  --gold: #5b9dff;
  --gold-2: #8cbcff;
  --gold-dim: rgba(91, 157, 255, 0.18);
  --teal: #5eead4;
  --teal-dim: rgba(94, 234, 212, 0.18);
  --indigo: #9aa8ff;
  --indigo-dim: rgba(154, 168, 255, 0.16);
  --danger: #ef7a6c;
  --danger-dim: rgba(239, 122, 108, 0.16);
  --ok: #7ed9a0;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.48);
  --shadow-sm: 0 8px 24px rgba(0, 0, 0, 0.28);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: Outfit, Inter, "Segoe UI", "Helvetica Neue", ui-sans-serif, system-ui, sans-serif;
  --sidebar: 280px;
  --rail: 68px;
  --top: 49px;
  --page-w: 1920px;
  --gutter: max(12px, calc((100vw - var(--page-w)) / 2));
  --radius: 16px;
  --radius-sm: 10px;
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --dur: 0.25s;
  --motion-micro: 80ms;
  --motion-quick: 150ms;
  --motion-fast: 250ms;
  --radius-xs: 4px;
  --glass: rgba(255, 255, 255, 0.03);
  --glass-strong: rgba(0, 0, 0, 0.28);
  --glass-border: rgba(140, 180, 255, 0.18);
  --glass-shine: inset 0 1px 0 rgba(180, 210, 255, 0.16);
  --blur: blur(28px) saturate(1.85);
  --well: linear-gradient(180deg, rgba(120, 170, 255, 0.16), rgba(80, 130, 255, 0.06));
  --well-bg: rgba(91, 157, 255, 0.10);
  --well-border: rgba(150, 190, 255, 0.22);
  --color-band-lo: #1f8a7c;
  --color-band-hi: #9ee7ff;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { color-scheme: dark; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background-color: var(--bg);
  background-image:
    radial-gradient(800px 480px at 88% -10%, rgba(70, 120, 255, 0.22), transparent 52%),
    linear-gradient(rgba(90, 140, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(90, 140, 255, 0.045) 1px, transparent 1px);
  background-size: auto, 72px 72px, 72px 72px;
  color: var(--text);
  font: 14.5px/1.45 var(--sans);
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  isolation: isolate;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 20% 110%, rgba(70, 90, 255, 0.55), transparent 58%),
    radial-gradient(ellipse 70% 45% at 78% 115%, rgba(210, 40, 170, 0.42), transparent 55%),
    radial-gradient(ellipse 50% 40% at 50% 120%, rgba(40, 180, 255, 0.32), transparent 50%);
  filter: blur(8px);
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.12;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  -webkit-mask-image: radial-gradient(ellipse 95% 58% at 50% 118%, #000 10%, transparent 72%);
  mask-image: radial-gradient(ellipse 95% 58% at 50% 118%, #000 10%, transparent 72%);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
code, .mono { font-family: var(--mono); font-size: 0.86em; }

#app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  width: 100%;
  padding-inline: var(--gutter);
  box-sizing: border-box;
  position: relative;
  z-index: 1;
  animation: page-enter var(--dur) var(--ease);
}

/* ---------- top bar (Sanctum-style, full-bleed) ---------- */
#topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: var(--top);
  min-height: var(--top);
  max-height: var(--top);
  padding: 8px var(--gutter);
  overflow: hidden;
  background: rgba(0, 0, 0, 0.28);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--glass-shine);
  position: sticky;
  top: 0;
  z-index: 20;
  flex-shrink: 0;
}
#topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-right: 8px;
  text-decoration: none;
  color: var(--text);
  flex-shrink: 0;
}
#topbar .brand-icon { height: 22px; width: auto; display: block; flex-shrink: 0; }
#topbar .brand-word {
  height: 22px;
  width: auto;
  max-height: 33px;
  display: block;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
}
#topbar .brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.02em; white-space: nowrap; }
#topbar nav { display: flex; gap: 4px; align-items: center; }
#topbar button { white-space: nowrap; flex-shrink: 0; }
#topbar .btn {
  height: 33px;
  padding: 5px 9px;
  border-radius: 6px;
  font-size: 13.5px;
}
#topbar .rail-btn.active,
#topbar button.active {
  background: var(--gold-dim);
  border-color: var(--gold);
  color: #dbe8ff;
}
#topbar .ver { font-size: 11px; color: var(--muted); margin-left: 6px; font-family: var(--mono); }
.spacer { flex: 1; min-width: 8px; }
.btn.menu-btn { display: none; }
.btn.icon {
  width: 40px;
  padding: 0;
  justify-content: center;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
.login-brand .brand-icon { height: 36px; width: auto; display: block; }
.login-brand .brand-word { height: 28px; width: auto; display: block; object-fit: contain; }
.brand-name { font-weight: 650; letter-spacing: -0.02em; font-size: 15px; }
.brand-sub {
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}
.ver {
  color: var(--gold);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
}

.searchwrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(8, 10, 14, 0.38);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  margin: 8px 10px 6px;
  color: var(--muted);
  flex: 0 0 auto;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), color 0.2s;
}
.searchwrap:focus-within {
  border-color: rgba(91, 157, 255, 0.45);
  color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.searchwrap input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  height: 36px;
  color: var(--text);
  min-width: 0;
}
.searchwrap input::placeholder { color: var(--muted); }
.slash {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 1px 6px;
  color: var(--muted);
}

.top-actions { margin-left: auto; display: flex; gap: 8px; flex-shrink: 0; }

.app-rail {
  display: none;
  width: var(--rail);
  flex-shrink: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  padding: 10px 6px 14px;
  margin: 10px 0 12px 12px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--glass-shine), 0 18px 50px rgba(0,0,0,0.35);
  z-index: 16;
}
.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 100%;
  min-height: 56px;
  padding: 8px 2px 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  font-weight: 600;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s, border-color 0.18s;
}
.rail-btn svg { flex-shrink: 0; }
.rail-btn:hover { color: var(--text); background: rgba(255,255,255,0.08); }
.rail-btn.active {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: rgba(91, 157, 255, 0.32);
}
.rail-btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }
.app-dock { display: none; }

.section-pane {
  display: none;
  flex: 1;
  overflow: auto;
  padding: 48px 44px 80px;
  max-width: 760px;
}
.section-pane h1 {
  font-size: 28px;
  letter-spacing: -0.03em;
  margin: 6px 0 12px;
}
.section-pane p { color: var(--text-dim); max-width: 58ch; }
body.section-items #section-items,
body.section-loot #section-loot { display: block; }
body.section-items .sidebar,
body.section-loot .sidebar,
body.section-items #main,
body.section-loot #main { display: none; }
body.section-items .stats-only,
body.section-loot .stats-only { display: none !important; }



.btn {
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  padding: 0 14px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.01em;
  font-weight: 500;
  transition: background 0.18s var(--ease), border-color 0.18s, transform 0.18s var(--ease), box-shadow 0.18s;
}
.btn:hover { border-color: rgba(232,228,218,0.22); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn.primary {
  background: #ffffff;
  border-color: #ffffff;
  color: #000000;
  font-weight: 650;
  box-shadow: 0 6px 16px rgba(91, 157, 255, 0.22);
}
.btn.primary:hover { background: #dbe7ff; filter: none; }
.btn.ghost { background: transparent; }
.btn.ghost.active {
  background: var(--gold-dim);
  border-color: rgba(91,157,255,0.45);
  color: var(--gold);
}
.btn.danger { background: var(--danger-dim); border-color: rgba(239,122,108,0.35); color: #ffc4bc; }
.btn.danger:hover { background: #5a2420; }
.btn.tiny { height: 32px; padding: 0 10px; font-size: 13px; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* ---------- shell / sidebar ---------- */
.shell { display: flex; flex: 1; min-height: 0; position: relative; gap: 12px; padding: 0 0 14px; }
.sidebar-backdrop {
  display: none;
}
.sidebar {
  width: var(--sidebar);
  flex-shrink: 0;
  margin: 10px 0 12px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--glass-shine), 0 18px 50px rgba(0,0,0,0.32);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
}
.side-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 8px 14px;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.side-head #btn-add {
  text-transform: none;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}
.side-tools {
  display: flex;
  align-items: center;
  padding: 0 14px 8px;
  border-bottom: 1px solid var(--line);
}
.hide-samples {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.hide-samples input { accent-color: var(--gold); width: 16px; height: 16px; }

.stat-list {
  overflow-x: hidden;
  overflow-y: auto;
  flex: 1;
  min-width: 0;
  padding: 8px 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cat-label {
  padding: 10px 8px 0;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
}
.stat-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 8px;
  padding: 5px 8px 6px;
  margin: 0;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.045);
  backdrop-filter: blur(14px) saturate(1.35);
  -webkit-backdrop-filter: blur(14px) saturate(1.35);
  box-shadow: var(--glass-shine);
  text-align: left;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  width: 100%;
  line-height: 1.2;
  transition: background 0.2s var(--ease), border-color 0.2s, transform 0.2s var(--ease);
}
.stat-item:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.22); }
.stat-item.active {
  background: var(--gold-dim);
  border-color: rgba(91, 157, 255, 0.32);
  box-shadow: inset 0 0 0 1px rgba(91,157,255,0.06);
}
.stat-item .name {
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.015em;
  font-size: 13px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-item .key {
  grid-column: 1;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.stat-item.active .key { color: #9ec2ff; }
.pill {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.pill.sample { background: var(--indigo-dim); color: var(--indigo); }
.side-empty { padding: 22px 16px; color: var(--muted); line-height: 1.5; }
.side-foot {
  padding: 10px 16px 14px;
  color: var(--muted);
  font-size: 11.5px;
  font-family: var(--mono);
  border-top: 1px solid var(--line);
  letter-spacing: 0.04em;
}

.main {
  flex: 1;
  min-width: 0;
  overflow: auto;
  margin: 10px 0 12px;
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--glass-shine), 0 18px 50px rgba(0,0,0,0.28);
}

.hidden { display: none !important; }

/* ---------- empty ---------- */
.empty-board {
  max-width: 560px;
  margin: 10vh auto 0;
  padding: 0 28px 64px;
  animation: panel-enter 0.5s var(--ease);
}
.empty-visual {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 52px;
  margin-bottom: 22px;
  width: 168px;
}
.empty-visual span {
  flex: 1;
  border-radius: 1px 1px 0.5px 0.5px;
  background: linear-gradient(180deg, var(--gold-2), var(--teal));
  opacity: 0.85;
  transform-origin: bottom;
  animation: bar-grow 0.7s var(--ease) both;
}
.empty-visual span:nth-child(1) { height: 18%; animation-delay: 0.02s; }
.empty-visual span:nth-child(2) { height: 28%; animation-delay: 0.06s; }
.empty-visual span:nth-child(3) { height: 40%; animation-delay: 0.10s; }
.empty-visual span:nth-child(4) { height: 48%; animation-delay: 0.14s; }
.empty-visual span:nth-child(5) { height: 60%; animation-delay: 0.18s; }
.empty-visual span:nth-child(6) { height: 72%; animation-delay: 0.22s; }
.empty-visual span:nth-child(7) { height: 84%; animation-delay: 0.26s; }
.empty-visual span:nth-child(8) { height: 100%; animation-delay: 0.30s; }
.empty-kicker {
  color: var(--gold);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 600;
}
.empty-board h1 {
  font-size: clamp(26px, 4vw, 34px);
  margin: 10px 0 14px;
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.15;
}
.empty-board p { color: var(--text-dim); font-size: 15px; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 14px; }
.hint { font-size: 13px; color: var(--muted); }

/* ---------- detail / compare ---------- */
.detail, .compare-view {
  padding: 22px 26px 64px;
  max-width: none;
  animation: panel-enter 0.42s var(--ease);
}
.detail-head, .compare-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.title-edit {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: -0.03em;
  padding: 2px 10px 2px 0;
  width: min(560px, 100%);
  transition: border-color 0.2s, background 0.2s, padding 0.2s;
}
.title-edit:hover, .title-edit:focus {
  border-color: var(--line-2);
  background: var(--surface);
  outline: none;
  padding-left: 10px;
}
.keyline { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; color: var(--muted); }
.key-link { color: inherit; text-decoration: none; }
.key-link:hover code { border-color: var(--gold); color: var(--text); }
.keyline code {
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 1.5px;
  color: var(--text-dim);
  font-size: 12.5px;
}
.cat-edit, .desc-edit {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 1.5px;
  padding: 3px 8px;
  color: var(--text-dim);
  min-width: 90px;
  transition: border-color 0.2s, background 0.2s;
}
.cat-edit:hover, .desc-edit:hover, .cat-edit:focus, .desc-edit:focus {
  border-color: var(--line-2); background: var(--surface); outline: none; color: var(--text);
}
.desc-edit { width: 100%; max-width: none; margin: 6px 0 16px; color: var(--text-dim); }
.detail-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.save-dot { color: var(--muted); font-size: 12px; min-width: 72px; text-align: right; }
.save-dot.ok { color: var(--ok); }
.save-dot.err { color: var(--danger); }

.view-tabs {
  display: flex;
  align-items: center;
  gap: 22px;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
.detail .view-tabs { margin-top: 0; }
.pane-meta .meta-extras { margin: 4px 0 8px; }
.pane-meta .desc-edit { margin-top: 12px; }
.view-tab {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 8px 0 10px;
  margin-bottom: -1px;
  font-size: 14px;
  font-weight: 550;
}
.view-tab:hover { color: var(--text); }
.view-tab.active {
  color: var(--text);
  border-bottom-color: var(--gold);
}
.view-pane[hidden] { display: none !important; }
.view-summary .curve-strip { margin-bottom: 0; }

.curve-strip {
  background: var(--well);
  border: 1px solid var(--well-border);
  border-radius: var(--radius);
  padding: 14px 16px 14px;
  margin-bottom: 16px;
  box-shadow: var(--glass-shine);
}
.curve-meta {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}
.curve-row {
  display: grid;
  grid-template-columns: repeat(18, minmax(0, 1fr));
  gap: 3px;
  height: 128px;
  min-height: 112px;
  align-items: stretch;
}
.curve-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: transparent;
  border: 0;
  overflow: visible;
}
.curve-col .plot {
  position: relative;
  flex: 1 1 auto;
  min-height: 80px;
  background: rgba(91, 157, 255, 0.06);
  border: 1px solid rgba(150, 190, 255, 0.10);
  border-radius: 8px;
  overflow: hidden;
}
.curve-col .seg {
  position: absolute;
  left: 0; right: 0;
  background: linear-gradient(180deg, var(--gold-2), var(--teal));
  opacity: 0.62;
  border-radius: 0.75px;
  transition: top 0.45s var(--ease), height 0.45s var(--ease);
}
.curve-col .labs {
  flex: 0 0 auto;
  padding: 3px 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1.15;
  pointer-events: none;
}
.curve-col .mx, .curve-col .mn {
  font-family: var(--mono);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}
.curve-col .mx { color: var(--text); flex: 0 0 auto; padding-bottom: 3px; }
.curve-col .mn { color: var(--muted); }
.curve-col .tn {
  position: static;
  left: auto; right: auto; bottom: auto;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  font-family: var(--mono);
}
.curve-vals {
  align-items: baseline;
}
.curve-vals span {
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.curve-vals strong {
  color: var(--text);
  font-weight: 650;
  margin-right: 6px;
  font-family: inherit;
}
.curve-chart {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 8px;
  align-items: stretch;
}
.curve-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  padding: 2px 0 18px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* one-at-a-time stat tools */
.tool-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 14px;
  margin: 2px 0 12px;
}
.tool-chip {
  appearance: none;
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  color: var(--muted);
  padding: 3px 0;
  height: auto;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}
.tool-chip:hover { color: var(--text); }
.tool-chip.active {
  color: var(--text);
  border-bottom-color: var(--gold);
}
.tools-panel[hidden] { display: none !important; }
.tools-panel.open {
  display: block;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  margin: 0 0 14px;
  padding: 14px 16px 16px;
  box-shadow: var(--glass-shine);
}
.tools-panel.just-applied {
  animation: confirm-flash 0.75s var(--ease);
  border-color: rgba(126, 217, 160, 0.4);
}
.tools-fill, .tools-scale { padding: 0; background: none; border: 0; }
.tools-fill[hidden], .tools-scale[hidden] { display: none !important; }
.tools-kicker {
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 2px;
}
.tools-lead {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  max-width: 62ch;
}
.apply-confirm {
  display: inline-block;
  margin-left: 8px;
  color: var(--ok);
  font-size: 12.5px;
  font-weight: 600;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.apply-confirm.show {
  opacity: 1;
  transform: none;
}
.tools-grid .apply-confirm {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  min-height: 1.2em;
}
.tools-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr)) minmax(148px, 1.1fr) auto;
  gap: 10px 12px;
  align-items: end;
}
.scale-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 12px;
  align-items: end;
  max-width: 280px;
}
.tool-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.tool-field > span {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
}
.tool-in {
  width: 100%;
  background: var(--well-bg);
  border: 1px solid var(--well-border);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
select.tool-in {
  font-family: var(--sans);
  font-size: 13.5px;
  appearance: auto;
  cursor: pointer;
}
.tool-in:focus { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.tool-apply .btn { height: 38px; white-space: nowrap; }

/* ---------- table ---------- */
.table-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  background: var(--well);
  border: 1px solid var(--well-border);
  box-shadow: var(--glass-shine);
}
.tiers {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  min-width: 640px;
}
.tiers th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(8, 16, 36, 0.72);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  z-index: 1;
  font-weight: 600;
}
.tiers td { padding: 7px 10px; border-bottom: 1px solid rgba(232,228,218,0.04); vertical-align: middle; }
.tiers tbody tr {
  transition: background 0.2s var(--ease);
}
.tiers tbody tr:hover td { background: rgba(255,255,255,0.018); }
.tiers tbody tr:focus-within td,
.tiers tbody tr.row-on td {
  background: rgba(91, 157, 255, 0.06);
}
.tiers .tnum {
  font-family: var(--mono);
  color: var(--muted);
  width: 48px;
  font-weight: 600;
}
.cell-in {
  width: 112px;
  background: var(--well-bg);
  border: 1px solid var(--well-border);
  border-radius: 8px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  cursor: ew-resize;
  touch-action: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
}
#curve-t1-min, #curve-t1-max, #curve-t18-min, #curve-t18-max {
  cursor: ew-resize;
  touch-action: none;
}
body.is-scrubbing, body.is-scrubbing * { cursor: ew-resize !important; user-select: none !important; }
input.scrubbing { caret-color: transparent; }
.cell-in:focus { outline: 0; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-dim); }
.cell-in.bad { border-color: var(--danger); background: var(--danger-dim); }
.span-val { font-family: var(--mono); color: var(--text-dim); width: 88px; }

.bar-track {
  position: relative;
  height: 18px;
  background: var(--well-bg);
  border: 1px solid var(--well-border);
  border-radius: 999px;
  min-width: 220px;
  overflow: hidden;
}
.bar-fill {
  position: absolute;
  top: 2px; bottom: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(74,212,196,0.85), rgba(91,157,255,1));
  min-width: 2px;
  transition: left 0.45s var(--ease), width 0.45s var(--ease);
}
.bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--mono);
  color: #f4f7fb;
  text-shadow: 0 1px 2px #000;
  pointer-events: none;
}

.banner {
  background: var(--indigo-dim);
  border: 1px solid rgba(154,168,255,0.22);
  color: #c9d2fb;
  padding: 10px 14px;
  border-radius: 2.5px;
  margin-bottom: 14px;
  font-size: 13.5px;
  animation: panel-enter 0.4s var(--ease);
}

.compare-grid { display: grid; gap: 8px; }
.cmp-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  align-items: center;
}
.cmp-bars { position: relative; height: 30px; background: var(--well-bg); border: 1px solid var(--well-border); border-radius: 12px; }
.cmp-fill {
  position: absolute;
  top: 4px;
  height: 8px;
  border-radius: 3px;
  opacity: 0.92;
  transition: left 0.45s var(--ease), width 0.45s var(--ease);
}
.cmp-fill.a { background: var(--teal); top: 5px; }
.cmp-fill.b { background: var(--gold); top: 16px; }
.legend { display: flex; gap: 16px; color: var(--text-dim); margin: 8px 0 14px; font-size: 13.5px; flex-wrap: wrap; }
.swatch { width: 10px; height: 10px; border-radius: 0.75px; display: inline-block; margin-right: 6px; }
.swatch.a { background: var(--teal); }
.swatch.b { background: var(--gold); }

/* ---------- modals ---------- */
.modal {
  border: 1px solid var(--glass-border);
  background: var(--glass-strong);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  color: var(--text);
  border-radius: 20px;
  padding: 0;
  width: min(500px, calc(100vw - 28px));
  box-shadow: var(--glass-shine), var(--shadow);
}
.modal.wide { width: min(740px, calc(100vw - 28px)); }
.modal::backdrop { background: rgba(6, 7, 10, 0.72); backdrop-filter: blur(6px); }
.modal[open] { animation: modal-in 0.28s var(--ease); }
.modal[open]::backdrop { animation: fade-in 0.22s ease; }
.modal form { display: flex; flex-direction: column; gap: 14px; padding: 22px 22px 18px; }
.modal header h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -0.02em; }
.modal header p { margin: 0; color: var(--text-dim); }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; flex-wrap: wrap; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
.field em { font-style: normal; color: var(--gold); font-size: 11px; margin-left: 6px; }
.field input, .field select, .modal textarea {
  background: var(--well-bg);
  border: 1px solid var(--well-border);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.field input:focus, .field select:focus, .modal textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}
.modal textarea {
  min-height: 180px;
  font-family: var(--mono);
  font-size: 12.5px;
  resize: vertical;
}
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fmt { color: var(--text-dim); font-size: 13.5px; }
.fmt ul { margin: 8px 0 0; padding-left: 18px; }
.warn { color: #ffb4ac !important; }
.preview {
  background: #000000;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px;
  max-height: 160px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  white-space: pre-wrap;
}
#add-key-hint { color: var(--muted); }
#add-key-hint.bad { color: var(--danger); }

.toast {
  position: fixed;
  bottom: 20px;
  right: var(--gutter);
  background: var(--surface-3);
  border: 1px solid var(--line-2);
  padding: 12px 16px;
  border-radius: 3px;
  box-shadow: var(--shadow);
  z-index: 40;
  animation: toast-in 0.32s var(--ease);
  max-width: min(360px, calc(100vw - 32px));
}
.toast.err { border-color: rgba(239,122,108,0.45); }

/* ---------- motion ---------- */
@keyframes page-enter {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes panel-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
@keyframes bar-grow {
  from { transform: scaleY(0.2); opacity: 0; }
  to { transform: none; opacity: 0.85; }
}
@keyframes confirm-flash {
  0% { box-shadow: 0 0 0 1px rgba(126,217,160,0.45), 0 0 28px rgba(126,217,160,0.22); }
  100% { box-shadow: 0 0 0 1px var(--gold-dim), var(--shadow-sm); }
}
@keyframes drawer-in {
  from { transform: translateX(-105%); }
  to { transform: translateX(0); }
}

/* ========== Breakpoints ==========
   Candybar / phone:        max-width 599px
   Fold / compact tablet:   600px–1199px  (Z Fold 2 inner, portrait + landscape)
   Desktop:                 min-width 1200px
   Dual-segment (optional): if horizontal-viewport-segments: 2, keep width layout
*/
.main { container-type: inline-size; container-name: board; }
.tools-fill { container-type: inline-size; }

/* Fill-curve fields wrap when the fill column (not the viewport) is tight */
@container (max-width: 480px) {
  .tools-grid {
    grid-template-columns: repeat(2, minmax(64px, 1fr));
    gap: 8px 10px;
  }
  .tool-apply { grid-column: 1 / -1; }
  .tools-grid .apply-confirm { grid-column: 1 / -1; }
}

/* Sticky first column on real tables (fold + desktop). Candybar uses cards. */
@media (min-width: 600px) {
  .tiers th:first-child,
  .tiers td.tnum {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg);
    box-shadow: 6px 0 8px -6px rgba(0, 0, 0, 0.55);
  }
  .tiers th:first-child { z-index: 3; }
  .tiers tbody tr:hover td.tnum { background: rgba(91,157,255,0.08); }
  .tiers tbody tr:focus-within td.tnum,
  .tiers tbody tr.row-on td.tnum { background: rgba(91,157,255,0.12); }
}

/* ---------- Fold / compact tablet: 600–1199 (Z Fold 2 inner) ---------- */
@media (min-width: 600px) and (max-width: 1199px) {
  :root { --sidebar: 220px; --radius: 14px; }
  .shell { gap: 8px; padding: 0 10px 10px 0; }
  .app-rail { margin: 8px 0 10px 8px; border-radius: 16px; }
  .sidebar, .main { margin: 8px 0 10px; border-radius: 16px; }
  body { font-size: 13.5px; }
  .slash { display: none; }
  #topbar { gap: 8px; height: var(--top); padding: 8px var(--gutter); }
  .brand-name { font-size: 14.5px; }
  .searchwrap input { height: 34px; }
  .btn { height: 34px; padding: 0 11px; }
  .btn.tiny { height: 32px; padding: 0 9px; font-size: 12.5px; }
  .btn.icon { width: 36px; }
  .btn.menu-btn { display: none; }

  .sidebar {
    width: var(--sidebar);
    position: relative;
    transform: none;
    box-shadow: none;
  }
  .side-head {
    padding: 10px 10px;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 10.5px;
  }
  .hide-samples { font-size: 12px; gap: 6px; }
  .stat-item {
    padding: 5px 8px 6px;
    margin: 0;
    width: 100%;
    gap: 0 6px;
  }
  .stat-list { gap: 8px; padding: 8px 8px 12px; }
  .stat-item .name { font-size: 13px; }
  .stat-item .key { font-size: 10.5px; }
  .cat-label { padding: 12px 12px 4px; font-size: 10px; }
  .side-foot { padding: 8px 12px 12px; font-size: 11px; }

  .detail, .compare-view {
    padding: 14px 14px 48px;
    max-width: none;
  }
  .title-edit { font-size: 22px; width: min(420px, 100%); }
  .desc-edit { max-width: none; margin: 4px 0 12px; }

  .tools-panel { margin: 0 0 12px; padding: 12px 14px 14px; }
  .tools-fill, .tools-scale { padding: 0; }
  .tools-lead { font-size: 12.5px; margin-bottom: 10px; }
  .tools-kicker { font-size: 11px; }
  .scale-row { max-width: none; }
  .tool-in { padding: 6px 8px; font-size: 12.5px; }
  .tool-apply .btn { height: 34px; }

  .curve-strip { padding: 10px 12px 8px; margin-bottom: 12px; }
  .curve-row { height: 150px; min-height: 130px; gap: 3px; }
  .curve-col .tn, .curve-col .mx, .curve-col .mn { font-size: 9px; }
  .curve-chart { grid-template-columns: 36px 1fr; gap: 6px; }
  .curve-axis { padding: 2px 0 16px; }

  .tiers { min-width: 560px; }
  .tiers th { padding: 8px 8px; font-size: 10.5px; }
  .tiers td { padding: 5px 8px; }
  .cell-in { width: 92px; padding: 6px 8px; font-size: 12.5px; }
  .bar-track { min-width: 148px; height: 16px; }
  .span-val { width: 64px; font-size: 12.5px; }

  .compare-grid { gap: 6px; }
  .cmp-row { grid-template-columns: 32px 1fr; gap: 8px; }
  .cmp-bars { height: 26px; }
}

/* Wider slim rail in the upper fold band (portrait). Landscape overrides below. */
@media (min-width: 900px) and (max-width: 1199px) and (orientation: portrait) {
  :root { --sidebar: 232px; }
  .tool-strip { margin-bottom: 10px; }
}

/* Landscape Fold inner: same chrome, more table / compare width */
@media (min-width: 600px) and (max-width: 1199px) and (orientation: landscape) {
  :root { --sidebar: 208px; }
  .banner { padding: 7px 12px; margin-bottom: 8px; font-size: 12.5px; }
  .detail, .compare-view { padding: 10px 12px 28px; }
  .title-edit { font-size: 20px; }
  .desc-edit { margin: 2px 0 8px; }
  .tools-panel { margin: 0 0 8px; }
  .tools-fill, .tools-scale { padding: 0; }
  .tools-lead { font-size: 12px; margin-bottom: 6px; }
  .curve-strip { padding: 8px 10px 6px; margin-bottom: 8px; }
  .curve-row { height: 140px; min-height: 120px; }
  .compare-grid {
    display: grid;
    grid-template-rows: repeat(9, auto);
    grid-auto-flow: column;
    gap: 6px 18px;
  }
}

/* ---------- Candybar / phone: ≤599 ---------- */
@media (max-width: 599px) {
  :root { --top: auto; --sidebar: 280px; --radius: 14px; }
  .shell { gap: 0; padding: 0; }
  .app-rail, .sidebar, .main { margin: 0; border-radius: 0; border: none; box-shadow: none; }
  .btn.menu-btn { display: inline-flex; width: 44px; height: 44px; }
  .slash { display: none; }
  #topbar {
    flex-wrap: nowrap;
    gap: 8px;
    height: var(--top);
    padding: 8px var(--gutter);
  }
  #sections { display: none; }
  #topbar .menu-btn { display: inline-flex; }
  .app-rail { display: none; }
  .app-dock {
    display: flex;
    align-items: stretch;
    gap: 4px;
    padding: 4px 8px calc(6px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--glass-border);
    background: var(--glass-strong);
    backdrop-filter: var(--blur);
    -webkit-backdrop-filter: var(--blur);
    box-shadow: var(--glass-shine);
    z-index: 22;
    flex-shrink: 0;
  }
  .app-dock .rail-btn {
    flex: 1;
    min-height: 52px;
    font-size: 11px;
  }
  .section-pane { padding: 28px 18px 32px; }
  .brand { min-width: 0; }
  .brand-name { font-size: 14.5px; }
  .searchwrap input { height: 44px; }
  #topbar .stats-only.btn { padding: 5px 8px; }
  .btn { height: 44px; padding: 0 14px; min-width: 44px; }
  .btn.tiny { height: 44px; padding: 0 12px; }
  .hide-samples { min-height: 44px; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(6, 7, 10, 0.58);
    z-index: 24;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s var(--ease);
  }
  .sidebar-backdrop.show {
    opacity: 1;
    pointer-events: auto;
  }
  .sidebar {
    position: fixed;
    z-index: 30;
    top: 0;
    bottom: 0;
    left: 0;
    width: min(320px, 88vw);
    transform: translateX(-105%);
    transition: transform 0.32s var(--ease);
    box-shadow: none;
    padding-top: env(safe-area-inset-top);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow);
  }
  .stat-item {
    min-height: 44px;
    padding: 8px 10px;
    align-items: center;
  }
  .stat-list { gap: 6px; }
  body.drawer-open { overflow: hidden; }

  .detail, .compare-view { padding: 16px 14px 80px; }
  .detail-head, .compare-head { flex-direction: column; align-items: stretch; }
  .detail-actions { width: 100%; }
  .title-edit { font-size: 22px; width: 100%; }
  .empty-board { margin-top: 6vh; padding: 0 20px 48px; }
  .row2 { grid-template-columns: 1fr; }
  .bar-track { min-width: 140px; }
  .modal footer .btn { min-height: 44px; }
  .field input, .field select { min-height: 44px; }
  .tool-in { min-height: 44px; }
  .tool-apply .btn { height: 44px; width: 100%; }
  .curve-row { height: 120px; min-height: 100px; gap: 2px; }
  .curve-col .mx, .curve-col .mn, .curve-col .tn { font-size: 8px; }
  .curve-axis { padding: 2px 0 16px; }

  .tools-panel { margin: 0 0 14px; padding: 12px 12px 14px; }
  .tools-grid { grid-template-columns: repeat(2, 1fr); }
  .tool-apply { grid-column: 1 / -1; }
  .scale-row { max-width: none; }
  .tools-fill, .tools-scale { padding: 0; }
  .tool-chip { min-height: 44px; }
  .view-tab { min-height: 44px; }

  /* 18-tier table as min/max cards */
  .table-scroll { overflow: visible; }
  .tiers { min-width: 0; }
  .tiers thead { display: none; }
  .tiers, .tiers tbody { display: block; width: 100%; }
  .tiers tbody tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 12px;
    margin-bottom: 10px;
    align-items: end;
  }
  .tiers td {
    padding: 0;
    border: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .tiers td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 600;
  }
  .tiers .tnum {
    grid-column: 1 / -1;
    width: auto;
    font-size: 14px;
    color: var(--text);
    flex-direction: row;
    align-items: center;
    gap: 8px;
    position: static;
    box-shadow: none;
    background: transparent;
  }
  .tiers .tnum::before { content: none; }
  .tiers td.window-cell,
  .tiers td.span-cell { grid-column: 1 / -1; }
  .cell-in { width: 100%; min-height: 44px; font-size: 16px; }
  .bar-track { min-width: 0; width: 100%; height: 22px; }
  .span-val { width: auto; font-size: 14px; }
  .toast { left: 12px; right: 12px; bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }
}

/* Dual-segment viewports (Surface Duo, etc.): do not hinge-span.
   Z Fold 2 inner is one flexible display — width + orientation already cover it. */
@media (horizontal-viewport-segments: 2) {
  .shell { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  .empty-visual span { opacity: 0.85; transform: none; }
}

/* ---------- login ---------- */
.login-body {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}
.login-card {
  width: min(420px, 100%);
  position: relative;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  padding: 32px 32px 28px;
  box-shadow: var(--glass-shine), var(--shadow);
}
.login-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(165deg, rgba(255,255,255,0.16) 0%, transparent 42%);
}
.login-brand { margin-bottom: 22px; }
.login-card h1 {
  margin: 0 0 8px;
  font-size: 22px;
  letter-spacing: -0.03em;
}
.login-lead { color: var(--text-dim); margin: 0 0 18px; font-size: 14px; }
.login-card .field { margin-bottom: 12px; }
.login-card .btn.primary { width: 100%; height: 40px; margin-top: 8px; }
.login-err { color: var(--danger); font-size: 13.5px; margin: 0 0 8px; }

/* ---------- account / tokens ---------- */
#usernav {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
}
.token-once {
  background: #000000;
  border: 1px solid rgba(91,157,255,0.35);
  border-radius: 2px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  word-break: break-all;
  color: var(--gold-2);
}
.token-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 12px; }
.token-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--glass-border);
  border-radius: 2px;
  box-shadow: var(--glass-shine);
}
.token-row .meta { color: var(--muted); font-size: 12px; font-family: var(--mono); }

/* ---------- item-tier legend + modifier ---------- */
.tier-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  color: var(--muted);
  font-size: 12.5px;
  margin: 0 0 14px;
  padding: 8px 12px;
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border: 1px solid var(--glass-border);
  border-radius: 2px;
  box-shadow: var(--glass-shine);
}
.tier-legend strong { color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; }
.tier-legend code { font-size: 11.5px; color: var(--text); }
.pill.mod {
  background: var(--teal-dim);
  color: var(--teal);
  letter-spacing: 0.06em;
}
select,
.mod-select,
select.tool-in,
.field select,
.meta-extras select {
  appearance: none;
  -webkit-appearance: none;
  color-scheme: dark;
  color: var(--text);
  cursor: pointer;
  min-height: 36px;
  padding: 8px 32px 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-line, var(--line-2));
  background-color: #121821;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.5 L6 6.5 L11 1.5' fill='none' stroke='%235eead4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
  font: 500 13.5px/1.3 var(--sans);
  transition: border-color var(--motion-quick) var(--ease-out), box-shadow var(--motion-quick) var(--ease-out), background-color var(--motion-quick) var(--ease-out);
}
select:hover,
.mod-select:hover {
  border-color: color-mix(in srgb, var(--teal) 45%, var(--line-2));
  background-color: #161e28;
}
select:focus,
.mod-select:focus,
select.tool-in:focus,
.field select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-dim);
}
select option,
.mod-select option {
  background-color: #0c1118;
  color: #e8eef4;
}
select option:checked,
select option:hover {
  background-color: #121821;
  color: #5eead4;
}
.meta-extras {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 8px 12px;
  margin-top: 10px;
  max-width: none;
}
.meta-extras .field { margin: 0; }
.meta-extras .field span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 3px;
}
.meta-extras .field-wide { grid-column: 1 / -1; }
.meta-extras .field small { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.meta-extras input, .meta-extras select { width: 100%; }
.banner.ladder-banner { border-color: rgba(91, 157, 255, 0.35); color: #c5dcff; }

/* ---------- add-stat 18-tier table ---------- */
.add-tiers-wrap {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg);
}
.add-tiers { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.add-tiers th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 6px 8px;
  position: sticky;
  top: 0;
  background: #000000;
}
.add-tiers td { padding: 3px 8px; }
.add-tiers .cell-in { width: 88px; padding: 5px 8px; font-size: 12.5px; }
.modal.wide-add { width: min(640px, calc(100vw - 28px)); }


@media (prefers-reduced-transparency: reduce) {
  #topbar, .app-rail, .sidebar, .tools-panel, .modal, .login-card, .app-dock,
  .stat-item, .searchwrap, .tier-legend, .table-scroll, .token-row {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--surface);
  }
}


.cockpit-create {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--glass-border);
}
.cockpit-create h3 {
  margin: 0 0 10px;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.cockpit-admin { margin: 8px 0 12px; }
.cockpit-row .muted { color: var(--muted); font-weight: 400; }
#usernav .hidden { display: none !important; }

.key-in { font-family: var(--mono); letter-spacing: 0.04em; text-transform: uppercase; }

.sum-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}
@container board (min-width: 1200px) {
  .sum-grid { grid-template-columns: repeat(9, minmax(0, 1fr)); }
}
.sum-cell {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid rgba(150, 190, 255, 0.14);
  border-radius: 8px;
  background: rgba(91, 157, 255, 0.04);
  min-width: 0;
}
.sum-cell .t {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.04em;
  flex: 0 0 auto;
}
.sum-cell .v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sum-cell .mx { font-weight: 650; }
.sum-cell .mn { color: var(--muted); }
@media (max-width: 599px) {
  .sum-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}


/* ---------- range field (bold plot) ---------- */
.plot-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 2px 0 10px;
  flex-wrap: wrap;
}
.plot-controls { display: flex; align-items: center; gap: 8px; }
.desc-edit { margin-bottom: 8px; }
.vitals {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  font: 500 13px/1.25 var(--mono);
  color: var(--muted);
  letter-spacing: -0.02em;
}
.vitals .k { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
.vitals .v { color: var(--text); font-weight: 650; font-size: 15px; }
.vitals .vital.warn .v { color: #f0c56e; }
.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0,0,0,0.35);
  flex-shrink: 0;
}
.seg-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--muted);
  min-height: 34px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.seg-btn:hover { color: var(--text); background: var(--surface-2); }
.seg-btn.on { color: var(--text); background: var(--gold-dim); }
.range-well {
  height: min(64vh, 640px);
  min-height: 520px;
  background: #000;
  border: 1px solid var(--well-border);
  border-radius: var(--radius);
  position: relative;
  overflow: hidden;
  box-shadow: var(--glass-shine), 0 18px 50px rgba(0,0,0,0.35);
}
.rf-inner, .rf-svg { width: 100%; height: 100%; display: block; }
.rf-overlays { position: absolute; inset: 0; pointer-events: none; }
.tile-num {
  position: absolute;
  pointer-events: auto;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid var(--gold);
  background: #05070c;
  color: #fff;
  font: 650 13px/1 var(--mono);
  text-align: center;
  padding: 0 4px;
  z-index: 3;
  outline: none;
}
.plot-label {
  font: 650 13px/1 var(--mono);
  fill: var(--text);
  letter-spacing: -0.03em;
}
.plot-label-dim { fill: var(--muted); font-weight: 500; font-size: 12px; }
.plot-label-hi { fill: #fff; font-weight: 700; }
.plot-inspect {
  min-height: 40px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  padding: 10px 4px 14px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  font-variant-numeric: tabular-nums;
}
.plot-inspect strong { color: var(--text); font-size: 15px; font-weight: 650; }
.tool-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 4px 0 10px; }

.range-shell {
  background: #000;
  border: 1px solid var(--well-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--glass-shine), 0 18px 50px rgba(0,0,0,0.35);
  margin-bottom: 8px;
}
.range-shell .range-well {
  height: min(62vh, 620px);
  min-height: 500px;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}
.range-shell .plot-inspect {
  min-height: 36px;
  margin: 0;
  padding: 8px 14px 10px;
  border: 0;
  border-top: 1px solid var(--line);
  background: #000;
}
.seg-btn.solo {
  border: 1px solid var(--line-2);
  border-radius: 10px;
  background: rgba(0,0,0,0.35);
  margin-left: 2px;
}
.seg-btn.solo.on { background: var(--gold-dim); }
.tools-panel.sculpt-bar {
  margin: 0 0 10px;
  padding: 0 12px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  border-radius: 12px;
  transform: translateY(-6px);
  transition: max-height var(--motion-fast) var(--ease-out),
              opacity var(--motion-quick) var(--ease-out),
              padding var(--motion-quick) var(--ease-out),
              transform var(--motion-fast) var(--ease-out);
}
.tools-panel.sculpt-bar.open {
  max-height: 160px;
  opacity: 1;
  padding: 10px 12px 8px;
  transform: translateY(0);
}
.tools-panel.sculpt-bar[hidden] { display: block !important; }
.tools-panel.sculpt-bar .tools-grid { margin: 0; }
.detail .meta-extras { margin-top: 8px; }

/* zip motion + zip select language */
.view-tab {
  transition: color var(--motion-quick) var(--ease-out), border-color var(--motion-quick) var(--ease-out);
}
.view-tab.active { border-bottom-color: var(--teal); color: #fff; }
.seg-btn {
  transition: color var(--motion-quick) var(--ease-out), background var(--motion-quick) var(--ease-out), transform var(--motion-micro) var(--ease-out);
}
.seg-btn:active { transform: scale(0.96); }
.seg-btn.on {
  color: #07201c;
  background: var(--teal);
}
.seg-btn.solo.on {
  background: var(--teal);
  color: #07201c;
  border-color: transparent;
}
.stat-item {
  transition: background var(--motion-quick) var(--ease-out), border-color var(--motion-quick) var(--ease-out), transform var(--motion-quick) var(--ease-out);
}
.stat-item.active {
  border-color: color-mix(in srgb, var(--teal) 45%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--teal) 25%, transparent);
}
.pane-stat, .pane-meta {
  animation: zip-enter var(--motion-fast) var(--ease-out);
}
.range-shell {
  animation: zip-enter var(--motion-fast) var(--ease-out);
}
.plot-toolbar .vitals .v {
  transition: color var(--motion-quick) var(--ease-out);
}
.tile-num {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px var(--teal-dim);
  transition: box-shadow var(--motion-quick) var(--ease-out), border-color var(--motion-quick) var(--ease-out);
}
.pill.sample {
  color: var(--teal);
  background: var(--teal-dim);
}
@keyframes zip-enter {
  from { opacity: 0; transform: translateY(10px); filter: blur(6px); }
  to { opacity: 1; transform: none; filter: none; }
}
.meta-extras .field {
  animation: zip-enter var(--motion-fast) var(--ease-out) both;
}
.meta-extras .field:nth-child(1) { animation-delay: 0ms; }
.meta-extras .field:nth-child(2) { animation-delay: 40ms; }
.meta-extras .field:nth-child(3) { animation-delay: 80ms; }
.meta-extras .field:nth-child(4) { animation-delay: 120ms; }
.meta-extras .field:nth-child(5) { animation-delay: 160ms; }
.meta-extras .field:nth-child(6) { animation-delay: 200ms; }
.meta-extras .field:nth-child(7) { animation-delay: 240ms; }
.meta-extras .field:nth-child(8) { animation-delay: 280ms; }
.meta-extras .field:nth-child(9) { animation-delay: 320ms; }


/* === local trial: +15% interactive visibility. Delete this whole block to revert. === */
.btn:not(.primary):not(.danger) {
  background: rgba(80, 140, 255, 0.115);
  border-color: rgba(150, 190, 255, 0.25);
}
.btn.ghost {
  background: rgba(80, 140, 255, 0.09);
  border-color: rgba(150, 190, 255, 0.28);
}
.btn:not(.primary):hover,
.btn.ghost:hover {
  background: rgba(80, 140, 255, 0.184);
  border-color: rgba(180, 210, 255, 0.32);
}
.btn.primary {
  box-shadow: 0 6px 18px rgba(91, 157, 255, 0.25);
}
.btn.danger {
  background: rgba(239, 122, 108, 0.184);
  border-color: rgba(239, 122, 108, 0.40);
}
.rail-btn {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(140, 180, 255, 0.16);
}
.rail-btn:hover { background: rgba(255, 255, 255, 0.092); }
.stat-item {
  background: rgba(255, 255, 255, 0.052);
  border-color: rgba(140, 180, 255, 0.207);
}
.stat-item:hover {
  background: rgba(255, 255, 255, 0.104);
  border-color: rgba(255, 255, 255, 0.253);
}
.seg {
  border-color: rgba(150, 190, 255, 0.253);
  background: rgba(8, 12, 20, 0.48);
}
.seg-btn { color: #93a8d4; }
.seg-btn.on,
.seg-btn.solo.on {
  background: rgba(91, 157, 255, 0.207);
}
.view-tab { color: #93a8d4; }
.searchwrap {
  background: rgba(8, 10, 14, 0.437);
  border-color: rgba(140, 180, 255, 0.207);
}
select,
.mod-select,
select.tool-in,
.field select,
.meta-extras select {
  border-color: rgba(150, 190, 255, 0.253);
  background-color: #161e28;
}
.cell-in,
.tool-in,
.title-edit,
.cat-edit,
.desc-edit {
  border-color: rgba(150, 190, 255, 0.22);
}
.plot-controls .seg-btn.solo {
  border: 1px solid rgba(150, 190, 255, 0.25);
  background: rgba(80, 140, 255, 0.09);
}
/* === end local trial === */
