/* Two themes. Default is the day board, [data-theme="light"]; without it, sumi (墨, ink). Fields keep the same pastels in both. */
:root {
  --bg: #101211;
  --panel: #1b1d1c;
  --panel-2: #272a28;
  --line: #333634;
  --ink: #f3f5f0;
  --muted: #a5a8a3;
  --faint: #727571;
  --accent: #e2492f;      /* shu, vermilion: seals and alerts */
  --accent-soft: rgba(226, 73, 47, 0.18);
  --gold: #e1f488;      /* moegi: kotsu and highlights */
  --indigo: #b4b1ee;
  --ok: #8fcf9c;
  --warn: #f0b35a;
  --bad: #ef5a3f;
  --ghost: rgba(243, 245, 240, 0.55);
  /* tile fields: fuji (wisteria), matcha, kaki (persimmon), moegi (sprout), sora (sky), ai (grey indigo) */
  --fuji: #dbd9f1;  --fuji-ink: #171a1f;
  --matcha: #d6e4c1; --matcha-ink: #171a1f;
  --kaki: #f3c39d;  --kaki-ink: #171a1f;
  --moegi: #e1f488; --moegi-ink: #171a1f;
  --sora: #cfe1f0;  --sora-ink: #171a1f;
  --ai: #cbced5;    --ai-ink: #171a1f;
  --solid: #f3f5f0; --solid-ink: #101211;
  --radius: 22px;
  --display: "Geist", "Zen Kaku Gothic New", system-ui, sans-serif;
  --serif: "Shippori Mincho", "Yu Mincho", "Hiragino Mincho ProN", serif;
  --sans: "Geist", "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic UI", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #e3e5e4;
  --panel: #f3f5f0;
  --panel-2: #e8ebe4;
  --line: #d6d9d3;
  --ink: #171a1f;
  --muted: #6b6e69;
  --faint: #8e918c;
  --accent: #d23a20;
  --accent-soft: rgba(210, 58, 32, 0.14);
  --gold: #56620f;
  --indigo: #5b58b0;
  --ok: #2c7a45;
  --warn: #9a5e00;
  --bad: #c23a22;
  --ghost: rgba(23, 26, 31, 0.45);
  --solid: #101211; --solid-ink: #f3f5f0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); }
a { color: inherit; }
button, select, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 500; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: 28px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.ja { font-family: var(--serif); color: var(--muted); font-size: 0.85em; margin-left: 0.5em; }
.hidden { display: none !important; }

/* -- shell ----------------------------------------------------------------------- */

.topbar {
  display: flex; align-items: center; gap: 28px;
  padding: 14px 28px;
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; }
.brand .mark {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); align-self: center;
  box-shadow: inset -5px -4px 0 rgba(0, 0, 0, 0.25);
}
.brand b { font-family: var(--display); font-size: 19px; font-weight: 600; letter-spacing: 0.14em; }
.brand span { font-family: var(--serif); color: var(--muted); font-size: 13px; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  text-decoration: none; padding: 7px 14px; border-radius: 999px; color: var(--muted); font-size: 14px;
}
.topbar nav a:hover { color: var(--ink); background: var(--panel-2); }
.topbar nav a.active { color: var(--ink); background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.topbar .spacer { flex: 1; }
.pill {
  font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: rgba(114, 176, 127, 0.4); }
.pill.warn { color: var(--warn); border-color: rgba(227, 164, 59, 0.4); }
.pill.bad { color: var(--bad); border-color: rgba(226, 73, 47, 0.45); }

main { max-width: 1320px; margin: 0 auto; padding: 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); max-width: 720px; }

.grid { display: grid; gap: 18px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.side { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
@media (max-width: 1000px) { .cols-2, .cols-3, .side { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border-radius: var(--radius); padding: 22px; }
.panel > h2, .panel > h3 { margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

/* -- controls -------------------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2);
  cursor: pointer; text-decoration: none; font-size: 14px; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--solid); border-color: var(--solid); color: var(--solid-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.rec::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }

label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
select, input[type=text], textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; min-height: 90px; line-height: 1.6; }
select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

/* -- lists & tables -------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
th, td { padding: 10px 8px; border-bottom: 1px solid var(--line); }
tr.link { cursor: pointer; }
tr.link:hover td { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.stat { display: grid; gap: 2px; }
.stat b { font-size: 30px; font-family: var(--display); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat > span { color: var(--muted); font-size: 13px; }

.empty { color: var(--faint); padding: 18px 0; text-align: center; }

/* -- charts ---------------------------------------------------------------------- */

.lanes { width: 100%; display: block; }
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* -- kotsu cards ----------------------------------------------------------------- */

.kcard {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel-2); padding: 14px 16px; display: grid; gap: 8px;
}
.kcard .k-title { font-family: var(--display); font-size: 18px; }
.kcard dl { margin: 0; display: grid; grid-template-columns: 70px 1fr; gap: 6px 12px; font-size: 14px; }
.kcard dt { color: var(--gold); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; padding-top: 2px; }
.kcard dd { margin: 0; }
.kcard .k-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--faint); }
.kcard .k-sub { color: var(--muted); font-size: 13px; font-family: var(--serif); }
.langs { display: flex; gap: 4px; }
.langs button {
  border: 1px solid var(--line); background: transparent; border-radius: 6px; padding: 2px 8px; font-size: 12px;
  cursor: pointer; color: var(--muted);
}
.langs button.on { color: var(--ink); border-color: var(--gold); }

/* -- surprises ------------------------------------------------------------------- */

.surprise {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  display: grid; gap: 4px; background: var(--panel);
}
.surprise:hover { border-color: var(--faint); }
.surprise.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.surprise .s-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.surprise .s-sum { font-size: 13px; color: var(--muted); }
.surprise.dismissed { opacity: 0.55; }

.mic { position: relative; }
.mic.listening { background: var(--accent); border-color: var(--accent); color: #fff; }
.mic.listening::after {
  content: ""; position: absolute; inset: -4px; border-radius: 10px; border: 2px solid var(--accent);
  animation: pulse 1.2s ease-out infinite;
}
@keyframes pulse { from { opacity: 0.9; transform: scale(1); } to { opacity: 0; transform: scale(1.12); } }

/* -- live ------------------------------------------------------------------------ */

.big-score { font-family: var(--display); font-size: 64px; line-height: 1; font-variant-numeric: tabular-nums; }
.meter { height: 8px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--gold); border-radius: 99px; transition: width 0.4s; }
.chan-row { display: grid; grid-template-columns: 110px 1fr 44px; gap: 10px; align-items: center; font-size: 13px; }

.toast-stack { position: fixed; right: 24px; bottom: 24px; display: grid; gap: 10px; z-index: 50; width: 380px; }
.toast {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); animation: rise 0.25s ease-out;
}
.toast.buzz { border-color: var(--accent); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }

.qr-box { display: grid; place-items: center; gap: 10px; text-align: center; }
.qr-box img { width: 200px; height: 200px; background: #fff; border-radius: 8px; padding: 6px; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); display: inline-block; }
.status-dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(114, 176, 127, 0.18); }

/* -- radar ----------------------------------------------------------------------- */

.risk { height: 6px; border-radius: 99px; background: var(--panel-2); overflow: hidden; width: 120px; }
.risk > i { display: block; height: 100%; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display);
  background: var(--panel-2); border: 1px solid var(--line); font-size: 14px; flex: none;
}
.person { display: flex; gap: 10px; align-items: center; }
.person small { display: block; color: var(--muted); font-size: 12px; }
.spark { display: block; }


/* -- theme switch ---------------------------------------------------------------- */

.switch {
  width: 64px; height: 36px; border-radius: 999px; border: 0; padding: 4px; cursor: pointer; flex: none;
  background: var(--solid); display: flex; align-items: center;
}
.switch i {
  width: 28px; height: 28px; border-radius: 50%; background: var(--moegi); display: block;
  transition: transform 0.25s ease;
}
.switch[aria-checked="true"] i { transform: translateX(28px); }
.switch:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.topbar .switch { width: 52px; height: 30px; }
.topbar .switch i { width: 22px; height: 22px; }
.topbar .switch[aria-checked="true"] i { transform: translateX(22px); }
@media (prefers-reduced-motion: reduce) { .switch i { transition: none; } }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px 16px; padding: 12px 16px; }
  .topbar nav { order: 3; width: 100%; overflow-x: auto; }
  .topbar nav .ja, .topbar .spacer { display: none; }
  .topbar #ai-pill { margin-left: auto; }
  main { padding: 18px 16px; }
}

/* -- bento dashboard -------------------------------------------------------------- */

.bento { display: grid; gap: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: dense; }
.tile { background: var(--panel); border-radius: var(--radius); padding: 26px 28px; display: flex; flex-direction: column; min-width: 0; }
.tile h2 { font-size: 21px; }
.tile .sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.tile.span-2 { grid-column: span 2; }
.tile.tall { grid-row: span 2; }
.tile.f-ai { background: var(--ai); color: var(--ai-ink); }
.tile.f-moegi { background: var(--moegi); color: var(--moegi-ink); }
.tile.f-kaki { background: var(--kaki); color: var(--kaki-ink); }
.tile.f-moegi .sub, .tile.f-kaki .sub, .tile.f-ai .sub { color: inherit; opacity: 0.75; }
.tile.f-moegi .ja, .tile.f-kaki .ja, .tile.f-ai .ja { color: inherit; opacity: 0.7; }
.tile-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.tile-head .sub { margin: 0; }
a.tile { text-decoration: none; color: inherit; }

.lead-tile { min-height: 340px; justify-content: space-between; gap: 28px; }
.lead-tile .top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.where { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.where::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid color-mix(in srgb, currentColor 45%, transparent); border-radius: 999px; padding: 4px 12px; font-size: 14px; white-space: nowrap; }
.lead-tile h1 { font-size: clamp(40px, 4.4vw, 66px); line-height: 0.98; letter-spacing: -0.045em; font-weight: 500; }
.lead-tile h1 span { opacity: 0.55; }

.gauge { display: grid; place-items: center; margin-top: auto; padding-top: 18px; position: relative; }
.gauge svg { width: 100%; max-width: 250px; display: block; }
.gauge b {
  position: absolute; bottom: 0; font-family: var(--display); font-weight: 400; font-size: 76px;
  letter-spacing: -0.04em; line-height: 1;
}

.faces { display: flex; align-items: center; margin-top: auto; padding-top: 22px; }
.faces .avatar { width: 46px; height: 46px; margin-left: -8px; border: 3px solid var(--panel); font-size: 15px; font-weight: 500; }
.faces .avatar:first-child { margin-left: 0; }
.faces .avatar:nth-child(4n+1) { background: var(--fuji); color: var(--fuji-ink); }
.faces .avatar:nth-child(4n+2) { background: var(--sora); color: var(--sora-ink); }
.faces .avatar:nth-child(4n+3) { background: var(--kaki); color: var(--kaki-ink); }
.faces .avatar:nth-child(4n+4) { background: var(--matcha); color: var(--matcha-ink); }
.faces .more { margin-left: auto; font-size: 40px; letter-spacing: -0.03em; }

.toggle-tile { gap: 18px; justify-content: space-between; }
.toggle-tile .row { justify-content: space-between; flex-wrap: nowrap; align-items: flex-start; }
.toggle-tile h2 { font-size: 23px; line-height: 1.15; }

.pipe { display: grid; gap: 10px; margin-top: auto; padding-top: 26px; }
.pipe-bar { display: flex; gap: 6px; height: 64px; }
.pipe-bar > div { border-radius: 14px; padding: 10px 12px; display: flex; align-items: flex-end; font-size: 14px; min-width: 52px; }
.pipe-legend { display: flex; gap: 6px; }
.pipe-legend > div { display: grid; }
.pipe-legend b { font-size: 34px; font-weight: 400; letter-spacing: -0.03em; }
.pipe-legend span { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.pipe-legend span::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--dot); }

.bignum { font-family: var(--display); font-size: clamp(72px, 7vw, 108px); letter-spacing: -0.05em; line-height: 0.95; margin-top: 28px; }
.bignum small { font-size: 0.42em; letter-spacing: -0.03em; margin-left: 10px; }
.delta { color: var(--indigo); font-size: 15px; margin-top: 10px; }
.trend { margin-top: auto; width: 100%; height: 280px; display: block; }

.day { display: grid; gap: 10px; margin-top: auto; padding-top: 22px; }
.slot { display: grid; grid-template-columns: 56px 1fr; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.slot time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.slot div { border-radius: 14px; padding: 10px 14px; background: var(--panel-2); line-height: 1.3; }
.slot div small { display: block; font-size: 13px; opacity: 0.75; }
.slot.master div { background: var(--kaki); color: var(--kaki-ink); }
.slot.pass div { background: var(--moegi); color: var(--moegi-ink); }
.slot.learn div { background: var(--fuji); color: var(--fuji-ink); }
.slot:hover div { filter: brightness(1.06); }

.ticket { position: relative; overflow: hidden; justify-content: space-between; min-height: 320px; }
.ticket::before, .ticket::after {
  content: ""; position: absolute; width: 28px; height: 28px; border-radius: 50%; background: var(--bg); bottom: 104px;
}
.ticket::before { left: -14px; } .ticket::after { right: -14px; }
.ticket .name { font-size: 32px; letter-spacing: -0.03em; line-height: 1.05; }
.ticket .stub { display: flex; justify-content: space-between; align-items: flex-end; border-top: 2px dashed color-mix(in srgb, currentColor 35%, transparent); padding-top: 18px; margin-top: 18px; }
.ticket .stub b { font-size: 52px; font-weight: 400; letter-spacing: -0.04em; line-height: 1; }
.ticket .stub span { text-align: right; font-size: 14px; opacity: 0.8; }

.chip-cloud { margin-top: auto; padding-top: 24px; }
.chip-cloud .chip { border: 0; background: var(--panel-2); display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; }
.chip-cloud .chip.solid { background: var(--solid); color: var(--solid-ink); }
.chip-cloud .chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--muted)); }

@media (max-width: 1100px) { .bento { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .bento { grid-template-columns: 1fr; }
  .tile.span-2 { grid-column: auto; } .tile.tall { grid-row: auto; }
  .tile { padding: 22px; }
}

@media (max-width: 640px) { .trend { height: 190px; } .brand { white-space: nowrap; } }

/* Pastel fields carry dark ink in both themes, so anything solid on them stays black. */
.hero-copy, .tile.f-ai, .tile.f-moegi, .tile.f-kaki { --solid: #101211; --solid-ink: #f3f5f0; }
