:root {
  --bg: #0b0f13;
  --bg-elev: #12181f;
  --bg-elev-2: #171e26;
  --line: #27323c;
  --line-soft: #1c252e;
  --ink: #e7eef4;
  --ink-dim: #9aa8b4;
  --ink-mute: #6d7b87;
  --paper: #c45c3a;
  --paper-soft: #d47855;
  --go: #3ea572;
  --go-bg: #10291f;
  --go-line: #2e6b4c;
  --stop: #e15b4a;
  --skip: #c4a35a;
  --radius: 14px;
  --sans: "IBM Plex Sans", "Noto Sans HK", "Noto Sans TC", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.45;
}

body {
  background-image:
    radial-gradient(1200px 500px at 10% -10%, #15202a 0%, transparent 55%),
    linear-gradient(180deg, #0d1217 0%, var(--bg) 40%);
}

#app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 14px 16px 28px;
}

h1,
h2,
p,
ul,
ol,
dl,
table {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 12px 14px 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.panel h2 {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
  margin-bottom: 10px;
}

.empty {
  color: var(--ink-mute);
  font-size: 12px;
}

.num,
.when,
.last,
.grade,
.sym,
.fill,
.extra,
.session-meta,
.path-label,
.side {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

/* —— header —— */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-bottom: 12px;
}

.topbar-left,
.topbar-right {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 10px;
}

.back {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-dim);
  font-size: 11px;
  background: #0e141a;
}

.topbar h1 {
  font-size: 15px;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.topbar h1 .slash,
.topbar h1 .en {
  color: var(--ink-dim);
  font-weight: 500;
}

.badge-paper {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--paper);
  color: #1a0f0c;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.delayed-cue {
  color: var(--ink-mute);
  font-size: 11px;
}

.geo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-mute);
  font-size: 11px;
}

.retry {
  color: var(--paper-soft);
  font-weight: 600;
  padding: 0;
}

.retry:hover {
  text-decoration: underline;
}

.tz-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  background: #0e141a;
}

.tz-toggle button {
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-mute);
}

.tz-toggle button[aria-pressed="true"] {
  color: var(--ink);
  background: #1c262f;
  box-shadow: inset 0 0 0 1px #3a4a58;
}

.session-meta {
  color: var(--ink-dim);
  font-size: 11px;
  white-space: nowrap;
}

/* —— mosaic —— */
.mosaic {
  display: grid;
  grid-template-columns: minmax(300px, 1.1fr) minmax(0, 1.5fr) minmax(0, 1.5fr) minmax(236px, 0.88fr);
  grid-template-areas:
    "watch path path risk"
    "watch setups setups risk"
    "feed feed fills fills";
  gap: 12px;
}

.watchlist { grid-area: watch; }
.pathmap { grid-area: path; }
.setups { grid-area: setups; }
.risk { grid-area: risk; }
.feed { grid-area: feed; }
.fills { grid-area: fills; }

/* —— watchlist —— */
.wl-table {
  font-size: 12px;
}

.wl-row {
  display: grid;
  grid-template-columns: minmax(4.8rem, auto) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  column-gap: 6px;
  align-items: center;
  padding: 5px 0;
}

.wl-row + .wl-row {
  border-top: 1px solid var(--line-soft);
}

.wl-row.head {
  padding-top: 0;
  font-size: 10px;
  font-weight: 500;
  color: var(--ink-mute);
}

.wl-row.head + .wl-row {
  border-top: 0;
}

.wl-row .num,
.wl-row.head > :nth-child(2),
.wl-row.head > :nth-child(3),
.wl-row.head > :nth-child(4) {
  text-align: right;
}

.wl-sym {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.watchlist .sym {
  font-weight: 600;
}

.wl-tag {
  justify-self: end;
}

.tag {
  display: inline-block;
  font-size: 10px;
  color: var(--ink-mute);
  background: #1a232c;
  border-radius: 3px;
  padding: 1px 5px;
}

.tag.dly {
  margin-left: 2px;
  color: var(--ink-mute);
}

.wl-row.candidate .last {
  color: var(--paper-soft);
}

.wl-row.quiet .last,
.wl-row.quiet .sym {
  color: var(--ink-dim);
}

.asof {
  margin-top: 10px;
  font-size: 10px;
  color: var(--ink-mute);
}

/* —— path map —— */
.paths {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.path {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--bg-elev-2);
}

.path.active {
  background: var(--go-bg);
  border-color: var(--go-line);
}

.path-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--ink-dim);
}

.path.active .path-label {
  color: var(--go);
}

.path-text {
  font-size: 12.5px;
}

.pill-active {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #d8ffe8;
  background: #1f6b45;
  border-radius: 999px;
  padding: 2px 8px;
}

.levels {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-mute);
  font-family: var(--mono);
}

/* —— setups —— */
.setup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.setup {
  background: var(--bg-elev-2);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px;
}

.grade {
  font-size: 28px;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 6px;
}

.grade-C .grade {
  font-size: 22px;
  color: var(--ink-dim);
}

.setup-name {
  font-weight: 600;
  font-size: 13px;
}

.setup-status {
  font-size: 11px;
  color: var(--ink-mute);
  margin: 2px 0 6px;
}

.setup .notes {
  font-size: 12px;
  color: var(--ink-dim);
}

/* —— risk —— */
.risk dl {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.risk dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 12.5px;
}

.risk dt {
  color: var(--ink-dim);
}

.risk dd {
  margin: 0;
  font-family: var(--mono);
  font-weight: 500;
  white-space: nowrap;
}

.risk .neg { color: var(--stop); }
.risk .pos { color: var(--go); }

.meter {
  height: 4px;
  background: #1a232c;
  border-radius: 999px;
  margin: 12px 0 8px;
  overflow: hidden;
}

.meter span {
  display: block;
  height: 100%;
  background: var(--paper);
}

.risk-foot {
  font-size: 11px;
  color: var(--ink-mute);
  white-space: nowrap;
}

/* —— feed / fills —— */
.feed ol,
.fills ol {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.feed li,
.fills li {
  font-size: 12.5px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
  line-height: 1.55;
}

.feed li:last-child,
.fills li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.feed .when,
.fills .when,
.sep {
  color: var(--ink-mute);
  font-size: 11px;
}

.feed .kind,
.fills .side {
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.03em;
}

.kind-entry .kind { color: var(--go); }
.kind-skip .kind { color: var(--skip); }
.kind-exit .kind { color: var(--stop); }
.side-bot .side { color: var(--go); }
.side-sld .side { color: var(--stop); }

.feed .detail,
.fills .extra,
.fills .fill {
  color: var(--ink-dim);
}

.fills .extra {
  font-size: 11px;
}

.evidence {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.evidence-box {
  min-height: 72px;
  border: 1px dashed #3a4652;
  border-radius: 8px;
  background: #0e141a;
  color: var(--ink-mute);
  font-size: 11px;
  font-family: var(--mono);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px;
}

.colophon {
  margin-top: 14px;
  font-size: 11px;
  color: var(--ink-mute);
  max-width: 72ch;
}

.loading-panel,
.error-panel {
  margin-top: 24px;
  padding: 28px;
}

.error-panel h1 {
  font-size: 16px;
  margin-bottom: 8px;
}

.error-panel .hint {
  color: var(--ink-mute);
  margin-top: 8px;
}

code {
  font-family: var(--mono);
  font-size: 12px;
}

@media (max-width: 960px) {
  .mosaic {
    grid-template-columns: 1fr;
    grid-template-areas:
      "watch"
      "path"
      "setups"
      "risk"
      "feed"
      "fills";
  }

  .setup-grid {
    grid-template-columns: 1fr;
  }

  .wl-table {
    font-size: 11.5px;
  }

  .risk-foot {
    white-space: normal;
  }

  .session-meta {
    white-space: normal;
  }

  .path {
    grid-template-columns: 52px 1fr;
  }

  .path .pill-active {
    grid-column: 2;
    justify-self: start;
  }

}

@media (max-width: 420px) {
  #app {
    padding: 10px 10px 24px;
  }

  .topbar h1 {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
