:root {
  --bg: #ffffff;
  --card: #ffffff;
  --surface: #f7f8fa;
  --text: #0c0e13;
  --text-2: #3b3f47;
  --muted: #6b7079;
  --line: #e4e6ea;
  --line-strong: #c9ccd3;
  --accent: #2340d8;
  --accent-2: #1a31b0;
  --accent-text: #ffffff;
  --accent-soft: #eef1fd;
  --warn-bg: #fff6e0;
  --warn-text: #6b4a00;
  --bad: #c0362c;
  --fit: #d98a00;
  --vert: #7a4fd6;
  --strip-bg: #f1f2f5;
  --radius: 4px;
  --gutter: 16px;
  --sans: "Manrope", "Manrope Fallback", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --head: "Geist", "Geist Fallback", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --kana-font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

/* dark palette: follows the OS unless the host sets data-theme="light"; data-theme="dark" forces it */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c0f; --card: #0f1115; --surface: #14161b; --text: #f1f2f4; --text-2: #c6c9cf; --muted: #8c919a;
    --line: #23262d; --line-strong: #353943; --accent: #7088ff; --accent-2: #93a5ff; --accent-text: #0b0c0f;
    --accent-soft: #171d3a; --warn-bg: #3a2d0c; --warn-text: #ffd98a; --bad: #ff8a80; --fit: #ffb340; --vert: #a98bf5;
    --strip-bg: #1a1d23; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0c0f; --card: #0f1115; --surface: #14161b; --text: #f1f2f4; --text-2: #c6c9cf; --muted: #8c919a;
  --line: #23262d; --line-strong: #353943; --accent: #7088ff; --accent-2: #93a5ff; --accent-text: #0b0c0f;
  --accent-soft: #171d3a; --warn-bg: #3a2d0c; --warn-text: #ffd98a; --bad: #ff8a80; --fit: #ffb340; --vert: #a98bf5;
  --strip-bg: #1a1d23; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; } /* also for elements whose class sets a display */

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* site nav (shared with blog/blog.css) */
.site-nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px); -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.nav-inner {
  max-width: 1200px; margin: 0 auto; height: 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 28px; font-family: var(--head);
}
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; letter-spacing: -0.01em; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); position: relative; flex: none; }
.brand .mark::before, .brand .mark::after { content: ""; position: absolute; background: #fff; border-radius: 1px; }
.brand .mark::before { left: 6px; right: 6px; top: 10px; height: 2.4px; }
.brand .mark::after { left: 6px; top: 5px; bottom: 5px; width: 2.4px; box-shadow: 7.6px 0 0 #fff; }
.site-nav nav { display: flex; gap: 22px; }
.site-nav nav a { color: var(--muted); text-decoration: none; font-size: 14.5px; }
.site-nav nav a:hover, .site-nav nav a[aria-current="page"] { color: var(--text); }
.nav-cta {
  margin-left: auto; display: inline-flex; align-items: center; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong); color: var(--text); border-radius: 6px; text-decoration: none; font: 500 14px var(--head);
}
.nav-cta:hover { border-color: var(--text); }
@media (max-width: 560px) { .nav-cta { display: none; } .nav-inner { gap: 16px; } .site-nav nav { gap: 14px; } }

/* ------------------------------------------------------------------ page frame */
.top, .reader, .foot {
  max-width: 1240px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.top { padding-top: 24px; }
h1 { font: 600 1.5rem/1.2 var(--head); margin: 0 0 8px; letter-spacing: -0.02em; text-wrap: balance; }
.lede { margin: 0; color: var(--text-2); font-size: 0.95rem; line-height: 1.6; max-width: 66ch; text-wrap: pretty; }
.lede a { color: var(--accent); }
::selection { background: color-mix(in srgb, var(--accent) 26%, transparent); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--card); color: var(--text);
  font: 500 0.95rem var(--head);
  cursor: pointer; user-select: none; -webkit-user-select: none;
  touch-action: manipulation; transition: border-color 0.15s, background-color 0.15s, color 0.15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .check input:focus-visible, .examples button:focus-visible, .kana .ch:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.block { display: flex; width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: default; transform: none; }
.btn[disabled]:hover { border-color: var(--line-strong); }
.btn.small { min-height: 38px; padding: 0 12px; gap: 6px; font-size: 0.85rem; }
.file { position: relative; }
.file input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
@supports selector(:has(*)) {
  .file:focus-within { outline: none; }
  .file:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
}
/* every other control gets the same keyboard ring */
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.key {
  font: 500 0.72rem/1 var(--mono); padding: 3px 5px; margin-left: 2px;
  border: 1px solid var(--line-strong); border-radius: 4px; color: var(--muted); background: var(--surface);
}
@media (hover: none), (pointer: coarse), (max-width: 480px) { .key { display: none; } }
.check {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 4px;
  font-size: 0.92rem; cursor: pointer; user-select: none; -webkit-user-select: none;
}
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ------------------------------------------------------------------ source bar: the way in */
.source {
  margin-top: 18px; padding: 12px; display: grid; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
}
.source-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; }
.source-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.source-actions .btn, .source-settings .btn, .seg label { white-space: nowrap; }
.source-settings { display: flex; align-items: center; gap: 8px; }
.setting-label { font: 500 0.8rem/1.2 var(--head); color: var(--muted); white-space: nowrap; }
.dragging .source { border-color: var(--accent); }

/* model choice for pictures: Fast | Accurate (radio buttons drawn as one segmented control) */
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; background: var(--card); }
.seg label {
  position: relative; display: inline-flex; align-items: center; min-height: 42px; padding: 0 14px;
  font: 500 0.9rem var(--head); color: var(--text-2);
  cursor: pointer; user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: background-color 0.15s, color 0.15s;
}
.seg label + label { border-left: 1px solid var(--line-strong); }
.seg label:hover { color: var(--text); }
.seg label.on { background: var(--accent-soft); color: var(--accent); }
.seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.seg input:disabled { cursor: default; }
.seg label:has(input:disabled) { opacity: 0.5; cursor: default; }
.seg label:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: -3px; }
.seg input:focus-visible { outline: none; }

/* reading options: a small menu under its button */
.options { position: relative; }
.options > summary { list-style: none; }
.options > summary::-webkit-details-marker { display: none; }
.options[open] > summary { border-color: var(--text); }
.options-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px;
  display: grid; gap: 2px; padding: 8px; background: var(--card);
  border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 12px 28px rgba(12, 14, 19, 0.16);
}
.options-panel .btn { margin-top: 6px; }

/* model loading, in the source bar */
.loading { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; color: var(--text-2); }
.loading .bar { position: relative; flex: 0 0 64px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.loading .bar::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 40%; border-radius: 2px; background: var(--accent);
  animation: hxh-slide 1.1s ease-in-out infinite; will-change: transform;
}
.loading.error { color: var(--bad); font-weight: 600; }
.loading.error .bar { display: none; }
@keyframes hxh-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

/* examples: a strip that scrolls inside the bar, never the page */
.examples-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.examples {
  flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 8px; overflow-x: auto; padding: 2px 2px 4px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.examples button {
  flex: 0 0 auto; scroll-snap-align: start; padding: 3px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--strip-bg); cursor: pointer; touch-action: manipulation;
  transition: border-color 0.15s;
}
.examples button:hover { border-color: var(--muted); }
.examples button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.examples img { display: block; height: 26px; width: auto; border-radius: 4px; }
.examples button.page img { height: 56px; }

/* ------------------------------------------------------------------ empty: before any picture */
.empty {
  margin-top: 16px; min-height: 340px; padding: 32px 20px;
  display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center;
  border: 1.5px dashed var(--line-strong); border-radius: 8px; color: var(--muted); cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.empty:hover, .dragging .empty { border-color: var(--accent); background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.empty svg { width: 40px; height: 40px; color: var(--accent); margin-bottom: 4px; }
.empty-title { font: 600 1.1rem/1.3 var(--head); color: var(--text); }
.empty-text { font-size: 0.9rem; max-width: 42ch; }

/* ------------------------------------------------------------------ workspace: picture | text */
.workspace { margin-top: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
#work, #live { scroll-margin-top: 64px; }
.stage-col { min-width: 0; }
.text-col { min-width: 0; }
@media (min-width: 960px) {
  .workspace { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); gap: 28px; align-items: start; }
  .stage-col { position: sticky; top: calc(56px + env(safe-area-inset-top, 0px) + 16px); }
  .lines > li { scroll-margin-top: 80px; scroll-margin-bottom: 24px; }
}
/* phones and tablets: the picture stays in view at the top while the text scrolls under it */
@media (max-width: 959px) {
  .stage-col {
    position: sticky; top: calc(56px + env(safe-area-inset-top, 0px)); z-index: 6;
    margin: 0 calc(-1 * max(16px, env(safe-area-inset-left, 0px)));
    padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px max(16px, env(safe-area-inset-left, 0px));
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .lines > li { scroll-margin-top: calc(var(--stage-h, 260px) + 80px); }
}

.stage {
  position: relative; display: flex; justify-content: center;
  background: var(--strip-bg); border-radius: 8px; overflow: hidden;
}
#view {
  display: block; max-width: 100%;
  touch-action: pinch-zoom; /* one finger draws the box; two fingers still zoom the page */
  cursor: crosshair;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.stage-btn {
  position: absolute; top: 10px; right: 10px; min-height: 36px; padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: 6px; color: var(--text);
  background: color-mix(in srgb, var(--card) 94%, transparent); font: 500 0.85rem var(--head);
  box-shadow: 0 2px 10px rgba(12, 14, 19, 0.14); cursor: pointer; touch-action: manipulation;
}
.stage-btn:hover { border-color: var(--text); }
.stage-btn:disabled { display: none; }
/* progress over the image: models loading, page being read */
.stage-busy {
  position: absolute; inset: 0; display: grid; place-items: start center; padding: 16px 12px;
  background: color-mix(in srgb, var(--strip-bg) 50%, transparent); pointer-events: none;
}
.busy-pill {
  display: inline-flex; align-items: center; gap: 10px; margin: 0; padding: 8px 14px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--text);
  font: 500 0.9rem/1.3 var(--head); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
}
.spinner {
  flex: none; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--accent) 22%, transparent); border-top-color: var(--accent);
  animation: hxh-spin 0.8s linear infinite; will-change: transform; /* keeps turning while a read blocks the page */
}
@keyframes hxh-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ text column */
.hint { margin: 0 0 14px; font-size: 0.85rem; color: var(--muted); }
.hint.note { color: var(--warn-text); background: var(--warn-bg); border-radius: 6px; padding: 8px 10px; }
.text-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 38px; }
.text-head h2 { margin: 0; font: 600 1.05rem/1.3 var(--head); letter-spacing: -0.01em; }
.summary { margin: 2px 0 12px; font-size: 0.82rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* the whole reading, selectable as text; a click on a line selects it */
.transcript {
  margin: 0 0 20px; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  font-family: var(--kana-font); font-size: 1.15rem; line-height: 1.6; overflow-wrap: anywhere;
}
.transcript .tl { display: block; cursor: pointer; border-radius: 4px; margin: 0 -4px; padding: 0 4px; transition: background-color 0.15s, color 0.15s; }
.transcript .tl:hover, .transcript .tl.hover { background: color-mix(in srgb, var(--accent-soft) 70%, transparent); }
.transcript .tl.on { color: var(--accent); }

.lines-title { margin: 0 0 6px; font: 500 0.8rem/1.3 var(--head); color: var(--muted); }
.lines { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.lines > li { border-bottom: 1px solid var(--line); }
.lines button.line, .lines div.line {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 52px; padding: 8px;
  border: 0; border-radius: 0; background: transparent; color: var(--text);
  font: inherit; text-align: left; transition: background-color 0.15s;
}
.lines button.line { cursor: pointer; touch-action: manipulation; }
.lines button.line:hover, .lines button.line.hover { background: var(--surface); }
.lines button.line:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.lines button.line[aria-pressed="true"] { background: transparent; }
.lines .num {
  flex: 0 0 auto; display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 6px;
  border-radius: 12px; background: var(--accent); color: #fff; font: 700 0.76rem/1 var(--sans);
  font-variant-numeric: tabular-nums;
}
.lines .vertical .num { background: var(--vert); }
.lines .body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.lines .lk { font-family: var(--kana-font); font-size: 1.15rem; line-height: 1.35; overflow-wrap: anywhere; }
.lines .lr { font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.lines .tag {
  flex: 0 0 auto; font-size: 0.72rem; line-height: 1; padding: 4px 7px; border-radius: 999px;
  color: var(--muted); border: 1px solid var(--line); background: var(--card);
}
.lines button.line.low { opacity: 0.62; }
.lines button.line.low .num { background: var(--muted); }
/* the opened line: its badge beside the large reading, which replaces the row's own small text */
.lines > li.open { display: grid; grid-template-columns: 40px minmax(0, 1fr); background: var(--accent-soft); }
.lines > li.open > button.line {
  grid-column: 1; grid-row: 1; align-self: stretch; align-items: flex-start; width: auto; min-height: 0;
  padding: 16px 0 8px 8px; background: transparent;
}
.lines > li.open > button.line .body, .lines > li.open > button.line .tag { display: none; }
.lines > li.open > .result { grid-column: 2; grid-row: 1; }

/* loading placeholders while a page is read */
.lines > li.skeleton { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px; }
.skeleton .sk { display: block; border-radius: 6px; background: var(--line); }
.skeleton .sk-num { width: 24px; height: 24px; border-radius: 12px; flex: none; }
.skeleton .sk-text { height: 14px; flex: 0 1 var(--w, 50%); }
@media (prefers-reduced-motion: no-preference) {
  .skeleton .sk { animation: hxh-pulse 1.2s ease-in-out infinite alternate; }
}
@keyframes hxh-pulse { from { opacity: 1; } to { opacity: 0.45; } }

.low-toggle { min-height: 40px; margin: 8px 0 0; font-size: 0.85rem; color: var(--text-2); }
.low-toggle input { width: 18px; height: 18px; }
.low-toggle .count {
  display: inline-grid; place-items: center; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 0.75rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* copy buttons: the label swaps to "Copied" without changing the button's width */
.btn.copy { display: inline-grid; place-items: center; }
.copy > span { grid-area: 1 / 1; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.copy svg { flex: none; width: 16px; height: 16px; }
.copy:not(.done) .copy-done, .copy.done .copy-idle { visibility: hidden; }
.copy.done, .copy.done:hover { border-color: var(--accent); color: var(--accent); }

/* ------------------------------------------------------------------ the selected line, opened in place */
.result { padding: 8px 10px 16px 4px; }
.result-head { display: flex; align-items: flex-start; gap: 12px; }
.result-text { flex: 1 1 auto; min-width: 0; }
.result-head .copy { flex: none; margin-top: 6px; }
.kana {
  font-family: var(--kana-font);
  font-size: 2.1rem; line-height: 1.25; font-weight: 500;
  white-space: pre-wrap; overflow-wrap: anywhere; min-height: 1.25em;
}
.kana .empty { font-family: var(--sans); font-size: 1rem; color: var(--muted); font-weight: 400; }
.kana .ch.unsure {
  text-decoration: underline dotted var(--fit); text-decoration-thickness: 3px; text-underline-offset: 0.18em;
  cursor: pointer; border-radius: 6px;
}
.kana .ch.unsure.on { background: var(--card); }
.romaji { font-size: 1rem; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; letter-spacing: 0.02em; }
.detail { font-size: 0.88rem; margin-top: 6px; color: var(--text); }
.detail b { font-family: var(--kana-font); font-size: 1.05rem; }
.expected { font-size: 0.88rem; margin-top: 8px; color: var(--muted); }
.expected .kana-inline { font-family: var(--kana-font); color: var(--text); }
.expected .ok { color: var(--accent); font-weight: 600; }
.expected .no { color: var(--bad); font-weight: 600; }

.strip { margin: 12px 0 0; }
.strip-box { position: relative; width: 100%; }
#strip {
  display: block; width: 100%; height: auto; aspect-ratio: 16 / 1; max-width: 100%; /* app.js sets the model's real ratio */
  image-rendering: pixelated; image-rendering: crisp-edges;
  border-radius: 4px; background: var(--strip-bg);
}
.pad-mark {
  position: absolute; top: 0; bottom: 0; right: 0;
  border-left: 2px dashed var(--fit);
  background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(217, 138, 0, 0.18) 6px 9px);
  pointer-events: none;
}
.pad-mark span {
  position: absolute; right: 4px; bottom: 2px; font-size: 0.7rem; font-weight: 600;
  color: #fff; background: rgba(0, 0, 0, 0.55); padding: 0 4px; border-radius: 3px;
}
figcaption { font-size: 0.78rem; color: var(--muted); margin-top: 6px; }
.notices { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 6px; }
.notices li { background: var(--warn-bg); color: var(--warn-text); border-radius: 6px; padding: 8px 10px; font-size: 0.85rem; }
.notices li.info { background: var(--card); color: var(--text); }
.timing { font-size: 0.78rem; color: var(--muted); margin: 10px 0 0; font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------------ live camera */
.live-stage { position: relative; display: flex; justify-content: center; background: #000; border-radius: 8px; overflow: hidden; }
.live-stage video, .live-stage canvas { display: block; }
.live-stage canvas { position: absolute; touch-action: manipulation; cursor: pointer; }
.live-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 16px; }
.live-stats { flex: 1 1 100%; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.live-tools .btn { flex: 1 1 0; }

/* ------------------------------------------------------------------ how it works */
.about { margin: 36px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); }
.about summary { cursor: pointer; font: 600 1rem/1.8 var(--head); min-height: 32px; border-radius: 4px; width: fit-content; }
.about p { font-size: 0.92rem; color: var(--text-2); margin: 10px 0 0; max-width: 72ch; }
.about strong { color: var(--text); }

/* drop an image anywhere: a full-window target */
.drop-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}
.drop-panel {
  pointer-events: none; display: grid; justify-items: center; align-content: center; gap: 14px;
  width: 100%; height: 100%; max-width: 1240px; padding: 24px;
  border: 2px dashed var(--accent); border-radius: 8px; color: var(--accent); text-align: center;
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
}
.drop-panel svg { width: 48px; height: 48px; }
.drop-panel p { margin: 0; font: 600 1.4rem/1.3 var(--head); letter-spacing: -0.01em; color: var(--text); }

/* short messages (paste, drop, copy) */
.toast {
  position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); z-index: 90;
  width: max-content; max-width: min(520px, calc(100vw - 32px)); margin: 0; padding: 10px 14px;
  border-radius: 6px; background: var(--text); color: var(--bg); font-size: 0.9rem; line-height: 1.45;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2); cursor: pointer;
  opacity: 0; transform: translate(-50%, 12px); pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast:empty { visibility: hidden; }

.foot { margin-top: 28px; padding-top: 14px; border-top: 1px solid var(--line); padding-bottom: max(24px, env(safe-area-inset-bottom)); font-size: 0.8rem; }
.foot p { margin: 0 0 4px; }
.muted { color: var(--muted); }
#status.error { color: var(--bad); font-weight: 600; }
#model-info span { display: block; }

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .loading .bar::after { animation-duration: 3s; }
  .toast, .btn, .seg label, .lines button.line, .examples button, .empty, .transcript .tl { transition: none; }
}

/* ------------------------------------------------------------------ sizes */
@media (min-width: 700px) {
  .top { padding-top: 28px; }
  h1 { font-size: 1.75rem; }
}
@media (max-width: 699px) {
  .source-row { align-items: stretch; }
  .source-actions { width: 100%; }
  .source-actions .file { flex: 1 1 100%; }
  .source-actions .btn:not(.file) { flex: 1 1 0; }
  .source-settings { width: 100%; }
  .source-settings .seg { margin-right: auto; }
  .examples-row { align-items: flex-start; flex-direction: column; gap: 6px; }
  .examples { width: 100%; }
  .empty { min-height: 220px; }
  .kana { font-size: 1.8rem; }
}
@media (max-width: 480px) {
  .result-head { flex-direction: column; align-items: flex-start; gap: 8px; } /* the big kana keeps the full width */
  .result-head .copy { margin-top: 0; }
}

/* three nav links must fit a 360 px phone on one line */
.brand, .site-nav nav a { white-space: nowrap; }
@media (max-width: 480px) {
  .nav-inner { gap: 14px; }
  .site-nav nav { gap: 12px; }
  .site-nav nav a { font-size: 13.5px; }
  .brand { font-size: 15px; gap: 7px; }
}

/* theme toggle (web/theme.js) */
.theme-toggle {
  margin-left: auto; width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0;
  border: 1px solid var(--line-strong); border-radius: 6px; background: transparent; color: var(--text); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--text); }
.theme-toggle svg { width: 18px; height: 18px; display: none; }
.theme-toggle[data-mode="auto"] .ic-auto, .theme-toggle[data-mode="light"] .ic-light, .theme-toggle[data-mode="dark"] .ic-dark { display: block; }
.theme-toggle + .nav-cta { margin-left: 0; }

/* author credit under the intro */
.top .byline { margin: 10px 0 0; font-size: 13.5px; color: var(--muted); }
.top .byline a { color: var(--text); font-weight: 600; text-decoration: none; }
.top .byline a:hover { color: var(--accent); }

/* Thai and Japanese reader pages: Latin stays in Geist/Manrope, the script falls back to Noto */
html[lang="th"] {
  --sans: "Manrope", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --head: "Geist", "Noto Sans Thai", "Leelawadee UI", "Thonburi", system-ui, sans-serif;
  --mono: "Geist Mono", "Noto Sans Thai", "Leelawadee UI", "Thonburi", ui-monospace, Menlo, Consolas, monospace;
}
html[lang="ja"] {
  --sans: "Manrope", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --head: "Geist", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, system-ui, sans-serif;
  --mono: "Geist Mono", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", Meiryo, ui-monospace, Menlo, Consolas, monospace;
}
html[lang="th"] .lede, html[lang="th"] .about p { line-height: 1.8; }
html[lang="ja"] .lede, html[lang="ja"] .about p { line-height: 1.85; }
