/* ================= Tokens ================= */
:root {
  --bg: #f2f5f9;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --text: #0d1b2c;
  --muted: #5b6b7f;
  --line: #dbe3ec;
  --accent: #0a6f94;
  --accent-soft: #e2f1f7;
  --accent-ink: #ffffff;
  --mayday: #c8102e;
  --mayday-soft: #fde8eb;
  --panpan: #c25e00;
  --panpan-soft: #fff0e0;
  --securite: #137a4f;
  --securite-soft: #e2f5ec;
  --routine: #52667d;
  --routine-soft: #eaeff4;
  --role-a: #0a6f94;
  --role-b: #6a4bc4;
  --role-c: #9a6b00;
  --radio-body: #1e2328;
  --radio-edge: #0f1215;
  --lcd-bg: #bcd39a;
  --lcd-ink: #1d2a12;
  --shadow: 0 1px 2px rgb(13 27 44 / .05), 0 6px 20px rgb(13 27 44 / .06);
  --radius: 14px;
  --radius-s: 9px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #07111d; --surface: #0e1c2c; --surface-2: #122437; --text: #e4edf6; --muted: #8ea2b8; --line: #1f3650;
    --accent: #4cc3ea; --accent-soft: #10334a; --accent-ink: #04131f;
    --mayday: #ff6470; --mayday-soft: #3a1219; --panpan: #ffa94d; --panpan-soft: #3a2410;
    --securite: #3ddc97; --securite-soft: #0e3325; --routine: #9fb2c7; --routine-soft: #1a2c40;
    --role-a: #4cc3ea; --role-b: #b39cff; --role-c: #f0c050;
    --lcd-bg: #1a2a12; --lcd-ink: #b6f36a;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #07111d; --surface: #0e1c2c; --surface-2: #122437; --text: #e4edf6; --muted: #8ea2b8; --line: #1f3650;
  --accent: #4cc3ea; --accent-soft: #10334a; --accent-ink: #04131f;
  --mayday: #ff6470; --mayday-soft: #3a1219; --panpan: #ffa94d; --panpan-soft: #3a2410;
  --securite: #3ddc97; --securite-soft: #0e3325; --routine: #9fb2c7; --routine-soft: #1a2c40;
  --role-a: #4cc3ea; --role-b: #b39cff; --role-c: #f0c050;
  --lcd-bg: #1a2a12; --lcd-ink: #b6f36a;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .25);
  color-scheme: dark;
}

/* ================= Base ================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.55 var(--font); overflow-x: hidden;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.7rem, 1.2rem + 2vw, 2.4rem); }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent); }
svg { width: 1.15em; height: 1.15em; flex: none; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: var(--accent-ink); padding: 8px 12px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono { font-family: var(--mono); }
.en { font-family: var(--font); font-weight: 500; }
.lead { font-size: 1.06rem; color: var(--muted); max-width: 72ch; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap { gap: 10px; }
.center { justify-content: center; }
#app { outline: none; padding-top: 24px; padding-bottom: 32px; min-height: 70vh; }

/* ================= Top bar ================= */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { display: flex; align-items: center; gap: 18px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); font-weight: 600; white-space: nowrap; }
.brand svg { width: 30px; height: 30px; color: var(--accent); }
.brand b { color: var(--accent); }
#nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
#nav::-webkit-scrollbar { display: none; }
#nav a {
  padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--muted);
  font-size: .93rem; white-space: nowrap; transition: background .15s, color .15s;
}
#nav a:hover { color: var(--text); background: var(--surface-2); }
#nav a.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.top-actions { display: flex; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--text); }
.icon-btn.on { color: var(--accent); border-color: var(--accent); }
@media (max-width: 820px) {
  .topbar-in { flex-wrap: wrap; gap: 6px 12px; padding-top: 8px; }
  .brand { order: 1; flex: 1; }
  .top-actions { order: 2; }
  #nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 8px; }
}

/* ================= Buttons & controls ================= */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content: center;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); text-decoration: none; cursor: pointer;
  font-weight: 550; font-size: .95rem; transition: transform .08s, background .15s, border-color .15s;
  min-height: 42px;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; min-height: 34px; font-size: .88rem; }
.btn.big { padding: 13px 24px; font-size: 1.05rem; margin-top: 12px; }
.say {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface);
  color: var(--accent); border-radius: 999px; padding: 6px 12px 6px 9px; cursor: pointer; font-size: .88rem; font-weight: 550;
}
.say:hover { border-color: var(--accent); }
.say.icon { padding: 5px; width: 32px; height: 32px; justify-content: center; }
.say.speaking, .btn.speaking { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 22%, transparent); } }

.chips, .presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.presets { margin: 8px 0 12px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 6px 13px; cursor: pointer; font-size: .88rem; color: var(--muted);
}
.chip small { color: var(--accent); font-weight: 600; margin-left: 2px; }
.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.on small { color: inherit; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; gap: 2px; }
.seg.wrap { flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 550; font-size: .92rem; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.small button { padding: 5px 11px; font-size: .86rem; }

.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; min-width: 0; }
.field > span { font-size: .8rem; color: var(--muted); font-weight: 550; }
.field input, .field select {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-s); border: 1px solid var(--line);
  background: var(--surface-2); min-height: 42px;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.search { max-width: 520px; margin-bottom: 20px; }
.check, .rate { display: inline-flex; align-items: center; gap: 8px; font-size: .92rem; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.rate input { width: 110px; accent-color: var(--accent); }

/* ================= Layout blocks ================= */
.page-head { margin-bottom: 18px; }
.panel, .card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: 22px; margin-bottom: 20px; }
.card { padding: 18px; }
.card p { color: var(--muted); margin: 0; font-size: .94rem; }
.grid { display: grid; gap: 16px; }
.grid.cards { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); margin-bottom: 24px; }
.grid.cards.four { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 20px; }
.grid.two > .panel { margin-bottom: 0; }
section.grid.two { margin-bottom: 20px; }
.grid.two.tight, .grid.three.tight { gap: 0 12px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid.ll { grid-template-columns: 1fr 1.3fr .9fr 1fr 1.3fr .9fr; gap: 0 10px; }
@media (max-width: 620px) { .grid.ll { grid-template-columns: 1fr 1.3fr .9fr; } }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.section-head h2 { margin: 0; }
.link-card { text-decoration: none; color: var(--text); display: flex; flex-direction: column; gap: 6px; transition: transform .15s, border-color .15s; }
.link-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.link-card h3 { margin: 4px 0 0; }
.card-ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.card-ic svg { width: 22px; height: 22px; }
.tag {
  display: inline-block; font-size: .74rem; font-weight: 650; letter-spacing: .02em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.tag.small { font-size: .66rem; padding: 2px 6px; }
.callout { border-radius: var(--radius-s); padding: 12px 14px; background: var(--accent-soft); margin: 12px 0; font-size: .94rem; }
.callout.warn { background: var(--panpan-soft); }
.callout.good { background: var(--securite-soft); }
.list { margin: 0 0 12px; padding-left: 1.3em; }
.list li { margin-bottom: 6px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; font-weight: 550; margin-bottom: -1px; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

.table-wrap { overflow-x: auto; margin: 0 -4px; }
.tbl { width: 100%; border-collapse: collapse; font-size: .94rem; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.tbl td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.t-act { text-align: right; width: 1%; }
.ch-tbl tbody tr { cursor: pointer; }
.ch-tbl tbody tr:hover { background: var(--surface-2); }
.ch-tbl tbody tr.sel { background: var(--accent-soft); }
.mistakes .bad { color: var(--mayday); }
.mistakes .good { color: var(--securite); }

/* ================= Home ================= */
.hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 32px; align-items: center; padding: 12px 0 28px; }
.eyebrow { display: inline-block; font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 10px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; } .hero .radio { max-width: 380px; } }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; display: flex; flex-direction: column; }
.stat b { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.stat b small { font-size: .95rem; color: var(--muted); font-weight: 500; }
.stat span { color: var(--muted); font-size: .88rem; }
.formula { display: flex; flex-wrap: wrap; align-items: stretch; gap: 8px; margin: 8px 0 16px; }
.f-step { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; min-width: 120px; flex: 1; }
.f-t { font-weight: 650; font-size: .9rem; }
.f-t em { color: var(--accent); font-style: normal; }
.f-ex { font-size: .84rem; color: var(--muted); }
.f-arrow { align-self: center; color: var(--muted); }
@media (max-width: 620px) { .f-arrow { display: none; } .f-step { flex-basis: 100%; } }
.priority { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.prio { display: grid; grid-template-columns: 34px 110px 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center; padding: 10px 14px; border-radius: var(--radius-s); background: var(--routine-soft); border-left: 4px solid var(--routine); }
.prio-n { grid-row: span 2; font-size: 1.4rem; font-weight: 800; color: var(--routine); }
.prio-sig { grid-row: span 2; font-weight: 800; letter-spacing: .03em; }
.prio-name { font-weight: 600; }
.prio-d { color: var(--muted); font-size: .88rem; }
.prio.mayday { background: var(--mayday-soft); border-color: var(--mayday); } .prio.mayday .prio-n, .prio.mayday .prio-sig { color: var(--mayday); }
.prio.panpan { background: var(--panpan-soft); border-color: var(--panpan); } .prio.panpan .prio-n, .prio.panpan .prio-sig { color: var(--panpan); }
.prio.securite { background: var(--securite-soft); border-color: var(--securite); } .prio.securite .prio-n, .prio.securite .prio-sig { color: var(--securite); }
@media (max-width: 520px) { .prio { grid-template-columns: 28px 1fr; } .prio-sig { grid-row: auto; } .prio-name { grid-column: 2; } .prio-d { grid-column: 2; } .prio-n { grid-row: span 3; } }

/* ================= Radio widget ================= */
.radio {
  background: linear-gradient(160deg, #2b3137, var(--radio-body) 60%);
  border: 2px solid var(--radio-edge); border-radius: 22px; padding: 16px 18px 18px;
  box-shadow: 0 18px 40px rgb(0 0 0 / .28), inset 0 1px 0 rgb(255 255 255 / .08);
  color: #c9d1d9; width: 100%; max-width: 420px; justify-self: center;
}
.radio-top { display: flex; justify-content: space-between; align-items: center; font-size: .7rem; letter-spacing: .14em; margin-bottom: 12px; color: #8b96a1; }
.led { width: 9px; height: 9px; border-radius: 50%; background: #3a4148; }
.led.on { background: #ff3b3b; box-shadow: 0 0 10px #ff3b3b; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .35; } }
.lcd {
  background: var(--lcd-bg); color: var(--lcd-ink); border-radius: 10px; padding: 12px 16px;
  font-family: var(--mono); box-shadow: inset 0 2px 8px rgb(0 0 0 / .35);
}
.lcd-row { display: flex; align-items: baseline; gap: 10px; }
.lcd-s { font-size: .9rem; font-weight: 700; }
.lcd-pw { margin-left: auto; }
.lcd-ch { font-size: 3.4rem; font-weight: 800; line-height: 1; letter-spacing: .02em; }
.lcd-freq { font-size: 1.05rem; font-weight: 700; margin-top: 4px; }
.lcd-tag { font-size: .74rem; letter-spacing: .08em; margin-top: 4px; opacity: .85; min-height: 1.2em; }
.radio-keys { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.key {
  flex: 1; min-width: 48px; text-align: center; padding: 9px 6px; border-radius: 9px; font-size: .74rem; font-weight: 700; letter-spacing: .05em;
  background: linear-gradient(#3a4148, #2a3036); border: 1px solid #111; color: #d7dee5; box-shadow: 0 2px 0 #0b0d0f;
}
button.key { cursor: pointer; font-family: inherit; }
button.key:active { transform: translateY(2px); box-shadow: none; }
.key.red { background: linear-gradient(#e0323f, #a51422); color: #fff; }
.radio-sim { display: grid; grid-template-columns: minmax(280px, 400px) 1fr; gap: 24px; align-items: center; margin-bottom: 24px; }
@media (max-width: 760px) { .radio-sim { grid-template-columns: 1fr; } }
.ch-info h3 { margin-top: 10px; }
.ch-info p { color: var(--text); }
.ch-info-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ch-badge {
  display: inline-block; font-family: var(--mono); font-weight: 800; font-size: .9rem; padding: 3px 9px; border-radius: 7px;
  background: var(--routine-soft); color: var(--text); white-space: nowrap;
}
.ch-badge.small { font-size: .72rem; padding: 2px 7px; }
.ch-badge.cat-distress { background: var(--mayday-soft); color: var(--mayday); }
.ch-badge.cat-ship { background: var(--accent-soft); color: var(--accent); }
.ch-badge.cat-nav, .ch-badge.cat-coast { background: var(--panpan-soft); color: var(--panpan); }
.ch-badge.cat-port, .ch-badge.cat-marina { background: var(--securite-soft); color: var(--securite); }
.range-out { font-size: 1.1rem; padding: 12px 14px; border-radius: var(--radius-s); background: var(--accent-soft); }
.range-out b { font-size: 1.8rem; color: var(--accent); }
.mmsi-out { display: grid; gap: 6px; }
.kv { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.kv span { color: var(--muted); font-size: .84rem; min-width: 70px; }
.facts .card h3 { margin-bottom: 6px; }

/* ================= Alphabet ================= */
.abc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 24px; }
.abc-grid.nums { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
.abc {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; column-gap: 12px; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer;
  transition: border-color .15s, transform .1s;
}
.abc:hover { border-color: var(--accent); }
.abc.speaking { border-color: var(--accent); background: var(--accent-soft); animation: none; }
.abc-l { grid-row: span 3; font-size: 2rem; font-weight: 800; color: var(--accent); line-height: 1; align-self: center; font-family: var(--mono); min-width: 1.1em; }
.abc-w { font-weight: 700; }
.abc-p { font-size: .76rem; color: var(--muted); font-family: var(--mono); }
.abc-ru { font-size: .8rem; color: var(--muted); }
.spell-out { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 16px; min-height: 60px; }
.sp { display: flex; flex-direction: column; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 6px 12px; font-weight: 600; }
.sp b { font-family: var(--mono); color: var(--accent); font-size: 1.25rem; }
.sp-gap { width: 14px; }
.trainer { text-align: center; }
.t-score { display: flex; justify-content: center; gap: 22px; flex-wrap: wrap; margin: 16px 0; color: var(--muted); }
.t-score b { color: var(--text); }
.t-q { min-height: 120px; display: grid; place-items: center; }
.t-big { font-size: 5rem; font-weight: 800; font-family: var(--mono); color: var(--accent); line-height: 1; }
.t-big.word { font-size: 2.8rem; font-family: var(--font); }
.t-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; max-width: 640px; margin: 12px auto; }
.t-fb { min-height: 1.6em; font-weight: 550; }
.t-fb.ok { color: var(--securite); } .t-fb.bad { color: var(--mayday); }
.opt {
  padding: 14px; border-radius: var(--radius-s); border: 1.5px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: 1rem; text-align: left; display: flex; align-items: center; gap: 12px;
}
.t-opts .opt { justify-content: center; }
.opt.letter { font-size: 1.6rem; font-family: var(--mono); }
.opt:hover:not(:disabled) { border-color: var(--accent); }
.opt.ok { border-color: var(--securite); background: var(--securite-soft); }
.opt.bad { border-color: var(--mayday); background: var(--mayday-soft); }
.opt:disabled { cursor: default; color: inherit; }

/* ================= Distress ================= */
.c-mayday { color: var(--mayday); } .c-panpan { color: var(--panpan); } .c-securite { color: var(--securite); }
.proc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 18px; margin-bottom: 20px; }
.proc { --c: var(--accent); --cs: var(--accent-soft); background: var(--surface); border: 1px solid var(--line); border-top: 5px solid var(--c); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.proc.mayday { --c: var(--mayday); --cs: var(--mayday-soft); }
.proc.panpan { --c: var(--panpan); --cs: var(--panpan-soft); }
.proc.securite { --c: var(--securite); --cs: var(--securite-soft); }
.proc-head { display: flex; flex-direction: column; gap: 2px; }
.proc-sig { font-size: 1.8rem; font-weight: 850; color: var(--c); letter-spacing: .02em; }
.proc-title { font-weight: 600; }
.proc-title .muted { font-family: var(--mono); font-size: .8rem; font-weight: 500; }
.proc-when { margin: 0; }
.proc-ex { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: .92rem; }
.proc-meta { display: flex; flex-direction: column; gap: 2px; font-size: .86rem; background: var(--cs); padding: 8px 10px; border-radius: var(--radius-s); }
.proc .btn { align-self: flex-start; margin-top: auto; }
.mnemo { display: flex; gap: 4px; }
.mnemo span { flex: 1; text-align: center; font-weight: 800; font-family: var(--mono); background: var(--c); color: #fff; border-radius: 6px; padding: 4px 0; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.steps li { display: flex; gap: 10px; align-items: flex-start; }
.steps li > div { display: flex; flex-direction: column; font-size: .92rem; }
.steps small { color: var(--muted); }
.st-k { flex: none; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 7px; display: grid; place-items: center; font-weight: 800; font-size: .8rem; background: var(--cs, var(--accent-soft)); color: var(--c, var(--accent)); font-family: var(--mono); }
.steps.big li > div { font-size: .96rem; padding-top: 2px; }
.sample { border: 1px solid var(--line); border-radius: var(--radius-s); padding: 10px 12px; }
.sample summary { cursor: pointer; font-weight: 600; }
.sample .en { margin-top: 8px; font-size: .92rem; }
.sample .say { margin-bottom: 8px; }
mark { background: none; color: inherit; }
mark.pw { color: var(--accent); font-weight: 700; }
mark.pw-alert, b.pw-alert { color: var(--mayday); font-weight: 800; }
mark.pw-smcp { color: var(--role-b); font-weight: 700; }
.cat-card { border-top: 4px solid var(--routine); }
.cat-card.mayday { border-top-color: var(--mayday); } .cat-card.panpan { border-top-color: var(--panpan); } .cat-card.securite { border-top-color: var(--securite); }
.cat-card p { margin-bottom: 6px; }
.mayday-soft { border-left: 4px solid var(--mayday); }
.ctrl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.ctrl { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 14px; }
.ctrl-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ctrl-say { font-family: var(--mono); font-size: .78rem; color: var(--muted); }
.ctrl p { margin: 6px 0 0; font-size: .92rem; }
.timeline { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 0; counter-reset: t; }
.timeline li { position: relative; padding: 0 0 16px 34px; display: flex; flex-direction: column; }
.timeline li::before { counter-increment: t; content: counter(t); position: absolute; left: 0; top: 0; width: 24px; height: 24px; border-radius: 50%; background: var(--mayday); color: #fff; font-size: .76rem; font-weight: 800; display: grid; place-items: center; }
.timeline li::after { content: ""; position: absolute; left: 11px; top: 26px; bottom: 2px; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline b { color: var(--mayday); }
.timeline span { color: var(--muted); font-size: .92rem; }

/* Builder */
.builder { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 20px; align-items: start; }
@media (max-width: 900px) { .builder { grid-template-columns: 1fr; } }
.b-form fieldset { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
.b-form legend { font-weight: 700; margin-bottom: 8px; padding: 0; }
.b-form .seg { margin-bottom: 4px; }
.b-form .seg.small { margin-bottom: 12px; }
#bType button.on.t-mayday, #bType button.on.t-relay, #bType button.on.t-cancel { color: var(--mayday); }
#bType button.on.t-panpan { color: var(--panpan); }
#bType button.on.t-securite { color: var(--securite); }
.b-out { position: sticky; top: 76px; border-top: 5px solid var(--mayday); }
.b-out.t-panpan { border-top-color: var(--panpan); }
.b-out.t-securite { border-top-color: var(--securite); }
.b-out.t-mayday .st-k, .b-out.t-relay .st-k, .b-out.t-cancel .st-k { background: var(--mayday-soft); color: var(--mayday); }
.b-out.t-panpan .st-k { background: var(--panpan-soft); color: var(--panpan); }
.b-out.t-securite .st-k { background: var(--securite-soft); color: var(--securite); }
@media (max-width: 900px) { .b-out { position: static; } }
.msg { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 4px; }
.msg li { display: flex; gap: 12px; padding: 8px 10px; border-radius: var(--radius-s); transition: background .15s; }
.msg li > div { display: flex; flex-direction: column; }
.msg li .en { font-size: 1.02rem; }
.msg li small { color: var(--muted); font-size: .8rem; }
.msg li.speaking { background: var(--accent-soft); }

/* ================= Dialogues ================= */
.dlg-card .dlg-top { display: flex; align-items: center; gap: 8px; }
.lvl { color: var(--accent); font-size: .7rem; letter-spacing: 2px; }
.done { margin-left: auto; width: 24px; height: 24px; border-radius: 50%; background: var(--securite); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.ch-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.tag.cat-distress, .chip.cat-distress.on { background: var(--mayday-soft); color: var(--mayday); border-color: var(--mayday); }
.tag.cat-urgency, .chip.cat-urgency.on { background: var(--panpan-soft); color: var(--panpan); border-color: var(--panpan); }
.tag.cat-safety, .chip.cat-safety.on { background: var(--securite-soft); color: var(--securite); border-color: var(--securite); }
.crumbs { display: flex; gap: 8px; font-size: .88rem; color: var(--muted); margin-bottom: 12px; }
.crumbs a { text-decoration: none; }
.dlg-head { display: grid; grid-template-columns: 1fr auto; gap: 20px; align-items: start; }
.dlg-head h1 { margin-top: 8px; }
@media (max-width: 760px) { .dlg-head { grid-template-columns: 1fr; } }
.roles { display: grid; gap: 8px; min-width: 220px; }
.role { display: grid; grid-template-columns: 12px 1fr; column-gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 8px 12px; }
.role small { grid-column: 2; color: var(--muted); font-size: .8rem; }
.role .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--rc); grid-row: span 2; }
.role-A { --rc: var(--role-a); } .role-B { --rc: var(--role-b); } .role-C { --rc: var(--role-c); }
.toolbar { display: flex; align-items: center; gap: 14px 20px; flex-wrap: wrap; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 12px; position: sticky; top: 68px; z-index: 5; box-shadow: var(--shadow); }
.toolbar .btn.primary { margin-left: auto; }
@media (max-width: 820px) { .toolbar { top: 104px; } }
@media (max-width: 560px) { .toolbar { position: static; } .toolbar .btn.primary { margin-left: 0; width: 100%; } }
.practice-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; color: var(--muted); font-size: .92rem; }
.transcript { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 24px; }
.ln {
  max-width: min(760px, 92%); background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--rc);
  border-radius: var(--radius); padding: 12px 16px; box-shadow: var(--shadow); transition: box-shadow .2s, transform .2s;
}
.ln.role-B { align-self: flex-end; border-left-width: 1px; border-right: 4px solid var(--rc); }
.ln.role-C { align-self: center; }
.ln.active { box-shadow: 0 0 0 3px color-mix(in srgb, var(--rc) 40%, transparent), var(--shadow); }
.ln-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ln-head .who { font-weight: 700; color: var(--rc); font-size: .9rem; }
.ln-head .say { margin-left: auto; }
.ln .en { margin: 0 0 4px; font-size: 1.02rem; }
.ln .ru { margin: 0; color: var(--muted); font-size: .92rem; }
.hide-ru .ln .ru { display: none; }
.ln .note { margin: 8px 0 0; font-size: .86rem; padding: 6px 10px; background: var(--accent-soft); border-radius: 7px; }
.ln.mine { border-style: dashed; background: var(--surface-2); }
.ln .prompt { margin: 4px 0 2px; font-size: .84rem; color: var(--muted); }
.ln .ru-prompt { font-size: 1.02rem; font-weight: 600; margin-bottom: 10px; }
.ln.revealed { animation: pop .35s ease; }
@keyframes pop { from { transform: scale(.98); opacity: .6; } }
.evt { align-self: center; display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .88rem; padding: 6px 14px; border: 1px dashed var(--line); border-radius: 999px; text-align: center; max-width: 92%; }
.evt.active { border-color: var(--accent); color: var(--text); }
.finish { align-self: center; text-align: center; padding: 18px 22px; border-radius: var(--radius); background: var(--securite-soft); display: grid; gap: 12px; justify-items: center; }
.finish b { color: var(--securite); font-size: 1.1rem; }
.tips { border-left: 4px solid var(--accent); }
.pager { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pager .btn { max-width: 100%; }
.pager .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= Prowords ================= */
.pw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.pw-card { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-s); padding: 12px 14px; }
.pw-card p { margin: 6px 0 0; font-size: .92rem; }
.pw-card .en { color: var(--muted); }
.pw-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pw-head b { font-family: var(--mono); letter-spacing: .02em; color: var(--accent); }

/* ================= Quiz ================= */
.quiz { max-width: 760px; margin: 0 auto; }
.q-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .9rem; margin-bottom: 8px; }
.q-bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; margin-bottom: 22px; }
.q-bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.q-text { font-size: 1.35rem; margin-bottom: 18px; }
.q-opts { display: grid; gap: 10px; }
.q-l { flex: none; width: 28px; height: 28px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: var(--muted); }
.q-fb { margin-top: 16px; }
.q-fb .btn { margin-top: 4px; }
.result { text-align: center; }
.result .panel { text-align: left; margin-top: 20px; }
.ring {
  --p: 0; width: 150px; height: 150px; border-radius: 50%; margin: 10px auto 16px; display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--line) 0);
}
.ring span { width: 118px; height: 118px; border-radius: 50%; background: var(--bg); display: grid; place-items: center; font-size: 2rem; font-weight: 800; }

/* ================= Footer & toast ================= */
.foot { color: var(--muted); font-size: .82rem; padding-top: 20px; padding-bottom: 32px; border-top: 1px solid var(--line); }
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: .92rem; max-width: calc(100% - 32px);
  transition: opacity .2s, transform .2s; z-index: 60; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* ================= Theory ================= */
.theory { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.toc-wrap { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
.toc-wrap .field.search { margin-bottom: 12px; }
.toc { display: flex; flex-direction: column; gap: 2px; }
.toc a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-s);
  text-decoration: none; color: var(--muted); font-size: .92rem; border-left: 3px solid transparent;
}
.toc a:hover { color: var(--text); background: var(--surface); }
.toc a.on { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.toc a.dim { opacity: .35; }
.toc-n {
  flex: none; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px;
  background: var(--surface-2); border: 1px solid var(--line); font-size: .74rem; font-weight: 700; font-family: var(--mono); color: var(--muted);
}
.toc a.on .toc-n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toc-mobile { display: none; }
.th-sec { scroll-margin-top: 80px; }
.th-sec h2 { display: flex; align-items: center; gap: 10px; font-size: 1.4rem; margin-bottom: 14px; }
.th-sec h2 .toc-n { width: 30px; height: 30px; font-size: .85rem; background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.th-sec h3 { margin: 22px 0 8px; font-size: 1.05rem; }
.th-sec .table-wrap { margin-bottom: 12px; }
.th-sec .tbl td { vertical-align: top; }
.th-sec .tbl.phr td:last-child { width: 1%; text-align: right; vertical-align: middle; }
.th-sec .tbl.phr .say { padding: 5px; width: 32px; height: 32px; justify-content: center; }
.th-sec > p > .say:first-child { vertical-align: middle; margin-right: 6px; padding: 5px; width: 32px; height: 32px; justify-content: center; }
.formula-line {
  font-family: var(--mono); font-size: .9rem; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-s); padding: 10px 12px; margin: 8px 0 12px; overflow-x: auto;
}
.bad-list li::marker { color: var(--mayday); }
@media (max-width: 900px) {
  .theory { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .toc-wrap { position: static; max-height: none; overflow: visible; }
  .toc-side { display: none; }
  .toc-mobile { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; margin-bottom: 16px; }
  .toc-mobile summary { cursor: pointer; font-weight: 600; }
  .toc-mobile .toc { margin-top: 8px; }
  .th-sec { scroll-margin-top: 120px; }
}
@media print {
  .topbar, .toc-wrap, .foot, .say { display: none !important; }
  .theory { display: block; }
  .panel { box-shadow: none; break-inside: avoid-page; }
}
