/* ─────────────────────────────────────────────────────────────────────────
   Design tokens — Matcha (Astryx) palette, spacing, radii and shadows
   ───────────────────────────────────────────────────────────────────────── */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-2: #f8f8f1;
  --hover: rgba(62, 72, 29, 0.05);
  --text: #3e481d;
  --text-2: #5a6b2a;
  --text-3: #707e46;
  --border: #dce3ce;
  --border-strong: #b7c29e;
  --accent: #3d7a00;
  --accent-hover: #336700;
  --on-accent: #ffffff;
  --accent-muted: rgba(77, 153, 0, 0.1);
  --focus: rgba(77, 153, 0, 0.28);
  --ink-muted: rgba(62, 72, 29, 0.06);

  --success: #4d9900;
  --success-text: #3d7a00;
  --success-bg: rgba(77, 153, 0, 0.12);
  --warning: #f2c000;
  --warning-text: #664f00;
  --warning-bg: rgba(242, 192, 0, 0.2);
  --error: #cc0000;
  --error-text: #b10000;
  --error-bg: rgba(253, 0, 0, 0.07);
  --info-text: #2e4a6e;
  --info-bg: rgba(58, 94, 140, 0.1);

  --chart-1: #38a48b;
  --chart-2: #c19800;
  --chart-3: #c44a70;
  --chart-grid: #e7ead4;

  --overlay: rgba(33, 39, 10, 0.36);
  --shadow-low: 0 1px 2px rgba(62, 72, 29, 0.05), 0 2px 6px rgba(62, 72, 29, 0.06);
  --shadow-med: 0 2px 4px rgba(62, 72, 29, 0.05), 0 4px 12px rgba(62, 72, 29, 0.1);
  --shadow-high: 0 4px 6px rgba(62, 72, 29, 0.1), 0 16px 32px rgba(62, 72, 29, 0.15);

  --r-inner: 6px;
  --r-el: 12px;
  --r-box: 18px;
  --r-full: 999px;

  --s-1: 0.375rem;
  --s-2: 0.75rem;
  --s-3: 1.125rem;
  --s-4: 1.5rem;
  --s-5: 1.875rem;
  --s-6: 2.25rem;
  --s-8: 3rem;

  --fast: 125ms;
  --med: 300ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);

  --font: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;
}

/* ── Base ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
::selection { background: var(--accent-muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mono { font-family: var(--mono); font-feature-settings: 'zero' 0; }
.tnum { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-3); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 16px; height: 16px; }
.icon.xs { width: 14px; height: 14px; }

/* ── Layout primitives ────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-box); box-shadow: var(--shadow-low); }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-3); }

.mark { width: 32px; box-shadow: 0 2px 8px rgba(61, 122, 0, 0.3); height: 32px; border-radius: 10px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-weight: 700; font-size: 15px; letter-spacing: -0.02em; }
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }

/* ── Day colours (Matcha categorical: teal, gold, blue, purple, pink) ── */
.c1 { --c: #38a48b; --c-ink: #245546; --c-bg: #ddf6ee; }
.c2 { --c: #e0b100; --c-ink: #664f00; --c-bg: #fff2cc; }
.c3 { --c: #5d96de; --c-ink: #2e4a6e; --c-bg: #e3efff; }
.c4 { --c: #aa7ada; --c-ink: #553a70; --c-bg: #f1e8ff; }
.c5 { --c: #f86592; --c-ink: #a03a5a; --c-bg: #ffe6ec; }
.cg { --c: #6fb93e; --c-ink: #3d7a00; --c-bg: #e4f6d8; }
.tile { display: grid; place-items: center; flex: none; border-radius: 12px; background: var(--c-bg); color: var(--c-ink); font-weight: 700; letter-spacing: -0.02em; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; background: var(--c-bg); color: var(--c-ink); white-space: nowrap; }
.strip { display: flex; gap: 6px; }
.strip i { width: 22px; height: 6px; border-radius: 3px; background: var(--c); }

/* ── Form controls ────────────────────────────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.hint { font-size: 13px; color: var(--text-3); line-height: 1.5; }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-el);
  outline: none; transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.input::placeholder { color: var(--text-3); opacity: 0.8; }
.input:hover { border-color: var(--text-3); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--focus); }
textarea.input { height: auto; min-height: 104px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
select.input { appearance: none; padding-right: 38px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23707e46' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-full);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-size: 14px; font-weight: 600; white-space: nowrap; cursor: pointer; text-decoration: none;
  transition: background var(--fast) var(--ease), border-color var(--fast) var(--ease), color var(--fast) var(--ease), transform var(--fast) var(--ease);
}
.btn:hover { background: var(--hover); border-color: var(--text-3); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover); color: var(--text); }
.btn.danger { color: var(--error-text); }
.btn.danger:hover { background: var(--error-bg); border-color: var(--error); }
.btn.lg { height: 48px; padding: 0 24px; font-size: 15px; }
.btn.sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn.xs { height: 28px; padding: 0 10px; font-size: 12px; gap: 6px; }
.btn.block { width: 100%; }
.btn.icon-only { width: 34px; padding: 0; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite; opacity: 0.8; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Status pills ─────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--r-full); font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--accent-muted); color: var(--text-2); }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.live { background: var(--success-bg); color: var(--success-text); }
.pill.live .dot { animation: breathe 2s ease-in-out infinite; }
.pill.ok { background: var(--success-bg); color: var(--success-text); }
.pill.warn { background: var(--warning-bg); color: var(--warning-text); }
.pill.bad { background: var(--error-bg); color: var(--error-text); }
.pill.info { background: var(--info-bg); color: var(--info-text); }
.pill.outline { background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
@keyframes breathe { 50% { opacity: 0.35; } }

.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-el); font-size: 14px; background: var(--error-bg); color: var(--error-text); animation: fadeUp var(--med) var(--ease); }
.alert .icon { margin-top: 2px; }

/* ── Motion ───────────────────────────────────────────────────────────── */
.view-enter { animation: fadeUp 360ms var(--ease) backwards; }
.view-leave { animation: fadeOut 160ms var(--ease) forwards; }
.seq > * { animation: fadeUp 420ms var(--ease) backwards; }
.seq > *:nth-child(2) { animation-delay: 40ms; }
.seq > *:nth-child(3) { animation-delay: 80ms; }
.seq > *:nth-child(4) { animation-delay: 120ms; }
.seq > *:nth-child(5) { animation-delay: 160ms; }
.seq > *:nth-child(6) { animation-delay: 200ms; }
.seq > *:nth-child(n+7) { animation-delay: 240ms; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } }
@keyframes fadeOut { to { opacity: 0; } }

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; width: calc(100% - 32px); }
.toast { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: var(--r-el); background: var(--accent); color: var(--on-accent); font-size: 14px; font-weight: 500; box-shadow: var(--shadow-high); animation: fadeUp var(--med) var(--ease); max-width: 100%; }
.toast.out { animation: fadeOut 200ms var(--ease) forwards; }
.toast.bad { background: var(--error); color: #fff; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition-duration: 1ms !important; }
}
