/* Values from 90_テンプレート/08_デザインテンプレート/00_デザイン知能/02_トークン/tokens.json (profile: app).
   Type 16/20/30/48 (as rem of a 20px root, so the device text size scales it), spacing 4/8/16/24/32/48, radius 8/16/9999, hues navy/amber/vermilion/moss.
   Layout (02_設計/…画面の再設計): the camera frame on top, one answer below it, one button at the
   thumb. No boxes around content; state is shown by words and position, never by flipping the ground. */
:root {
  color-scheme: light dark;
  --surface: #FFFFFF; --raised: #F7F7F6; --sunken: #EFEFEE;
  --ink: #1A1A1A; --ink-strong: #0E0E0E; --muted: #5C5C5C; --on-primary: #FFFFFF;
  --rule: #DCDCDC; --rule-strong: #B4B4B3;
  --primary: #1F3864; --primary-hover: #2B4A7E; --primary-subtle: #E8EDF5;
  --accent: #E39A2E; --accent-subtle: #FBF1DF;
  --danger: #8C3B36; --danger-subtle: #F6EAE9;
  --positive: #2F6B4F; --positive-subtle: #E7F0EB;
  --focus: #E39A2E;
  --frame: #0E0E0E; --on-frame: #EFEFEE;
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px; --s6: 48px;
  --r1: 8px; --r2: 16px; --round: 9999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  font-family: "BIZ UDPGothic", "BIZ UDゴシック", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 125%; line-height: 1.7; -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface: #0E0E0E; --raised: #1A1A1A; --sunken: #2E2E2E;
    --ink: #EFEFEE; --ink-strong: #FFFFFF; --muted: #B4B4B3; --on-primary: #0E0E0E;
    --rule: #2E2E2E; --rule-strong: #5C5C5C;
    --primary: #8FAFD9; --primary-hover: #B3C9E6; --primary-subtle: #14243F;
    --accent: #E9B463; --accent-subtle: #2E2413;
    --danger: #D9847E; --danger-subtle: #2E1817;
    --positive: #7FBB9C; --positive-subtle: #12241B;
    --frame: #1A1A1A;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { word-break: auto-phrase; margin: 0; background: var(--surface); color: var(--ink); min-height: 100dvh; display: flex; flex-direction: column; }
main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 0 var(--s3); }
h2 { font-size: 1.5rem; line-height: 1.4; margin: 0 0 var(--s3); }
h3 { font-size: 1rem; margin: var(--s5) 0 var(--s2); }
p { margin: 0 0 var(--s3); }
a { color: var(--primary); text-underline-offset: 4px; }
strong { font-weight: 700; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 4px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: var(--s3); top: -100px; background: var(--primary); color: var(--on-primary); padding: var(--s2) var(--s3); border-radius: var(--r1); z-index: 10; }
.skip:focus { top: var(--s2); }
.fine { font-size: 0.8rem; color: var(--muted); }
/* A name kept whole on one line when it fits; it still breaks when the text is enlarged beyond the width. */
.nowrap { display: inline-block; max-width: 100%; }
.icon { width: 24px; height: 24px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Header: name and settings, nothing else. */
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); width: 100%; max-width: 560px; margin: 0 auto; padding: var(--s3); }
.brand { display: flex; align-items: center; gap: var(--s2); font-size: 1rem; margin: 0; letter-spacing: 0.04em; }

/* Buttons. Three kinds only: primary (one per screen), sub (filled ground, no border), quiet (header). */
.button { font: inherit; font-size: 1rem; font-weight: 700; min-height: 56px; padding: var(--s2) var(--s4); border-radius: var(--r2); border: 2px solid transparent; background: var(--raised); color: var(--ink); cursor: pointer; display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--s2); min-width: 0; max-width: 100%; overflow-wrap: anywhere; text-align: center; transition: background-color 120ms var(--ease); }
.button:hover:not(:disabled) { background: var(--sunken); }
.button:disabled { color: var(--muted); cursor: not-allowed; }
.button:disabled .icon { opacity: 0.5; }
.button.primary { background: var(--primary); color: var(--on-primary); }
.button.primary:hover:not(:disabled) { background: var(--primary-hover); }
.button.primary:disabled { opacity: 0.45; color: var(--on-primary); }
.button.large { width: 100%; min-height: 72px; }
.button.quiet { min-height: 48px; font-size: 0.8rem; padding: var(--s1) var(--s3); background: transparent; }
.button.quiet:hover:not(:disabled) { background: var(--raised); }
.button[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--accent); }

/* The camera frame: the stage. People with some sight aim with it. */
.viewfinder { position: relative; aspect-ratio: 2 / 1; margin: var(--s2) 0 var(--s3); background: var(--frame); border-radius: var(--r2); overflow: hidden; }
/* contain: the whole picture that is sent, edges included, so aiming matches what is read. */
.viewfinder video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.viewfinder-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--s3); margin: 0; padding: var(--s3); text-align: center; background: var(--primary-subtle); color: var(--primary); font-size: .8rem; }
.camera-rest { width: 80px; height: 64px; max-height: 40%; flex-shrink: 1; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
/* While reading: a steady amber frame and dot. The button label says it in words. */
.viewfinder-live { display: none; position: absolute; inset: 0; border: 4px solid var(--accent); border-radius: var(--r2); pointer-events: none; }
.viewfinder-live::after { content: ""; position: absolute; top: var(--s3); left: var(--s3); width: 16px; height: 16px; border-radius: var(--round); background: var(--accent); }
body[data-phase="scanning"] .viewfinder-live, body[data-phase="starting"] .viewfinder-live, body[data-phase="once"] .viewfinder-live, body[data-phase="voice"] .viewfinder-live { display: block; }

/* What to read: one row, selected marked by weight and a thick bar, not by ground. */
.modes { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); border-bottom: 2px solid var(--rule); }
.mode { position: relative; display: grid; place-items: center; min-height: 56px; cursor: pointer; color: var(--muted); }
.mode input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.mode-name { font-size: 1rem; line-height: 1.4; }
.mode:has(input:checked) { color: var(--ink-strong); font-weight: 700; }
.mode:has(input:checked)::after { content: ""; position: absolute; left: var(--s4); right: var(--s4); bottom: -2px; height: 4px; border-radius: var(--round); background: var(--primary); }
.mode:has(input:focus-visible) { outline: 4px solid var(--focus); outline-offset: -4px; border-radius: var(--r1); }
.mode:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }

/* The answer: no box. Label, the word, the sentence, when. */
.result { padding: var(--s3) 0; min-height: 192px; }
.result-kind { font-size: 0.8rem; font-weight: 700; color: var(--muted); margin-bottom: var(--s1); letter-spacing: 0.06em; }
.result-text { font-size: 1.5rem; line-height: 1.5; font-weight: 700; color: var(--ink-strong); margin: 0; overflow-wrap: anywhere; }
.result-meta { font-size: 0.8rem; color: var(--muted); margin: var(--s2) 0 0; }
.result-meta:empty { display: none; }
.result[data-kind="empty"] .result-text { font-size: 1rem; font-weight: 400; color: var(--muted); }
/* Preserve the reserved space while removing the obsolete instruction from sight and accessibility. */
body[data-phase]:not([data-phase="idle"]) .result[data-kind="empty"] > * { visibility: hidden; }
.result[data-kind="verified"] .result-kind { color: var(--positive); }
.result[data-kind="notice"] .result-kind { color: var(--danger); }
.result[data-kind="conversation"] .result-text { font-weight: 400; }
/* The confirmed kind or name, as large as the page allows: what a low-vision user looks for. */
.result-headline { font-size: 2.4rem; line-height: 1.25; font-weight: 700; color: var(--ink-strong); margin: 0 0 var(--s3); overflow-wrap: anywhere; }
.result:has(.result-headline:not([hidden])) .result-text { font-size: 1rem; font-weight: 400; color: var(--ink); }
.result .details { width: 100%; margin-top: var(--s3); font-size: .8rem; }

.photo-confirm { border-left: 4px solid var(--accent); padding: var(--s2) 0 var(--s2) var(--s3); margin-bottom: var(--s3); }
.photo-confirm p { font-weight: 700; margin-bottom: var(--s2); }
.notice { background: var(--accent-subtle); border-left: 4px solid var(--accent); border-radius: var(--r1); padding: var(--s3); margin-top: var(--s2); font-weight: 700; }

/* Bottom: what is happening, then the one button, then the two helpers. Within thumb reach. */
.actions { position: relative; display: grid; gap: var(--s2); padding: var(--s2) 0 calc(var(--s3) + env(safe-area-inset-bottom)); background: var(--surface); z-index: 2; }
.status { min-height: 3.4em; margin: 0; font-size: 0.8rem; color: var(--muted); display: flex; align-items: end; }
.status.error { color: var(--danger); font-weight: 700; }
.huge { width: 100%; min-height: 96px; font-size: 1.5rem; letter-spacing: 0.06em; gap: var(--s3); }
.stop-mark { display: none; width: 24px; height: 24px; border-radius: var(--r1); background: currentColor; }
.huge.active .stop-mark { display: block; }
.button:active:not(:disabled) { border-color: var(--accent); }
.row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
.row .button { padding: var(--s2); }

/* First visit: a page to read, not a card. */
.intro { padding: var(--s5) 0 var(--s6); }
.lead { font-size: 1rem; font-weight: 700; margin-bottom: var(--s4); }
.promises { margin: 0 0 var(--s5); padding: 0; list-style: none; display: grid; gap: var(--s3); }
.promises li { padding-left: var(--s3); border-left: 4px solid var(--rule); }
.stack { display: grid; gap: var(--s2); margin-bottom: var(--s4); }

/* Settings: a full sheet on phones. */
dialog { border: 0; border-radius: var(--r2); padding: 0; width: min(560px, calc(100vw - 2 * var(--s3))); max-height: calc(100dvh - 2 * var(--s3)); background: var(--surface); color: var(--ink); }
dialog::backdrop { background: rgb(14 14 14 / 0.6); }
.settings { padding: var(--s4); display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
.settings > * { min-width: 0; }
.settings-heading { position: sticky; top: calc(-1 * var(--s4)); z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin: calc(-1 * var(--s4)) calc(-1 * var(--s4)) 0; padding: var(--s3) var(--s4); background: var(--surface); border-bottom: 2px solid var(--rule); }
.settings h2 { margin: 0; }
.settings h3 { margin: var(--s3) 0 0; padding-top: var(--s4); border-top: 2px solid var(--rule); }
.settings fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s2); }
.settings legend { font-weight: 700; margin-bottom: var(--s2); padding: 0; }
.choice { display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; column-gap: var(--s3); min-height: 48px; cursor: pointer; }
.choice .fine { grid-column: 2; }
.choice input { width: 28px; height: 28px; accent-color: var(--primary); flex: none; }
.field { display: grid; gap: var(--s2); font-weight: 700; }
select, input[type="file"] { width: 100%; font: inherit; font-size: 1rem; min-height: 56px; padding: var(--s2) var(--s3); border-radius: var(--r1); border: 2px solid var(--rule-strong); background: var(--surface); color: var(--ink); max-width: 100%; }

.foot { text-align: center; font-size: 0.8rem; color: var(--muted); padding: var(--s3) var(--s3) var(--s5); }
body:has(#app:not([hidden])) .foot { display: none; }

@media (max-width: 480px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; margin: 0; border-radius: 0; }
}
/* Wide screens: the camera on the left, the answer and the controls on the right. */
@media (min-width: 900px) {
  main, .bar { max-width: 1040px; }
  #app:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); column-gap: var(--s6); align-content: start;
    grid-template-areas: "frame result" "modes result" ". confirm" ". actions"; }
  .bar { padding-top: var(--s5); padding-bottom: var(--s5); }
  .viewfinder { grid-area: frame; margin-top: 0; aspect-ratio: 4 / 3; }
  .modes { grid-area: modes; align-self: start; }
  .result { grid-area: result; padding-top: 0; min-height: 0; }
  .photo-confirm { grid-area: confirm; }
  .actions { grid-area: actions; position: static; }
}
@media (max-height: 650px) { .actions { position: static; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .mode:has(input:checked)::after { background: Highlight; }
  .viewfinder-live { border-color: Highlight; }
}
