:root {
  --paper: #f4eddf;
  --paper-deep: #e8ddca;
  --card: rgba(255, 252, 245, .86);
  --ink: #202326;
  --muted: #6f6a60;
  --line: rgba(48, 43, 36, .16);
  --cinnabar: #a83b31;
  --cinnabar-dark: #7e2824;
  --gold: #b28b45;
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --sans: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-synthesis: none;
  line-height: 1.65;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 12% 8%, rgba(178, 139, 69, .08), transparent 24rem),
    linear-gradient(180deg, #f8f2e7 0%, var(--paper) 42%, #efe5d5 100%);
}

button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 3px solid rgba(168, 59, 49, .42);
  outline-offset: 3px;
}

a { color: var(--cinnabar-dark); }

.site-header, main, .site-footer { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 88px;
  border-bottom: 1px solid var(--line);
}

.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-seal {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--cinnabar);
  border-radius: 50%;
  color: var(--cinnabar);
  font-family: var(--serif);
  font-size: 20px;
}
.brand strong { display: block; font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: .12em; }
.brand small { display: block; color: var(--muted); font-size: 11px; letter-spacing: .08em; }
.text-button { min-height: 44px; padding: 8px 2px; border: 0; background: transparent; color: var(--cinnabar-dark); font-size: 13px; }
.text-button:hover { text-decoration: underline; text-underline-offset: 4px; }

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(180px, .9fr);
  align-items: center;
  min-height: 390px;
  gap: 36px;
  padding: 70px 7vw 76px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background-image: linear-gradient(90deg, rgba(244, 237, 223, .98) 0%, rgba(244, 237, 223, .84) 54%, rgba(244, 237, 223, .54) 100%), url('/assets/hero-washi.webp');
  background-size: cover;
  background-position: center;
}
.hero::after { position: absolute; right: 10%; bottom: 26px; width: 120px; height: 1px; background: var(--cinnabar); content: ""; opacity: .65; }
.hero-copy { position: relative; z-index: 1; max-width: 640px; }
.eyebrow { margin: 0 0 12px; color: var(--cinnabar); font-size: 11px; font-weight: 700; letter-spacing: .2em; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.25; }
h1 { margin-bottom: 18px; font-size: clamp(38px, 7vw, 74px); font-weight: 700; letter-spacing: .05em; }
h1 em { color: var(--cinnabar); font-style: normal; }
.title-line { display: block; white-space: nowrap; }
.hero-lede { max-width: 500px; margin-bottom: 28px; color: #4c4a45; font-size: clamp(15px, 2vw, 18px); }
.hero-link { display: inline-flex; align-items: center; gap: 18px; min-height: 44px; color: var(--cinnabar-dark); font-size: 14px; font-weight: 700; text-decoration: none; }
.hero-link span { display: grid; width: 30px; height: 30px; place-items: center; border: 1px solid var(--cinnabar); border-radius: 50%; }
.hero-link:hover span { background: var(--cinnabar); color: #fff; }
.hero-mark { display: grid; grid-template-columns: repeat(3, 1fr); justify-self: end; width: min(300px, 100%); color: rgba(32, 35, 38, .78); font-family: var(--serif); font-size: clamp(60px, 12vw, 140px); line-height: 1; text-align: center; transform: rotate(7deg); }
.hero-mark span:nth-child(2) { color: var(--cinnabar); transform: translateY(38px); }

.workbench { padding: 76px 0 92px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 24px; }
.section-heading h2, .about-strip h2 { margin-bottom: 0; font-size: clamp(27px, 4vw, 42px); }
.section-note { margin: 0 0 4px; color: var(--muted); font-size: 12px; }
.workbench-grid { display: grid; grid-template-columns: minmax(228px, .68fr) minmax(0, 1.55fr); gap: 18px; align-items: start; }
.panel { border: 1px solid var(--line); border-radius: 2px; background: var(--card); box-shadow: 0 18px 45px rgba(78, 60, 31, .06); }
.search-panel { padding: 24px 20px; }
.practice-panel { min-width: 0; padding: clamp(22px, 4vw, 42px); }
.field-label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.search-row { display: flex; align-items: center; gap: 8px; }
input[type="search"] { width: 100%; min-width: 0; min-height: 48px; padding: 9px 12px; border: 1px solid rgba(32, 35, 38, .35); border-radius: 2px; background: #fffdf8; color: var(--ink); font-size: 16px; }
input[type="search"]::placeholder { color: #9b9589; }
.search-count { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
.field-hint { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.status-message { min-height: 1.5em; margin: 8px 0 0; color: var(--cinnabar-dark); font-size: 12px; }
.result-list { display: grid; max-height: 475px; margin: 5px -8px 24px; overflow-y: auto; overscroll-behavior: contain; }
.result-item { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; align-items: center; gap: 7px; width: 100%; min-height: 54px; padding: 7px 8px; border: 0; border-bottom: 1px solid rgba(48, 43, 36, .1); background: transparent; color: var(--ink); text-align: left; }
.result-item:hover, .result-item[aria-current="true"] { background: rgba(168, 59, 49, .08); }
.result-char { font-family: var(--serif); font-size: 24px; }
.result-reading { overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.result-meta { color: var(--muted); font-size: 10px; }
.saved-tools { padding-top: 18px; border-top: 1px solid var(--line); }
.tool-heading { margin-bottom: 8px; font-size: 12px; font-weight: 700; }
.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 8px 14px; border: 1px solid rgba(32, 35, 38, .27); border-radius: 2px; background: rgba(255, 252, 245, .7); color: var(--ink); font-size: 13px; font-weight: 700; line-height: 1.2; }
.button:hover { border-color: var(--cinnabar); color: var(--cinnabar-dark); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button-primary { border-color: var(--cinnabar); background: var(--cinnabar); color: #fff; }
.button-primary:hover { border-color: var(--cinnabar-dark); background: var(--cinnabar-dark); color: #fff; }
.button-quiet { color: var(--muted); }

.selected-header { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 26px; }
.selected-header h2 { display: flex; align-items: baseline; gap: 12px; margin: 0; font-size: clamp(38px, 7vw, 66px); }
.reading { color: var(--muted); font-family: var(--sans); font-size: 13px; font-weight: 400; letter-spacing: .04em; }
.selected-facts { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; max-width: 280px; color: var(--muted); font-size: 11px; text-align: right; }
.selected-facts span { padding: 3px 7px; border-bottom: 1px solid var(--line); }
.selected-facts b { color: var(--ink); font-size: 14px; }
.stage-shell { padding: 14px; border: 1px solid var(--line); background: rgba(255, 253, 248, .76); }
.stage-caption, .progress-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.stage-caption { padding: 0 4px 8px; border-bottom: 1px solid rgba(48, 43, 36, .1); }
.stroke-stage { display: grid; min-height: clamp(240px, 35vw, 400px); place-items: center; padding: 20px; color: var(--ink); }
.stroke-stage svg { width: min(100%, 360px); height: auto; max-height: 360px; overflow: visible; }
.stroke-stage .stroke-shape { fill: none; stroke: currentColor !important; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; transition: opacity .2s ease, stroke-dashoffset .8s ease; }
.stroke-stage .stroke-shape.is-visible { opacity: 1; stroke-dashoffset: 0 !important; }
.stroke-stage .stroke-shape.is-current { opacity: .96; }
.stroke-stage .stroke-shape.is-highlighted { stroke: var(--cinnabar) !important; filter: drop-shadow(0 0 1px rgba(168, 59, 49, .25)); }
.stroke-stage .stroke-shape.is-highlight-helper { opacity: .28; stroke: var(--gold) !important; stroke-dasharray: 3 5 !important; stroke-dashoffset: 0 !important; }
.stage-fallback { max-width: 300px; color: var(--muted); font-size: 13px; text-align: center; }
.progress-line { padding: 10px 4px 0; }
.progress-track { flex: 1; height: 4px; overflow: hidden; background: #ded4c5; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--cinnabar); transition: width .25s ease; }
.controls { display: grid; gap: 10px; padding: 16px 0 20px; border-bottom: 1px solid var(--line); }
.main-controls .button-primary { min-width: 84px; }
.step-controls { justify-content: space-between; }
.speed-control { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
select { min-height: 44px; padding: 6px 28px 6px 9px; border: 1px solid rgba(32, 35, 38, .27); border-radius: 2px; background: #fffdf8; color: var(--ink); font-size: 13px; }
.details-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 22px; padding-top: 22px; }
.detail-block { min-width: 0; }
.detail-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.detail-heading h3 { margin: 0; font-size: 17px; }
.detail-tip { color: var(--muted); font-size: 10px; }
.part-list { display: flex; flex-wrap: wrap; gap: 8px; }
.part-button { min-height: 44px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 2px; background: transparent; color: var(--ink); text-align: left; }
.part-button span { display: block; color: var(--muted); font-size: 10px; }
.part-button[aria-pressed="true"] { border-color: var(--cinnabar); background: rgba(168, 59, 49, .1); color: var(--cinnabar-dark); }
.note-copy { margin: 0; color: #59554e; font-size: 12px; line-height: 1.8; }
.about-strip { display: grid; grid-template-columns: minmax(200px, .8fr) minmax(0, 1.1fr) minmax(180px, .7fr); gap: 32px; align-items: start; padding: 36px 0; border-top: 1px solid var(--line); }
.about-strip h2 { font-size: clamp(24px, 4vw, 34px); }
.about-strip > p { margin: 2px 0 0; color: #58544d; font-size: 14px; }
.about-strip .quiet-note { color: var(--muted); font-size: 11px; }
.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 24px 0 38px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.site-footer p { margin: 0; }
.site-footer a { color: inherit; }
.error-page { display: grid; min-height: 80vh; align-content: center; justify-items: start; width: min(720px, calc(100% - 40px)); margin: auto; }
.error-page h1 { font-size: clamp(34px, 6vw, 58px); }
.error-page p:not(.eyebrow) { color: var(--muted); }
.legal-page { max-width: 860px; padding: 72px 0 96px; }
.legal-page h1 { font-size: clamp(36px, 6vw, 62px); }
.legal-page section { margin-top: 42px; padding-top: 28px; border-top: 1px solid var(--line); }
.legal-page h2 { font-size: clamp(24px, 4vw, 34px); }
.legal-page p, .legal-page dd { color: #504c45; }
.legal-page code { overflow-wrap: anywhere; font-size: .92em; }
.license-list { display: grid; gap: 1px; margin: 24px 0; background: var(--line); }
.license-list div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 18px; padding: 16px; background: rgba(255, 252, 245, .92); }
.license-list dt { font-weight: 700; }
.license-list dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .workbench-grid { grid-template-columns: 1fr; }
  .result-list { max-height: 260px; }
  .about-strip { grid-template-columns: 1fr 1fr; }
  .about-strip .quiet-note { grid-column: 1 / -1; }
}

@media (max-width: 600px) {
  .site-header, main, .site-footer { width: min(100% - 28px, 1240px); }
  .site-header { min-height: 74px; }
  .brand small { display: none; }
  .hero { grid-template-columns: 1fr; min-height: 410px; gap: 16px; padding: 58px 8vw 64px; }
  .hero-mark { position: absolute; right: 6vw; bottom: 20px; width: 180px; font-size: 74px; opacity: .72; }
  .hero-mark span:nth-child(2) { transform: translateY(22px); }
  .section-heading, .selected-header { display: block; }
  .section-note { margin-top: 10px; }
  .selected-facts { justify-content: start; max-width: none; margin-top: 12px; text-align: left; }
  .selected-header h2 { font-size: 48px; }
  .details-grid, .about-strip { grid-template-columns: 1fr; }
  .about-strip .quiet-note { grid-column: auto; }
  .step-controls { align-items: stretch; }
  .step-controls .button { flex: 1 1 0; padding-inline: 8px; }
  .speed-control { width: 100%; justify-content: space-between; }
  .speed-control select { flex: 1; }
  .site-footer { display: block; }
  .site-footer p + p { margin-top: 7px; }
  .legal-page { padding-block: 48px 72px; }
  .license-list div { grid-template-columns: 1fr; gap: 6px; }
}

@media print {
  :root { --paper: #fff; --card: #fff; }
  body { background: #fff; }
  .site-header, .hero, .search-panel, .controls, .about-strip, .site-footer, .details-grid, .stage-caption { display: none !important; }
  main { width: 100%; }
  .workbench { padding: 0; }
  .workbench-grid, .practice-panel { display: block; border: 0; box-shadow: none; }
  .selected-header { margin-bottom: 12px; }
  .stroke-stage { min-height: 0; padding: 0; }
  .stroke-stage svg { width: 300px; }
  .progress-line { border-bottom: 1px solid #333; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
