/* RapidTablet design tokens + base components (v3)
   ------------------------------------------------------------------------------------------
   Light "paper" theme is the default; dark is opt-in with <html data-theme="dark">.
   Rules of the system:
   - One accent. Orange is for the primary action on a screen and for flags. Nothing else.
   - Lime belongs to the character and the live indicator only.
   - Navy is the ink and the top bar.
   - Sentence case everywhere. Hierarchy comes from size and colour, not from bold or caps.
   - 8 px grid (4 px only for optical nudges inside components).
   - Hairlines between things, not boxes inside boxes.
   - Touch targets 44-56 px tall that do not look like toy buttons.
   - No animation except the character's 2 fps pen tick / blink (steps(), ~0 CPU).
   ------------------------------------------------------------------------------------------ */

@font-face {
  font-family: "Inter";
  src: url("fonts/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: block;
}

:root {
  /* ---- Brand (fixed, theme independent) ---- */
  --brand-navy: #060916;
  --brand-navy-2: #0B1024;
  --brand-navy-3: #1B2547;
  --brand-orange: #FF5A1F;
  --brand-orange-2: #FF835D;
  --brand-lime: #C6FD64;

  /* ---- Paper theme (default) ---- */
  --bg: #F6F5F1;                 /* the desk: warm paper */
  --surface: #FFFFFF;            /* the page: cards, sheets, bars */
  --surface-sunken: #EFEDE8;     /* wells, inputs at rest, thumbnails */
  --surface-hover: #F3F1EC;
  --surface-selected: #ECEAE4;

  --text: #0E1325;               /* navy ink */
  --text-2: #4A5068;             /* secondary: meta, reasons */
  --text-3: #7B8196;             /* tertiary: timestamps, sources, hints */
  --text-disabled: #A9ADBB;

  --hairline: rgba(6, 9, 22, .085);
  --hairline-strong: rgba(6, 9, 22, .16);
  --focus-ring: 0 0 0 3px rgba(255, 90, 31, .28);

  --accent: #FF5A1F;             /* primary action fill */
  --accent-hover: #F24F14;
  --accent-press: #DD450E;
  --on-accent: #FFFFFF;
  --accent-text: #C2410C;        /* orange used as text on paper (AA 4.9:1) */
  --accent-soft: #FFF1EA;        /* tint behind a flagged note */
  --accent-soft-line: rgba(255, 90, 31, .22);

  --live: #C6FD64;               /* the "taking notes" dot */
  --live-on-paper: #5E8A12;      /* lime is invisible on paper: use this when the dot sits on white */

  --ink-fill: #0E1325;           /* checked checkbox, selected segment */
  --on-ink-fill: #FFFFFF;

  /* Top bar is always navy, in both themes */
  --topbar-bg: #060916;
  --topbar-text: #F2F4F8;
  --topbar-text-2: #A3ADCB;
  --topbar-hairline: rgba(255, 255, 255, .09);
  --topbar-control: rgba(255, 255, 255, .07);
  --topbar-control-hover: rgba(255, 255, 255, .12);
  --topbar-control-line: rgba(255, 255, 255, .14);

  /* ---- Type (Inter) ---- */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-features: "ss03";                  /* Inter round quotes and commas */

  --fs-caption: 13px;   --lh-caption: 18px;   /* timestamps, sources, chip text */
  --fs-small: 15px;     --lh-small: 22px;     /* meta lines, secondary rows */
  --fs-body: 17px;      --lh-body: 26px;      /* document text, list titles */
  --fs-lead: 20px;      --lh-lead: 28px;      /* greeting subline, goal */
  --fs-glance: 24px;    --lh-glance: 31px;    /* "bring up next": readable at arm's length, never smaller */
  --fs-title: 28px;     --lh-title: 34px;     /* page titles */
  --fs-display: 32px;   --lh-display: 40px;   /* greeting */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-strong: 650;     /* wordmark-adjacent emphasis; use sparingly */

  --tracking-tight: -0.018em;   /* titles and display */
  --tracking-snug: -0.011em;    /* glance text, row titles */
  --tracking-normal: -0.006em;  /* body */

  /* ---- Spacing: 8 px grid ---- */
  --s-0: 2px;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 40px;
  --s-8: 48px;
  --s-9: 64px;
  --gutter: 40px;               /* page side padding at 1280 */

  /* ---- Radii ---- */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 10px;     /* buttons, inputs */
  --r-lg: 14px;     /* cards, sheets */
  --r-xl: 20px;
  --r-pill: 999px;

  /* ---- Elevation ---- */
  --shadow-0: none;
  --shadow-1: 0 1px 2px rgba(6, 9, 22, .05);
  --shadow-2: 0 1px 2px rgba(6, 9, 22, .04), 0 8px 24px -10px rgba(6, 9, 22, .14);
  --shadow-pop: 0 2px 6px rgba(6, 9, 22, .06), 0 24px 48px -16px rgba(6, 9, 22, .28);
  --shadow-button: 0 1px 1px rgba(6, 9, 22, .04);
  --shadow-primary: inset 0 1px 0 rgba(255, 255, 255, .18), 0 1px 2px rgba(194, 65, 12, .30);

  /* ---- Sizes ---- */
  --topbar-h: 64px;
  --tap-sm: 44px;   /* minimum */
  --tap: 48px;      /* default button */
  --tap-lg: 56px;   /* bottom bar, primary page actions */
  --icon: 20px;
  --icon-sm: 16px;
  --avatar-xs: 20px;
  --avatar-sm: 28px;
  --avatar-md: 40px;
  --hairline-w: 1px;

  color-scheme: light;
}

/* ---- Dark theme: evening use. Same structure, lower glare. ---- */
:root[data-theme="dark"] {
  --bg: #0A0E1B;
  --surface: #11162A;
  --surface-sunken: #0D1222;
  --surface-hover: #161C33;
  --surface-selected: #1B2240;

  --text: #ECEEF5;
  --text-2: #A7AFC8;
  --text-3: #6F7893;
  --text-disabled: #4B5370;

  --hairline: rgba(255, 255, 255, .075);
  --hairline-strong: rgba(255, 255, 255, .14);

  --accent-text: #FF8A5E;
  --accent-soft: rgba(255, 90, 31, .10);
  --accent-soft-line: rgba(255, 90, 31, .28);
  --live-on-paper: #C6FD64;

  --ink-fill: #ECEEF5;
  --on-ink-fill: #0A0E1B;

  --topbar-bg: #060916;
  --topbar-hairline: rgba(255, 255, 255, .07);

  --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-2: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
  --shadow-pop: 0 24px 48px -16px rgba(0, 0, 0, .7);
  --shadow-button: none;
  --shadow-primary: inset 0 1px 0 rgba(255, 255, 255, .16);

  color-scheme: dark;
}

/* =========================================================================================
   Base
   ========================================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-feature-settings: var(--font-features);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  letter-spacing: var(--tracking-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p, ul, ol { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button { font: inherit; color: inherit; letter-spacing: inherit; }
.tnum { font-variant-numeric: tabular-nums; }

/* Type roles */
.t-display { font-size: var(--fs-display); line-height: var(--lh-display); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }
.t-title   { font-size: var(--fs-title);   line-height: var(--lh-title);   font-weight: var(--fw-semibold); letter-spacing: var(--tracking-tight); }
.t-glance  { font-size: var(--fs-glance);  line-height: var(--lh-glance);  font-weight: var(--fw-semibold); letter-spacing: var(--tracking-snug); }
.t-lead    { font-size: var(--fs-lead);    line-height: var(--lh-lead);    color: var(--text-2); }
.t-body    { font-size: var(--fs-body);    line-height: var(--lh-body); }
.t-small   { font-size: var(--fs-small);   line-height: var(--lh-small);   color: var(--text-2); }
.t-caption { font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--text-3); }
.t-row     { font-size: var(--fs-body);    line-height: 24px; font-weight: var(--fw-medium); letter-spacing: var(--tracking-snug); }

/* Section label: sentence case, quiet, never all-caps */
.label {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-small); line-height: var(--lh-small);
  font-weight: var(--fw-semibold); color: var(--text);
  letter-spacing: var(--tracking-snug);
}
.label .count { font-weight: var(--fw-medium); color: var(--text-3); font-variant-numeric: tabular-nums; }
.label .spacer { flex: 1; }

/* Icons: 24-unit grid, 1.75 stroke, inherit colour */
.i { width: var(--icon); height: var(--icon); flex: none; fill: none; stroke: currentColor;
     stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.i-sm { width: var(--icon-sm); height: var(--icon-sm); }

/* =========================================================================================
   Buttons: primary (orange, one per screen), secondary, quiet
   ========================================================================================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: var(--tap); padding: 0 var(--s-5);
  border: var(--hairline-w) solid transparent; border-radius: var(--r-md);
  font-size: 16px; line-height: 1; font-weight: var(--fw-semibold); letter-spacing: -0.006em;
  white-space: nowrap; cursor: pointer; text-decoration: none;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.btn .i { margin-left: -2px; }
.btn-sm { height: var(--tap-sm); padding: 0 var(--s-4); font-size: 15px; }
.btn-lg { height: var(--tap-lg); padding: 0 var(--s-6); font-size: 17px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }
.btn-icon.btn-sm { width: var(--tap-sm); }

.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--shadow-primary); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: var(--accent-press); }

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--hairline-strong); box-shadow: var(--shadow-button); }
.btn-secondary:hover { background: var(--surface-hover); }

.btn-quiet { background: transparent; color: var(--text-2); font-weight: var(--fw-medium); }
.btn-quiet:hover { background: var(--surface-hover); color: var(--text); }

/* On the navy top bar */
.on-navy .btn-secondary { background: var(--topbar-control); color: var(--topbar-text); border-color: var(--topbar-control-line); box-shadow: none; }
.on-navy .btn-secondary:hover { background: var(--topbar-control-hover); }
.on-navy .btn-quiet { color: var(--topbar-text-2); }
.on-navy .btn-quiet:hover { background: var(--topbar-control); color: var(--topbar-text); }

/* Text link-style action inside content */
.link { color: var(--accent-text); font-weight: var(--fw-medium); text-decoration: none; }

/* =========================================================================================
   Surfaces: cards, sheets, lists
   ========================================================================================= */
.card {
  background: var(--surface);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--s-5); }
.sheet { /* a document page */
  background: var(--surface);
  border: var(--hairline-w) solid var(--hairline);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
}

.list > li, .list > .row { border-top: var(--hairline-w) solid var(--hairline); }
.list > li:first-child, .list > .row:first-child { border-top: 0; }
.row {
  display: flex; align-items: center; gap: var(--s-4);
  min-height: 56px; padding: var(--s-3) var(--s-4);
}
.row-lg { min-height: 72px; padding: var(--s-4) var(--s-5); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: var(--fs-body); line-height: 24px; font-weight: var(--fw-medium); letter-spacing: var(--tracking-snug);
              white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-2);
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: var(--text-3); }
.divider { height: 1px; background: var(--hairline); border: 0; margin: 0; }

/* =========================================================================================
   Small parts
   ========================================================================================= */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 10px; border-radius: var(--r-pill);
  background: var(--surface-sunken); color: var(--text-2);
  font-size: var(--fs-caption); line-height: 1; font-weight: var(--fw-medium); white-space: nowrap;
}
.chip-outline { background: transparent; border: 1px solid var(--hairline-strong); }
.chip-accent { background: var(--accent-soft); color: var(--accent-text); }
.chip .i { width: 14px; height: 14px; stroke-width: 2; }

.source { /* "prairiemetal.example", "Minutes · Sep 24": where a fact came from */
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-caption); line-height: var(--lh-caption); color: var(--text-3); white-space: nowrap;
}
.source .i { width: 13px; height: 13px; stroke-width: 2; }

.check { /* checkbox */
  width: 24px; height: 24px; flex: none; border-radius: 7px;
  border: 1.5px solid var(--hairline-strong); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center; color: transparent;
}
.check .i { width: 16px; height: 16px; stroke-width: 2.5; }
.check.on { background: var(--ink-fill); border-color: var(--ink-fill); color: var(--on-ink-fill); }

.person { /* initials avatar for people (not the character) */
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: var(--surface-sunken); color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: var(--fw-semibold); letter-spacing: 0;
  box-shadow: inset 0 0 0 1px var(--hairline);
}

.field {
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--tap); padding: 0 var(--s-4);
  background: var(--surface-sunken); border: 1px solid transparent; border-radius: var(--r-md);
  color: var(--text-3); font-size: 16px;
}
.field.on-surface { background: var(--surface); border-color: var(--hairline-strong); }

.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-sunken); border-radius: var(--r-md); }
.seg > span { height: 38px; padding: 0 var(--s-4); display: inline-flex; align-items: center; gap: 6px; border-radius: 8px;
              font-size: 15px; font-weight: var(--fw-medium); color: var(--text-2); }
.seg > span.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.seg .count { color: var(--text-3); font-variant-numeric: tabular-nums; }

.kbd-hint { font-size: var(--fs-caption); color: var(--text-3); }

/* =========================================================================================
   App chrome
   ========================================================================================= */
.topbar {
  height: var(--topbar-h); padding: 0 var(--s-5) 0 var(--s-5);
  display: flex; align-items: center; gap: var(--s-3);
  background: var(--topbar-bg); color: var(--topbar-text);
  border-bottom: 1px solid var(--topbar-hairline);
}
.topbar .brand { display: flex; align-items: center; gap: 10px; }
.topbar .brand img.icon { width: 28px; height: 28px; }
.topbar .brand img.wordmark { height: 19px; }
.topbar .spacer { flex: 1; }
.topbar .clock { font-size: 15px; color: var(--topbar-text-2); font-variant-numeric: tabular-nums; margin-right: var(--s-2); }
.topbar .sep { width: 1px; height: 24px; background: var(--topbar-hairline); margin: 0 var(--s-2); }

/* Status chip: "Taking notes · 12:04" with the character avatar */
.status {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 16px 0 6px; border-radius: var(--r-pill);
  background: var(--topbar-control); box-shadow: inset 0 0 0 1px var(--topbar-control-line);
  color: var(--topbar-text); font-size: 15px; font-weight: var(--fw-medium); white-space: nowrap;
}
.status img { width: 32px; height: 32px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 3px rgba(198, 253, 100, .18); }
.status .time { color: var(--topbar-text-2); font-variant-numeric: tabular-nums; }
.status.paused .dot { background: var(--topbar-text-2); box-shadow: none; }
/* status chip on paper (e.g. inside a card) */
.status.on-paper { background: var(--surface-sunken); box-shadow: inset 0 0 0 1px var(--hairline); color: var(--text); }
.status.on-paper .dot { background: var(--live-on-paper); box-shadow: none; }
.status.on-paper .time { color: var(--text-2); }

.assistant-note { /* the character speaking in-line: small, dignified */
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--fs-small); line-height: var(--lh-small); color: var(--text-2);
}
.assistant-note img { width: 28px; height: 28px; flex: none; }

/* Reduce motion everywhere; the character honours this too. */
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
