/* JS Notes - core tokens + shared shell. Own look (docs/decisions.md 2026-09-25): no
   Martin palette. Type scale from Jeremy's token-dashboard quota pop-out (plan s3).
   Page-specific styles live in list.css / note.css; tokens live ONLY here. */

*, *::before, *::after { box-sizing: border-box; }

:root {
  /* Type (compact desktop window) */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fs-item: 13px;      /* the main line of every item */
  --fs-meta: 11px;      /* thin dates/status line */
  --fs-ui: 12px;        /* buttons, selects, header */
  --fs-title: 14px;
  --lh: 1.45;
  --row-pad-y: 3px;
  --gutter: 10px;
  --tap: 26px;          /* min control size on desktop; 44 on touch */
  --radius: 5px;
  --maxw: 760px;        /* a wide window just centres the column */

  /* Light */
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f3f4f5;
  --text: #1c1f23;
  --muted: #6a7178;
  --faint: #99a0a7;
  --border: #e5e7ea;
  --border-strong: #d3d7dc;
  --hover: #f1f3f5;
  --accent: #2f6fde;
  --accent-soft: #e7effc;
  --focus: #2f6fde;
  --danger: #c93a3a;

  --st-todo: #2f6fde;   --st-todo-bg: #e8f0fd;
  --st-sent: #a86a07;   --st-sent-bg: #fbf1dd;
  --st-done: #22855b;   --st-done-bg: #e2f4ea;
  --st-archived: #6a7178; --st-archived-bg: #eef0f2;

  color-scheme: light;
}

/* Dark: token-dashboard's palette as the starting point (plan s3). */
:root[data-theme="dark"] {
  --bg: #0a0e14;
  --surface: #0f1419;
  --surface-2: #131922;
  --text: #e6edf3;
  --muted: #8b98a6;
  --faint: #5f6b78;
  --border: #1f2630;
  --border-strong: #283040;
  --hover: #131922;
  --accent: #4a9eff;
  --accent-soft: #14233a;
  --focus: #4a9eff;
  --danger: #e5484d;
  --st-todo: #6cb0ff;   --st-todo-bg: #13243a;
  --st-sent: #e8a23b;   --st-sent-bg: #2b2112;
  --st-done: #3fb68b;   --st-done-bg: #10271f;
  --st-archived: #8b98a6; --st-archived-bg: #1a2029;
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #0a0e14;
    --surface: #0f1419;
    --surface-2: #131922;
    --text: #e6edf3;
    --muted: #8b98a6;
    --faint: #5f6b78;
    --border: #1f2630;
    --border-strong: #283040;
    --hover: #131922;
    --accent: #4a9eff;
    --accent-soft: #14233a;
    --focus: #4a9eff;
    --danger: #e5484d;
    --st-todo: #6cb0ff;   --st-todo-bg: #13243a;
    --st-sent: #e8a23b;   --st-sent-bg: #2b2112;
    --st-done: #3fb68b;   --st-done-bg: #10271f;
    --st-archived: #8b98a6; --st-archived-bg: #1a2029;
    color-scheme: dark;
  }
}

/* Touch (phone, tablet): keyed on the POINTER, not the width - Jeremy's desktop window
   is ~460px wide and must keep the compact 13px look (plan s3). 16px editable text (iOS zooms below 16px on focus), 44px targets. */
@media (pointer: coarse) {
  :root {
    --fs-item: 16px;
    --fs-meta: 12px;
    --fs-ui: 15px;
    --fs-title: 17px;
    --row-pad-y: 6px;
    --gutter: 14px;
    --tap: 44px;
  }
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-item);
  line-height: var(--lh);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}
body { min-height: 100vh; min-height: 100dvh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: 3px; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Dev banner (bypass active). */
.devbar {
  background: repeating-linear-gradient(135deg, #f6c343 0 8px, #f2b705 8px 16px);
  color: #1c1f23; font-size: 10px; font-weight: 600; letter-spacing: .04em;
  text-align: center; padding: 1px 0; text-transform: uppercase;
}

/* Page column + top bar, shared by every page. */
.page { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter) 24px; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 4px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding-top: max(4px, env(safe-area-inset-top));
}
.topbar-title {
  font-size: var(--fs-title); font-weight: 600; margin: 0;
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 2px; flex: none; }

/* Buttons */
.btn, .icon-btn {
  font: inherit; font-size: var(--fs-ui); color: var(--text);
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; min-height: var(--tap);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.btn { padding: 2px 8px; border-color: var(--border-strong); background: var(--surface); }
.btn:hover, .icon-btn:hover { background: var(--hover); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.icon-btn { min-width: var(--tap); padding: 0 4px; color: var(--muted); }
.icon-btn:hover { color: var(--text); }

/* Small status toast (saves, errors). */
.toast {
  position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  font-size: var(--fs-ui); padding: 6px 12px; border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0,0,0,.18); z-index: 50;
  max-width: calc(100vw - 32px);
}
.toast[hidden] { display: none; }

/* Login */
.page-login { display: grid; place-items: center; min-height: 100vh; }
.login-card {
  width: min(320px, calc(100% - 32px)); padding: 24px; text-align: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
}
.login-title { font-size: 18px; margin: 0 0 12px; }
.login-btn { width: 100%; min-height: 40px; margin-top: 8px; }
.login-switch { display: inline-block; margin-top: 10px; font-size: var(--fs-ui); }
.login-error { color: var(--danger); font-size: var(--fs-ui); }
