/* Per My Vision: site chrome and shared UI. Red pen styles live in redpen.css. */
:root {
  --bg: #f3f1ec;
  --paper: #ffffff;
  --ink: #1e1d1a;
  --muted: #6d6a62;
  --line: #e2ded4;
  --brand: #0f3d3e;
  --brand-ink: #ffffff;
  --accent: #d9632b;
  --hl: #fde8a8;
  --hl-active: #f9cf5b;
  --theft: #f6d3c3;
  --real: #e4f1ea;
  --real-ink: #1d5b3f;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.05);
  --sheet: #fffdf8;
  --pen: #c8231b;
  --stamp: #b3261e;
  --sticky: #fff4a8;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --serif: ui-serif, Georgia, serif;
  --hand: "Caveat", "Bradley Hand", "Segoe Print", cursive;
  --maxw: 1180px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171714;
    --paper: #22221e;
    --ink: #ecebe6;
    --muted: #a3a097;
    --line: #37362f;
    --brand: #7fc4bf;
    --brand-ink: #0d1f1f;
    --accent: #f08a57;
    --hl: #5a4a17;
    --hl-active: #7d6516;
    --theft: #5b3223;
    --real: #1d3328;
    --real-ink: #9fd9b9;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--ink); font: 16px/1.55 var(--sans); overflow-x: hidden; }
body > main { flex: 1; width: 100%; }
a { color: inherit; }
img, canvas, svg { max-width: 100%; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- Site header (injected by shell.js) ---------- */
.site-header { position: sticky; top: 0; z-index: 20; background: var(--paper); border-bottom: 1px solid var(--line); }
.site-header-inner { max-width: var(--maxw); margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.logo { display: block; width: 36px; height: 36px; border-radius: 9px; }
.brand-name { display: block; font-weight: 700; line-height: 1.2; }
.brand-sub { display: block; color: var(--muted); font-size: 12px; line-height: 1.2; }
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.site-nav a { text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; padding: 6px 10px; border-radius: 999px; white-space: nowrap; }
.site-nav a:hover { color: var(--ink); background: var(--bg); }
.site-nav a[aria-current="page"] { color: var(--ink); background: var(--bg); }
/* Grouped nav: dropdowns on desktop, labeled sections in the mobile menu. */
.nav-group { position: relative; }
.nav-group-btn { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--muted); font: 600 14px var(--sans); padding: 6px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.nav-group-btn:hover, .nav-group.open .nav-group-btn, .nav-group.here .nav-group-btn { color: var(--ink); background: var(--bg); }
.caret { width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-2px) rotate(45deg); transition: transform .15s; }
.nav-group.open .caret { transform: translateY(1px) rotate(-135deg); }
.nav-menu { display: none; position: absolute; top: calc(100% + 8px); right: 0; min-width: 260px; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12); padding: 6px; z-index: 30; }
.nav-group.open .nav-menu { display: block; }
.site-nav .nav-item { display: block; border-radius: 8px; padding: 8px 10px; color: var(--ink); white-space: normal; }
.site-nav .nav-item[aria-current="page"] { background: var(--bg); }
.nav-hint { display: block; color: var(--muted); font-weight: 500; font-size: 12.5px; margin-top: 1px; }
.menu-btn { display: none; margin-left: auto; background: none; border: 1px solid var(--line); color: var(--ink); border-radius: 8px; padding: 6px 10px; font: 600 14px var(--sans); cursor: pointer; }
@media (max-width: 760px) {
  .brand-sub { display: none; }
  .menu-btn { display: inline-flex; align-items: center; gap: 6px; }
  .site-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--paper); border-bottom: 1px solid var(--line); padding: 6px 16px 12px; box-shadow: var(--shadow); }
  .site-header.open .site-nav { display: flex; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); clip-path: inset(0 -100vmax -100vmax -100vmax); } /* scrim below the open menu, not over the header */
  .site-nav a { padding: 10px 8px; border-radius: 6px; font-size: 15px; }
  .nav-group-btn, .nav-group-btn:disabled { display: block; width: 100%; text-align: left; opacity: 1; padding: 14px 8px 4px; border-radius: 0; border-top: 1px solid var(--line); margin-top: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .6px; cursor: default; pointer-events: none; background: none !important; }
  .caret { display: none; }
  .nav-menu { display: block; position: static; min-width: 0; border: 0; box-shadow: none; padding: 0; background: none; }
  .site-nav .nav-item { padding: 8px; }
}

/* ---------- Footer (injected by shell.js) ---------- */
.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.site-footer-inner { max-width: var(--maxw); margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }
.site-footer a { color: var(--muted); }

/* ---------- Layout ---------- */
main { max-width: var(--maxw); margin: 0 auto; padding: 32px 16px 80px; }
main.narrow { max-width: 760px; }
h1 { font-size: clamp(28px, 5vw, 40px); line-height: 1.1; margin: 0 0 10px; letter-spacing: -0.5px; }
.lede { color: var(--muted); margin: 0 0 20px; }
.fineprint { color: var(--muted); font-size: 12px; margin-top: 16px; }
.error { color: var(--accent); font-weight: 600; }
.prose { max-width: 700px; }
.prose h2 { font-size: 20px; margin: 32px 0 8px; }
.prose p, .prose li { color: var(--ink); }
.prose ul { padding-left: 20px; }
.prose li { margin: 4px 0; }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 999px; padding: 10px 18px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.big { padding: 14px 24px; font-size: 17px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn:focus-visible, .menu-btn:focus-visible, .site-nav a:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Cards ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; box-shadow: var(--shadow); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
a.card { display: block; text-decoration: none; color: var(--ink); transition: transform .15s, border-color .15s; }
a.card:hover { transform: translateY(-2px); border-color: var(--muted); }
.card h3 { margin: 0 0 6px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 14px; }

.score-card { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 16px; min-width: 150px; box-shadow: var(--shadow); }
.score-num { font-size: 28px; font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; }
.score-num.hot { color: var(--accent); }
.score-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .6px; }

/* ---------- Compose / loading (shared by input-taking surfaces) ---------- */
.compose { max-width: 760px; margin: 0 auto; }
textarea { width: 100%; min-height: 320px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: 15px/1.6 var(--serif); resize: vertical; box-shadow: var(--shadow); }
textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.compose-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 12px; }
.count { color: var(--muted); font-size: 13px; margin-left: auto; }
.loading { text-align: center; padding: 80px 0; color: var(--muted); }
.spinner { width: 36px; height: 36px; margin: 0 auto 16px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.scores { display: flex; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* ---------- "What this actually means" toggle ---------- */
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 600; font-size: 14px; position: relative; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.track { width: 38px; height: 22px; flex-shrink: 0; border-radius: 999px; background: var(--line); position: relative; transition: background .15s; }
.thumb { position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.toggle input:checked + .track { background: var(--real-ink); }
.toggle input:checked + .track .thumb { transform: translateX(16px); }
.toggle input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Real layer panel ---------- */
.real-panel { margin-top: 28px; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 24px 28px; box-shadow: var(--shadow); }
.real-panel h2 { margin: 0 0 8px; font-size: 20px; }
.real-panel h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 20px 0 8px; }
.real-summary { font-size: 17px; margin: 0; }
.real-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.checks, .risks { list-style: none; padding: 0; margin: 0; }
.checks li, .risks li { padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.checks .mark { display: inline-block; width: 20px; font-weight: 800; }
.checks .pass .mark { color: var(--real-ink); }
.checks .fail .mark { color: var(--accent); }
.checks .tip, .risks .fix { display: block; color: var(--muted); padding-left: 20px; }
.risks .fix { padding-left: 0; }
.ideas { margin-top: 20px; font-size: 14px; }
.ideas .claimed { color: var(--accent); font-weight: 600; }

/* ---------- Share dialog + toast ---------- */
dialog { border: none; border-radius: 12px; padding: 16px; background: var(--paper); color: var(--ink); max-width: min(92vw, 520px); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog canvas { width: 100%; height: auto; border-radius: 8px; display: block; }
.dialog-row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 50; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow); animation: toast-in .2s ease-out; max-width: calc(100vw - 32px); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

@media (max-width: 860px) {
  .real-grid { grid-template-columns: 1fr; }
  .scores { width: 100%; }
  .score-card { flex: 1; min-width: 0; }
  .real-panel { padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Demo launch: banner, sample picker, waitlist ---------- */
.demo-banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 14px; padding: 8px 16px; background: #fff4a8; color: #2d2a1f; font-size: 14px; border-bottom: 1px solid rgba(0,0,0,.06); }
.demo-banner .btn.sm, .btn.sm { padding: 6px 12px; font-size: 13px; }
.sample-picker { margin: 4px 0 18px; }
.sample-label { margin: 0 0 6px; }
.sample-label .ink { font-size: 22px; }
.sample-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sample-chip { display: inline-block; text-decoration: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 999px; padding: 6px 12px; font: 600 13.5px var(--sans); }
.sample-chip:hover, .sample-chip.on { border-color: var(--pen); color: var(--pen); }
.sample-status { margin: 0 0 6px; color: var(--muted); font-size: 14px; }
.sample-status .ink { font-size: 20px; margin-right: 4px; }
.btn.pressed { transform: scale(.95); filter: brightness(.88); transition: transform .12s, filter .12s; }
.sample-or { margin: 10px 0 0; color: var(--muted); font-size: 14px; }
.linklike { background: none; border: 0; padding: 0; color: var(--ink); font: inherit; text-decoration: underline; cursor: pointer; }
.waitlist-dialog { border: 0; border-radius: 14px; padding: 0; width: min(94vw, 520px); background: var(--paper); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.waitlist-dialog::backdrop { background: rgba(0,0,0,.45); }
.wl-close-row { display: flex; justify-content: flex-end; padding: 6px 8px 0; }
.wl-x { background: none; border: 0; font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.wl-body { padding: 0 24px 22px; }
.wl-body h2 { margin: 0 0 6px; font-size: 24px; }
.wl-lede { margin: 0 0 16px; color: var(--muted); }
.wl-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 4px; }
#wl-email { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); font: 16px var(--sans); }
.wl-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.waitlist-dialog fieldset { border: 0; padding: 0; margin: 14px 0 0; }
.waitlist-dialog legend { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.waitlist-dialog legend span { color: var(--muted); font-weight: 500; }
.wl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.wl-chips label { position: relative; }
.wl-chips input { position: absolute; opacity: 0; }
.wl-chips span { display: inline-block; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.wl-chips input:checked + span { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.wl-chips input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
#wl-turnstile { margin-top: 12px; }
.wl-submit { width: 100%; margin-top: 16px; padding: 12px; }
.wl-error { color: var(--pen); font-weight: 600; margin: 10px 0 0; }
.wl-fine { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.wl-done { text-align: center; padding: 10px 0 8px; }
.wl-done-ink { font-size: 30px; margin: 0 0 6px; }
html.demo-mode .demo-hide { display: none !important; }
.demo-only { display: none !important; }
html.demo-mode .demo-only { display: block !important; }
.waitlist-cta { text-align: center; max-width: 640px; margin: 56px auto; padding: 32px 24px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.waitlist-cta h2 { margin: 0 0 8px; }
.wl-cta-ink { font-size: 30px; margin: 0; }

/* Print / "Save as PDF" from My Desk: just the artifact, no chrome. */
@media print {
  body { background: #fff !important; }
  .site-header, .site-footer, .toast, dialog, .brock-cursor, .menu-btn,
  .actions, .desk-actions, .btn, button, .toggle, .compose, .loading { display: none !important; }
  .paper { transform: none !important; box-shadow: none !important; }
  main { padding: 0 !important; max-width: none !important; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Polish pass (UI review) ---------- */
/* Dark mode: red ink needs to be brighter on dark surfaces; on printed paper
   (always light) it stays the classic dark red. */
@media (prefers-color-scheme: dark) {
  :root { --pen: #ff7a6e; }
  .paper, .notes-paper { --pen: #c8231b; } /* printed paper stays light in dark mode */
  .demo-banner { background: #3a3215; color: #f3e7b0; border-bottom-color: rgba(255,255,255,.06); }
  .demo-banner .btn.primary { background: #0f3d3e; color: #fff; }
  .redacted { background: #000 !important; outline: 1px solid var(--line); }
  .track { background: #5a584f; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
  dialog::backdrop { background: rgba(0,0,0,.7); backdrop-filter: blur(2px); }
}
/* Bigger tap targets on phones. */
@media (max-width: 640px) {
  .menu-btn, .btn.sm, .chip, .sample-chip, .demo-banner .btn { min-height: 44px; }
  .sample-chip { display: inline-flex; align-items: center; }
  .toggle { padding-block: 11px; }
  .site-footer a { display: inline-block; padding: 12px 0; }
}

.page-title { font-size: clamp(26px, 4.5vw, 36px); line-height: 1.1; letter-spacing: -0.5px; margin: 0 0 6px; }

.nav-about { display: none; }
@media (max-width: 760px) { .site-nav .nav-about { display: block; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 14px; } }
[hidden] { display: none !important; }

.real-hint { font-size: 19px; color: var(--pen); margin-left: 6px; white-space: nowrap; animation: hint-nudge 1.6s ease-in-out 3; }
@keyframes hint-nudge { 50% { transform: translateX(-4px); } }
@media (max-width: 640px) { .real-hint { display: none; } }

/* ---------- Mobile polish ---------- */
.banner-short { display: none; }
@media (max-width: 640px) {
  /* Preview banner: one compact line instead of three. */
  .demo-banner { flex-wrap: nowrap; justify-content: space-between; text-align: left; font-size: 13px; padding: 6px 12px; gap: 10px; }
  .banner-long { display: none; }
  .banner-short { display: inline; }
  .demo-banner .btn { min-height: 36px; padding: 6px 12px; font-size: 13px; white-space: nowrap; flex: none; }

  /* Sample chips: one swipeable row instead of a tall stack. */
  .sample-chips { flex-wrap: nowrap; overflow-x: auto; scroll-snap-type: x proximity; margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 28px), transparent); mask-image: linear-gradient(90deg, transparent 0, #000 16px, #000 calc(100% - 28px), transparent); }
  .sample-chips::-webkit-scrollbar { display: none; }
  .sample-chip { flex: none; scroll-snap-align: start; white-space: nowrap; }

  /* In the preview, the paste box is secondary: keep it short. */
  html.demo-mode #compose textarea { min-height: 150px; }

  /* Result-page actions: tidy pairs instead of a ragged stack. */
  #result .actions { gap: 8px; width: 100%; }
  #result .actions .btn { flex: 1 1 calc(50% - 4px); justify-content: center; text-align: center; font-size: 14px; padding: 10px 12px; }
  #result .actions .toggle { flex: 1 1 100%; }
}
