/* Alfa Bravo Desk - MIT (c) 2026 ipusiron. */
:root {
  color-scheme: light;
  --bg: #f4f6f2;
  --paper: #fffffb;
  --ink: #17283a;
  --muted: #4a5a69;
  --line: #b5c3cc;
  --accent: #1f5f8b;
  --mark: #ffe9a8;
  --mark-line: #8a6408;
  --single-line: #4a5a69;
  --now: #d9f0e3;
  --shadow: #d8dcd4;
  --on-accent: #fffffb;
  --warn: #9b2c1f;
  --notice-bg: #fff1dc;
  --notice-ink: #4a2600;
  --notice-line: #b85c00;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1a26;
  --paper: #182838;
  --ink: #e8eff5;
  --muted: #bccad6;
  --line: #5d7387;
  --accent: #8cc4ec;
  --mark: #5a4a14;
  --mark-line: #e0b84a;
  --single-line: #bccad6;
  --now: #1f4634;
  --shadow: #08121c;
  --on-accent: #10202e;
  --warn: #ffb4a8;
  --notice-bg: #3d2a12;
  --notice-ink: #ffe2bf;
  --notice-line: #f0a24a;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
/* パネルの領域が画面の高さ以上なので、ページにはいつもスクロールバーが出る（タブを替えても幅が変わらない） */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 1rem/1.6 system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  /* 日本語は語の切れ目（<wbr>）だけで折り返す。英語は空白で折り返す */
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: strict;
}
button, input, textarea { font: inherit; color: inherit; }
button {
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  padding: .4rem .8rem;
  border: 1px solid var(--muted);
  border-radius: 8px;
  background: var(--paper);
}
button:disabled { opacity: .5; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
a { color: var(--accent); }
.wrap { width: min(100% - 2rem, 1000px); margin-inline: auto; }
.mono, code, .mono-cells td { font-family: ui-monospace, Consolas, "Courier New", monospace; }
.nowrap { white-space: nowrap; }

/* ===== 見出し：狭い幅は縦に、900px以上は3列（左の空き・題名・ボタン。左右を同じ幅にして題名を中央に置く） ===== */
.site-header { padding: 1.4rem 0 .4rem; }
.header-content { display: flex; flex-direction: column; align-items: center; gap: .7rem; }
.header-title { text-align: center; min-width: 0; }
@media (min-width: 900px) {
  .header-content { display: grid; grid-template-columns: 270px minmax(0, 1fr) 270px; align-items: center; }
  .header-title { grid-column: 2; }
  .header-buttons { grid-column: 3; justify-self: end; }
}
h1 { margin: 0; font-size: clamp(1.5rem, 4.5vw, 2rem); line-height: 1.2; }
h1 span { color: var(--accent); }
.subtitle { margin: .35rem 0 0; color: var(--muted); font-size: .9375rem; }
.header-buttons { display: flex; gap: .4rem; }
.tool-button { border-radius: 999px; font-weight: 700; white-space: nowrap; }
.tool-icon { margin-right: .3rem; }

/* ===== 冒頭の説明 ===== */
.intro { margin: .8rem 0 0; }
.intro p { margin: 0 0 .5rem; }
noscript { display: block; margin: .8rem 0; padding: .6rem; border: 1px solid var(--warn); color: var(--warn); }

/* ===== タブ ===== */
.tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .15rem;
  margin-top: 1rem;
  padding: .15rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: .3rem .2rem;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  text-align: center;
  line-height: 1.3;
}
.tab-name { font-size: .9375rem; font-weight: 700; }
@media (max-width: 429px) {
  .tab-name { font-size: .8125rem; }
}
.tab-en { font-size: .75rem; color: var(--muted); }
:root[lang="en"] .tab-en { display: none; }
/* 選んだタブは色と下線で示し、文字の太さは変えない（太さで幅が変わり、折り返し方が変わらないように） */
.tab[aria-selected="true"] { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }
/* タブを替えても、ページの下端が縮んで表示の位置が飛ばないよう、パネルの領域は画面の高さ以上にする */
.panels { min-height: 100vh; min-height: 100dvh; overflow-anchor: none; }
.panel {
  margin: -1px 0 1rem;
  padding: .9rem;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 3px 3px 0 var(--shadow);
  min-width: 0;
}
.panel h2 { margin: 0 0 .3rem; font-size: 1.15rem; color: var(--accent); }
.lead { margin: 0 0 .6rem; color: var(--muted); font-size: .9375rem; }
h3 { margin: 1.1rem 0 .4rem; font-size: 1rem; color: var(--accent); }

/* ===== 入力と切り替え ===== */
label.field { display: block; font-weight: 700; margin: .4rem 0 .25rem; }
input[type="text"], textarea {
  width: 100%;
  padding: .5rem .6rem;
  border: 1px solid var(--muted);
  border-radius: 6px;
  background: var(--bg);
  font-size: 1rem;
}
input[type="text"] { font-family: ui-monospace, Consolas, "Courier New", monospace; font-size: 1.15rem; }
textarea { min-height: 7.5rem; resize: vertical; line-height: 1.55; overflow-wrap: break-word; word-break: normal; }
.counter { margin: .2rem 0 0; color: var(--muted); font-size: .8125rem; text-align: right; }
.warn { margin: .2rem 0 0; color: var(--warn); font-size: .875rem; font-weight: 700; }
.row { display: flex; flex-wrap: wrap; gap: .6rem 1.2rem; align-items: flex-start; margin-top: .6rem; }
fieldset.seg { margin: 0; padding: 0; border: 0; min-width: 0; }
fieldset.seg legend { padding: 0; margin-bottom: .2rem; font-size: .875rem; font-weight: 700; }
.seg-buttons { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--muted); border-radius: 8px; overflow: hidden; }
.seg-buttons button { border: 0; border-radius: 0; min-height: 44px; white-space: nowrap; }
.seg-buttons button + button { border-left: 1px solid var(--muted); }
/* 選んだボタンは色で示し、太さは変えない（太さで幅が変わると、ボタンの折り返しが変わって画面が動く） */
.seg-buttons button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
/* 3択のボタンは、狭い幅では縦に並べる（2つと1つに折れて見分けにくくならないように） */
@media (max-width: 599px) {
  .seg-three { display: inline-grid; grid-template-columns: minmax(0, 1fr); }
  .seg-three button { text-align: left; }
  .seg-three button + button { border-left: 0; border-top: 1px solid var(--muted); }
}
.seg-note { margin: .25rem 0 0; font-size: .8125rem; color: var(--muted); }
/* 選べる説明をすべて重ねて置き、選んだものだけを見せる（切り替えても高さが変わらない） */
.seg-note.stack { display: grid; }
/* 説明の付いた切り替えは1行を使い、説明をパネルの幅いっぱいに置く */
fieldset.seg-wide { flex: 1 1 100%; }
.seg-note.stack > span { grid-area: 1 / 1; }
.seg-note.stack > .off { visibility: hidden; }

/* ===== 結果の表 ===== */
.result-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .2rem 1rem; }
.english-note { margin: 0 0 .4rem; font-size: .8125rem; color: var(--muted); }
.table-wrap { max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: .9375rem; }
th, td { padding: .35rem .5rem; border: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: var(--bg); font-size: .875rem; }
.spell-table .num { color: var(--muted); width: 2.6rem; text-align: right; }
.spell-table th.num { text-align: right; }
.spell-table .ch { width: 3.4rem; text-align: center; }
.spell-table .type { white-space: nowrap; width: 4.2rem; }
.chbox {
  display: inline-block;
  min-width: 1.9rem;
  padding: .05rem .3rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: 1.1rem;
  white-space: pre;
}
.case, .sub { color: var(--muted); font-size: .8125rem; }
.case { margin-right: .15rem; }
.word { font-weight: 700; }
.skip { display: block; color: var(--muted); font-size: .75rem; }
.spell-table tr.now td { background: var(--now); }
.spell-table tr.now td:first-child { box-shadow: inset 5px 0 0 var(--accent); font-weight: 700; color: var(--accent); }
.empty { color: var(--muted); font-size: .9375rem; }

/* ===== 読み上げとコピー ===== */
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .9rem 0 .2rem; }
.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.speed-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .4rem 1rem; margin-top: .3rem; }
.seg-inline { flex: none; }
.speak-status { margin: 0; min-height: 1.6em; }
.status { font-size: .8125rem; color: var(--muted); }
.copy-box { margin-top: .8rem; padding: .5rem .7rem; border: 1px dashed var(--line); border-radius: 6px; background: var(--bg); }
.copy-label { margin: 0 0 .2rem; font-size: .8125rem; font-weight: 700; color: var(--muted); }
.copy-text {
  margin: 0;
  font-family: ui-monospace, Consolas, "Courier New", monospace;
  font-size: .875rem;
  word-break: normal;
  overflow-wrap: anywhere;
  min-height: 1.4em;
}

/* ===== タブ2 ===== */
.found-text {
  padding: .6rem .8rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  line-height: 2.1;
  word-break: normal;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  min-height: 3rem;
}
mark { color: inherit; padding: 0 .1rem; border-radius: 2px; }
mark.seq { background: var(--mark); border-bottom: 2px solid var(--mark-line); }
mark.single { background: transparent; border: 1px dashed var(--single-line); }
mark.unread { background: transparent; border: 2px solid var(--warn); }
mark.unread sup { color: var(--warn); }
mark.now { outline: 3px solid var(--accent); outline-offset: 1px; }
mark sup { font-size: .7rem; font-weight: 700; color: var(--accent); margin-left: .1rem; font-family: ui-monospace, Consolas, monospace; }
.decoded { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0; }
.decoded .gap { width: .8rem; }
.decoded-item {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 3.6rem;
  padding: .2rem .3rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}
.decoded-item.now { background: var(--now); box-shadow: inset 0 -4px 0 var(--accent); }
.decoded-item.unread { border: 2px solid var(--warn); }
.decoded-item.unread b { color: var(--warn); }
.mode-line { margin: .1rem 0 .4rem; font-size: .875rem; font-weight: 700; }
.tidy { margin-top: .4rem; }
.decoded-item b { font-family: ui-monospace, Consolas, monospace; font-size: 1.3rem; }
.decoded-item small { font-size: .7rem; color: var(--muted); white-space: nowrap; }
.decoded-line {
  margin: .2rem 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 1.4rem;
  letter-spacing: .12em;
  word-break: normal;
  overflow-wrap: anywhere;
}
.singles { margin: .2rem 0; padding-left: 1.3rem; }
.variants-table td:nth-child(odd) { font-family: ui-monospace, Consolas, "Courier New", monospace; }

/* ===== タブ3 ===== */
.letter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .5rem; }
@media (max-width: 599px) {
  .letter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .4rem; }
}
/* 幅360px未満では2列にする（3列ではカタカナの長い語が語の途中で折れる） */
@media (max-width: 359px) {
  .letter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
/* カードの高さを、表の中でいちばん高いカードにそろえる */
.letter-grid { grid-auto-rows: 1fr; }
.letter-card {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-areas: "lt spk" "sp sp" "kn kn" "ic ic";
  align-items: center;
  align-content: start;
  gap: 0 .3rem;
  padding: .4rem .5rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  text-align: left;
  min-width: 0;
}
.letter-card .lt { grid-area: lt; font-family: ui-monospace, Consolas, monospace; font-size: 1.5rem; font-weight: 700; color: var(--accent); line-height: 1.1; }
.letter-card .spk { grid-area: spk; justify-self: end; font-size: .75rem; color: var(--accent); }
.letter-card .sp { grid-area: sp; font-weight: 700; }
.letter-card .kn { grid-area: kn; font-size: .75rem; color: var(--muted); line-height: 1.3; }
.letter-card .ic { grid-area: ic; font-size: .75rem; color: var(--muted); line-height: 1.3; }
.letter-card.now { background: var(--now); box-shadow: inset 4px 0 0 var(--accent); }
.study-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 290px), 1fr)); gap: .8rem; }
.study-card { padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); min-width: 0; }
.study-card h4 { margin: 0 0 .35rem; font-size: 1rem; }
.study-card h4 .no { display: inline-block; min-width: 1.6rem; color: var(--accent); }
.study-card p { margin: 0 0 .5rem; font-size: .9375rem; }
.study-card table { font-size: .8125rem; background: var(--paper); }

/* ===== 出典 ===== */
.site-footer { padding: .4rem 0 2rem; font-size: .875rem; color: var(--muted); text-align: center; }
.site-footer p { margin: .3rem 0; }
.sources { margin: 0; padding-left: 1.2rem; }
.sources li + li { margin-top: .25rem; }

/* ===== ヘルプ ===== */
html.dialog-open { overflow: hidden; }
.help-dialog {
  width: min(100% - 2rem, 44rem);
  max-height: min(90dvh, 48rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
}
.help-dialog::backdrop { background: rgba(8, 18, 28, .6); }
.help-frame { display: flex; flex-direction: column; max-height: min(90dvh, 48rem); }
.help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .6rem .9rem;
  border-bottom: 1px solid var(--line);
}
.help-head h2 { margin: 0; font-size: 1.15rem; color: var(--accent); }
.help-body { overflow-y: auto; padding: .4rem .9rem 1rem; scrollbar-gutter: stable; }
.help-body h3 { margin: 1rem 0 .3rem; }
.help-body p { margin: 0 0 .5rem; font-size: .9375rem; }
.help-features { margin: 0; padding-left: 1.2rem; }
.help-features li + li { margin-top: .5rem; }
.help-go { display: block; margin-top: .25rem; min-height: 40px; font-size: .875rem; color: var(--accent); }

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

/* ===== 狭い幅：英語の単語を途中で折らない ===== */
.spell-table td, .variants-table td, .study-card td, th { overflow-wrap: normal; }
.spell-table th { white-space: nowrap; }
.letter-card .sp { overflow-wrap: normal; }
@media (max-width: 389px) {
  .spell-table th, .spell-table td { padding: .3rem .35rem; }
  .letter-card { padding: .35rem; }
  .letter-card .sp { font-size: .8125rem; }
}

/* ===== 説明の文：最後の行に短い句だけが落ちないようにする（対応しないブラウザーでは、ふつうの折り返しのまま） ===== */
p, li, .seg-note.stack > span { text-wrap: pretty; }
/* 日本語の短い句（js/i18n.js）は句の中で折り返さない */
.ph { white-space: nowrap; }

/* ===== 声についての知らせ：読み上げのボタンのすぐ下に、注意の色の帯で出す ===== */
.voice-notice {
  margin: .5rem 0 0;
  padding: .5rem .7rem;
  border-left: 6px solid var(--notice-line);
  border-radius: 4px;
  background: var(--notice-bg);
  color: var(--notice-ink);
  font-size: .875rem;
}
.notice-label { display: inline-block; margin-right: .5rem; font-weight: 700; }
.notice-howto { margin-top: .2rem; }
.notice-howto summary { cursor: pointer; font-weight: 700; text-decoration: underline; min-height: 32px; display: inline-flex; align-items: center; }
.notice-howto p { margin: .2rem 0 0; }
.find-hint { margin: 0 0 .4rem; font-size: .875rem; }
.copy-note { margin: 0 0 .2rem; font-size: .75rem; color: var(--muted); }
/* 数字のカードと、ICAO式で読むボタン */
.card-wrap { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.card-wrap .letter-card { flex: 1 1 auto; }
.icao-speak { min-height: 44px; padding: .25rem .5rem; text-align: left; font-size: .75rem; line-height: 1.3; color: var(--accent); }
.icao-speak.now { background: var(--now); box-shadow: inset 4px 0 0 var(--accent); }
/* ICAO式も同じ綴りの数字：ボタンと同じ大きさの、押せない短い文 */
.icao-same {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: .25rem .5rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: .75rem;
  line-height: 1.3;
  color: var(--muted);
}
.switch:disabled .switch-state { font-weight: 400; }

/* ===== オン・オフのスイッチ（読み上げで大文字・小文字も言う） ===== */
.switch { display: inline-flex; align-items: center; gap: .5rem; text-align: left; }
.switch-track {
  position: relative;
  flex: none;
  width: 2.6rem;
  height: 1.5rem;
  border: 2px solid var(--muted);
  border-radius: 999px;
  background: var(--bg);
}
.switch-knob {
  position: absolute;
  top: .125rem;
  left: .125rem;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--muted);
}
.switch[aria-checked="true"] .switch-track { border-color: var(--accent); background: var(--accent); }
.switch[aria-checked="true"] .switch-knob { left: auto; right: .125rem; background: var(--on-accent); }
.switch-state { font-weight: 700; min-width: 2em; }
