/* =============================================================================
   mera.bot shared theme + type system
   Used by every page in html/. Load it before a page's own stylesheet:
     <link rel="stylesheet" href="assets/css/mera.css?v=dev">
     <script defer src="assets/js/mera.js?v=dev"></script>
   Holds: fonts, the type system (FONT_BEST.md: role ladder, weights 400/500/600,
   line-heights, tracking, measure, spacing scale), colour tokens (light default,
   dark as a user option) with spec-name aliases, base, logo, buttons, icon buttons,
   the crew "mochi" bots, the post-signup survey, the update toast and the plain
   document layout (privacy, 404, offline). Page-specific layout stays in each page.

   Type system rules in short (see __md_info/font_best.md):
     - Body 16 px, set in rem. Inputs never under 16 px. Nothing under 12 px.
     - Roles only: Display, Title, Heading, Subheading, Lead, Body, Body-Small,
       Label, Overline, Caption, Code. No ad-hoc sizes in pages.
     - Weights 400 / 500 / 600 only. 600 is for Title and Display. strong = 500.
     - Primary ink ≥15:1, muted ≥7:1 on every ground, so muted is safe at 12 px.
     - Light ground by default; dark mode is a user choice, never the default.
   ========================================================================== */

/* ---------- Fonts: Geist + Geist Mono (SIL OFL), self-hosted, three weights ---------- */
@font-face{font-family:"Geist";src:url("../fonts/geist.woff2") format("woff2");font-weight:400 600;font-display:swap}
@font-face{font-family:"Geist Mono";src:url("../fonts/geist-mono.woff2") format("woff2");font-weight:400 600;font-display:swap}
@font-face{font-family:"Geist Fallback";src:local("Arial");size-adjust:104%;ascent-override:92%;descent-override:22%;line-gap-override:0%}
/* Matched to Geist Mono (0.600em advance, 1.005/0.295 ascent/descent) from Menlo's 0.602em; Courier New shares the 0.6em advance. */
@font-face{font-family:"Geist Mono Fallback";src:local("Menlo"),local("Consolas"),local("Courier New");size-adjust:99.7%;ascent-override:100.8%;descent-override:29.6%;line-gap-override:0%}

/* ---------- Tokens ----------
   Every colour is light-dark(light, dark). The active theme is set on <html data-theme>
   by mera.js (default light; dark is a user option). */
:root{
  color-scheme:light;

  /* ----- Type: family ----- */
  --sans:"Geist","Geist Fallback",ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
  --mono:"Geist Mono","Geist Mono Fallback",ui-monospace,SFMono-Regular,Menlo,monospace;

  /* ----- Type: size ladder (the only sizes that exist). Fluid steps are rem-dominant. ----- */
  --font-size-caption:0.75rem;                                /* 12 */
  --font-size-small:0.875rem;                                 /* 14 */
  --font-size-body:1rem;                                      /* 16 */
  --font-size-lead:1.125rem;                                  /* 18 */
  --font-size-sub:1.25rem;                                    /* 20 */
  --font-size-heading:1.5rem;                                 /* 24 */
  --font-size-title:clamp(2rem,1.75rem + 1vw,2.5rem);         /* 32–40 */
  --font-size-display:clamp(2.75rem,2.4rem + 1.4vw,3.75rem);  /* 44–60 */

  /* ----- Type: weights ----- */
  --weight-regular:400;
  --weight-medium:500;
  --weight-semibold:600;

  /* ----- Type: line-height ----- */
  --leading-display:1.05;
  --leading-title:1.1;
  --leading-heading:1.2;
  --leading-sub:1.3;
  --leading-lead:1.5;
  --leading-body:1.55;
  --leading-small:1.5;
  --leading-caption:1.45;
  --leading-label:1.3;

  /* ----- Type: tracking ----- */
  --tracking-display:-0.02em;
  --tracking-title:-0.015em;
  --tracking-heading:-0.01em;
  --tracking-caps:0.06em;

  /* ----- Measure and spacing ----- */
  --measure:65ch;
  --space-1:0.25rem;--space-2:0.5rem;--space-3:0.75rem;--space-4:1rem;--space-5:1.5rem;
  --space-6:2rem;--space-7:3rem;--space-8:4rem;--space-9:6rem;--space-10:8rem;
  --space-paragraph:1em;
  --space-heading-above:2.5em;
  --space-heading-below:0.5em;
  --space-card:var(--space-5);
  --space-section-app:var(--space-7);
  --space-section:clamp(2.5rem,8vw,6rem);
  --gutter:clamp(1rem,3.5vw,2.5rem);

  /* ----- Grounds. Light paper sits in the OKLCH L 98–100% band so the ink keeps its ratios. ----- */
  --ink:light-dark(#F9F9F7,#0F100D);        /* page ground */
  --tile:light-dark(#FFFFFF,#1C1D18);       /* cards, panels */
  --tile-2:light-dark(#F2F2EE,#24251F);     /* raised / hover */
  --tile-warm:light-dark(#FBF0E8,#2A1A12);  /* warm card */
  --tile-dark:light-dark(#EFEFEA,#141510);  /* deep card */
  --night:light-dark(#E9E9F0,#26271F);
  --field:light-dark(#FFFFFF,#1A1B17);      /* inputs */
  --field-line:light-dark(#8A8A82,#6E6F66); /* input boundaries, ≥3:1 (WCAG 1.4.11): 3.30:1 on paper, 3.40:1 on the dark field */
  --line:light-dark(#DDDDD6,#2A2B25);       /* hairlines, borders */
  --line-2:light-dark(#C9C9C1,#3A3B35);     /* decorative strong rule: dashed ghosts, redaction bars; never a control boundary */

  /* ----- Ink. Ratios on the light paper #F9F9F7 / dark #0F100D (2026-10-16). ----- */
  --bone:light-dark(#18181B,#EEEDE6);       /* primary text: 16.8:1 / 16.3:1 */
  --soft:light-dark(#2E2F33,#C9C8C0);       /* body copy: 12.7:1 / 11.4:1 */
  --muted:light-dark(#444A53,#B4B4AB);      /* secondary: ≥7.2:1 on every ground and tile, safe at 12 px */
  --dim:var(--muted);                       /* tertiary: same as muted (no text below 7:1) */
  --faint:var(--muted);                     /* placeholders, legal */

  /* ----- The single accent ----- */
  --signal:#FF6B2C;                          /* fills: buttons, lead bot */
  --signal-hi:#FF8A55;                       /* fill hover */
  --signal-ink:light-dark(#8F2F03,#FF8A55);  /* orange as text: 7.7:1 / 8.2:1 (links, small labels) */
  --signal-display:light-dark(#B8400B,#FF6B2C); /* orange as large (≥24 px) display text: 5.3:1 */
  --on-signal:#160A04;                       /* text on orange: 8.1:1 */
  --on-bot:#16140F;                          /* glyph ink on a crew bot body */
  --signal-glow:color-mix(in oklab,var(--signal) 28%,transparent);
  --sheen:rgb(255 255 255 / .25);              /* top-edge highlight on orange fills */

  /* ----- Status (text) ----- */
  --warn:light-dark(#713F12,#FDE68A);
  --bad:light-dark(#991B1B,#FCA5A5);
  --ok:light-dark(#14532D,#86EFAC);

  /* ----- Motion, shape ----- */
  --spring:cubic-bezier(.34,1.56,.64,1);
  --out:cubic-bezier(.16,1,.3,1);
  --r-pill:999px; --r-tile:24px; --r-sm:14px;
  --shadow:0 1px 0 light-dark(#fff,#ffffff0d) inset, 0 18px 40px -24px light-dark(#3d2a1a33,#00000099);

  /* ----- Spec aliases (font_best.md Part 7/8 names). Here --ink is the page ground and --bone the text,
     the inverse of the spec's --ink; new code uses these names. Recorded in DESIGN_OVERRIDES.md. ----- */
  --color-bg:var(--ink);
  --color-surface:var(--tile);
  --color-text:var(--bone);
  --color-text-muted:var(--muted);
  --color-accent:var(--signal);
  --color-accent-hover:var(--signal-hi);
  --color-on-accent:var(--on-signal);
  --color-link:var(--signal-ink);
  --color-focus:var(--signal-ink);            /* 7.73:1 on light paper, 8.20:1 on dark; --signal was 2.70:1 */
  --font-sans:var(--sans);
  --font-mono:var(--mono);
}
:root[data-theme="dark"]{color-scheme:dark}
:root[data-theme="light"]{color-scheme:light}
@media (prefers-contrast:more){:root{--soft:var(--bone);--muted:var(--bone)}}

/* ---------- Base ---------- */
*,*::before,*::after{box-sizing:border-box}
html{background:var(--ink);color:var(--bone);font-family:var(--sans);font-synthesis:none;font-optical-sizing:auto;-webkit-text-size-adjust:100%;text-size-adjust:100%;-webkit-tap-highlight-color:transparent}
body{margin:0;background:var(--ink);color:var(--bone);font:var(--weight-regular) var(--font-size-body)/var(--leading-body) var(--sans);-webkit-font-smoothing:antialiased}
:lang(ja),:lang(zh),:lang(ko){line-height:1.7}

/* Roles via semantic elements. Pages set only which role an element is, never a size. */
h1{font-size:var(--font-size-title);font-weight:var(--weight-semibold);line-height:var(--leading-title);letter-spacing:var(--tracking-title);text-wrap:balance;margin:0}
h2{font-size:var(--font-size-heading);font-weight:var(--weight-medium);line-height:var(--leading-heading);letter-spacing:var(--tracking-heading);text-wrap:balance;margin:0}
h3{font-size:var(--font-size-sub);font-weight:var(--weight-medium);line-height:var(--leading-sub);letter-spacing:0;text-wrap:balance;margin:0}
h4,h5,h6{font-size:var(--font-size-body);font-weight:var(--weight-medium);line-height:var(--leading-body);margin:0}
p,li,dd,dt,blockquote{text-wrap:pretty}
p{max-inline-size:var(--measure)}
small{font-size:var(--font-size-caption);line-height:var(--leading-caption)}
strong,b{font-weight:var(--weight-medium)}            /* emphasis is a half-step, never 700 */
em,i{font-style:italic}
a{color:var(--signal-ink);text-decoration:underline;text-underline-offset:0.15em;text-decoration-thickness:from-font}
a:hover{color:var(--signal-display)}
code,kbd,pre{font-family:var(--mono);font-size:max(0.875em,0.875rem)}
pre{overflow-x:auto;max-inline-size:100%}
td,th,[data-numeric]{font-variant-numeric:tabular-nums}
button,input,select,textarea{font:inherit;color:inherit}
input,select,textarea{font-size:max(var(--font-size-body),100%);min-block-size:2.5rem}   /* ≥16 px: no iOS zoom */
::placeholder{color:var(--muted);opacity:1}
button{cursor:pointer}
:focus-visible{outline:2px solid var(--color-focus);outline-offset:3px}
@media (forced-colors:active){:focus-visible{outline:2px solid CanvasText;outline-offset:2px}}
::selection{background:color-mix(in oklab,var(--signal) 35%,transparent)}
[hidden]{display:none!important}
.sr{position:absolute!important;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
.mono{font-family:var(--mono);font-weight:var(--weight-medium)}
.skip{position:fixed;left:var(--space-4);top:var(--space-4);z-index:90;padding:var(--space-2) var(--space-4);border-radius:var(--r-pill);background:var(--bone);color:var(--ink);
  font-size:var(--font-size-small);font-weight:var(--weight-medium);text-decoration:none;translate:0 -200%}
.skip:focus{translate:none;color:var(--ink)}
.skip:focus-visible{outline-color:var(--signal-ink)}
main[tabindex="-1"]:focus{outline:none}

/* ---------- Role classes, for places where the semantic element is not available ---------- */
.t-display{font-size:var(--font-size-display);font-weight:var(--weight-semibold);line-height:var(--leading-display);letter-spacing:var(--tracking-display);text-wrap:balance}
.t-title{font-size:var(--font-size-title);font-weight:var(--weight-semibold);line-height:var(--leading-title);letter-spacing:var(--tracking-title);text-wrap:balance}
.t-heading{font-size:var(--font-size-heading);font-weight:var(--weight-medium);line-height:var(--leading-heading);letter-spacing:var(--tracking-heading)}
.t-subheading{font-size:var(--font-size-sub);font-weight:var(--weight-medium);line-height:var(--leading-sub);letter-spacing:0}
.t-lead{font-size:var(--font-size-lead);font-weight:var(--weight-regular);line-height:var(--leading-lead)}
.t-body{font-size:var(--font-size-body);font-weight:var(--weight-regular);line-height:var(--leading-body)}
.t-body-sm{font-size:var(--font-size-small);font-weight:var(--weight-regular);line-height:var(--leading-small)}
.t-label{font-size:var(--font-size-small);font-weight:var(--weight-medium);line-height:var(--leading-label)}
.t-overline{font-size:var(--font-size-caption);font-weight:var(--weight-medium);line-height:var(--leading-label);letter-spacing:var(--tracking-caps);text-transform:uppercase}
.t-caption{font-size:var(--font-size-caption);font-weight:var(--weight-regular);line-height:var(--leading-caption)}
.t-code{font-family:var(--mono);font-size:max(0.875em,0.875rem)}
.t-muted{color:var(--muted)}
.t-numeric{font-variant-numeric:tabular-nums}
.reading{font-size:var(--font-size-lead);line-height:var(--leading-lead)}

/* ---------- Logo: the live mark (Hello's body, joined-arch "m" eyes). The wordmark keeps 600. ---------- */
.brand{display:inline-flex;align-items:center;gap:10px;text-decoration:none;color:var(--bone);font-weight:var(--weight-semibold);font-size:var(--font-size-sub);letter-spacing:-.02em;line-height:1}
.brand:hover{color:var(--bone)}
.brand b{font:inherit}
.mark{width:32px;height:32px;display:block;flex:none}
.mark .mk-eyes{transform-box:fill-box;transform-origin:50% 60%}
.mark .mk-look{transition:transform .25s var(--out)}
@media (prefers-reduced-motion: no-preference){
  .mark .mk-eyes{animation:mk-blink 5.2s infinite}
  .brand:hover .mark .mk-eyes{animation:mk-blink .9s 1}
}
@keyframes mk-blink{0%,88%,100%{transform:scaleY(1)}90%{transform:scaleY(.12)}92%{transform:scaleY(1)}95%{transform:scaleY(1)}97%{transform:scaleY(.12)}99%{transform:scaleY(1)}}

/* ---------- Buttons: Body (16/500), 48 px tall; compact = Label (14/500), 40 px ---------- */
.btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:48px;padding:0 var(--space-5);border-radius:var(--r-pill);border:0;
  background:var(--signal);color:var(--on-signal);font:var(--weight-medium) var(--font-size-body)/var(--leading-label) var(--sans);text-decoration:none;white-space:nowrap;cursor:pointer;
  transition:transform .15s ease,background .2s ease,box-shadow .2s ease,color .2s ease}
.btn:hover{background:var(--signal-hi);color:var(--on-signal)}
.btn:active{transform:translateY(1px) scale(.98)}
.btn[disabled]{opacity:.45;cursor:not-allowed;transform:none}
.btn.lg{min-height:56px;padding:0 var(--space-6)}
.btn.sm{min-height:40px;padding:0 var(--space-4);font-size:var(--font-size-small)}
.btn.ghost{background:transparent;color:var(--bone);box-shadow:inset 0 0 0 1px var(--line)}
.btn.ghost:hover{background:var(--tile-2);color:var(--bone)}
.btn .ico{width:20px;height:20px;flex:none}
.iconbtn{width:44px;height:44px;border-radius:50%;border:1px solid var(--line);background:transparent;display:grid;place-items:center;color:var(--soft);
  transition:background .2s,color .2s,transform .15s}
.iconbtn:hover{background:var(--tile);color:var(--bone)}
.iconbtn:active{transform:scale(.96)}
.iconbtn svg{width:20px;height:20px}

/* ---------- Crew bots ("mochi") ----------
   Body colour = personality temperature, from the TONE scale in mera.js.
   The six crew values below are precomputed from that scale. Faces are drawn shapes, not text. */
.m{--c:oklch(var(--l) var(--ch) var(--h));--hi:oklch(calc(var(--l) + .13) calc(var(--ch) * .45) var(--h));--lo:oklch(calc(var(--l) - .1) calc(var(--ch) * 1.08) calc(var(--h) - 12));
  border-radius:50% 50% 46% 46% / 56% 56% 44% 44%!important;border:0!important;color:oklch(.24 .04 var(--h));
  background:
    radial-gradient(10% 6.5% at 25% 71%, oklch(.72 .17 8 / .6), transparent 100%),
    radial-gradient(10% 6.5% at 75% 71%, oklch(.72 .17 8 / .6), transparent 100%),
    radial-gradient(46% 34% at 36% 22%, color-mix(in oklab,#fff 68%,var(--hi)), transparent 100%),
    linear-gradient(180deg,var(--hi),var(--c) 52%,var(--lo))!important;
  box-shadow:inset 0 -.18em .32em color-mix(in oklab,var(--lo) 70%,transparent), 0 .5em .8em -.5em color-mix(in oklab,var(--lo) 80%,transparent)}
.m-hello{--h:401.7;--l:.740;--ch:.165}  /* warm: soft signal orange, the lead */
.m-peek{--h:256.2;--l:.800;--ch:.114}   /* cool: sky */
.m-nudge{--h:279.7;--l:.800;--ch:.119}  /* periwinkle */
.m-snooze{--h:275;--l:.800;--ch:.118}   /* dusk lilac */
.m-spark{--h:391.7;--l:.728;--ch:.168}  /* warmest: coral */
.m-hmm{--h:249.1;--l:.800;--ch:.113}    /* coolest: blue */
/* drawn eyes (mera.js drawFace): the two characters stay the face, drawn soft */
.m .face{display:inline-flex;gap:.04em;margin-top:.24em;letter-spacing:0;font-size:1.32em}
.e{position:relative;display:inline-block;width:.6em;height:1em;font-style:normal;text-align:center;line-height:1;font-weight:600}
.e::before,.e::after{content:"";position:absolute;left:50%;top:50%}
.e.g-arch::before{width:.44em;height:.26em;translate:-50% -60%;border:.09em solid currentColor;border-bottom:0;border-radius:.5em .5em 0 0}
.e.g-bead::before{width:.34em;height:.4em;translate:-50% -50%;border-radius:50%;background:currentColor}
.e.g-bead::after{width:.11em;height:.11em;translate:.02em -.17em;border-radius:50%;background:#fff}
.e.g-dot::before{width:.24em;height:.27em;translate:-50% -30%;border-radius:50%;background:currentColor}
.e.g-dot::after{width:.08em;height:.08em;translate:.01em -.06em;border-radius:50%;background:#fff}
.e.g-dash::before{width:.42em;height:.09em;translate:-50% -50%;border-radius:.1em;background:currentColor}
.e.g-txt{font-size:.92em;font-weight:600;line-height:1.05}
.e.g-txt::before,.e.g-txt::after{display:none}

/* ---------- Motion pause: html.still (set by mera.js from mera_still). Pages stop their own loops under it too. ---------- */
.still .mark .mk-eyes{animation:none}

/* ---------- Post-signup survey (MERA.survey): Body legend, Caption hint, Body-Small options ---------- */
.mq{margin:var(--space-3) 0 0;padding:var(--space-3) 0 0;border:0;border-top:1px solid var(--line);display:grid;gap:var(--space-2);min-width:0}
.mq legend{padding:0;margin-bottom:var(--space-2);font-size:var(--font-size-body);font-weight:var(--weight-medium);line-height:var(--leading-body);color:var(--bone)}
.mq legend small{display:block;margin-top:2px;font-weight:var(--weight-regular);color:var(--muted)}
.mq-opts{display:grid;gap:var(--space-2)}
.mq-opt{display:flex;gap:var(--space-3);align-items:flex-start;width:100%;min-height:48px;padding:var(--space-3) var(--space-4);border-radius:var(--r-sm);border:1px solid var(--line);background:var(--ink);color:var(--soft);
  text-align:left;font-size:var(--font-size-small);line-height:var(--leading-small);cursor:pointer;transition:border-color .2s,background .2s}
.mq-opt:hover{border-color:color-mix(in oklab,var(--signal) 55%,var(--line))}
.mq-opt b{flex:none;font:var(--weight-medium) var(--font-size-small)/var(--leading-small) var(--mono);color:var(--signal-ink)}
.mq-note{display:none;gap:var(--space-2)}
.mq.depends .mq-note{display:grid}
.mq-note input{min-width:0;min-height:44px;padding:0 var(--space-3);border-radius:12px;border:1px solid var(--field-line);background:var(--field);color:var(--bone)}
.mq-note .btn{justify-self:start;min-height:44px}
.mq-thanks{margin:0;font-size:var(--font-size-small);line-height:var(--leading-small);color:var(--soft)}
.mq-thanks .mono{margin-right:6px;color:var(--signal-ink)}

/* ---------- Update toast (mera.js, any page): Body-Small message, Label action ---------- */
.mera_toast{position:fixed;left:50%;bottom:calc(var(--space-4) + env(safe-area-inset-bottom));z-index:80;translate:-50% 0;display:flex;align-items:center;gap:var(--space-3);
  max-width:calc(100vw - 2 * var(--space-4));padding:var(--space-2) var(--space-2) var(--space-2) var(--space-4);border-radius:var(--r-pill);background:var(--bone);color:var(--ink);
  font-size:var(--font-size-small);line-height:var(--leading-small);box-shadow:var(--shadow)}
.mera_toast button{flex:none;min-height:40px;padding:0 var(--space-4);border:0;border-radius:var(--r-pill);background:var(--signal);color:var(--on-signal);font-weight:var(--weight-medium)}
.mera_toast button:hover{background:var(--signal-hi)}
.mera_toast button:focus-visible{outline-color:var(--ink)}

/* ---------- Document pages (privacy, 404, offline): one column of reading text ---------- */
.doc{max-width:calc(var(--measure) + 2 * var(--gutter));margin:0 auto;padding:0 var(--gutter)}
.doc-nav{display:flex;align-items:center;justify-content:space-between;gap:var(--space-4);padding-block:var(--space-5)}
.doc-main{padding-block:var(--space-7) var(--space-9)}
.doc-main h1{margin-bottom:var(--space-4)}
.doc-main h2{margin:var(--space-7) 0 var(--space-3)}
.doc-main p,.doc-main ul{margin:0 0 var(--space-4);color:var(--soft)}
.doc-main ul{padding-left:1.25em;max-inline-size:var(--measure)}
.doc-main li+li{margin-top:var(--space-2)}
.doc-main .t-lead{color:var(--soft)}
.doc-meta{font-size:var(--font-size-small);color:var(--muted)}
.doc-actions{display:flex;flex-wrap:wrap;gap:var(--space-3);margin-top:var(--space-6)}
.doc-foot{border-top:1px solid var(--line);padding-block:var(--space-6);font-size:var(--font-size-small);color:var(--muted)}
