/* ============================================================
   Doc — design tokens & shared foundation
   One system, all pages. Light "paper" theme, mobile-first.
   Load order: fonts <link> → tokens.css → page <style>.
   Page styles consume these variables; nothing here uses !important.
   ============================================================ */

:root {
  /* Paper & surfaces */
  --bg: #F7F4EE;            /* warm off-white — the desk */
  --surface: #FFFFFF;       /* cards lift to true white */
  --surface-warm: #FBF9F3;  /* input wells, quiet fills */
  --line: #E5E0D5;          /* warm hairline */
  --line-strong: #D2CBBC;

  /* Ink */
  --ink: #1F2A24;           /* deep evergreen-black, 14.6:1 on paper */
  --ink-soft: #52605A;      /* secondary text, 6.6:1 */
  --ink-muted: #77837C;     /* labels, timestamps, 4.5:1 */

  /* The one accent — emerald, used sparingly */
  --accent: #0E7C58;        /* 4.9:1 on white — safe for text & buttons */
  --accent-ink: #0A5C42;    /* hover / pressed */
  --accent-tint: #ECF4EF;   /* soft fill */
  --accent-line: #C3DCCF;   /* borders on tinted elements */

  /* Semantic (rare) */
  --amber: #8F5F10;
  --amber-tint: #FAF3E2;
  --alert: #B3261E;
  --alert-tint: #FBEAE8;

  /* Type */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;

  /* Shape & depth */
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;
  --shadow-card: 0 1px 2px rgba(31, 42, 36, 0.04), 0 8px 28px rgba(31, 42, 36, 0.06);
  --shadow-raised: 0 2px 4px rgba(31, 42, 36, 0.06), 0 16px 48px rgba(31, 42, 36, 0.10);

  /* Spacing rhythm */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;
}

/* ---- Base ---- */
* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0;
  line-height: 1.25;
  margin: 0;
}

a { color: var(--accent); }

::selection { background: var(--accent-tint); }

/* ---- The D. wordmark — Doc's identity ----
   A paper tile with a serif D. and an emerald citation-underline:
   the highlight swipe of a marked-up study. Replaces the AI portrait. */
.doc-mark {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(31, 42, 36, 0.05);
  user-select: none;
}
.doc-mark::after {
  content: '';
  position: absolute;
  left: 22%;
  right: 20%;
  bottom: 19%;
  height: 3px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}
.doc-mark-sm { width: 36px; height: 36px; border-radius: 10px; font-size: 18px; }
.doc-mark-sm::after { height: 2.5px; }
.doc-mark-lg { width: 64px; height: 64px; border-radius: 16px; font-size: 34px; }
.doc-mark-lg::after { height: 4px; }

/* ---- Shared controls ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #FFFFFF;
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease;
}
.btn:hover { background: var(--accent-ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { background: var(--line-strong); color: #FFFFFF; cursor: not-allowed; transform: none; }

.btn-quiet {
  background: var(--surface);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.btn-quiet:hover { background: var(--surface-warm); color: var(--ink); border-color: var(--line-strong); }

.btn-ghost {
  background: transparent;
  color: var(--accent);
  border: none;
}
.btn-ghost:hover { background: var(--accent-tint); }

/* ---- Form primitives ---- */
.field-label,
label {
  display: block;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}

input[type="text"], input[type="number"], input[type="password"],
input[type="email"], select, textarea {
  width: 100%;
  min-height: 48px;
  background: var(--surface-warm);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;               /* ≥16px prevents iOS zoom-on-focus */
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
textarea { min-height: 88px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
  background: var(--surface);
}
input::placeholder, textarea::placeholder { color: var(--ink-muted); }
select option { background: var(--surface); color: var(--ink); }

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* ---- Range sliders (check-in) ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  min-height: 0;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: var(--line);
  outline: none;
  box-shadow: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  box-shadow: 0 1px 4px rgba(31, 42, 36, 0.25);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--surface);
  cursor: pointer;
}

/* ---- Utility ---- */
.muted { color: var(--ink-muted); }
