/* こえスタジオ
   デザインの方針: 収録スタジオの操作卓のように落ち着いた道具の画面。冷たい中間色のグレーに、差し色は朱色の1色だけ（オンエアの赤ランプから）。
   角丸は 8px で統一。書体は OS の日本語ゴシック、数字とコードは等幅。動きは押したときの手ごたえと状態の切り替えだけ。 */

:root {
  --bg: #f4f4f2;
  --surface: #fcfcfb;
  --surface-2: #ebebe8;
  --line: #d6d6d2;
  --text: #1c1d20;
  --text-2: #4f5156;
  --text-3: #66686d;
  --accent: #c8431e;
  --accent-text: #a8340f;
  --accent-soft: #fbe9e3;
  --on-accent: #ffffff;
  --danger: #b42318;
  --ok: #2f6f4a;
  --shadow: 0 1px 2px rgb(28 29 32 / 0.06), 0 8px 24px rgb(28 29 32 / 0.08);
  --radius: 8px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "BIZ UDGothic", monospace;
  --topbar: 56px;
  --tabbar: 0px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a;
    --surface: #1d1f23;
    --surface-2: #272a2f;
    --line: #363940;
    --text: #ececea;
    --text-2: #b9bbc0;
    --text-3: #9d9fa5;
    --accent: #f0714a;
    --accent-text: #f58a68;
    --accent-soft: #3b231b;
    --on-accent: #16171a;
    --danger: #ff8a7a;
    --ok: #7fcf9f;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16171a;
  --surface: #1d1f23;
  --surface-2: #272a2f;
  --line: #363940;
  --text: #ececea;
  --text-2: #b9bbc0;
  --text-3: #9d9fa5;
  --accent: #f0714a;
  --accent-text: #f58a68;
  --accent-soft: #3b231b;
  --on-accent: #16171a;
  --danger: #ff8a7a;
  --ok: #7fcf9f;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 12px 32px rgb(0 0 0 / 0.35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.35; font-weight: 700; }
h1 { font-size: 1.35rem; letter-spacing: 0.01em; }
h2 { font-size: 1rem; }
p { margin: 0; }
code { font-family: var(--mono); font-size: 0.88em; background: var(--surface-2); padding: 0.05em 0.35em; border-radius: 4px; }
a { color: var(--accent-text); text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: var(--radius); z-index: 30; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- 上の帯 ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-name { font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.brand-sub { color: var(--text-3); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-tag { display: none; color: var(--text-3); font-size: 0.72rem; border: 1px solid var(--line); border-radius: var(--radius); padding: 0 6px; white-space: nowrap; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.key-chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius);
  padding: 4px 10px; font-size: 0.82rem; cursor: pointer; white-space: nowrap;
}
.key-chip.warn { border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft); }
.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid transparent; background: transparent; border-radius: var(--radius); cursor: pointer; font-size: 1.05rem;
}
.icon-btn:hover { background: var(--surface-2); }

.demo-banner {
  padding: 8px 16px; background: var(--accent-soft); color: var(--text); font-size: 0.88rem;
  border-bottom: 1px solid var(--line);
}
.link-btn { border: 0; background: none; color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0 4px; }

/* ---- 骨組み ---- */
.shell { display: grid; grid-template-columns: 184px minmax(0, 1fr); min-height: calc(100dvh - var(--topbar)); }
.sidenav {
  position: sticky; top: var(--topbar); align-self: start;
  display: flex; flex-direction: column; gap: 2px; padding: 16px 10px;
  height: calc(100dvh - var(--topbar));
  border-right: 1px solid var(--line);
}
.nav-item {
  text-align: left; border: 0; background: transparent; padding: 9px 12px; border-radius: var(--radius);
  cursor: pointer; color: var(--text-2); font-weight: 500;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: inset 3px 0 0 var(--accent), var(--shadow); }
.tabbar { display: none; }
main { min-width: 0; outline: none; }
.view { padding: 24px 28px 40px; max-width: 1280px; }
.lead { color: var(--text-2); margin: 6px 0 20px; max-width: 70ch; }
.hint { color: var(--text-3); font-size: 0.85rem; margin: 4px 0 14px; }
.help { color: var(--text-3); font-size: 0.83rem; margin-top: 6px; }
.help-block { margin: -6px 0 16px; }
.note { color: var(--text-3); font-size: 0.83rem; margin-top: 24px; max-width: 70ch; }

/* ---- 入力 ---- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; border: 0; padding: 0; min-width: 0; }
.field-narrow { max-width: 220px; }
.field > .btn-ghost, .field > .btn-primary { align-self: flex-start; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field > label, .label, legend.label { font-size: 0.85rem; font-weight: 600; color: var(--text-2); padding: 0; }
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 8px 10px; line-height: 1.6;
}
textarea { resize: vertical; min-height: 4.5em; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.select-sm { width: auto; padding: 5px 8px; font-size: 0.85rem; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 0.9rem; cursor: pointer; padding: 3px 0; }
.check input { margin-top: 0.35em; accent-color: var(--accent); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; }

/* ---- ボタン ---- */
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: var(--radius); padding: 9px 18px; cursor: pointer; font-weight: 600; white-space: nowrap;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--accent); color: var(--on-accent); border: 1px solid var(--accent); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--text)); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { border-color: var(--text-3); }
.btn-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost:disabled:hover { border-color: var(--line); }
.btn-sm { padding: 5px 11px; font-size: 0.85rem; font-weight: 500; }
.btn-primary:active:not(:disabled), .btn-ghost:active { transform: translateY(1px) scale(0.985); }
.danger { color: var(--danger); }
.danger-fill { background: var(--danger); border-color: var(--danger); color: var(--on-accent); }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: var(--radius); padding: 3px; gap: 3px; }
.segmented button { border: 0; background: transparent; border-radius: 6px; padding: 7px 8px; cursor: pointer; color: var(--text-2); font-weight: 500; }
.segmented button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---- 生成: 台本 ---- */
.gen-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 28px; align-items: start; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.editor-tools { display: flex; gap: 8px; align-items: center; min-width: 0; }
#sampleSelect { min-width: 0; max-width: 260px; }
.parts { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.part { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 10px; }
.part-head { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.part-num { font-family: var(--mono); font-size: 0.8rem; color: var(--text-3); min-width: 1.6em; }
.part-speaker { width: auto; padding: 4px 8px; font-size: 0.85rem; }
.part-style { flex: 1; min-width: 180px; display: flex; gap: 6px; align-items: center; }
.part-style input { padding: 5px 9px; font-size: 0.88rem; }
.part-text { min-height: 5.5em; font-size: 1rem; }
.part-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.part-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.part-len { font-family: var(--mono); font-size: 0.78rem; color: var(--text-3); }
.mini { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 2px 9px; font-size: 0.8rem; cursor: pointer; color: var(--text-2); }
.mini:hover { color: var(--text); border-color: var(--text-3); }
.mini[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.palette { margin-top: 8px; padding: 10px; background: var(--surface-2); border-radius: var(--radius); display: grid; gap: 8px; }
.palette-group { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.palette-group > span { font-size: 0.78rem; color: var(--text-3); width: 4.5em; flex: none; }
.tag-btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 2px 8px; font-size: 0.82rem; cursor: pointer; }
.tag-btn:hover { border-color: var(--accent); }
.tag-btn small { color: var(--text-3); font-family: var(--mono); margin-left: 4px; font-size: 0.72rem; }
.add-part { margin-top: 12px; width: 100%; border-style: dashed; color: var(--text-2); }

/* ---- 読みのチェック ---- */
.yomi { margin-top: 24px; }
.yomi-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.yomi-count { font-size: 0.83rem; color: var(--text-3); }
.yomi-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.yomi-item { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; font-size: 0.86rem; }
.yomi-item .orig { font-family: var(--mono); font-weight: 600; background: var(--accent-soft); padding: 0 4px; border-radius: 4px; }
.yomi-item .msg { color: var(--text-3); font-size: 0.78rem; margin-top: 2px; }
.yomi-item .sugg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.yomi-ok { color: var(--text-3); font-size: 0.86rem; padding: 4px 0; }

/* ---- 生成: 右の設定 ---- */
.runpanel {
  position: sticky; top: calc(var(--topbar) + 16px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: calc(100dvh - var(--topbar) - 32px);
}
.run-scroll { padding: 16px 16px 4px; overflow: auto; }
.run-foot { padding: 12px 16px 14px; border-top: 1px solid var(--line); }
.run-actions { display: flex; gap: 8px; }
.run-actions .btn-primary { flex: 1; }
.estimate { font-size: 0.83rem; color: var(--text-3); margin-bottom: 8px; font-family: var(--mono); }
.estimate.error { color: var(--danger); }
.run-status { font-size: 0.85rem; color: var(--text-2); margin-top: 8px; min-height: 1.4em; }
.run-status.error { color: var(--danger); }
.run-status:empty { min-height: 0; margin: 0; }
.run-sheet-toggle { display: none; }
.voice-btn {
  width: 100%; text-align: left; display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 10px; cursor: pointer;
}
.voice-btn:hover { border-color: var(--text-3); }
.voice-btn .vname { font-weight: 600; }
.voice-btn .vsub { color: var(--text-3); font-size: 0.8rem; display: block; line-height: 1.4; }
.voice-btn .vmeta { flex: 1; min-width: 0; }
.voice-btn .chev { color: var(--text-3); }
.speaker-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; align-items: center; }
.speaker-row input { padding: 7px 8px; }

/* ---- 結果 ---- */
.result {
  position: sticky; bottom: 0; z-index: 5;
  margin-top: 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between;
}
.result-main { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 100%; }
.wave { flex: 1; min-width: 0; height: 56px; cursor: pointer; display: block; }
.time { font-family: var(--mono); font-size: 0.82rem; color: var(--text-3); white-space: nowrap; }
.result-meta { font-size: 0.82rem; color: var(--text-3); }
.result-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.play-btn {
  width: 44px; height: 44px; flex: none; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--on-accent); display: grid; place-items: center; font-size: 0.95rem;
}
.play-btn.small { width: 34px; height: 34px; font-size: 0.78rem; background: var(--surface-2); color: var(--text); }
.play-btn.small.playing, .play-btn.playing { background: var(--accent); color: var(--on-accent); }
.play-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---- 声を選ぶ（ダイアログ） ---- */
dialog.sheet {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 0; width: min(680px, calc(100vw - 32px)); max-height: min(82dvh, 760px); box-shadow: var(--shadow);
}
dialog.sheet[open] { display: flex; flex-direction: column; }
dialog.sheet::backdrop { background: rgb(10 10 12 / 0.45); }
.sheet-wide { width: min(860px, calc(100vw - 32px)); }
.sheet-small { width: min(420px, calc(100vw - 32px)); padding: 20px !important; gap: 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 8px; }
.sheet-foot { padding: 8px 16px 14px; margin: 0; }
.sheet-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 14px; }
.sheet-small .sheet-actions { padding: 0; justify-content: flex-end; }
.tabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 8px 10px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 500; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tabs button:disabled { opacity: 0.45; cursor: not-allowed; }
.filters { display: flex; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.filters select, .filters input { width: auto; padding: 5px 8px; font-size: 0.85rem; }
.filters input { flex: 1; min-width: 140px; }
.voice-list { list-style: none; margin: 0; padding: 4px 8px 8px; overflow: auto; flex: 1; min-height: 120px; }
.voice-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px; border-radius: var(--radius); }
.voice-row:hover { background: var(--surface-2); }
.voice-row.selected { background: var(--accent-soft); }
.voice-row .vtitle { font-weight: 600; }
.voice-row .vtitle small { font-weight: 400; color: var(--text-3); margin-left: 6px; font-family: var(--mono); font-size: 0.75rem; }
.voice-row .vdesc { color: var(--text-2); font-size: 0.83rem; line-height: 1.5; }
.voice-row .vtags { color: var(--text-3); font-size: 0.78rem; }
.empty { color: var(--text-3); padding: 24px 12px; text-align: center; font-size: 0.9rem; }
.code { margin: 0; padding: 14px 16px; overflow: auto; flex: 1; font-family: var(--mono); font-size: 0.8rem; line-height: 1.55; background: var(--surface-2); white-space: pre; }

/* ---- 聞き比べ ---- */
.compare-form { max-width: 760px; }
.compare-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 3px 4px 3px 10px; font-size: 0.85rem; }
.chip button { border: 0; background: transparent; cursor: pointer; color: var(--text-3); width: 22px; height: 22px; border-radius: 6px; }
.chip button:hover { background: var(--surface-2); color: var(--text); }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 3px 10px; font-size: 0.82rem; cursor: pointer; color: var(--text-2); }
.chip-btn:hover { border-color: var(--accent); color: var(--text); }
.cmp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; margin-top: 20px; }
.cmp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.cmp-card .cmp-top { display: flex; gap: 10px; align-items: center; }
.cmp-card .cmp-name { font-weight: 600; }
.cmp-card .cmp-sub { color: var(--text-3); font-size: 0.8rem; }
.cmp-card canvas { width: 100%; height: 36px; display: block; }
.cmp-card .cmp-stats { font-family: var(--mono); font-size: 0.78rem; color: var(--text-3); }
.cmp-card .cmp-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cmp-card.loading { color: var(--text-3); }
.skeleton { height: 36px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2)); background-size: 200% 100%; }
@media (prefers-reduced-motion: no-preference) {
  .skeleton { animation: shimmer 1.4s linear infinite; }
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---- 声をつくる ---- */
.design-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 28px; align-items: start; }
.design-form { max-width: 560px; }
.design-result { margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: grid; gap: 8px; }
.myvoice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.myvoice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.myvoice .mv-name { font-weight: 600; }
.myvoice .mv-desc { color: var(--text-2); font-size: 0.84rem; grid-column: 2; line-height: 1.5; }
.myvoice .mv-meta { color: var(--text-3); font-size: 0.78rem; grid-column: 2; }
.myvoice .mv-actions { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---- 履歴 ---- */
.hist-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-width: 980px; }
.hist { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; }
.hist .h-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist .h-meta { color: var(--text-3); font-size: 0.8rem; grid-column: 2; }
.hist .h-actions { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

/* ---- 設定 ---- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; margin-top: 16px; max-width: 760px; }
.panel h2 { margin-bottom: 4px; }
.panel form, .panel .field { margin-top: 12px; }
.dict-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.dict-form .field { margin: 0; }
.dict-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; gap: 6px; flex-wrap: wrap; }

/* ---- 知らせ ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--tabbar)); transform: translateX(-50%); z-index: 40;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: var(--radius); font-size: 0.9rem; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}

/* ---- スマホ ---- */
@media (max-width: 1100px) {
  .gen-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; }
  .design-layout { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  :root { --tabbar: 60px; }
  body { font-size: 15px; }
  .brand-sub { display: none; }
  .brand-tag { display: inline-block; }
  .topbar { padding: 0 12px; gap: 8px; }
  .brand { gap: 6px; }
  .brand img { width: 24px; height: 24px; }
  .brand-name { font-size: 0.98rem; }
  .topbar-right { gap: 4px; }
  .key-chip { padding: 3px 8px; font-size: 0.78rem; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidenav { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar .nav-item { text-align: center; border-radius: 0; font-size: 0.8rem; padding: 6px 2px; }
  .tabbar .nav-item[aria-current="page"] { box-shadow: inset 0 3px 0 var(--accent); background: transparent; color: var(--text); }
  .view { padding: 16px 16px calc(var(--tabbar) + 32px); }
  #view-generate { padding-bottom: calc(var(--tabbar) + 150px); }
  .gen-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-tools { width: 100%; }
  #sampleSelect { flex: 1; max-width: none; }
  .part-style { flex-basis: 100%; order: 3; }
  /* 生成の設定は下から引き出すシートにする。閉じているときは見積もりと生成ボタンだけ見える */
  .runpanel {
    position: fixed; left: 0; right: 0; bottom: var(--tabbar); top: auto; z-index: 15;
    border-radius: var(--radius) var(--radius) 0 0; border-bottom: 0; max-height: 78dvh;
  }
  .runpanel .run-scroll { display: none; }
  .runpanel.open .run-scroll { display: block; }
  .run-sheet-toggle { display: inline-flex; }
  .result { position: static; }
  .result-actions { justify-content: flex-start; }
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .dict-form { grid-template-columns: minmax(0, 1fr); }
  .yomi-list { grid-template-columns: minmax(0, 1fr); }
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 88dvh; margin: auto 0 0; border-radius: var(--radius) var(--radius) 0 0; }
  .toast { bottom: calc(var(--tabbar) + 96px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
