/* Kigensei shared design layer (17 Nov 2026). Loaded after each page's own <style>, so these rules win.
   Rules: every text colour meets WCAG AA on the surface it sits on; every control is at least 44 x 44 CSS px;
   one visible focus ring; motion is switched off for people who ask for less of it.
   Contrast ratios (checked with axe and by hand): --stone on --warm-white 5.9, on --paper 5.6, on --mist 5.0;
   --gold-ink on --warm-white 6.1, on --paper 5.8; --on-dark on --ink 11+, --on-dark-muted on --ink 7.9. */
:root {
  --stone: #665f53;
  --gold-ink: #745a18;
  --rust: #8b4a3c;
  --on-dark: #e6dfd2;
  --on-dark-muted: #b5ad9e;
  --focus: #1a1814;
  --focus-halo: #e8d5a3;
}
html { -webkit-text-size-adjust: 100%; }
body { font-weight: 400; line-height: 1.6; text-rendering: optimizeLegibility; }
::selection { background: var(--gold-light); color: var(--ink); }

/* Focus: dark ring with a light halo, so it shows on the paper and on the dark panels */
:where(a, button, input, textarea, select, summary, [tabindex]):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 6px var(--focus-halo);
  border-radius: 2px;
}
.dark :where(a, button):focus-visible, .tiles-section :where(a, button):focus-visible, footer :where(a, button):focus-visible, .sidebar :where(a, button):focus-visible {
  outline-color: var(--gold-light);
  box-shadow: 0 0 0 6px rgba(26,24,20,.9);
}

/* Skip link */
.skip-link { position: absolute; left: 12px; top: -64px; z-index: 3000; padding: 12px 18px; background: var(--ink); color: var(--paper); text-decoration: none; font-size: .9rem; }
.skip-link:focus { top: 12px; }

/* Text colours that used to fail contrast */
.section-eyebrow-text, .hero-eyebrow-text, .origin-label, .step-number, .entry-eyebrow, .science-fact-principle, .meta { color: var(--gold-ink); }
.section-eyebrow-line, .hero-eyebrow-line { background: var(--gold-ink); }
.tiles-header .section-eyebrow-text { color: var(--gold-light); }
.tiles-header .section-eyebrow-line { background: var(--gold-light); }
.tiles-header .section-body { color: var(--on-dark); }
.check-in-status.pending { color: var(--gold-ink); border-color: var(--gold-ink); }
.disclaimer-text, .section-body, .science-note, .how-step-body, .modal-science-desc, .evidence-limit, .science-cite, .science-fact-source,
.header-info p, .header-phase, .nav-back, .save-indicator, .inline-disclaimer, .inline-disclaimer a, .formula-subtitle, .recipe-intro, .step-guidance,
.formula-card-name, .check-in-date, .saved-answer-meta, .formula-card-age, .modal-science-cite { color: var(--stone); }
.saved-answer-meta, .formula-card-age, .modal-science-cite { opacity: 1; }
.phase-tab { color: var(--stone); }
.phase-tab:hover, .phase-tab.active { color: var(--ink); }
.evidence-badge { color: var(--gold-ink); border-color: var(--gold-ink); }
.correction-box strong, .modal-correction strong { color: var(--rust); }
.tile-entry { color: var(--gold-light); }
.tile-number { color: var(--gold-light); }
.tile-romaji, .tile-question { color: var(--on-dark); }
.tile-romaji { color: var(--on-dark-muted); }

/* Sidebar (dark) */
.sidebar-sub, .sidebar-label, .sidebar-formula-label, .formula-count, .sidebar-item-q { color: var(--on-dark-muted); }
.sidebar-item-kanji, .sidebar-item-romaji { color: var(--on-dark); }
.sidebar-item .sidebar-item-status { color: var(--on-dark-muted); border-color: rgba(255,255,255,.35); }
.sidebar-item.completed { opacity: 1; }
button.sidebar-item { width: 100%; text-align: left; background: transparent; border: 0; color: inherit; font: inherit; cursor: pointer; min-height: 52px; }

/* Footer (dark) */
footer .footer-tagline, footer .footer-legal, footer .footer-copyright, footer .footer-arch { color: var(--on-dark-muted); }
footer .footer-legal { max-width: 560px; }
footer a { color: var(--on-dark); text-underline-offset: 3px; }
footer a:hover { color: #fff; }
footer .footer-bottom { flex-wrap: wrap; gap: 12px 24px; }
footer .footer-links { display: flex; flex-wrap: wrap; gap: 4px 20px; list-style: none; margin: 18px 0 0; padding: 0; }
footer .footer-links a { display: inline-flex; align-items: center; min-height: 44px; font-size: .85rem; }
footer .operator { font-size: .78rem; line-height: 1.7; color: var(--on-dark-muted); margin-top: 6px; max-width: 560px; }

/* Controls: 44px targets everywhere */
a.btn-primary, a.btn-secondary { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.btn-primary, .btn-secondary, .modal-cta, .hero-cta, .phase-tab, .nav-back, .entry-help, .modal-close, .support-float, .nav-links a {
  min-height: 44px;
}
.btn-secondary { border-color: var(--stone); }
.nav-back { min-width: 44px; padding: 0 12px; }
.modal-close { min-width: 44px; background: none; border: 0; cursor: pointer; font-size: 1.1rem; color: var(--ink); }
.phase-tab { padding: 12px 22px; }
.entry-help { display: inline-flex; align-items: center; padding: 0; }
.step-input { border-color: var(--stone); }
.step-input:focus { border-color: var(--ink); }
.sidebar-item { cursor: pointer; }
.recipe-nav .btn-primary { min-height: 48px; }

/* Landing: nav that stays readable on every section (the old one blended into the page) */
nav.site-nav {
  mix-blend-mode: normal;
  background: rgba(250, 247, 242, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--mist);
  padding: 10px 48px;
}
nav.site-nav .nav-logo { display: inline-flex; align-items: center; min-height: 44px; }
nav.site-nav .nav-links { align-items: center; gap: 8px; }
nav.site-nav .nav-links a { display: inline-flex; align-items: center; padding: 0 12px; color: var(--stone); }
nav.site-nav .nav-links a:hover { color: var(--ink); }
nav.site-nav .nav-links a.nav-begin { background: var(--ink); color: var(--paper); padding: 0 18px; }
nav.site-nav .nav-links a.nav-begin:hover { background: var(--gold-ink); color: #fff; }

/* Landing: hero actions and promise line */
.hero { padding-top: 132px; }
.hero-body { font-weight: 400; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; opacity: 0; animation: fadeUp .8s ease .8s forwards; }
.hero-actions .hero-cta { opacity: 1; animation: none; }
.hero-cta { text-decoration: none; }
.hero-cta.secondary { background: transparent; color: var(--ink); border: 1px solid var(--ink); }
.hero-cta.secondary::before { background: var(--gold-light); }
.hero-link { color: var(--ink); text-underline-offset: 4px; display: inline-flex; align-items: center; min-height: 44px; font-size: .95rem; }
.promise { display: flex; flex-wrap: wrap; gap: 8px 10px; list-style: none; margin: 40px 0 0; padding: 0; opacity: 0; animation: fadeUp .8s ease 1s forwards; }
.promise li { font-size: .82rem; color: var(--ink); background: rgba(255,255,255,.7); border: 1px solid var(--mist); padding: 8px 14px; }
.promise li::before { content: "✓"; color: var(--moss); margin-right: 8px; font-weight: 700; }
.hero-scroll { display: none; }

/* Landing: audience chooser */
.modes { background: var(--paper); padding: 96px 48px; }
.modes-inner { max-width: 1100px; margin: 0 auto; }
.mode-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 48px; }
.mode { display: flex; flex-direction: column; background: var(--warm-white); border: 1px solid var(--mist); padding: 32px 28px; text-decoration: none; color: var(--ink); transition: border-color .25s, transform .25s; }
.mode:hover { border-color: var(--ink); transform: translateY(-2px); }
.mode h3 { font-family: "Iowan Old Style", "Palatino Linotype", "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif; font-size: 1.35rem; font-weight: 600; margin-bottom: 8px; }
.mode p { color: var(--stone); font-size: .95rem; line-height: 1.7; flex: 1; }
.mode .go { margin-top: 20px; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); display: inline-flex; align-items: center; min-height: 44px; }
.mode .tag { font-size: .7rem; letter-spacing: .18em; text-transform: uppercase; color: var(--gold-ink); margin-bottom: 14px; }
.modes-note { margin-top: 28px; font-size: .88rem; color: var(--stone); max-width: 720px; line-height: 1.7; }
.modes-note a { color: var(--ink); text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 44px; }

/* Landing: myth check and the share loop */
.myths { padding: 120px 48px 40px; max-width: 1100px; margin: 0 auto; }
.myth-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 56px; }
.myth { border: 1px solid var(--mist); background: #fff; padding: 28px; display: flex; flex-direction: column; }
.myth .said { font-size: .72rem; letter-spacing: .16em; text-transform: uppercase; color: var(--stone); margin-bottom: 10px; }
.myth blockquote { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.15rem; line-height: 1.45; color: var(--ink); margin-bottom: 18px; }
.myth .found { font-size: .94rem; line-height: 1.7; color: var(--ink); border-top: 1px solid var(--mist); padding-top: 16px; flex: 1; }
.myth .found strong { color: var(--rust); font-weight: 600; }
.myth .src { font-size: .78rem; color: var(--stone); margin-top: 12px; }
.myth .src a { color: var(--stone); text-underline-offset: 3px; display: inline-flex; align-items: center; min-height: 44px; }
.share-btn { align-self: flex-start; margin-top: 10px; min-height: 44px; padding: 0 16px; background: transparent; border: 1px solid var(--stone); color: var(--ink); font: inherit; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.share-btn:hover { border-color: var(--ink); background: var(--paper); }
.share-status { font-size: .8rem; color: var(--moss); min-height: 1.4em; margin-top: 8px; }
.myths-foot { margin-top: 28px; font-size: .88rem; color: var(--stone); max-width: 720px; line-height: 1.7; }

/* Tiles are real buttons now */
button.tile { font: inherit; text-align: left; color: inherit; border: 1px solid rgba(255,255,255,.14); width: 100%; }
.tile-arrow { opacity: .8; }
.hero-kanji, .hero-title { font-weight: 400; }
.hero-title { color: var(--stone); }
.how-step-num { color: rgba(116,90,24,.35); }
.disclaimer-icon { opacity: .7; }
.disclaimer-text a { color: var(--ink); min-height: 24px; }
.support-float { min-height: 44px; font-size: .8rem; }
.reveal { transition: opacity .6s ease, transform .6s ease; }

/* Recipe: mobile principle stepper (the sidebar is hidden under 900px, so this replaces it) */
.stepper { display: none; }
.stepper ol { list-style: none; display: flex; gap: 6px; margin: 0; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; background: var(--ink); }
.stepper li { flex: 1 0 auto; }
.stepper button { min-width: 48px; min-height: 48px; width: 100%; padding: 0 10px; background: transparent; color: var(--on-dark); border: 1px solid rgba(255,255,255,.35); font: inherit; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.1rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.stepper button .num { font-family: Inter, ui-sans-serif, sans-serif; font-size: .72rem; opacity: .85; }
.stepper button[aria-current="step"] { background: var(--gold-light); border-color: var(--gold-light); color: var(--ink); }
.stepper button.done::after { content: "✓"; font-size: .8rem; color: #9fd0a8; }
.stepper button[aria-current="step"].done::after { color: var(--moss); }

/* Recipe: support link, entry gate */
.support-bar { display: none; }
.entry-modes { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 14px; font-size: .84rem; color: var(--stone); }
.entry-modes a { color: var(--ink); display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border: 1px solid var(--mist); text-decoration: none; }
.entry-modes a[aria-current="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.entry-card .entry-help { color: var(--ink); }

/* Recipe: share block in the formula view (shares the site link only, never answers) */
.share-card { margin-top: 32px; padding: 24px; border: 1px solid var(--mist); background: var(--paper); }
.share-card h3 { font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.1rem; margin-bottom: 8px; }
.share-card p { font-size: .9rem; line-height: 1.7; color: var(--stone); margin-bottom: 4px; }

@media (max-width: 900px) {
  nav.site-nav { padding: 6px 16px; }
  .modes, .myths { padding-left: 24px; padding-right: 24px; }
  .mode-grid, .myth-grid { grid-template-columns: 1fr; }
  .hero { padding-top: 108px; }
  .stepper { display: block; position: sticky; top: 0; z-index: 400; }
  .support-bar { display: flex; justify-content: center; background: var(--paper); border-bottom: 1px solid var(--mist); }
  .support-bar a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; color: var(--ink); font-size: .84rem; }
  .support-float { display: none; }
  .main { padding-bottom: 0; }
  .recipe-nav { position: sticky; bottom: 0; z-index: 300; }
}
@media (max-width: 600px) {
  nav.site-nav .nav-links { display: flex; }
  nav.site-nav .nav-links li:not(:last-child) { display: none; }
  .recipe-nav { flex-wrap: wrap; gap: 8px; }
  .nav-save { width: 100%; justify-content: space-between; }
  .save-indicator { max-width: 50%; }
  .phase-tab { padding: 12px 10px; font-size: .72rem; letter-spacing: .06em; }
  .phase-tabs { margin-left: -4px; }
  .header-info h1 { font-size: 1.1rem; }
  .header-kanji { font-size: 2rem; }
  .main-header { align-items: flex-start; gap: 8px; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .reveal { opacity: 1; transform: none; }
  .hero-eyebrow, .hero-kanji, .hero-title, .hero-body, .hero-actions, .promise, .support-float { opacity: 1; }
}
/* No script: show everything */
.no-js .reveal, noscript + * .reveal { opacity: 1; transform: none; }

@media print {
  .skip-link, .stepper, .support-bar, .share-card, nav.site-nav { display: none !important; }
}

/* Landing modal: hidden from keyboard and screen readers while closed */
.modal-overlay { visibility: hidden; transition: opacity .4s, visibility 0s linear .4s; }
.modal-overlay.active { visibility: visible; transition-delay: 0s; }
.modal-title { font-family: "Iowan Old Style", "Palatino Linotype", "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif; font-size: 1.5rem; font-weight: 600; color: var(--ink); line-height: 1.3; padding-right: 48px; }

/* Recipe: small print that used to sit at ~3:1 */
.step-hint, .step-timestamp { color: var(--stone); }
.step-input::placeholder { color: #6f685b; opacity: 1; }
.formula-card-qa + .formula-card-qa { margin-top: 14px; }
.formula-card-q { font-size: .72rem; letter-spacing: .06em; color: var(--stone); margin-bottom: 4px; }
.formula-card-content.empty { color: var(--stone); }
#mainContent:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.confirm-box { margin-top: 16px; padding: 18px 20px; border: 1px solid var(--rust); background: #fbf1ee; }
.confirm-box p { font-size: .92rem; color: var(--ink); line-height: 1.6; margin-bottom: 12px; }
.confirm-box .btn-primary { margin-right: 10px; }
@media print { .confirm-box { display: none !important; } }
.formula-card .formula-card-name { font-size: .78rem; font-weight: 400; margin-bottom: 14px; }
.share-btn { align-self: flex-start; margin-top: 10px; min-height: 44px; padding: 0 16px; background: transparent; border: 1px solid var(--stone); color: var(--ink); font: inherit; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; cursor: pointer; }
.disclaimer-links { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 6px; }
.disclaimer-links a { display: inline-flex; align-items: center; min-height: 44px; }
/* gold is a decoration colour; as text on a light surface it uses the darker ink version */
.modal-section-label, .origin-label, .entry-eyebrow, .step-number, .check-in-status.pending { color: var(--gold-ink); }
.source-link { display: inline-flex; align-items: center; min-height: 44px; }
.science-cite a { display: inline-flex; align-items: center; min-height: 44px; }
.formula-title { margin-top: 0; }
.formula-intersection-label { color: var(--on-dark-muted); }
.crisis-links { display: flex; flex-wrap: wrap; gap: 0 20px; margin-top: 4px; } .crisis-links a { display: inline-flex; align-items: center; min-height: 44px; }
.stepper { min-width: 0; width: 100%; max-width: 100vw; } .stepper ol { max-width: 100%; box-sizing: border-box; }
/* four-character names (生き甲斐, ポカヨケ, 侘び寂び, 一期一会) stay on one line in the sidebar */
.sidebar-item-kanji { white-space: nowrap; font-size: .95rem; flex: 0 0 auto; }
.sidebar-item > span:last-child, .sidebar-item-text { min-width: 0; }
/* the wordmark's second word is text, so it uses the AA-safe gold; the support link is there from the first paint */
nav.site-nav .nav-logo span, .footer-brand span { color: var(--gold-ink); }
footer .footer-brand span { color: var(--gold-light); }
.support-float { opacity: 1; animation: none; }

.legal-draft{margin:1rem 0 1.25rem;padding:.85rem 1rem;border:1px solid var(--line, #c8c4b8);background:var(--bg-sunk, #f4f1ea);border-radius:8px;max-width:40rem}
.legal-draft strong{font-weight:650}
