/* Arcwise. Calm, not gamified: no streaks, no scores, no red alerts.
   One teal for the human in the loop, one coral reserved for the safety gate. */
:root {
  color-scheme: light;
  --paper: #f6f4ef;
  --surface: #ffffff;
  --ink: #1d2327;
  --ink-2: #4a545b;
  --ink-3: #737d84;
  --line: #e2ded6;
  --teal: #1f6f6b;
  --teal-2: #e3efed;
  --coral: #b4513c;
  --coral-2: #f7e6e1;
  --amber-2: #f5eedc;
  --radius: 14px;
  --gap: 16px;
  --text: 16px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --serif: "Iowan Old Style", "Charter", Georgia, serif;
}
:root[data-size="large"] { --text: 18px; }
:root[data-size="xlarge"] { --text: 20px; }
:root[data-contrast="high"] {
  --paper: #ffffff; --ink: #000; --ink-2: #111; --ink-3: #333; --line: #555; --teal: #0b4f4b;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 400 var(--text)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--teal); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 8px; letter-spacing: -0.01em; }
h1 { font: 600 1.75em/1.15 var(--serif); }
h2 { font-size: 1.2em; font-weight: 600; }
h3 { font-size: 1em; font-weight: 600; }
p { margin: 0 0 12px; }
.muted { color: var(--ink-3); }
.small { font-size: 0.875em; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 6px; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip-link:focus { left: 8px; }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side {
  border-right: 1px solid var(--line);
  padding: 24px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--paper);
}
.brand { font: 600 1.35em var(--serif); margin: 0 8px 4px; }
.tag { margin: 0 8px 24px; color: var(--ink-3); font-size: 0.85em; }
.nav { list-style: none; padding: 0; margin: 0; display: grid; gap: 2px; }
.nav a {
  display: block; padding: 9px 12px; border-radius: 10px;
  color: var(--ink-2); text-decoration: none; font-size: 0.95em;
}
.nav a:hover { background: #ece8e0; }
.nav a[aria-current="page"] { background: var(--teal-2); color: var(--teal); font-weight: 600; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 8px; }
.main { padding: 32px clamp(16px, 4vw, 48px) 80px; max-width: 1040px; width: 100%; }
.page-head { margin-bottom: 24px; }
.page-head p { color: var(--ink-2); max-width: 62ch; }

.grid { display: grid; gap: var(--gap); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.card.flat { background: transparent; }
.card.teal { background: var(--teal-2); border-color: #c7ded9; }
.card.coral { background: var(--coral-2); border-color: #e9c4b9; }
.card.amber { background: var(--amber-2); border-color: #e7dcbc; }

/* controls */
button, .btn {
  font: inherit; font-size: 0.95em; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--ink); background: var(--ink); color: #fff;
  cursor: pointer; text-decoration: none;
}
button:hover { filter: brightness(1.1); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: #ece8e0; filter: none; }
.btn-teal { background: var(--teal); border-color: var(--teal); }
.btn-coral { background: var(--coral); border-color: var(--coral); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 0.85em; border-radius: 10px; }

label { display: block; font-weight: 600; font-size: 0.9em; margin-bottom: 6px; }
.field { margin-bottom: 16px; }
.hint { font-size: 0.85em; color: var(--ink-3); margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
  padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--teal-2); border-color: var(--teal); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 0 14px; min-height: 40px; font-weight: 500;
}
.chip[aria-pressed="true"] { background: var(--teal); color: #fff; border-color: var(--teal); }
.chip:hover { filter: none; border-color: var(--teal); }

.scale { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.scale button { background: #fff; color: var(--ink-2); border: 1px solid var(--line); flex-direction: column; min-height: 64px; gap: 2px; font-weight: 500; }
.scale button b { font-size: 1.2em; color: var(--ink); }
.scale button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #fff; }
.scale button[aria-pressed="true"] b { color: #fff; }

.pill { display: inline-block; font-size: 0.78em; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: #eeeae2; color: var(--ink-2); }
.pill.teal { background: var(--teal-2); color: var(--teal); }
.pill.coral { background: var(--coral-2); color: var(--coral); }
.pill.amber { background: var(--amber-2); color: #7a5d17; }

.list { list-style: none; padding: 0; margin: 0; }
.list li { padding: 14px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-3); }
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 0.92em; z-index: 60; max-width: calc(100vw - 32px);
}
.loading { color: var(--ink-3); padding: 24px 0; }
.err { color: var(--coral); font-size: 0.9em; margin-top: 8px; }

/* quotes and evidence */
mark.span { background: #fde9a8; padding: 0 2px; border-radius: 3px; }
.quote { border-left: 3px solid var(--teal); padding: 4px 0 4px 12px; color: var(--ink-2); font-family: var(--serif); }
.evidence { display: grid; gap: 10px; }
.evidence .rec { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fcfbf8; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 16px; font-size: 0.92em; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }
.conf { display: inline-flex; gap: 3px; vertical-align: middle; }
.conf i { width: 18px; height: 6px; border-radius: 3px; background: var(--line); }
.conf[data-band="Low"] i:nth-child(-n+1),
.conf[data-band="Moderate"] i:nth-child(-n+2),
.conf[data-band="Higher"] i:nth-child(-n+3) { background: var(--teal); }

/* recorder */
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--coral); display: inline-block; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.level { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; width: 160px; }
.level i { display: block; height: 100%; background: var(--teal); width: 0; transition: width 0.08s; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; }

/* charts */
canvas.chart { width: 100%; height: 220px; display: block; }
canvas.graph { width: 100%; height: 480px; display: block; border-radius: var(--radius); background: #fcfbf8; border: 1px solid var(--line); cursor: grab; }

/* timeline */
.tl { position: relative; padding-left: 22px; }
.tl::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl .day { font-weight: 600; margin: 20px 0 8px; color: var(--ink-2); }
.tl .item { position: relative; margin-bottom: 10px; }
.tl .item::before { content: ""; position: absolute; left: -21px; top: 18px; width: 10px; height: 10px; border-radius: 50%; background: var(--teal); border: 2px solid var(--paper); }
.tl .item[data-kind="decision"]::before { background: #7a5d17; }
.tl .item[data-kind="response"]::before { background: var(--ink-3); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth > .card { width: 100%; max-width: 440px; padding: 32px; }

/* crisis overlay */
.overlay { position: fixed; inset: 0; background: rgba(20, 24, 26, 0.55); display: grid; place-items: center; padding: 16px; z-index: 70; }
.overlay .card { max-width: 520px; width: 100%; }

/* mobile */
.menu-btn { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 40; transform: translateX(-102%); transition: transform 0.2s; height: 100vh; visibility: hidden; }
  .side.open { transform: none; visibility: visible; box-shadow: 0 0 40px rgba(0,0,0,0.15); }
  .menu-btn { display: inline-flex; position: sticky; top: 0; z-index: 30; margin: 12px 16px 0; }
  .main { padding-top: 16px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .scale button { min-height: 56px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
