/* MIRAI Voice — 同時通訳ブースの2チャンネル卓をモチーフに。
   日本語チャンネル＝藍、英語チャンネル＝銅。左が日本語、右が英語。 */
:root {
  --bg: #f1f2f4;
  --surface: #ffffff;
  --surface-2: #e7e9ee;
  --line: #d5d9e0;
  --fg: #14171c;
  --fg-2: #4a5260;
  --fg-3: #7b8494;
  --ja: #2b44a0;
  --ja-soft: #e5e9f7;
  --ja-ink: #1d307c;
  --en: #a6520c;
  --en-soft: #f6e9d9;
  --en-ink: #723805;
  --on-ch: #ffffff;
  --ok: #1d7849;
  --warn: #946000;
  --err: #b42318;
  --focus: #2f6fed;
  --shadow: 0 18px 50px rgba(20, 24, 33, .18);
  --scale: 1;
  --font-ui: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Segoe UI", sans-serif;
  --font-num: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1115; --surface: #161a20; --surface-2: #1f242c; --line: #2b323c;
    --fg: #edf0f4; --fg-2: #b3bbc7; --fg-3: #808a99;
    --ja: #93a7ff; --ja-soft: #1a2240; --ja-ink: #c8d2ff;
    --en: #f0a35b; --en-soft: #32230f; --en-ink: #ffd4aa;
    --on-ch: #0e1115; --ok: #4cc98a; --warn: #e8b04a; --err: #ff7b72; --focus: #7aa2ff;
    --shadow: 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e1115; --surface: #161a20; --surface-2: #1f242c; --line: #2b323c;
  --fg: #edf0f4; --fg-2: #b3bbc7; --fg-3: #808a99;
  --ja: #93a7ff; --ja-soft: #1a2240; --ja-ink: #c8d2ff;
  --en: #f0a35b; --en-soft: #32230f; --en-ink: #ffd4aa;
  --on-ch: #0e1115; --ok: #4cc98a; --warn: #e8b04a; --err: #ff7b72; --focus: #7aa2ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
kbd {
  display: inline-block; min-width: 1.6em; padding: 0 .4em; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 5px; background: var(--surface); font: 12px/1.6 var(--font-num); text-align: center; color: var(--fg-2);
}
code { font: 13px var(--font-num); background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- 全体レイアウト ---------- */
.app { display: grid; grid-template-rows: auto 1fr auto; height: 100%; min-height: 0; }

.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { position: relative; width: 26px; height: 22px; flex: none; }
.brand-mark i { position: absolute; top: 0; width: 17px; height: 17px; border-radius: 6px 6px 6px 2px; }
.brand-mark .bm-ja { left: 0; background: var(--ja); }
.brand-mark .bm-en { right: 0; top: 5px; background: var(--en); border-radius: 6px 6px 2px 6px; mix-blend-mode: multiply; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand-mark .bm-en { mix-blend-mode: screen; } }
:root[data-theme="dark"] .brand-mark .bm-en { mix-blend-mode: screen; }
.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .02em; }
.brand-pair { font-size: 12px; color: var(--fg-3); letter-spacing: .04em; white-space: nowrap; }
.brand-pair .sep { margin: 0 .35em; }
.brand-pair select {
  height: 26px; padding: 0 6px; border-radius: 7px; font-size: 12px; font-weight: 600; color: var(--fg-2);
  background: var(--surface-2); border-color: transparent; cursor: pointer; max-width: 11.5em;
}
.brand-pair select:hover { color: var(--fg); }

.mode-switch {
  display: inline-flex; padding: 3px; gap: 2px; border-radius: 11px; background: var(--surface-2); margin: 0 auto;
}
.mode-switch button {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 8px; cursor: pointer; color: var(--fg-2); font-weight: 600; font-size: 14px;
}
.mode-switch button[aria-selected="true"] { background: var(--surface); color: var(--fg); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.top-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.chip-btn { border: 0; cursor: pointer; font: inherit; font-size: 12px; }
.chip-btn:hover { color: var(--fg); }
.chips { display: flex; gap: 6px; margin-right: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px;
  background: var(--surface-2); font-size: 12px; color: var(--fg-2); white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--fg-3); flex: none; }
[data-state="ok"] > .dot { background: var(--ok); }
[data-state="warn"] > .dot { background: var(--warn); }
[data-state="err"] > .dot { background: var(--err); }
[data-state="busy"] > .dot { background: var(--warn); animation: blink 1s ease-in-out infinite; }
[data-state="live"] > .dot { background: var(--err); animation: blink 1.2s ease-in-out infinite; }

.tbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 13px; font-weight: 600; color: var(--fg-2);
}
.tbtn:hover { color: var(--fg); border-color: var(--fg-3); }
.tbtn .ic { width: 17px; height: 17px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: transparent; color: var(--fg-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }

.stage { overflow-y: auto; min-height: 0; scroll-behavior: smooth; }

/* ---------- 会話 ---------- */
.transcript {
  max-width: 1080px; margin: 0 auto; padding: 24px 20px 32px; display: flex; flex-direction: column; gap: 14px;
}
.turns { display: flex; flex-direction: column; gap: 14px; }
.turn {
  --ch: var(--ja); --ch-soft: var(--ja-soft); --ch-ink: var(--ja-ink);
  align-self: flex-start; max-width: min(860px, 88%); min-width: 0;
  padding: 12px 18px 14px; border-radius: 16px 16px 16px 6px; background: var(--ch-soft);
}
.turn[data-side="partner"] {
  --ch: var(--en); --ch-soft: var(--en-soft); --ch-ink: var(--en-ink);
  align-self: flex-end; border-radius: 16px 16px 6px 16px;
}
.turn-meta {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; font-size: 12px; color: var(--fg-3);
}
.turn-meta .dir { font-weight: 700; color: var(--ch-ink); letter-spacing: .03em; }
.turn-meta time, .turn-meta .eng { font-family: var(--font-num); font-size: 11.5px; font-variant-numeric: tabular-nums; }
.turn-meta .who { font-weight: 600; color: var(--fg-2); }
.turn .src {
  margin: 6px 0 4px; font-size: calc(15px * var(--scale)); line-height: 1.6; color: var(--fg-2); overflow-wrap: anywhere;
}
.turn .tgt {
  margin: 0; font-size: calc(25px * var(--scale)); line-height: 1.45; font-weight: 600; color: var(--fg);
  overflow-wrap: anywhere; text-wrap: pretty; word-break: auto-phrase;
}
.turn .tgt .pending { color: var(--fg-3); font-weight: 400; }
.turn .src:dir(rtl), .turn .tgt:dir(rtl) { text-align: right; }
.turn .tgt .fast { opacity: .82; }
.turn-actions { display: flex; gap: 4px; margin-top: 8px; }
.mini {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px; border-radius: 8px; border: 0;
  background: transparent; color: var(--ch-ink); font-size: 12px; font-weight: 600; cursor: pointer; opacity: .75;
}
.mini:hover { opacity: 1; background: color-mix(in srgb, var(--ch) 12%, transparent); }
.mini .ic { width: 15px; height: 15px; }
.badge-refined {
  display: inline-flex; align-items: center; gap: 3px; color: var(--ok); font-weight: 600;
}

/* ---------- 伝わったかの確認 ---------- */
mark.ck { background: none; color: inherit; border-radius: 3px; padding: 0 1px; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
mark.ck-num { text-decoration-color: var(--ja); }
mark.ck-side { text-decoration-color: var(--warn); }
mark.ck-neg { text-decoration-color: var(--err); text-decoration-style: wavy; text-decoration-thickness: 1.5px; }
.turn .tgt mark.ck { font-weight: 800; }
.turn-meta .ck {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  line-height: 20px; color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.turn-meta .ck[data-state="busy"] { color: var(--fg-3); background: color-mix(in srgb, var(--fg-3) 12%, transparent); }
.turn-meta .ck[data-state="warn"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.turn-meta .ck[data-state="alert"] { color: var(--err); background: color-mix(in srgb, var(--err) 14%, transparent); }
.turn-meta .ck[data-state="fixed"] { color: var(--ja-ink); background: color-mix(in srgb, var(--ja) 14%, transparent); }
/* 数字など一致：Claude では確かめていないので、安心の色（緑）にしない */
.turn-meta .ck[data-state="match"] { color: var(--fg-3); background: color-mix(in srgb, var(--fg-3) 10%, transparent); }
.turn-meta .ck[data-state="error"] { color: var(--warn); background: color-mix(in srgb, var(--warn) 14%, transparent); }
.turn[data-check="alert"] { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--err) 55%, transparent); }
.turn-check { margin-top: 8px; display: grid; gap: 4px; font-size: calc(14px * var(--scale)); line-height: 1.5; }
.turn-check .back { margin: 0; color: var(--fg-2); overflow-wrap: anywhere; }
.turn-check .back-label { font-weight: 700; color: var(--fg-3); font-size: .9em; margin-right: 2px; }
.turn-check .issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.turn-check .issue { padding-left: 1.3em; text-indent: -1.3em; font-weight: 600; }
.turn-check .issue::before { content: "⚠"; display: inline-block; width: 1.3em; text-indent: 0; }
.turn-check .issue.alert { color: var(--err); }
.turn-check .issue.alert::before { content: "⛔"; }
.turn-check .issue.warn { color: var(--warn); }
.turn-check .issue.note { color: var(--fg-3); font-weight: 400; }
.turn-check .issue.note::before { content: "・"; }
.turn-check .issue.fixed { color: var(--fg-3); font-weight: 400; }
.turn-check .issue.fixed::before { content: "↺"; }
.turn-check .fix { display: grid; gap: 4px; padding: 8px 10px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 70%, transparent); }
.turn-check .fix-text { margin: 0; font-weight: 600; color: var(--fg); overflow-wrap: anywhere; }
.turn-check .fix-btn { justify-self: start; opacity: 1; }
.turn-check .back-more { justify-self: start; }
.badge-refined .ic { width: 13px; height: 13px; stroke-width: 2.4; }

.turn.live {
  background: transparent; outline: 1.5px dashed color-mix(in srgb, var(--ch) 60%, transparent); outline-offset: -1.5px;
}
.turn.live .src { color: var(--fg); font-size: calc(19px * var(--scale)); }
.turn.live .src::after {
  content: ""; display: inline-block; width: 2px; height: 1.05em; margin-left: 3px; vertical-align: -0.15em;
  background: var(--ch); animation: blink 1s steps(2, start) infinite;
}
.turn.live .tgt { color: var(--fg-2); font-weight: 500; font-size: calc(21px * var(--scale)); }
.live-tag { font-weight: 700; color: var(--ch-ink); }

.empty {
  margin: 8vh auto 0; max-width: 560px; padding: 0 4px; color: var(--fg-2);
}
.empty-title { font-size: 20px; font-weight: 700; color: var(--fg); margin: 0 0 12px; text-wrap: balance; word-break: auto-phrase; }
.empty-list { margin: 0; padding-left: 1.2em; display: grid; gap: 8px; }

/* 会議モードの字幕は大きく */
[data-mode="meet"] .turn .tgt { font-size: calc(28px * var(--scale)); }
[data-mode="meet"] .turn[data-who="me"] .tgt { font-size: calc(22px * var(--scale)); }

/* ---------- 会議の準備 ---------- */
.meet-setup {
  max-width: 1080px; margin: 0 auto; padding: 18px 20px 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
}
.step {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.step[data-done="true"] { border-color: color-mix(in srgb, var(--ok) 55%, var(--line)); }
.step-head { display: flex; align-items: center; gap: 10px; }
.step-head h3 { margin: 0; font-size: 15px; }
.step-n {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--surface-2); font: 600 13px var(--font-num); color: var(--fg-2);
}
.step[data-done="true"] .step-n { background: var(--ok); color: var(--surface); }
.step-desc { margin: 0; font-size: 12.5px; color: var(--fg-3); }
.step-ctl { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.step-ctl select { flex: 1 1 160px; min-width: 0; }
.state { font-size: 12.5px; color: var(--fg-2); }
.state[data-state="ok"] { color: var(--ok); font-weight: 600; }
.state[data-state="err"] { color: var(--err); font-weight: 600; }
.meter { position: relative; width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; width: 0%; background: var(--ok); transition: width .08s linear; }

/* ---------- 操作卓 ---------- */
.console {
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px));
}
.console-row {
  max-width: 1080px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 16px; align-items: center;
}
.console-mid { display: flex; flex-direction: column; align-items: stretch; gap: 8px; min-width: 150px; }

.talk {
  --ch: var(--ja); --ch-soft: var(--ja-soft); --ch-ink: var(--ja-ink); --level: 0;
  position: relative; display: flex; align-items: center; gap: 14px; min-height: 76px; padding: 10px 22px;
  border-radius: 18px; border: 2px solid var(--ch); background: var(--surface); color: var(--ch-ink);
  cursor: pointer; text-align: left; touch-action: none; user-select: none; -webkit-user-select: none;
  transition: background .15s, color .15s, transform .08s;
}
.talk-en { --ch: var(--en); --ch-soft: var(--en-soft); --ch-ink: var(--en-ink); flex-direction: row-reverse; text-align: right; }
.talk:hover { background: var(--ch-soft); }
.talk:active { transform: scale(.985); }
.talk-ic { width: 30px; height: 30px; stroke-width: 1.7; }
.talk-text { display: flex; flex-direction: column; min-width: 0; }
.talk-label { font-size: 20px; font-weight: 700; letter-spacing: .01em; }
.talk-sub { font-size: 12.5px; color: var(--fg-3); font-weight: 500; }
.talk-ring {
  position: absolute; inset: -6px; border-radius: 22px; border: 3px solid var(--ch); pointer-events: none;
  opacity: 0; transform: scale(1); transition: opacity .1s linear, transform .1s linear;
}
.talk[aria-pressed="true"] { background: var(--ch); color: var(--on-ch); }
.talk[aria-pressed="true"] .talk-sub { color: color-mix(in srgb, var(--on-ch) 80%, transparent); }
.talk[aria-pressed="true"] .talk-ring { opacity: calc(.25 + var(--level) * .75); transform: scale(calc(1 + var(--level) * .035)); }
.talk[data-busy="true"] { border-style: dashed; }
.talk-wide { justify-content: center; }
/* ボタンなしで話せる状態（会議・自動） */
.talk[data-auto="true"]:not([aria-pressed="true"]) { background: var(--ch-soft); }
.talk[disabled] { opacity: .45; cursor: not-allowed; }

.switch { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--fg-2); }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  position: relative; width: 36px; height: 21px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--line); flex: none;
  transition: background .15s;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%; background: var(--surface);
  box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s;
}
.switch input:checked + .track { background: var(--ok); border-color: var(--ok); }
.switch input:checked + .track::after { transform: translateX(15px); }
.switch input:focus-visible + .track { outline: 2px solid var(--focus); outline-offset: 2px; }

.typebar { max-width: 1080px; margin: 12px auto 0; display: flex; gap: 8px; }
.typebar input {
  flex: 1; min-width: 0; width: 0; height: 40px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
}

.meet-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) minmax(0, 1fr); }
.meet-left { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; min-width: 0; }
.meet-status { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--fg-2); min-width: 0; max-width: 100%; }
.meet-status span { overflow: hidden; text-overflow: ellipsis; }

/* ---------- ボタン・入力 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--fg); background: var(--fg); color: var(--bg); font-weight: 600; font-size: 13.5px; cursor: pointer;
  white-space: nowrap;
}
.btn .ic { width: 17px; height: 17px; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--fg-3); }
.btn.small { height: 30px; padding: 0 11px; font-size: 12.5px; }
.btn.primary { background: var(--ja); border-color: var(--ja); color: var(--on-ch); }
.btn.block { width: 100%; height: 44px; font-size: 15px; }
.btn[disabled] { opacity: .5; cursor: default; }
select, input[type="text"], input[type="password"], textarea {
  height: 36px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); min-width: 0;
}
textarea { height: auto; padding: 10px; font: 13px/1.6 var(--font-num); resize: vertical; width: 100%; }
input[type="range"] { flex: 1; accent-color: var(--ja); min-width: 0; }
output { font: 12px var(--font-num); color: var(--fg-2); min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- ドロワー ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, .35); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 21; background: var(--surface);
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.drawer-head {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 10px 22px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 18px; }
.drawer-body { overflow-y: auto; padding: 16px 22px 40px; display: flex; flex-direction: column; gap: 14px; flex: 1; min-height: 0; }
.drawer-body > * { flex-shrink: 0; }
.lead { margin: 0; color: var(--fg-2); }
.fine { margin: 0; font-size: 12.5px; color: var(--fg-3); }
.checklist { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; }
.checklist li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 10px; padding: 10px 12px; font-size: 13.5px;
}
.checklist li + li { border-top: 1px solid var(--line); }
.badge { font-size: 12px; color: var(--fg-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge[data-s="ok"] { color: var(--ok); font-weight: 700; }
.badge[data-s="warn"] { color: var(--warn); font-weight: 600; }
.badge[data-s="err"] { color: var(--err); font-weight: 600; }
.badge[data-s="busy"] { color: var(--warn); }
.checklist li[data-done="true"] .btn { visibility: hidden; }

.help { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; }
.help summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.help-steps { margin: 10px 0 2px; padding-left: 1.3em; display: grid; gap: 8px; font-size: 13.5px; color: var(--fg-2); }
.help-steps.plain { list-style: none; padding-left: 0; }
.help-steps .sub { display: block; font-size: 12.5px; color: var(--fg-3); margin-top: 2px; }

.set-group { display: flex; flex-direction: column; gap: 10px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.set-group:last-child { border-bottom: 0; }
.set-group h3 { margin: 0; font-size: 14px; letter-spacing: .02em; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--fg-2); }
.field > span:first-child { font-weight: 600; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline select { flex: 1; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 13.5px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--ja); }
.engine-fields { display: none; flex-direction: column; gap: 10px; }
.engine-fields[data-show="true"] { display: flex; }

/* ---------- 相手に見せる ---------- */
.present {
  position: fixed; inset: 0; z-index: 30; background: var(--bg); display: grid; place-items: center; padding: 6vh 6vw;
}
.present-inner { max-width: 1200px; display: flex; flex-direction: column; gap: 3vh; }
.present-tgt { margin: 0; font-size: clamp(32px, 5.4vw, 88px); line-height: 1.3; font-weight: 700; text-wrap: balance; word-break: auto-phrase; }
.present-src { margin: 0; font-size: clamp(16px, 2vw, 30px); color: var(--fg-3); }
.present-close { position: absolute; top: 16px; right: 16px; }

/* ---------- 診療の道具 ---------- */
.drawer-wide { width: min(620px, 100vw); }
.tools-tabs { display: flex; gap: 4px; padding: 10px 22px 0; border-bottom: 1px solid var(--line); }
.tools-tabs button {
  border: 0; background: transparent; padding: 8px 12px 10px; cursor: pointer; color: var(--fg-2); font: inherit; font-weight: 600; font-size: 14px;
  border-bottom: 3px solid transparent; margin-bottom: -1px;
}
.tools-tabs button[aria-selected="true"] { color: var(--ja-ink); border-bottom-color: var(--ja); }
.tool-note { margin: 0; font-size: 13px; color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); border-radius: 8px; padding: 8px 10px; }
.tool-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.tool-item {
  width: 100%; text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--fg); font: inherit;
}
.tool-item:hover { border-color: var(--ja); }
.ti-ja { font-weight: 700; font-size: 14.5px; }
.ti-tl { font-size: 13px; color: var(--fg-3); }
.tool-doc-title { margin: 0; font-size: 16px; }
.tool-doc { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; }
.tool-doc .tl { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.tool-doc .ja { margin: 2px 0 0; font-size: 13px; color: var(--fg-3); }
.inline.wrap { flex-wrap: wrap; }
.intake-flags { border: 1px solid color-mix(in srgb, var(--err) 45%, transparent); background: color-mix(in srgb, var(--err) 8%, transparent); border-radius: 10px; padding: 8px 12px; }
.intake-flags strong { color: var(--err); font-size: 13px; }
.intake-flags p { margin: 2px 0 0; font-weight: 700; }
.intake-sum { margin: 0; display: grid; grid-template-columns: 1fr; gap: 2px; font-size: 14px; }
.intake-sum dt { color: var(--fg-3); font-size: 12.5px; margin-top: 8px; }
.intake-sum dd { margin: 0; overflow-wrap: anywhere; }
.intake-sum .flag { color: var(--err); font-weight: 700; }
.free { display: inline-flex; flex-direction: column; gap: 1px; }
.free-ja { font-weight: 600; }

.tool-view { position: fixed; inset: 0; z-index: 31; background: var(--bg); display: flex; flex-direction: column; }
.tv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface); }
.tv-head h2 { margin: 0; font-size: clamp(20px, 2.6vw, 30px); }
.tv-body { flex: 1; min-height: 0; overflow-y: auto; padding: 20px max(24px, calc((100vw - 900px) / 2)) 40px; display: flex; flex-direction: column; gap: 16px; }
.tv-foot { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; padding: 14px 24px 18px; border-top: 1px solid var(--line); background: var(--surface); }
.tv-foot .btn { min-height: 52px; padding: 0 28px; font-size: 18px; }
.tv-lead { margin: 0; font-size: 18px; }
.tv-fine { margin: 0; font-size: 14px; color: var(--fg-3); }
.tv-q { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: var(--surface); display: flex; flex-direction: column; gap: 8px; }
.tv-q h3 { margin: 0; font-size: 19px; }
.tv-hint { margin: 0; font-size: 14px; color: var(--fg-3); }
.tv-hint.strong { color: var(--ja-ink); font-weight: 600; }
.tv-opts { display: flex; flex-wrap: wrap; gap: 8px; }
.tv-opt {
  min-height: 48px; padding: 8px 16px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--surface); color: var(--fg);
  font: inherit; font-size: 16.5px; cursor: pointer; text-align: start;
}
.tv-opt[aria-pressed="true"] { background: var(--ja); border-color: var(--ja); color: var(--on-ch); font-weight: 700; }
.tv-other, .tv-text { font: inherit; font-size: 16.5px; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--fg); width: 100%; }
.tv-text { resize: vertical; }
.tv-doc { margin: 0; padding-inline-start: 1.3em; display: grid; gap: 16px; font-size: clamp(19px, 2.3vw, 28px); line-height: 1.5; font-weight: 600; }
.tv-thanks { margin: auto 0; text-align: center; font-size: clamp(24px, 3.4vw, 40px); font-weight: 700; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 150px; transform: translateX(-50%); z-index: 40; max-width: min(640px, calc(100vw - 32px));
  background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 13.5px; box-shadow: var(--shadow);
}

/* ---------- 最前面字幕（Document PiP） ---------- */
.pip-body { margin: 0; background: var(--bg); color: var(--fg); font: 14px/1.5 var(--font-ui); height: 100vh; }
.pip { display: flex; flex-direction: column; height: 100%; padding: 10px 14px 12px; gap: 8px; }
.pip-lines { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; }
.pip-line { margin: 0; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere; }
.pip-line.partner { font-size: calc(22px * var(--scale)); }
.pip-line.me { font-size: calc(15px * var(--scale)); color: var(--en-ink); }
.pip-line.live { color: var(--fg-2); font-weight: 500; }
.pip-bar { display: flex; align-items: center; gap: 10px; }
.pip-bar .talk { min-height: 46px; padding: 6px 14px; border-radius: 12px; flex: 1; justify-content: center; }
.pip-bar .talk-label { font-size: 15px; }
.pip-bar .talk-ic { width: 22px; height: 22px; }
.pip-status { font-size: 12px; color: var(--fg-3); white-space: nowrap; }

@keyframes blink { 50% { opacity: .25; } }

@media (max-width: 860px) {
  .meet-setup { grid-template-columns: 1fr; }
  .chips { display: none; }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; }
  .mode-switch { order: 3; width: 100%; }
  .mode-switch button { flex: 1; }
  .tbtn span { display: none; }
  .console { padding-inline: 16px; }
  .console-row, .meet-row { grid-template-columns: 1fr 1fr; }
  .console-mid { grid-column: 1 / -1; grid-row: 2; flex-direction: row; flex-wrap: wrap; justify-content: center; }
  .meet-row .talk-wide { grid-column: 1 / -1; }
  .meet-left { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .talk { min-height: 64px; padding: 8px 14px; }
  .talk-label { font-size: 16px; }
  .turn { max-width: 94%; }
  .transcript { padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* Web 版・拡張機能・タッチ端末で出し分ける */
html:not([data-platform="web"]) [data-only="web"] { display: none !important; }
html[data-platform="web"] [data-only="ext"] { display: none !important; }
html[data-touch="true"] [data-hide-touch] { display: none !important; }

/* 医院コード（ライセンス。拡張機能と Web 版） */
.gate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; }
.gate-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 28px 24px; display: flex; flex-direction: column; gap: 14px; }
.gate-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
.gate-card p { margin: 0; color: var(--fg-2); line-height: 1.7; }
.gate-card input { font: inherit; font-size: 18px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); width: 100%; box-sizing: border-box; }
.gate-card input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.gate-msg { min-height: 1.5em; color: var(--err) !important; font-size: 14px; }

/* スマートフォンの幅（Web 版を iPhone で開いたとき）：話すボタンの文字を1行に収め、お知らせは上に出す */
@media (max-width: 480px) {
  .talk { gap: 8px; padding: 8px 12px; min-height: 64px; }
  .talk-ic { width: 24px; height: 24px; }
  .talk-label { font-size: 15px; white-space: nowrap; }
  .talk-sub { font-size: 11.5px; }
  .toast { top: 64px; bottom: auto; }
}
.tool-view h2:focus { outline: none; }

/* ---------- 販売版（MIRAI Voice）で足したもの ---------- */
[data-state="send"] > .dot { background: var(--en); }

/* OS ごとの説明（Mac・Windows） */
html[data-os="win"] [data-os-only="mac"] { display: none !important; }
html:not([data-os="win"]) [data-os-only="win"] { display: none !important; }

/* AI 音声の印（患者様に、合成の声であることが分かるように。AI 音声で読み上げている間だけ出す） */
.ai-voice-tag { display: none; }
html[data-ai-voice="on"] .ai-voice-tag {
  display: inline-flex; align-items: center; gap: 4px; width: fit-content; padding: 2px 9px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; letter-spacing: .02em; line-height: 1.5;
  color: var(--en-ink); background: var(--en-soft); border: 1px solid color-mix(in srgb, var(--en) 45%, transparent);
}
html[data-ai-voice="on"] .ai-voice-tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--en); animation: blink 1.2s ease-in-out infinite; }
.talk-ai { margin-top: 4px; }
.talk-en .talk-ai { align-self: flex-end; }
.meet-ai { margin-top: 6px; }
.present-ai { position: absolute; top: 22px; left: 22px; font-size: clamp(14px, 1.6vw, 22px) !important; }
.tv-ai { margin-left: auto; margin-right: 8px; font-size: 15px !important; }
.pip-ai { font-size: 11px !important; }

/* 設定 */
.sub-group { display: flex; flex-direction: column; gap: 10px; padding-left: 14px; border-left: 3px solid var(--line); }
.sub-group h4 { margin: 0; font-size: 13.5px; }
.links { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 13.5px; }
.links a, .gate-links a, .consent a { color: var(--ja-ink); }
.consent-list { margin: 8px 0 0; padding-left: 1.2em; display: grid; gap: 4px; }
.voice-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.voice-item { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; }
.voice-label { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 13.5px; font-weight: 600; }
.voice-state { font-size: 12px; color: var(--ok); }
.voice-state.pending { color: var(--warn); }

/* 診療の道具：ネイティブの確認前の言語の知らせ */
.tool-warn { border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); border-radius: 10px; padding: 9px 12px; }
.tool-warn strong { color: var(--warn); font-size: 13.5px; }
.tool-warn p { margin: 3px 0 0; font-size: 13px; color: var(--fg-2); }
.tv-staff-note { flex-basis: 100%; margin: 0; text-align: center; font-size: 12.5px; color: var(--fg-3); }

/* 同意・声の登録の画面 */
.consent { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--bg) 94%, transparent); display: grid; place-items: center; padding: 24px 16px; overflow-y: auto; }
.consent-card { width: min(620px, 100%); max-height: calc(100vh - 48px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.consent-card h2 { margin: 0; font-size: 19px; }
.consent-card h2:focus { outline: none; }
.consent-body { display: flex; flex-direction: column; gap: 12px; font-size: 14px; }
.consent-body p { margin: 0; }
.consent-points, .consent-where { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; font-size: 13.5px; color: var(--fg-2); }
.consent-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.consent-item h3 { margin: 0; font-size: 15px; }
.consent-check { font-size: 15px; font-weight: 700; }
.consent-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.consent-actions .btn { min-height: 42px; padding: 0 18px; }
.vr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.vr-read { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: grid; gap: 6px; }
.vr-step { margin: 0; font-size: 12.5px; color: var(--fg-3); font-weight: 600; }
.vr-text { margin: 0; font-size: 16px; line-height: 1.7; }
.vr-digits { font-family: var(--font-num); font-size: 26px; font-weight: 700; letter-spacing: .2em; }
.vr-status { margin: 0; font-weight: 600; color: var(--fg-2); }
#vr-audio { width: 100%; }
@media (max-width: 480px) {
  .consent-card { padding: 18px 16px; }
  .consent-actions { justify-content: stretch; }
  .consent-actions .btn { flex: 1; }
}
.typebar .btn-next { flex: none; height: 36px; gap: 5px; }
.typebar .btn-next .ic { width: 16px; height: 16px; }
@media (max-width: 480px) {
  .typebar .btn-next span { display: none; }
}

/* ---------- 医院のプレミアム（取り決め §13） ---------- */
/* 医院の定型文（タブ・「機械の訳」の印・使えない契約の1行） */
.tools-tabs button { white-space: nowrap; flex: none; }
/* 狭い画面では、タブを横に送って見る（はみ出さない） */
@media (max-width: 640px) {
  .tools-tabs { overflow-x: auto; scrollbar-width: none; padding-inline: 12px; }
  .tools-tabs::-webkit-scrollbar { display: none; }
  .tools-tabs button { padding-inline: 9px; }
}
.tool-cat { margin: 6px 0 -4px; font-size: 13px; color: var(--fg-2); letter-spacing: .02em; }
.tool-premium { border-top: 1px dashed var(--line); padding-top: 10px; }
.mt-tag {
  display: inline-block; width: fit-content; margin-inline-start: 6px; padding: 0 6px; border-radius: 6px; vertical-align: middle;
  font-size: 11px; font-weight: 600; line-height: 1.6; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  font-family: var(--font-ui); letter-spacing: 0;
}
.mt-tag.alt { color: var(--fg-2); border-color: var(--line); }
.ti-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.ti-tags .mt-tag { margin-inline-start: 0; }
.tv-phrase { margin: auto 0 0; font-size: clamp(30px, 5vw, 76px); line-height: 1.35; font-weight: 700; text-wrap: balance; word-break: auto-phrase; overflow-wrap: anywhere; }
.tv-phrase-ja { margin: 0 0 auto; font-size: clamp(16px, 2vw, 26px); color: var(--fg-3); }
.tool-view[data-kind="phrase"] .tv-body { justify-content: center; gap: 3vh; }

/* 医院の問診票 */
.tv-q h3 .mt-tag { font-size: 11.5px; font-weight: 600; }
.intake-sub { margin: 10px 0 -6px; font-size: 13px; color: var(--fg-2); }

/* 多言語プリント・問診票のまとめの印刷 */
.print-confirm { border: 1px solid color-mix(in srgb, var(--warn) 55%, transparent); background: color-mix(in srgb, var(--warn) 12%, transparent); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.print-confirm strong { color: var(--warn); font-size: 14px; }
.print-confirm p { margin: 0; font-size: 13px; color: var(--fg-2); }
.print-group { border: 1px solid var(--line); border-radius: 12px; padding: 8px 14px 12px; margin: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.print-group legend { font-weight: 700; font-size: 14px; padding: 0 4px; }
.print-group-tools { display: flex; justify-content: flex-end; margin-top: -4px; }
.print-item { align-items: flex-start; }
.pi-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pi-ja { font-weight: 600; overflow-wrap: anywhere; }
.pi-tl { font-size: 12.5px; color: var(--fg-3); overflow-wrap: anywhere; }

/* 印刷用の画面：ふだんは出さない。印刷のときだけ、ほかを隠してこれだけを出す（A4） */
.print-sheet { display: none; }
@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
  :root[data-printing], :root[data-printing]:not([data-theme="light"]) { color-scheme: light !important; }
  html[data-printing], html[data-printing] body { height: auto !important; overflow: visible !important; background: #fff !important; color: #000 !important; }
  html[data-printing] body > :not(#print-sheet) { display: none !important; }
  html[data-printing] #print-sheet { display: block !important; }
  .ps { font: 10.5pt/1.55 var(--font-ui); color: #000; }
  .ps p { margin: 0; }
  .ps-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12pt; border-bottom: 1.2pt solid #000; padding-bottom: 6pt; margin-bottom: 12pt; }
  .ps-clinic { font-size: 15pt; font-weight: 700; }
  .ps-date { display: flex; flex-direction: column; align-items: flex-end; font-size: 10pt; text-align: end; }
  .ps-sec { margin: 0 0 14pt; }
  .ps-title { margin: 0 0 4pt; font-size: 13pt; display: flex; flex-wrap: wrap; gap: 2pt 12pt; align-items: baseline; break-after: avoid; page-break-after: avoid; }
  .ps-title-ja { font-size: 10.5pt; font-weight: 600; color: #333; }
  .ps-note { margin: 0 0 4pt !important; font-size: 8.5pt; color: #333; }
  .ps-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
  .ps-table th, .ps-table td { border: .6pt solid #999; padding: 5pt 7pt; vertical-align: top; text-align: start; overflow-wrap: anywhere; word-break: normal; }
  .ps-table thead th { background: #eee; font-size: 9pt; font-weight: 600; }
  .ps-table tr { break-inside: avoid; page-break-inside: avoid; }
  .ps-tl { font-size: 12pt; font-weight: 600; line-height: 1.5; }
  .ps-ja { font-size: 10.5pt; }
  .ps-tag { display: inline-block; margin-inline-start: 6pt; padding: 0 3pt; border: .6pt solid #666; border-radius: 3pt; font-size: 7.5pt; font-weight: 600; color: #333; vertical-align: middle; }
  .ps-foot { margin-top: 14pt; border-top: .8pt solid #999; padding-top: 6pt; display: flex; flex-direction: column; gap: 3pt; break-inside: avoid; }
  .ps-foot-tl { font-size: 11pt; font-weight: 600; }
  .ps-foot-ja { font-size: 10pt; }
  .ps-fine { font-size: 8pt; color: #444; }
  .ps-meta { margin: 0 0 6pt !important; font-size: 10pt; }
  .ps-flags { border: 1.2pt solid #000; padding: 5pt 8pt; margin: 0 0 10pt; break-inside: avoid; }
  .ps-flags strong { font-size: 9pt; }
  .ps-flags p { margin-top: 2pt; font-weight: 700; }
  .ps-qa .ps-q { width: 38%; background: #f4f4f4; font-size: 9.5pt; font-weight: 600; }
  .ps-qa .ps-a.flag { font-weight: 700; text-decoration: underline; }
}
