/* Thalamus — tokens per docs/thalamus-design-canon.md (Medulla repo).
   Source of truth: Sarabellum src/index.css. Dark default, light opt-in. */
:root {
  color-scheme: dark;
  --bg: #0f1115;
  --bg-elevated: #171a21;
  --bg-card: #1b1f28;
  --border: #2a2f3a;
  --border-soft: #232733;
  --text-primary: #eef0f4;
  --text-secondary: #9aa1af;
  --text-muted: #8a91a0;
  --accent: #7c9cff;
  --accent-soft: rgba(124, 156, 255, 0.15);
  --accent-text: #7c9cff;
  --on-accent: #0f1115;
  --accent-mood: #f2a65a;
  --accent-energy: #5ad1a8;
  --danger: #e0607a;
  --radius: 14px;
  --radius-sm: 8px;
}
:root[data-theme='light'] {
  color-scheme: light;
  --bg: #f5f6f8;
  --bg-elevated: #fff;
  --bg-card: #fff;
  --border: #dde1e8;
  --border-soft: #e7e9ef;
  --text-primary: #1a1d24;
  --text-secondary: #5b6270;
  --text-muted: #616875;
  --accent: #5e79c9;
  --accent-soft: rgba(94, 121, 201, 0.12);
  --accent-text: #4560a8;
  --accent-mood: #c97b2e;
  --accent-energy: #1f9a76;
  --danger: #c94360;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  font-synthesis: none;
}
a { color: var(--text-primary); text-decoration: none; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---- the not-found face (and the door behind it) ---- */
.notfound {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  font-family: system-ui, sans-serif;
}
.notfound h1 { font-size: 24px; font-weight: 500; margin: 0; }
.nf-divider { width: 1px; height: 40px; background: var(--border); }
.notfound p { color: var(--text-secondary); font-size: 14px; margin: 0; }

.door {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; padding: 16px;
}
.door .mark { font-size: 44px; animation: breathe 5.5s ease-in-out infinite; }
.door .mark span, .door .mark img { display: inline-block; animation: spin 18s linear infinite; }
@keyframes breathe {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(124,156,255,.28)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 14px rgba(124,156,255,.4)); }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.door form { display: flex; flex-direction: column; gap: 10px; width: min(320px, 90vw); }
.door .err { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }

/* ---- shell ---- */
.shell {
  max-width: 1200px; margin: 0 auto;
  padding: 28px 32px 48px;
  padding-left: max(32px, env(safe-area-inset-left));
  padding-right: max(32px, env(safe-area-inset-right));
  display: flex; flex-direction: column; gap: 24px;
}
.shell-header { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; }
.shell-header .title { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.shell-header h1 { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.shell-header .sub { font-size: 13px; color: var(--text-secondary); }
.crumb { font-size: 12px; color: var(--text-muted); }

.section-divider { display: flex; align-items: center; gap: 12px; }
.section-divider::before, .section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-soft); }
.section-divider span {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}

.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }

.card {
  background: var(--bg-card); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 20px 22px;
  display: flex; flex-direction: column; gap: 8px;
  transition: border-color 0.15s ease;
}
a.card:hover { border-color: var(--accent); color: var(--text-primary); }
.card .card-title { font-size: 15px; font-weight: 600; }
.card .card-sub { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.card .label { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }

.chip {
  border: 1px solid var(--border-soft); color: var(--text-secondary);
  border-radius: 999px; padding: 6px 14px; font-size: 12px; display: inline-block;
}
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }

.btn-primary {
  background: var(--accent); color: var(--on-accent); border: none;
  border-radius: var(--radius-sm); padding: 9px 16px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: filter 0.15s ease;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 9px 14px; font-size: 13px; cursor: pointer;
}
.input {
  background: var(--bg-elevated); color: var(--text-primary);
  border: 1px solid var(--border-soft); border-radius: var(--radius-sm);
  padding: 9px 12px; font-size: 14px;
}
.input:focus { outline: none; border-color: var(--accent); }

.rowbox { background: var(--bg-card); border: 1px solid var(--border-soft); border-radius: var(--radius); overflow-x: auto; }
.rowgrid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); font-size: 13px; min-width: 900px; }
.rowgrid > div { padding: 12px 16px; border-bottom: 1px solid var(--border-soft); }
.rowgrid > div.h {
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}
.rowgrid > div.last { border-bottom: none; }
.muted { color: var(--text-secondary); }
.faint { color: var(--text-muted); }
.good { color: var(--accent-energy); }
.warm { color: var(--accent-mood); }

.skeleton { height: 10px; background: var(--bg-elevated); border-radius: 6px; }
.footnote { font-size: 12px; color: var(--text-muted); line-height: 1.6; border-top: 1px solid var(--border-soft); padding-top: 14px; }

@media (max-width: 860px) {
  .shell { padding-left: 16px; padding-right: 16px; }
  .grid, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .input { font-size: 16px; }
}
@media (pointer: coarse) {
  .btn-primary, .btn-ghost { min-height: 40px; }
}
