/* ==========================================================================
   Machi 在留資格ガイド — shared stylesheet
   machicity.com/visa
   --------------------------------------------------------------------------
   Design: 公文書 × modern editorial.  Warm paper, ink type, Machi teal as the
   primary accent (mirrors --kx-accent in the main site / iOS AccentColor),
   vermilion reserved for warnings + the 済 stamp.

   NO webfonts: the site is served under a CSP with `font-src 'self' data:`,
   and it is loaded inside the iOS app's WKWebView where a font round-trip is
   a visible blank-text flash.  System JP/CN faces only.
   ========================================================================== */

:root {
  --paper:        #F8F7F4;
  --paper-2:      #F2F1EC;
  --card:         #FFFFFF;
  --ink:          #14171C;
  --ink-2:        #454D57;
  --ink-3:        #6B7280;
  --rule:         #DDDCD5;
  --rule-2:       #C7C6BE;
  --accent:       #136359;
  --accent-ink:   #0E4A43;
  --accent-wash:  #E5F2ED;
  --accent-line:  #9FC7BF;
  --seal:         #B3462F;
  --seal-wash:    #FBEDE9;
  --warn:         #A76A15;
  --warn-wash:    #FBF2E2;
  --ok:           #246B45;
  --ok-wash:      #E6F1EA;
  --shadow:       0 1px 2px rgba(20, 23, 28, .04), 0 8px 24px -12px rgba(20, 23, 28, .12);
  --shadow-lg:    0 2px 6px rgba(20, 23, 28, .05), 0 24px 48px -20px rgba(20, 23, 28, .22);

  --mincho: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Songti SC", "SimSun", serif;
  --gothic: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP",
            "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono:   ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --maxw: 1180px;
  --rad: 10px;
  --rad-sm: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:       #101216;
    --paper-2:     #16191F;
    --card:        #1A1D24;
    --ink:         #F0F2F6;
    --ink-2:       #B6BDC8;
    --ink-3:       #8A919D;
    --rule:        #2B2F38;
    --rule-2:      #3B414C;
    --accent:      #5CBEB2;
    --accent-ink:  #8AD6CC;
    --accent-wash: #16302C;
    --accent-line: #2F5C55;
    --seal:        #E88A72;
    --seal-wash:   #3A231D;
    --warn:        #E3B466;
    --warn-wash:   #322A18;
    --ok:          #6FC496;
    --ok-wash:     #17301F;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px -12px rgba(0,0,0,.6);
    --shadow-lg:   0 2px 6px rgba(0,0,0,.45), 0 24px 48px -20px rgba(0,0,0,.7);
  }
}
/* explicit override wins in both directions (app can force a theme) */
:root[data-theme="light"] {
  --paper:#F8F7F4; --paper-2:#F2F1EC; --card:#fff; --ink:#14171C; --ink-2:#454D57; --ink-3:#6B7280;
  --rule:#DDDCD5; --rule-2:#C7C6BE; --accent:#136359; --accent-ink:#0E4A43; --accent-wash:#E5F2ED;
  --accent-line:#9FC7BF; --seal:#B3462F; --seal-wash:#FBEDE9; --warn:#A76A15; --warn-wash:#FBF2E2;
  --ok:#246B45; --ok-wash:#E6F1EA;
}
:root[data-theme="dark"] {
  --paper:#101216; --paper-2:#16191F; --card:#1A1D24; --ink:#F0F2F6; --ink-2:#B6BDC8; --ink-3:#8A919D;
  --rule:#2B2F38; --rule-2:#3B414C; --accent:#5CBEB2; --accent-ink:#8AD6CC; --accent-wash:#16302C;
  --accent-line:#2F5C55; --seal:#E88A72; --seal-wash:#3A231D; --warn:#E3B466; --warn-wash:#322A18;
  --ok:#6FC496; --ok-wash:#17301F;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  scroll-padding-top: 5.5rem;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--gothic);
  font-size: 15.5px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
::selection { background: var(--accent-wash); color: var(--ink); }
hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

/* bilingual switch — one DOM, two languages */
body[data-lang="zh"] .ja { display: none !important; }
body[data-lang="ja"] .zh { display: none !important; }
/* inline variants keep flow inside a sentence */
.zh, .ja { }

/* ---------- app-embed mode (?embed=1 from the Machi iOS WebView) ---------- */
body[data-embed="1"] .site-return,
body[data-embed="1"] .foot-appcta { display: none !important; }
body[data-embed="1"] .topbar { padding-top: max(.5rem, env(safe-area-inset-top)); }
body[data-embed="1"] .sitefoot { padding-bottom: max(2rem, calc(env(safe-area-inset-bottom) + 1.5rem)); }

/* ==========================================================================
   Top bar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--rule);
}
@supports not (backdrop-filter: blur(4px)) { .topbar { background: var(--paper); } }
.topbar-in {
  max-width: var(--maxw); margin: 0 auto;
  display: flex; align-items: center; gap: .85rem;
  padding: .6rem 1.15rem;
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--ink); flex: none; }
.brand-mark {
  width: 27px; height: 27px; border-radius: 7px; flex: none;
  background: var(--accent); color: var(--card);
  display: grid; place-items: center;
  font-family: var(--mincho); font-weight: 700; font-size: .95rem; line-height: 1;
  letter-spacing: 0;
}
:root[data-theme="dark"] .brand-mark, .brand-mark { color: #fff; }
@media (prefers-color-scheme: dark) { .brand-mark { color: #101216; } }
:root[data-theme="light"] .brand-mark { color: #fff; }
:root[data-theme="dark"] .brand-mark { color: #101216; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: .86rem; font-weight: 700; letter-spacing: .01em; }
.brand-txt span { font-family: var(--mono); font-size: .58rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); }
.topbar-sp { flex: 1; }
.topbar-tools { display: flex; align-items: center; gap: .5rem; flex: none; }

.langsw { display: flex; border: 1px solid var(--rule-2); border-radius: 999px; overflow: hidden; background: var(--card); }
.langsw button {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-family: var(--mono); font-size: .64rem; letter-spacing: .1em;
  padding: .3rem .58rem; color: var(--ink-3); line-height: 1.6;
}
.langsw button[aria-pressed="true"] { background: var(--accent); color: #fff; }
:root[data-theme="dark"] .langsw button[aria-pressed="true"] { color: #101216; }
@media (prefers-color-scheme: dark) { .langsw button[aria-pressed="true"] { color: #101216; } }
:root[data-theme="light"] .langsw button[aria-pressed="true"] { color: #fff; }

.icon-btn {
  appearance: none; cursor: pointer; background: var(--card);
  border: 1px solid var(--rule-2); border-radius: 999px;
  width: 30px; height: 30px; display: grid; place-items: center;
  color: var(--ink-2); padding: 0; font-size: .8rem; line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

.site-return {
  font-family: var(--mono); font-size: .62rem; letter-spacing: .1em; text-transform: uppercase;
  text-decoration: none; color: var(--ink-3); border: 1px solid var(--rule-2);
  border-radius: 999px; padding: .3rem .62rem; white-space: nowrap;
}
.site-return:hover { border-color: var(--accent); color: var(--accent); }

/* The top bar has to survive a 320px viewport (and the iOS WebView at its
   narrowest). Shed the optional chrome before anything can overflow. */
@media (max-width: 520px) {
  .topbar-in { padding: .5rem .8rem; gap: .5rem; }
  .site-return { display: none; }
  .brand-txt span { display: none; }
  .brand-txt b { font-size: .82rem; }
}
@media (max-width: 380px) {
  .langsw button { padding: .3rem .42rem; font-size: .6rem; }
  .brand-txt { display: none; }
}

/* reading progress */
.progressbar { height: 2px; background: transparent; }
.progressbar > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .12s linear; }

/* ==========================================================================
   Page shell
   ========================================================================== */
.shell { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: 232px minmax(0, 1fr); gap: 0; }
.shell.narrow { grid-template-columns: minmax(0, 1fr); max-width: 900px; }

.toc {
  position: sticky; top: 3.4rem; align-self: start;
  max-height: calc(100vh - 3.6rem); overflow-y: auto;
  padding: 1.9rem 1rem 3rem 1.15rem;
  border-right: 1px solid var(--rule);
  font-size: .8rem;
}
.toc-label {
  font-family: var(--mono); font-size: .58rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-3); padding-left: .7rem; margin: 0 0 .55rem;
}
.toc a {
  display: block; padding: .34rem 0 .34rem .7rem; text-decoration: none;
  color: var(--ink-2); border-left: 2px solid var(--rule); line-height: 1.45;
}
.toc a:hover { border-left-color: var(--accent-line); color: var(--ink); background: var(--accent-wash); }
.toc a[aria-current="true"] { border-left-color: var(--accent); color: var(--accent-ink); font-weight: 700; background: var(--accent-wash); }
.toc .n { font-family: var(--mono); font-size: .62rem; opacity: .6; margin-right: .4rem; }
.toc-sep { border: 0; border-top: 1px solid var(--rule); margin: .9rem 0 .7rem; }

main.page { padding: 2.1rem 1.9rem 5rem; min-width: 0; }
.shell.narrow main.page { padding-left: 1.15rem; padding-right: 1.15rem; }

/* mobile section jumper */
.mobjump { display: none; }
@media (max-width: 900px) {
  .shell, .shell.narrow { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
  main.page { padding: 1.4rem 1.05rem 4.5rem; }
  html { scroll-padding-top: 7.5rem; }
  .mobjump {
    display: block; position: sticky; top: 3.35rem; z-index: 55;
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--rule); padding: .45rem 1.05rem;
  }
  .mobjump select {
    width: 100%; appearance: none; font-family: var(--gothic); font-size: .82rem;
    padding: .5rem 2rem .5rem .7rem; color: var(--ink);
    background: var(--card) no-repeat right .7rem center;
    background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
    background-size: 5px 5px, 5px 5px; background-position: right 1rem center, right .75rem center;
    border: 1px solid var(--rule-2); border-radius: var(--rad-sm);
  }
}

/* ==========================================================================
   Hero + headings
   ========================================================================== */
.hero { padding-bottom: 1.5rem; border-bottom: 3px double var(--rule-2); margin-bottom: 2.2rem; }
.eyebrow {
  font-family: var(--mono); font-size: .63rem; letter-spacing: .2em; text-transform: uppercase;
  color: var(--accent); font-weight: 500;
}
.hero h1 {
  font-family: var(--mincho); font-weight: 700; letter-spacing: .005em;
  font-size: clamp(1.65rem, 4.6vw, 2.5rem); line-height: 1.28; margin: .55rem 0 .6rem;
}
.hero .lede { font-size: .96rem; color: var(--ink-2); max-width: 62ch; margin: 0; }
.hero .metaline {
  font-family: var(--mono); font-size: .66rem; color: var(--ink-3);
  margin-top: 1.1rem; display: flex; flex-wrap: wrap; gap: .35rem 1.1rem;
}

section.sec { margin: 3rem 0; scroll-margin-top: 5rem; }
section.sec:first-of-type { margin-top: 2rem; }
h2 {
  font-family: var(--mincho); font-size: clamp(1.18rem, 2.6vw, 1.42rem); font-weight: 700;
  margin: 0 0 .9rem; padding-bottom: .5rem; border-bottom: 1px solid var(--ink);
  display: flex; align-items: baseline; gap: .7rem; line-height: 1.4;
}
h2 .n { font-family: var(--mono); font-size: .7rem; color: var(--accent); letter-spacing: .1em; flex: none; }
h3 { font-size: 1rem; font-weight: 700; margin: 2rem 0 .6rem; line-height: 1.55; display: flex; gap: .4rem; align-items: baseline; }
h3::before { content: "▍"; color: var(--accent); flex: none; }
h4 { font-size: .92rem; font-weight: 700; margin: 1.4rem 0 .45rem; }
p { margin: .75rem 0; }
.sub { color: var(--ink-2); font-size: .88rem; }
.tiny { font-size: .78rem; color: var(--ink-3); }
.mono { font-family: var(--mono); }
strong, b { font-weight: 700; }
mark { background: var(--accent-wash); color: var(--ink); padding: 0 .18em; border-radius: 2px; }

ul, ol { padding-left: 1.25rem; margin: .7rem 0; }
li { margin: .3rem 0; }
li::marker { color: var(--accent); }

/* ==========================================================================
   Callouts
   ========================================================================== */
.callout {
  border: 1px solid var(--rule-2); border-left-width: 4px; border-radius: var(--rad-sm);
  padding: .95rem 1.15rem; margin: 1.3rem 0; background: var(--card);
}
.callout .tag {
  font-family: var(--mono); font-size: .6rem; letter-spacing: .15em; text-transform: uppercase; font-weight: 500;
}
.callout h4 { margin: .3rem 0 .35rem; font-family: var(--mincho); font-size: 1rem; }
.callout p { margin: .4rem 0; font-size: .88rem; }
.callout p:last-child { margin-bottom: 0; }
.callout > :last-child { margin-bottom: 0; }
.c-warn { border-color: var(--seal); background: var(--seal-wash); }
.c-warn .tag { color: var(--seal); }
.c-note { border-color: var(--accent-line); background: var(--accent-wash); }
.c-note .tag { color: var(--accent-ink); }
.c-tip  { border-color: var(--warn); background: var(--warn-wash); }
.c-tip .tag { color: var(--warn); }
.c-ok   { border-color: var(--ok); background: var(--ok-wash); }
.c-ok .tag { color: var(--ok); }

.quote { border-left: 3px solid var(--rule-2); padding: .1rem 0 .1rem 1rem; margin: 1.1rem 0; color: var(--ink-2); font-size: .87rem; }

/* ==========================================================================
   Cards / grids
   ========================================================================== */
.grid { display: grid; gap: .9rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(215px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.card {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad);
  padding: 1.05rem 1.15rem; box-shadow: var(--shadow);
}
.card h3, .card h4 { margin-top: 0; }
.card.pad0 { padding: 0; overflow: hidden; }

a.card { text-decoration: none; color: inherit; display: block; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--accent-line); color: inherit; }

.navcard { display: flex; flex-direction: column; gap: .35rem; min-height: 100%; }
.navcard .k { font-family: var(--mono); font-size: .62rem; letter-spacing: .13em; color: var(--accent); text-transform: uppercase; }
.navcard .t { font-family: var(--mincho); font-weight: 700; font-size: 1.02rem; line-height: 1.4; }
.navcard .d { font-size: .82rem; color: var(--ink-2); line-height: 1.65; }
.navcard .go { margin-top: auto; padding-top: .5rem; font-family: var(--mono); font-size: .64rem; letter-spacing: .1em; color: var(--accent); }

/* stat tiles */
.stats { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); margin: 1.1rem 0; }
.stat { background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad-sm); padding: .8rem .9rem; }
.stat .v { font-family: var(--mono); font-size: 1.32rem; font-weight: 700; color: var(--accent-ink); line-height: 1.2; }
.stat .l { font-size: .74rem; color: var(--ink-3); margin-top: .2rem; line-height: 1.5; }

/* ==========================================================================
   Pills / badges
   ========================================================================== */
.pill {
  display: inline-block; font-family: var(--mono); font-size: .58rem; letter-spacing: .1em;
  padding: .12rem .42rem; border: 1px solid currentColor; border-radius: 3px;
  vertical-align: middle; white-space: nowrap; line-height: 1.7;
}
.p-must { color: var(--seal); }
.p-cond { color: var(--warn); border-style: dashed; }
.p-opt  { color: var(--ink-3); }
.p-ok   { color: var(--ok); }
.p-acc  { color: var(--accent); }
.badge {
  display: inline-block; padding: .18rem .5rem; border-radius: 999px; font-size: .68rem;
  font-weight: 700; background: var(--accent-wash); color: var(--accent-ink); line-height: 1.6;
}
.badge.warn { background: var(--seal-wash); color: var(--seal); }
.badge.neutral { background: var(--paper-2); color: var(--ink-2); }

/* ==========================================================================
   Checklists (localStorage-backed)
   ========================================================================== */
.block { background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad); margin: 1rem 0; overflow: hidden; }
.block-hd {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: .62rem 1rem; border-bottom: 1px solid var(--rule); background: var(--paper-2);
}
.block-hd .t { font-weight: 700; font-size: .87rem; line-height: 1.5; }
.block-hd .c { font-family: var(--mono); font-size: .63rem; color: var(--ink-3); flex: none; letter-spacing: .06em; }

.row { display: flex; gap: .85rem; padding: .8rem 1rem; border-bottom: 1px dotted var(--rule-2); }
.row:last-child { border-bottom: 0; }
.row:hover { background: color-mix(in srgb, var(--accent-wash) 45%, transparent); }
.box {
  flex: none; width: 22px; height: 22px; margin-top: 3px; padding: 0;
  border: 1.5px solid var(--ink-2); background: transparent; cursor: pointer;
  border-radius: 3px; position: relative; display: grid; place-items: center;
}
.box::after {
  content: "済"; position: absolute; inset: -7px; display: grid; place-items: center;
  font-family: var(--mincho); font-size: .74rem; font-weight: 700; color: var(--seal);
  border: 2px solid var(--seal); border-radius: 50%;
  background: color-mix(in srgb, var(--card) 60%, transparent);
  opacity: 0; transform: rotate(-16deg) scale(.5);
  transition: opacity .2s, transform .22s cubic-bezier(.34,1.56,.64,1);
}
.box[aria-checked="true"]::after { opacity: .95; transform: rotate(-9deg) scale(1); }
.box[aria-checked="true"] { border-color: var(--rule); }
.row.done .rt { opacity: .48; }
.row.done .rt .jp { text-decoration: line-through; text-decoration-color: var(--rule-2); }
.rt { flex: 1; min-width: 0; }
.rt .jp { display: block; font-weight: 700; font-size: .88rem; line-height: 1.55; }
.rt .cn { display: block; font-size: .83rem; color: var(--ink-2); margin-top: .1rem; line-height: 1.6; }
.rt .facts { display: block; font-family: var(--mono); font-size: .66rem; color: var(--ink-3); margin-top: .38rem; }
.rt .facts .f { display: inline-block; margin-right: .9rem; white-space: nowrap; }
.rt .facts b { color: var(--ink-2); font-weight: 700; }

/* Spans used as block rows inside inline-ish containers */
.flow-step .b .t, .flow-step .b .d,
.pager a .d, .pager a .t,
.foot-appcta .txt b, .foot-appcta .txt span { display: block; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ==========================================================================
   Tables
   ========================================================================== */
.tw { overflow-x: auto; margin: 1.1rem 0; border: 1px solid var(--rule); border-radius: var(--rad-sm); background: var(--card); -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .83rem; min-width: 520px; }
th {
  text-align: left; font-family: var(--mono); font-size: .62rem; letter-spacing: .09em;
  text-transform: uppercase; color: var(--ink-3); font-weight: 500;
  padding: .62rem .85rem; border-bottom: 1.5px solid var(--ink-2); white-space: nowrap;
  background: var(--paper-2); position: sticky; top: 0;
}
td { padding: .62rem .85rem; border-bottom: 1px dotted var(--rule-2); vertical-align: top; line-height: 1.65; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--accent-wash) 40%, transparent); }
td.k { font-weight: 700; white-space: nowrap; }
td.num { font-family: var(--mono); white-space: nowrap; }
.tw.compact table { min-width: 380px; }

/* ==========================================================================
   Tabs (Cat.1–4 selector etc.)
   ========================================================================== */
.tabs { display: flex; gap: .35rem; flex-wrap: wrap; margin: 1rem 0 .2rem; }
.tabs button {
  appearance: none; cursor: pointer; font-family: var(--gothic); font-size: .8rem; font-weight: 700;
  padding: .45rem .85rem; border: 1px solid var(--rule-2); border-radius: 999px;
  background: var(--card); color: var(--ink-2); line-height: 1.5;
}
.tabs button:hover { border-color: var(--accent-line); color: var(--accent-ink); }
.tabs button[aria-selected="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .tabs button[aria-selected="true"] { color: #101216; }
@media (prefers-color-scheme: dark) { .tabs button[aria-selected="true"] { color: #101216; } }
:root[data-theme="light"] .tabs button[aria-selected="true"] { color: #fff; }
[role="tabpanel"][hidden] { display: none; }

/* ==========================================================================
   Accordion (FAQ)
   ========================================================================== */
details.acc {
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad-sm);
  margin: .55rem 0; overflow: hidden;
}
details.acc > summary {
  cursor: pointer; list-style: none; padding: .8rem 2.4rem .8rem 1rem; position: relative;
  font-weight: 700; font-size: .89rem; line-height: 1.6;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after {
  content: "＋"; position: absolute; right: 1rem; top: .78rem; color: var(--accent);
  font-family: var(--mono); font-size: .95rem; transition: transform .18s ease;
}
details.acc[open] > summary::after { content: "−"; }
details.acc[open] > summary { border-bottom: 1px dotted var(--rule-2); }
details.acc .accbody { padding: .85rem 1rem 1rem; font-size: .87rem; color: var(--ink-2); }
details.acc .accbody > :first-child { margin-top: 0; }
details.acc .accbody > :last-child { margin-bottom: 0; }
details.acc summary:hover { background: var(--paper-2); }

/* ==========================================================================
   Timeline
   ========================================================================== */
.tl { position: relative; margin: 1.4rem 0 1.4rem .3rem; padding-left: 1.55rem; }
.tl::before { content: ""; position: absolute; left: 5px; top: .5rem; bottom: .5rem; width: 1px; background: var(--rule-2); }
.tl-item { position: relative; margin: 0 0 1.5rem; }
.tl-item::before {
  content: ""; position: absolute; left: -1.55rem; top: .45rem; width: 11px; height: 11px;
  border-radius: 50%; background: var(--paper); border: 2px solid var(--accent);
}
.tl-item.hot::before { background: var(--seal); border-color: var(--seal); }
.tl-when { font-family: var(--mono); font-size: .68rem; letter-spacing: .08em; color: var(--accent); font-weight: 500; }
.tl-what { font-weight: 700; font-size: .92rem; margin: .1rem 0 .2rem; line-height: 1.55; }
.tl-desc { font-size: .84rem; color: var(--ink-2); }

/* ==========================================================================
   Route / flow diagram
   ========================================================================== */
.flow { display: grid; gap: .6rem; margin: 1.2rem 0; }
.flow-step {
  display: grid; grid-template-columns: 2rem minmax(0,1fr); gap: .85rem; align-items: start;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad-sm); padding: .85rem 1rem;
}
.flow-step .i {
  width: 2rem; height: 2rem; border-radius: 50%; background: var(--accent-wash); color: var(--accent-ink);
  display: grid; place-items: center; font-family: var(--mono); font-weight: 700; font-size: .82rem;
}
.flow-step .b .t { font-weight: 700; font-size: .9rem; line-height: 1.55; }
.flow-step .b .d { font-size: .83rem; color: var(--ink-2); margin-top: .18rem; }

/* ==========================================================================
   Wizard (diagnose.html)
   ========================================================================== */
.wiz { max-width: 780px; margin: 0 auto; }
.wiz-steps { display: flex; gap: .3rem; margin: 0 0 1.4rem; }
.wiz-steps i { flex: 1; height: 3px; border-radius: 2px; background: var(--rule); transition: background .2s; }
.wiz-steps i.on { background: var(--accent); }
.wiz-steps i.cur { background: var(--accent); box-shadow: 0 0 0 2px var(--accent-wash); }

.q-num { font-family: var(--mono); font-size: .64rem; letter-spacing: .16em; color: var(--accent); text-transform: uppercase; }
.q-title { font-family: var(--mincho); font-size: clamp(1.15rem, 3.4vw, 1.5rem); font-weight: 700; margin: .4rem 0 .3rem; line-height: 1.42; }
.q-help { font-size: .85rem; color: var(--ink-2); margin: 0 0 1.15rem; }

.opts { display: grid; gap: .6rem; }
.opt {
  display: grid; grid-template-columns: 22px minmax(0,1fr); gap: .8rem; align-items: start;
  text-align: left; width: 100%; cursor: pointer;
  background: var(--card); border: 1.5px solid var(--rule); border-radius: var(--rad);
  padding: .85rem 1rem; font-family: var(--gothic); color: var(--ink);
  transition: border-color .14s ease, background .14s ease, transform .1s ease;
}
.opt:hover { border-color: var(--accent-line); background: var(--accent-wash); }
.opt:active { transform: scale(.995); }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-wash); }
.opt .mk {
  width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--rule-2);
  display: grid; place-items: center; margin-top: 2px; flex: none;
  font-size: .7rem; color: transparent; background: var(--card);
}
.opt[aria-pressed="true"] .mk { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] .opt[aria-pressed="true"] .mk { color: #101216; }
@media (prefers-color-scheme: dark) { .opt[aria-pressed="true"] .mk { color: #101216; } }
:root[data-theme="light"] .opt[aria-pressed="true"] .mk { color: #fff; }
.opt .ot { display: block; font-weight: 700; font-size: .92rem; line-height: 1.55; }
.opt .od { display: block; font-size: .81rem; color: var(--ink-2); margin-top: .18rem; line-height: 1.65; }
/* the label wrapper must be a block so .ot / .od stack inside the grid cell */
.opt > span:last-child { display: block; min-width: 0; }

.wiz-nav { display: flex; gap: .6rem; margin-top: 1.5rem; align-items: center; }
.wiz-nav .sp { flex: 1; }

.btn {
  appearance: none; cursor: pointer; font-family: var(--gothic); font-weight: 700; font-size: .85rem;
  padding: .6rem 1.15rem; border-radius: 999px; border: 1px solid var(--accent);
  background: var(--accent); color: #fff; line-height: 1.6; text-decoration: none; display: inline-block;
  transition: filter .14s ease, transform .1s ease;
}
:root[data-theme="dark"] .btn { color: #101216; }
@media (prefers-color-scheme: dark) { .btn { color: #101216; } }
:root[data-theme="light"] .btn { color: #fff; }
.btn:hover { filter: brightness(1.08); color: inherit; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: var(--rule-2); }
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; }
.btn.sm { font-size: .76rem; padding: .38rem .8rem; }

/* result */
.res-head {
  background: var(--accent-wash); border: 1px solid var(--accent-line); border-radius: var(--rad);
  padding: 1.2rem 1.3rem; margin-bottom: 1.4rem;
}
.res-head .k { font-family: var(--mono); font-size: .62rem; letter-spacing: .16em; text-transform: uppercase; color: var(--accent-ink); }
.res-head h2 { border: 0; padding: 0; margin: .35rem 0 .4rem; font-size: 1.35rem; }
.res-head p { margin: 0; font-size: .88rem; color: var(--ink-2); }
.chipline { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .8rem; }
.chip {
  font-family: var(--mono); font-size: .64rem; letter-spacing: .04em; padding: .22rem .55rem;
  border-radius: 999px; background: var(--card); border: 1px solid var(--rule-2); color: var(--ink-2);
}

.verdict { border-radius: var(--rad); border: 1px solid var(--rule); background: var(--card); padding: 1rem 1.15rem; margin: .8rem 0; }
.verdict.good { border-left: 4px solid var(--ok); }
.verdict.maybe { border-left: 4px solid var(--warn); }
.verdict.bad { border-left: 4px solid var(--seal); }
.verdict .vh { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; }
.verdict .vh .nm { font-family: var(--mincho); font-weight: 700; font-size: 1.05rem; }
.verdict .vb { font-size: .86rem; color: var(--ink-2); margin-top: .4rem; }

/* ==========================================================================
   Code / templates
   ========================================================================== */
.tmpl { background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad); margin: 1rem 0; overflow: hidden; }
.tmpl-hd { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .55rem .9rem; border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.tmpl-hd .t { font-weight: 700; font-size: .84rem; }
pre.doc {
  margin: 0; padding: 1rem 1.1rem; overflow-x: auto; font-family: var(--mono);
  font-size: .765rem; line-height: 1.95; white-space: pre-wrap; word-break: break-word;
  color: var(--ink); -webkit-overflow-scrolling: touch;
}
pre.doc .fill { background: var(--warn-wash); color: var(--warn); border-radius: 2px; padding: 0 .15em; }

/* ==========================================================================
   Footer
   ========================================================================== */
.sitefoot {
  border-top: 1px solid var(--rule); margin-top: 4rem; padding: 2.2rem 1.15rem 3rem;
  background: var(--paper-2);
}
.sitefoot-in { max-width: var(--maxw); margin: 0 auto; }
.footgrid { display: grid; gap: 1.4rem; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.footgrid h5 { font-family: var(--mono); font-size: .6rem; letter-spacing: .16em; text-transform: uppercase; color: var(--ink-3); margin: 0 0 .5rem; font-weight: 500; }
.footgrid a { display: block; font-size: .82rem; padding: .16rem 0; text-decoration: none; color: var(--ink-2); }
.footgrid a:hover { color: var(--accent); }
.footnote { margin-top: 2rem; padding-top: 1.2rem; border-top: 1px solid var(--rule); font-size: .76rem; color: var(--ink-3); line-height: 1.75; }
.foot-appcta {
  display: flex; flex-wrap: wrap; gap: .6rem; align-items: center;
  background: var(--card); border: 1px solid var(--rule); border-radius: var(--rad);
  padding: 1rem 1.15rem; margin-bottom: 1.6rem;
}
.foot-appcta .txt { flex: 1; min-width: 200px; }
.foot-appcta .txt b { display: block; font-size: .9rem; }
.foot-appcta .txt span { font-size: .8rem; color: var(--ink-2); }

/* prev / next */
.pager { display: flex; gap: .8rem; flex-wrap: wrap; margin-top: 3rem; padding-top: 1.4rem; border-top: 1px solid var(--rule); }
.pager a {
  flex: 1; min-width: 200px; text-decoration: none; color: inherit;
  border: 1px solid var(--rule); border-radius: var(--rad); padding: .8rem 1rem; background: var(--card);
}
.pager a:hover { border-color: var(--accent-line); }
.pager .d { font-family: var(--mono); font-size: .6rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.pager .t { font-weight: 700; font-size: .89rem; margin-top: .18rem; }
.pager a.next { text-align: right; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 1.6rem; transform: translate(-50%, 1.5rem);
  background: var(--ink); color: var(--paper); padding: .55rem 1.1rem; border-radius: 999px;
  font-size: .8rem; z-index: 200; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  box-shadow: var(--shadow-lg);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ==========================================================================
   Print
   ========================================================================== */
@media print {
  .topbar, .toc, .mobjump, .sitefoot, .pager, .wiz-nav, .langsw, .icon-btn, .site-return { display: none !important; }
  .shell { display: block; max-width: none; }
  main.page { padding: 0; }
  body { background: #fff; color: #000; font-size: 10.5pt; }
  .card, .block, .callout, .tw { break-inside: avoid; box-shadow: none; }
  section.sec { break-inside: auto; }
  a { color: #000; text-decoration: none; }
  details.acc { border: 1px solid #999; }
  details.acc > summary::after { display: none; }
  details.acc .accbody { display: block !important; }
}
