/* ---------- page chrome (neutral dark UI; previews carry the scheme colors) ---------- */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ui-bg: #16181d;
  --ui-bg-raised: #1e2128;
  --ui-bg-hover: #262a33;
  --ui-border: #2e333e;
  --ui-fg: #e4e7ee;
  --ui-fg-dim: #9aa1af;
  --ui-accent: #7aa2f7;
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", ui-monospace, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html, body { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--ui-bg);
  color: var(--ui-fg);
  line-height: 1.5;
}
a { color: var(--ui-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  display: grid;
  grid-template-areas: "topbar topbar" "sidebar detail";
  grid-template-columns: 290px 1fr;
  grid-template-rows: auto 1fr;
  height: 100vh;
}

/* ---------- topbar ---------- */

.topbar {
  grid-area: topbar;
  display: flex; align-items: center; gap: 2rem;
  padding: 0.7rem 1.2rem;
  background: var(--ui-bg-raised);
  border-bottom: 1px solid var(--ui-border);
}
.brand { font-weight: 700; font-size: 1.05rem; letter-spacing: 0.02em; }
.topnav { display: flex; gap: 1rem; }
.nav-link { color: var(--ui-fg-dim); padding: 0.2rem 0.6rem; border-radius: 6px; }
.nav-link.active { color: var(--ui-fg); background: var(--ui-bg-hover); }
.nav-link.disabled { cursor: default; opacity: 0.55; }
.nav-link.disabled:hover { text-decoration: none; }
.nav-link small { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; }
.topbar-right { margin-left: auto; }
.landing-privacy { margin-top: 0.8rem; font-size: 0.85rem; }
.landing p { margin-bottom: 0.6rem; }

/* ---------- sidebar ---------- */

.sidebar {
  grid-area: sidebar;
  display: flex; flex-direction: column; gap: 0.7rem;
  padding: 0.9rem;
  border-right: 1px solid var(--ui-border);
  overflow: hidden;
}
#search {
  width: 100%;
  padding: 0.5rem 0.7rem;
  background: var(--ui-bg-raised);
  border: 1px solid var(--ui-border);
  border-radius: 8px;
  color: var(--ui-fg);
  font-size: 0.9rem;
}
#search:focus { outline: 2px solid var(--ui-accent); outline-offset: -1px; }

.filter { display: flex; gap: 0.4rem; }
.filter label { flex: 1; }
.filter input { position: absolute; opacity: 0; pointer-events: none; }
.filter span {
  display: block; text-align: center;
  padding: 0.25rem 0; font-size: 0.8rem;
  border: 1px solid var(--ui-border); border-radius: 6px;
  color: var(--ui-fg-dim); cursor: pointer;
}
.filter input:checked + span {
  background: var(--ui-bg-hover); color: var(--ui-fg);
  border-color: var(--ui-accent);
}

.scheme-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.scheme-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  color: var(--ui-fg);
}
.scheme-item:hover { background: var(--ui-bg-hover); text-decoration: none; }
.scheme-item.active { background: var(--ui-bg-hover); outline: 1px solid var(--ui-accent); }
.scheme-item-name { flex: 1; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scheme-item-tag {
  font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.1rem 0.4rem; border-radius: 99px;
}
.scheme-item-tag.dark { background: #2a2d3a; color: #aab2d0; }
.scheme-item-tag.light { background: #e8e4d8; color: #6b6349; }

.mini-palette {
  display: inline-flex; gap: 2px; padding: 3px;
  border-radius: 5px; border: 1px solid var(--ui-border);
}
.mini-palette i { width: 8px; height: 14px; border-radius: 2px; display: inline-block; }
.empty { color: var(--ui-fg-dim); font-size: 0.85rem; padding: 0.5rem; }

/* ---------- detail ---------- */

.detail { grid-area: detail; overflow-y: auto; padding: 1.4rem 1.8rem 3rem; }
.landing { max-width: 480px; margin: 4rem auto; color: var(--ui-fg-dim); }
.landing h2 { color: var(--ui-fg); margin-bottom: 0.5rem; }

.detail-header h2 { font-size: 1.6rem; }
.detail-sub { display: flex; align-items: center; gap: 0.7rem; color: var(--ui-fg-dim); font-size: 0.9rem; }
.detail-notes { margin-top: 0.4rem; min-height: 1.5em; color: var(--ui-fg-dim); font-size: 0.88rem; font-style: italic; }

section { margin-top: 1.6rem; }
.section-title {
  font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--ui-fg-dim); margin-bottom: 0.7rem;
}

/* coverage badges */
.cov-legend {
  display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem;
  margin-bottom: 0.8rem; font-size: 0.75rem; color: var(--ui-fg-dim);
}
.cov-legend span { display: inline-flex; align-items: center; gap: 0.4rem; }
.cov-legend i { width: 0.85rem; height: 0.85rem; padding: 0; border-radius: 4px; }
.badge-group { margin-bottom: 0.6rem; }
.badge-group h4 { font-size: 0.75rem; color: var(--ui-fg-dim); font-weight: 500; margin-bottom: 0.3rem; }
.badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.badge {
  font-size: 0.78rem; padding: 0.18rem 0.6rem; border-radius: 99px;
  border: 1px solid var(--ui-border); color: var(--ui-fg-dim);
}
.badge.cov-default { background: #16321f; border-color: #2f7d46; color: #7fd99a; }
.badge.cov-collection { background: #172a3a; border-color: #2f628d; color: #85b8e8; }
.badge.cov-partial { background: #38301a; border-color: #8d762f; color: #e2c374; }
.badge.cov-none { opacity: 0.45; }

/* swatches */
h3 { font-size: 0.85rem; color: var(--ui-fg-dim); margin: 0.8rem 0 0.4rem; font-weight: 500; }
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.swatch {
  display: flex; flex-direction: column; align-items: stretch;
  width: 92px; cursor: pointer;
  background: var(--ui-bg-raised);
  border: 1px solid var(--ui-border); border-radius: 8px;
  overflow: hidden; color: inherit; font: inherit; padding: 0;
}
.swatch:hover { border-color: var(--ui-accent); }
.swatch-color { height: 40px; }
.swatch-label { font-size: 0.66rem; color: var(--ui-fg-dim); padding: 0.25rem 0.4rem 0; text-align: left; }
.swatch-hex { font-family: var(--mono); font-size: 0.7rem; padding: 0 0.4rem 0.3rem; text-align: left; }

/* ---------- previews ---------- */

.previews { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 480px)); gap: 1rem; }
.previews figure { min-width: 0; }
.previews figcaption { font-size: 0.78rem; color: var(--ui-fg-dim); margin-bottom: 0.35rem; }

.preview {
  height: 290px;
  display: flex; flex-direction: column;
  border-radius: 10px; overflow: hidden;
  border: 1px solid var(--ui-border);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  background: var(--p-bg); color: var(--p-fg);
  font-family: var(--mono); font-size: 0.72rem;
}

/* terminal */
.chrome {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; background: var(--p-bg-alt);
  border-bottom: 1px solid rgba(128, 128, 128, 0.25);
}
.dot { width: 10px; height: 10px; border-radius: 50%; }
.d1 { background: #ff5f57; } .d2 { background: #febc2e; } .d3 { background: #28c840; }
.chrome-title { margin-left: 8px; color: var(--p-muted); font-size: 0.68rem; }
.term-body { flex: 1; padding: 10px 12px; line-height: 1.55; overflow: auto; }
.t-fg { color: var(--p-fg); }
.t-muted { color: var(--p-muted); }
.t-red { color: var(--p-red); }      .t-green { color: var(--p-green); }
.t-blue { color: var(--p-blue); }    .t-cyan { color: var(--p-cyan); }
.t-magenta { color: var(--p-magenta); }
.t-brgreen { color: var(--p-br-green); } .t-bryellow { color: var(--p-br-yellow); }
.t-brblue { color: var(--p-br-blue); }
.t-cursor { color: var(--p-accent); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* editor */
.ed-tabs { display: flex; background: var(--p-bg-alt); border-bottom: 1px solid rgba(128,128,128,0.25); }
.ed-tab { padding: 6px 12px; color: var(--p-muted); border-right: 1px solid rgba(128,128,128,0.15); }
.ed-tab.active { background: var(--p-bg); color: var(--p-fg); box-shadow: inset 0 2px 0 var(--p-accent); }
.ed-body { flex: 1; padding: 8px 0; overflow: auto; }
.ed-line { display: flex; white-space: pre; line-height: 1.55; }
.ed-active { background: color-mix(in srgb, var(--p-muted) 14%, transparent); }
.ed-ln {
  width: 2.4em; flex: none; text-align: right; padding-right: 1em;
  color: var(--p-muted); opacity: 0.7; user-select: none;
}
.ed-status {
  display: flex; gap: 1.2em; padding: 4px 12px;
  background: var(--p-accent); color: var(--p-bg);
  font-size: 0.66rem; font-weight: 600;
}
.c-fg { color: var(--p-fg); }   .c-kw { color: var(--p-kw); }
.c-str { color: var(--p-str); } .c-fn { color: var(--p-fn); }
.c-num { color: var(--p-num); } .c-type { color: var(--p-type); }
.c-com { color: var(--p-com); font-style: italic; }
.c-var { color: var(--p-fg); }

/* desktop */
.desktop { font-family: var(--sans); }
.dt-wallpaper {
  position: relative; flex: 1; min-height: 0; padding: 16px;
  background:
    radial-gradient(120% 130% at 85% 10%, color-mix(in srgb, var(--p-accent) 38%, var(--p-bg)) 0%, transparent 55%),
    radial-gradient(110% 120% at 10% 95%, color-mix(in srgb, var(--p-magenta) 25%, var(--p-bg)) 0%, transparent 50%),
    var(--p-bg);
}
.dt-window {
  width: 78%; height: 160px; margin: 6px 0 0 8px;
  background: var(--p-bg-alt); border-radius: 8px; overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--p-fg) 18%, transparent);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.dt-titlebar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 10px; background: color-mix(in srgb, var(--p-bg) 60%, var(--p-bg-alt));
  color: var(--p-fg); font-size: 0.68rem;
}
.dt-btns i {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-left: 5px; background: var(--p-muted);
}
.dt-btns i:last-child { background: var(--p-red); }
.dt-window-body { display: flex; height: 100%; }
.dt-sidebar {
  width: 34%; padding: 6px; font-size: 0.66rem;
  background: color-mix(in srgb, var(--p-bg) 45%, var(--p-bg-alt));
  color: var(--p-fg);
}
.dt-side-item { padding: 3px 8px; border-radius: 5px; opacity: 0.8; }
.dt-side-item.sel { background: var(--p-accent); color: var(--p-bg); opacity: 1; font-weight: 600; }
.dt-files {
  flex: 1; display: grid; grid-template-columns: 1fr 1fr; align-content: start;
  gap: 4px; padding: 8px; font-size: 0.64rem; color: var(--p-fg);
}
.dt-file { display: flex; align-items: center; gap: 5px; padding: 3px 6px; border-radius: 5px; }
.dt-file.sel { background: color-mix(in srgb, var(--p-accent) 30%, transparent); outline: 1px solid var(--p-accent); }
.dt-icon { width: 12px; height: 10px; border-radius: 2px; flex: none; }
.dt-icon.folder { background: var(--p-accent); }
.dt-icon.doc { background: var(--p-muted); }
.dt-notification {
  position: absolute; right: 12px; top: 12px;
  display: flex; flex-direction: column; gap: 1px;
  padding: 7px 10px; border-radius: 8px; font-size: 0.62rem;
  background: color-mix(in srgb, var(--p-bg-alt) 88%, var(--p-fg));
  color: var(--p-fg);
  border-left: 3px solid var(--p-accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}
.dt-notification span { color: var(--p-muted); }
.dt-panel {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; background: var(--p-bg-alt);
  border-top: 1px solid color-mix(in srgb, var(--p-fg) 14%, transparent);
}
.dt-launcher { width: 14px; height: 14px; border-radius: 4px; background: var(--p-accent); }
.dt-task { width: 22px; height: 5px; border-radius: 3px; background: var(--p-muted); opacity: 0.5; }
.dt-task.active { background: var(--p-accent); opacity: 1; }
.dt-spacer { flex: 1; }
.dt-tray i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; background: var(--p-muted); }
.dt-clock { color: var(--p-fg); font-size: 0.66rem; }

/* ---------- duel mode ---------- */

.duel { max-width: 1100px; margin: 0 auto; }
.duel-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.6rem; margin-bottom: 1.1rem;
}
.duel-status { color: var(--ui-fg-dim); font-size: 0.9rem; }
.duel-status strong { color: var(--ui-fg); }
.duel-bye { display: block; min-height: 1.25em; font-size: 0.78rem; font-style: italic; }
.duel-controls { display: flex; align-items: center; gap: 0.35rem; }
.duel-pool-label { font-size: 0.75rem; color: var(--ui-fg-dim); margin-right: 0.2rem; }
.duel-pool-btn, .duel-restart, .duel-btn {
  font: inherit; font-size: 0.78rem; cursor: pointer;
  padding: 0.25rem 0.7rem; border-radius: 6px;
  background: var(--ui-bg-raised); color: var(--ui-fg-dim);
  border: 1px solid var(--ui-border);
}
.duel-pool-btn:hover, .duel-restart:hover, .duel-btn:hover {
  color: var(--ui-fg); border-color: var(--ui-accent);
}
.duel-pool-btn.active { color: var(--ui-fg); background: var(--ui-bg-hover); border-color: var(--ui-accent); }
.duel-restart { margin-left: 0.8rem; }

.duel-arena {
  display: grid; grid-template-columns: 1fr auto 1fr;
  align-items: stretch; gap: 1rem;
}
.duel-vs { align-self: center; font-weight: 800; color: var(--ui-fg-dim); font-size: 1.1rem; }
.duel-card {
  display: flex; flex-direction: column; gap: 0.6rem;
  padding: 0.9rem; min-width: 0;
  background: var(--ui-bg-raised);
  border: 1px solid var(--ui-border); border-radius: 12px;
  cursor: pointer;
}
.duel-card:hover, .duel-card:focus-visible {
  border-color: var(--ui-accent);
  outline: none;
  box-shadow: 0 0 0 1px var(--ui-accent);
}
.duel-card .preview { height: 250px; font-size: 0.62rem; }
.duel-card-head { display: flex; align-items: baseline; justify-content: space-between; }
.duel-card-head h3 { font-size: 1.05rem; color: var(--ui-fg); margin: 0; font-weight: 600; }
.duel-key {
  font-family: var(--mono); font-size: 0.75rem; color: var(--ui-fg-dim);
  border: 1px solid var(--ui-border); border-radius: 5px; padding: 0 0.4rem;
}
.duel-strip {
  display: flex; gap: 3px; padding: 5px;
  border-radius: 6px; border: 1px solid var(--ui-border);
}
.duel-strip i { flex: 1; height: 14px; border-radius: 3px; }
.duel-choose {
  text-align: center; font-size: 0.85rem; font-weight: 600;
  padding: 0.45rem; border-radius: 8px;
  background: var(--ui-bg-hover); color: var(--ui-fg);
}
.duel-card:hover .duel-choose { background: var(--ui-accent); color: var(--ui-bg); }
.duel-hint { text-align: center; margin-bottom: 0.9rem; color: var(--ui-fg-dim); font-size: 0.8rem; }

.duel-final { text-align: center; }
.duel-crown { font-size: 3rem; }
.duel-final h2 { margin-bottom: 0.8rem; }
.duel-final .duel-strip { max-width: 420px; margin: 0 auto 1.2rem; }
.duel-final .previews { text-align: left; margin-top: 0.5rem; justify-content: center; }
.duel-final-actions {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.7rem; margin-top: 1.3rem;
}
.duel-btn { font-size: 0.9rem; padding: 0.45rem 1.1rem; color: var(--ui-fg); }
.duel-final-actions .duel-restart { margin-left: 0; }

@media (max-width: 900px) {
  .duel-arena { grid-template-columns: 1fr; }
  .duel-vs { justify-self: center; }
}

/* ---------- stats page ---------- */

.stats { max-width: 1000px; margin: 0 auto; }
.stats-head { display: flex; align-items: center; justify-content: space-between; }
.stat-source { color: var(--ui-fg-dim); font-size: 0.82rem; margin: 0.3rem 0 1.2rem; }
.stat-note { color: var(--ui-fg-dim); font-size: 0.8rem; margin-bottom: 0.7rem; }
.stat-note a { color: var(--ui-accent); }

.stat-tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.8rem; margin-bottom: 1.6rem;
}
.stat-tile {
  padding: 0.8rem 1rem;
  background: var(--ui-bg-raised);
  border: 1px solid var(--ui-border); border-radius: 10px;
}
.stat-tile-value { font-size: 1.5rem; font-weight: 700; color: var(--ui-fg); }
.stat-tile-label { font-size: 0.75rem; color: var(--ui-fg-dim); }

.stat-table-wrap { overflow-x: auto; }
.stat-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.stat-table th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ui-fg-dim); font-weight: 500;
  padding: 0.3rem 0.6rem; border-bottom: 1px solid var(--ui-border);
}
.stat-table td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--ui-border); }
.stat-table .num, .stat-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.stat-name { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ui-fg); }
.stat-dots {
  display: inline-flex; gap: 2px; padding: 2px 3px; border-radius: 4px;
  border: 1px solid var(--ui-border);
}
.stat-dots i { width: 6px; height: 11px; border-radius: 2px; display: inline-block; }

.stat-bar-cell { min-width: 150px; }
.stat-bar {
  display: inline-block; vertical-align: middle;
  width: calc(100% - 3.4em); height: 8px; border-radius: 4px; overflow: hidden;
}
.stat-bar-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.stat-pct { display: inline-block; width: 2.8em; margin-left: 0.5em; color: var(--ui-fg-dim); font-size: 0.78rem; }

.stat-rivalry {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0.2rem 0.8rem;
  align-items: center; margin-bottom: 0.9rem; font-size: 0.85rem;
}
.stat-rival-name { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--ui-fg); }
.stat-rival-name.right { justify-content: flex-end; }
.stat-rival-score { color: var(--ui-fg-dim); font-variant-numeric: tabular-nums; }
.stat-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.stat-split {
  grid-column: 1 / -1;
  display: flex; gap: 2px; height: 8px; border-radius: 4px; overflow: hidden;
}
.stat-split span:first-child { border-radius: 4px 0 0 4px; }
.stat-split span:last-child { border-radius: 0 4px 4px 0; }

/* ---------- responsive ---------- */

@media (max-width: 760px) {
  .app {
    grid-template-areas: "topbar" "sidebar" "detail";
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    height: auto;
  }
  .sidebar { border-right: none; border-bottom: 1px solid var(--ui-border); }
  .scheme-list { max-height: 240px; }
}
