/*!
 * MorseHelper — stylesheet
 * Single file, no framework, no external fonts. Mobile first.
 * Sections: tokens -> reset -> layout -> header -> hero -> tool -> ads
 *           -> content -> tables -> faq -> footer -> utilities
 */

/* ------------------------------------------------------------------ *
 * 1. Design tokens
 * ------------------------------------------------------------------ */
:root {
  color-scheme: light;

  --bg: #f5f7fa;
  --bg-grad: radial-gradient(1200px 500px at 50% -220px, #e6ecff 0%, transparent 70%);
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e9edf5;

  --text: #0d1321;
  --text-muted: #57627a;
  --text-faint: #656f83;

  --border: #e0e5ef;
  --border-strong: #c9d1e0;

  --accent: #2f49d1;
  --accent-hover: #2439ab;
  --accent-ink: #ffffff;
  --accent-soft: #eef1ff;
  --link: #2439ab;

  --ok: #0f7a4d;
  --ok-soft: #e6f6ee;
  --warn: #8a5a00;
  --warn-soft: #fdf4e3;

  --shadow-sm: 0 1px 2px rgba(13, 19, 33, .05);
  --shadow-md: 0 4px 16px -4px rgba(13, 19, 33, .10), 0 1px 3px rgba(13, 19, 33, .05);
  --shadow-lg: 0 18px 44px -18px rgba(13, 19, 33, .22), 0 2px 6px rgba(13, 19, 33, .05);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;

  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --shell: 1180px;
  --gap: clamp(1rem, 3vw, 1.75rem);

  /* Reserved advertising heights — kept in sync with the AdSlot markup so
     that loading an ad never shifts the layout. */
  --ad-h-sm: 100px;
  --ad-h-md: 280px;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0a0e16;
  --bg-grad: radial-gradient(1200px 500px at 50% -220px, #16203a 0%, transparent 70%);
  --surface: #111826;
  --surface-2: #161f30;
  --surface-3: #1d2739;

  --text: #e9edf6;
  --text-muted: #9aa5bb;
  --text-faint: #949eb3;

  --border: #232d42;
  --border-strong: #33405a;

  --accent: #6d86ff;
  --accent-hover: #849aff;
  --accent-ink: #070b14;
  --accent-soft: #172142;
  --link: #9db0ff;

  --ok: #4ade9c;
  --ok-soft: #10281e;
  --warn: #f0c674;
  --warn-soft: #2a2113;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 16px -4px rgba(0, 0, 0, .55), 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 44px -18px rgba(0, 0, 0, .7), 0 2px 6px rgba(0, 0, 0, .4);
}

/* ------------------------------------------------------------------ *
 * 2. Reset & base
 * ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 4.5rem;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  margin: 0;
  background-color: var(--bg);
  background-image: var(--bg-grad);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 0 0 .6em;
  font-weight: 700;
}

h1 { font-size: clamp(1.9rem, 5.5vw, 2.85rem); letter-spacing: -.03em; }
h2 { font-size: clamp(1.35rem, 3.4vw, 1.85rem); }
h3 { font-size: clamp(1.05rem, 2.4vw, 1.2rem); }

p { margin: 0 0 1rem; }
ul, ol { margin: 0 0 1rem; padding-left: 1.25rem; }
li { margin-bottom: .35rem; }

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent); }

img, svg { max-width: 100%; height: auto; display: block; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--accent); color: var(--accent-ink); }

/* ------------------------------------------------------------------ *
 * 3. Layout helpers
 * ------------------------------------------------------------------ */
.shell {
  width: 100%;
  max-width: var(--shell);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 1.5rem);
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -100px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: .65rem 1rem;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; color: var(--accent-ink); }

section { scroll-margin-top: 4.5rem; }

.section {
  padding-block: clamp(2rem, 5vw, 3.25rem);
  border-top: 1px solid var(--border);
}
.section:first-of-type { border-top: 0; }

.section-intro {
  color: var(--text-muted);
  max-width: 68ch;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

/* Optional wide-screen layout with a sidebar advert. The sidebar only ever
   appears when there is genuinely enough room, so the tool never gets narrow. */
.layout { display: block; }

@media (min-width: 1500px) {
  :root { --shell: 1520px; }
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 2.5rem;
    align-items: start;
  }
  .layout > .rail { display: block; }
}

.rail { display: none; }
.rail .ad-slot { position: sticky; top: 5rem; }

/* ------------------------------------------------------------------ *
 * 4. Header
 * ------------------------------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 56px;
  padding-block: .4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  font-weight: 750;
  font-size: 1.02rem;
  letter-spacing: -.02em;
  color: var(--text);
  text-decoration: none;
  margin-right: auto;
  white-space: nowrap;
}
.brand:hover { color: var(--text); }
.brand-mark { flex: none; width: 26px; height: 26px; }
.brand em { font-style: normal; color: var(--text-muted); font-weight: 600; }

.nav { display: flex; align-items: center; gap: .15rem; }

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: .93rem;
  font-weight: 550;
  padding: .5rem .7rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a[aria-current="page"] { color: var(--text); }

.header-actions { display: flex; align-items: center; gap: .3rem; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.icon-btn svg { width: 18px; height: 18px; }

.theme-toggle .moon { display: none; }
:root[data-theme="dark"] .theme-toggle .sun { display: none; }
:root[data-theme="dark"] .theme-toggle .moon { display: block; }

.nav-toggle { display: none; }

/* Mobile navigation */
@media (max-width: 819px) {
  .nav-toggle { display: inline-grid; }
  .nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: .5rem clamp(1rem, 4vw, 1.5rem) 1rem;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
  }
  .nav[hidden] { display: none; }
  .nav a {
    padding: .85rem .5rem;
    font-size: 1rem;
    border-bottom: 1px solid var(--border);
  }
  .nav a:last-child { border-bottom: 0; }
}

/* ------------------------------------------------------------------ *
 * 5. Hero
 * ------------------------------------------------------------------ */
.hero { padding-block: clamp(1.5rem, 4vw, 2.5rem) 1.25rem; text-align: center; }

.hero h1 { margin-bottom: .4rem; }

.hero .lede {
  color: var(--text-muted);
  font-size: clamp(1rem, 2.3vw, 1.12rem);
  max-width: 60ch;
  margin-inline: auto;
  margin-bottom: 1.1rem;
}

.badges {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: .4rem .5rem;
  margin: 0;
  padding: 0;
}
.badges li {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  margin: 0;
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .3rem .7rem;
}
.badges svg { width: 13px; height: 13px; color: var(--ok); flex: none; }

/* A quiet dot-and-dash rule used as a decorative divider. */
.morse-rule {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 8px;
  margin: 1.5rem auto 0;
  opacity: .5;
}
.morse-rule span {
  display: block;
  height: 3px;
  border-radius: 2px;
  background: var(--accent);
}
.morse-rule .d { width: 3px; }
.morse-rule .h { width: 15px; }

/* ------------------------------------------------------------------ *
 * 6. The translator tool
 * ------------------------------------------------------------------ */
.tool { padding: clamp(.85rem, 2.5vw, 1.25rem); scroll-margin-top: 5rem; }

.panes {
  display: grid;
  grid-template-columns: 1fr;
  gap: .6rem;
  align-items: start;
}

@media (min-width: 880px) {
  .panes { grid-template-columns: 1fr auto 1fr; gap: .9rem; }
}


.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .7rem .75rem .6rem;
}

.pane:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .45rem;
}

.pane-head label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.counter { font-size: .74rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }

.pane textarea {
  width: 100%;
  min-height: 190px;
  resize: vertical;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 1.02rem;
  line-height: 1.6;
  padding: 0;
  outline: none;
}
.pane textarea::placeholder { color: var(--text-faint); }

#morse-input {
  font-family: var(--font-mono);
  font-size: 1rem;
  letter-spacing: .06em;
  word-break: break-word;
}

@media (min-width: 880px) {
  .pane textarea { min-height: 230px; }
}

.pane-note {
  margin: .5rem 0 0;
  font-size: .8rem;
  line-height: 1.45;
  color: var(--warn);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 25%, transparent);
  border-radius: var(--radius-sm);
  padding: .45rem .6rem;
}
.pane-note[hidden] { display: none; }
.pane-note code {
  font-family: var(--font-mono);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
  border-radius: 3px;
  padding: 0 .25em;
}

.pane-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .6rem;
  padding-top: .55rem;
  border-top: 1px solid var(--border);
}

/* Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 40px;
  padding: .5rem .8rem;
  font: inherit;
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color .12s ease, border-color .12s ease, transform .06s ease;
}
.btn:hover { background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-sm { min-height: 34px; padding: .3rem .6rem; font-size: .8rem; }

.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:disabled:hover { background: var(--surface); }

/* Comfortable touch targets on phones and small tablets. */
@media (max-width: 819px) {
  .btn-sm { min-height: 40px; padding: .45rem .75rem; }
}

/* Swap control ----------------------------------------------------- */
.swap { display: grid; place-items: center; padding: .1rem 0; }

.swap .icon-btn {
  width: 44px;
  height: 44px;
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.swap .icon-btn:hover { background: var(--accent-soft); }
.swap svg { width: 20px; height: 20px; }
.swap .v { display: none; }

@media (min-width: 880px) {
  .swap { align-self: center; }
  .swap .h { display: none; }
  .swap .v { display: block; }
}

/* Audio bar -------------------------------------------------------- */
.audio-bar {
  margin-top: .75rem;
  padding: .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid;
  gap: .75rem;
}

@media (min-width: 880px) {
  .audio-bar { grid-template-columns: auto 1fr; align-items: center; gap: 1.25rem; }
}

/* Wraps on narrow phones (360 CSS px is common on Android) so the transport
   row can never push the page wider than the viewport. */
.audio-transport { display: flex; align-items: center; flex-wrap: wrap; gap: .4rem; }

.signal-lamp {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: none;
  margin-left: .35rem;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  transition: background-color .05s linear, box-shadow .05s linear;
}
.signal-lamp.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px 1px color-mix(in srgb, var(--accent) 55%, transparent);
}

.audio-time {
  font-family: var(--font-mono);
  font-size: .78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  margin-left: .4rem;
  white-space: nowrap;
}

.audio-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .6rem 1rem;
}

.field { display: grid; gap: .15rem; min-width: 0; }

.field-label {
  display: flex;
  justify-content: space-between;
  gap: .5rem;
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-muted);
}
.field-label output { font-variant-numeric: tabular-nums; color: var(--text); }

input[type="range"] {
  width: 100%;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
}

/* Easier to drag with a thumb. */
@media (max-width: 819px) {
  input[type="range"] { height: 34px; }
}

.privacy-note {
  display: flex;
  align-items: flex-start;
  gap: .45rem;
  margin: .7rem 0 0;
  font-size: .82rem;
  color: var(--text-muted);
}
.privacy-note svg { width: 15px; height: 15px; flex: none; margin-top: .22rem; color: var(--ok); }

/* ------------------------------------------------------------------ *
 * 7. Advertising slots
 * ------------------------------------------------------------------ */
.ad-slot {
  margin-block: clamp(1.25rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  min-height: var(--ad-h, var(--ad-h-sm));
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-faint);
  overflow: hidden;
}

.ad-slot > .ad-label {
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.ad-slot ins { display: block; width: 100%; }

@media (min-width: 768px) {
  .ad-slot { min-height: var(--ad-h-desktop, var(--ad-h-md)); }
}

.ad-slot[data-format="horizontal"] { --ad-h: 100px; --ad-h-desktop: 120px; }
.ad-slot[data-format="in-article"] { --ad-h: 280px; --ad-h-desktop: 280px; }
.ad-slot[data-format="vertical"] { --ad-h: 600px; --ad-h-desktop: 600px; }

/* ------------------------------------------------------------------ *
 * 8. Content blocks
 * ------------------------------------------------------------------ */
.prose { max-width: 72ch; }
.prose h3 { margin-top: 1.6rem; }

.grid-2 {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}
@media (min-width: 780px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  display: grid;
  gap: .85rem;
  grid-template-columns: 1fr;
}
@media (min-width: 720px) { .steps { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1050px) { .steps { grid-template-columns: repeat(4, 1fr); } }

.steps li {
  counter-increment: step;
  margin: 0;
  padding: 1rem 1rem 1.05rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-bottom: .55rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: .8rem;
  font-weight: 700;
}
.steps strong { display: block; margin-bottom: .15rem; }
.steps p { margin: 0; font-size: .92rem; color: var(--text-muted); }

/* Example cards ---------------------------------------------------- */
.examples {
  display: grid;
  gap: .75rem;
  grid-template-columns: 1fr;
  padding: 0;
  margin: 0;
  list-style: none;
}
@media (min-width: 640px) { .examples { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .examples { grid-template-columns: repeat(3, 1fr); } }

.example {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  padding: .85rem .9rem .8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.example .phrase {
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .01em;
}
.example .code {
  font-family: var(--font-mono);
  font-size: .9rem;
  letter-spacing: .05em;
  color: var(--accent);
  word-break: break-word;
  overflow-wrap: anywhere;
  margin: 0;
}
.example .example-actions { display: flex; gap: .35rem; margin-top: auto; padding-top: .35rem; }

/* Related tool cards ----------------------------------------------- */
.tool-cards {
  display: grid;
  gap: .85rem;
  grid-template-columns: 1fr;
  list-style: none;
  padding: 0;
  margin: 0;
}
@media (min-width: 640px) { .tool-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1000px) { .tool-cards { grid-template-columns: repeat(3, 1fr); } }

.tool-card {
  margin: 0;
  position: relative;
  padding: 1rem 1.05rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.tool-card h3 { margin-bottom: .3rem; font-size: 1.02rem; }
.tool-card p { margin: 0; font-size: .9rem; color: var(--text-muted); }
.tool-card a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.tool-card a { text-decoration: none; }
.tool-card:has(a):hover { border-color: var(--accent); box-shadow: var(--shadow-md); }

.tool-card .soon {
  display: inline-block;
  margin-top: .5rem;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .55rem;
}

/* ------------------------------------------------------------------ *
 * 9. Reference tables
 * ------------------------------------------------------------------ */
.chart-grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: 1fr;
}
@media (min-width: 560px) { .chart-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .chart-grid { grid-template-columns: repeat(4, 1fr); } }

.chart-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: .5rem .75rem .75rem;
  min-width: 0;
}

.chart-block table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}

.chart-block caption {
  text-align: left;
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .45rem .1rem .5rem;
}

.chart-block th, .chart-block td {
  text-align: left;
  padding: .3rem .2rem;
  border-bottom: 1px solid var(--border);
}
.chart-block tbody tr:last-child td { border-bottom: 0; }
.chart-block thead th {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
  font-weight: 700;
}
.chart-block tbody th {
  width: 3.4em;
  font-weight: 700;
  font-size: 1rem;
}
.chart-block td.code {
  font-family: var(--font-mono);
  letter-spacing: .1em;
  color: var(--accent);
  white-space: nowrap;
  overflow-wrap: anywhere;
}
.chart-block tbody tr:hover { background: var(--surface-2); }

.chart-foot { display: flex; justify-content: flex-end; padding-top: .6rem; }

/* ------------------------------------------------------------------ *
 * 10. FAQ
 * ------------------------------------------------------------------ */
.faq { display: grid; gap: .55rem; max-width: 80ch; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.faq details[open] { border-color: var(--border-strong); }

.faq summary {
  cursor: pointer;
  list-style: none;
  padding: .85rem 2.6rem .85rem 1rem;
  font-weight: 650;
  position: relative;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary:hover { background: var(--surface-2); }

.faq summary::after {
  content: "";
  position: absolute;
  right: 1.1rem;
  top: 50%;
  width: 9px;
  height: 9px;
  margin-top: -6px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform .18s ease;
}
.faq details[open] summary::after { transform: rotate(-135deg); margin-top: -2px; }

.faq .answer { padding: 0 1rem .9rem; color: var(--text-muted); }
.faq .answer > :last-child { margin-bottom: 0; }

/* ------------------------------------------------------------------ *
 * 11. Footer
 * ------------------------------------------------------------------ */
.site-footer {
  margin-top: clamp(2rem, 5vw, 3rem);
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding-block: 2rem 1.5rem;
}

.footer-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
  margin-bottom: 1.5rem;
}
@media (min-width: 600px) { .footer-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .footer-grid { grid-template-columns: 1.5fr 1fr 1fr 1fr; } }

.footer-grid h2 {
  font-size: .78rem;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .7rem;
}
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: .45rem; }
.footer-grid a { color: var(--text-muted); text-decoration: none; font-size: .93rem; }
.footer-grid a:hover { color: var(--accent); text-decoration: underline; }
.footer-about p { font-size: .9rem; color: var(--text-muted); max-width: 42ch; }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  font-size: .85rem;
  color: var(--text-faint);
  display: flex;
  flex-wrap: wrap;
  gap: .35rem 1rem;
  justify-content: space-between;
}
.footer-bottom p { margin: 0; }

/* ------------------------------------------------------------------ *
 * 12. Toast & utilities
 * ------------------------------------------------------------------ */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translateX(-50%);
  z-index: 90;
  display: grid;
  gap: .4rem;
  justify-items: center;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 2rem);
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  background: var(--text);
  color: var(--bg);
  font-size: .88rem;
  font-weight: 600;
  padding: .55rem .9rem;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  animation: toast-in .18s ease-out;
}
.toast svg { width: 15px; height: 15px; flex: none; }
.toast.is-leaving { animation: toast-out .2s ease-in forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px) scale(.98); }
}

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.breadcrumb { font-size: .85rem; color: var(--text-muted); padding-top: 1.25rem; }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: .4rem; padding: 0; margin: 0; }
.breadcrumb li { margin: 0; }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; color: var(--text-faint); }

.todo {
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  padding: .85rem 1rem;
  margin-bottom: 1.25rem;
  font-size: .92rem;
  color: var(--text);
}
.todo strong { color: var(--warn); }
.todo p:last-child { margin-bottom: 0; }

.page-head { padding-block: 1.5rem 1rem; }
.page-head p { color: var(--text-muted); max-width: 65ch; margin-bottom: 0; }
.updated { font-size: .85rem; color: var(--text-faint); }

/* ------------------------------------------------------------------ *
 * 13. Reference pages (alphabet, numbers, chart)
 * Built from the existing tokens and components — no new design system.
 * ------------------------------------------------------------------ */

/* Active page in the main navigation, tab-style on desktop and in the
   mobile drawer alike. */
.nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 650;
}

/* Interactive reference tables: same card as the homepage chart, plus an
   audio and a copy control per row. */
.chart-block td.actions { width: 1%; white-space: nowrap; padding-left: .4rem; }

.code-actions { display: flex; gap: .25rem; justify-content: flex-end; }

.btn-mini {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  flex: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.btn-mini:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.btn-mini svg { width: 14px; height: 14px; }
.btn-mini[aria-pressed="true"],
.btn-mini.is-playing {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: var(--accent);
}

@media (max-width: 819px) {
  .btn-mini { width: 38px; height: 38px; }
}

.chart-block tbody tr.is-playing { background: var(--accent-soft); }
.chart-block tbody tr[hidden] { display: none; }

/* Dots and dashes drawn as shapes, used for the number pattern. */
.sig-row { display: flex; align-items: center; gap: 5px; }
.sig { display: block; height: 8px; border-radius: 4px; background: var(--accent); flex: none; }
.sig.dot { width: 8px; }
.sig.dash { width: 24px; }

.pattern-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .4rem;
}
.pattern-list li {
  display: grid;
  grid-template-columns: 2.2rem 1fr;
  align-items: center;
  gap: .75rem;
  margin: 0;
  padding: .5rem .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pattern-num { font-weight: 700; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.pattern-list li.is-pivot { border-color: var(--accent); background: var(--accent-soft); }

/* Small search / filter toolbar above a table. */
.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
  margin-bottom: 1rem;
}

.search-field { position: relative; flex: 1 1 220px; max-width: 340px; }
.search-field input {
  width: 100%;
  min-height: 42px;
  padding: .5rem .75rem;
  font: inherit;
  font-size: .95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.search-field input::placeholder { color: var(--text-faint); }

.filter-group { display: flex; flex-wrap: wrap; gap: .3rem; }
.filter-group .btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.empty-note { color: var(--text-muted); font-size: .92rem; margin: .5rem 0 0; }
.empty-note[hidden] { display: none; }

/* Two-pane variant of the existing tool layout, used by the number converter. */
@media (min-width: 880px) {
  .panes.panes-2 { grid-template-columns: 1fr 1fr; }
}

/* Compact card grid for the homepage "Explore Morse Code" links. */
.tool-cards.is-compact .tool-card { padding: .9rem 1rem 1rem; }
.tool-cards.is-compact h3 { font-size: .98rem; margin-bottom: .25rem; }
.tool-cards.is-compact p { font-size: .88rem; margin-bottom: .5rem; }

.card-cta {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  font-size: .88rem;
  font-weight: 650;
  color: var(--accent);
  text-decoration: none;
}
.card-cta::after { content: "\2192"; }

.print-only { display: none; }

/* ------------------------------------------------------------------ *
 * 14. Print — a clean reference sheet, nothing else
 * ------------------------------------------------------------------ */
@media print {
  /* Force a printable palette regardless of the chosen theme. */
  :root, :root[data-theme="dark"], :root[data-theme="light"] {
    --bg: #fff;
    --bg-grad: none;
    --surface: #fff;
    --surface-2: #fff;
    --surface-3: #fff;
    --text: #000;
    --text-muted: #222;
    --text-faint: #444;
    --border: #bbb;
    --border-strong: #888;
    --accent: #000;
    --accent-soft: #fff;
    --shadow-sm: none;
    --shadow-md: none;
    --shadow-lg: none;
  }

  .site-header,
  .site-footer,
  .ad-slot,
  .rail,
  .toast-region,
  .breadcrumb,
  .skip-link,
  .table-toolbar,
  .code-actions,
  .no-print { display: none !important; }

  .print-only { display: block !important; }

  body { background: #fff !important; }
  .card, .chart-block { box-shadow: none !important; }
  .section { border-top: 0; padding-block: .5rem; }
  .chart-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 1rem !important; }
  .chart-block { break-inside: avoid; page-break-inside: avoid; }
  .page-head { padding-block: 0 .5rem; }

  a[href^="http"]::after { content: ""; }
}

/* ------------------------------------------------------------------ *
 * 15. Consent banner
 * Fixed to the viewport, so it never shifts page content (no CLS).
 * Built by consent.js only when a choice has not been made yet.
 * ------------------------------------------------------------------ */
.consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 95;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  padding: .9rem clamp(1rem, 4vw, 1.5rem);
  animation: consent-in .2s ease-out;
}

@keyframes consent-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.consent-inner {
  max-width: var(--shell);
  margin-inline: auto;
  display: grid;
  gap: .75rem;
}

@media (min-width: 780px) {
  .consent-inner {
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 1.5rem;
  }
}

.consent-title {
  margin: 0 0 .15rem;
  font-weight: 700;
  font-size: .95rem;
}

.consent-text {
  margin: 0;
  font-size: .87rem;
  line-height: 1.55;
  color: var(--text-muted);
  max-width: 72ch;
}

.consent-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* Both choices are equally easy to reach and equally sized, which is what
   German consent rules require — no dark patterns. */
.consent-actions .btn { flex: 1 1 auto; min-width: 120px; min-height: 44px; }

@media (min-width: 780px) {
  .consent-actions .btn { flex: 0 0 auto; }
}

/* Keep the toast clear of the banner while it is on screen. */
.has-consent-banner .toast-region { bottom: 7.5rem; }

@media print {
  .consent-banner { display: none !important; }
}

/* ------------------------------------------------------------------ *
 * 16. Practice trainer (Learn Morse Code page)
 * ------------------------------------------------------------------ */
.trainer { padding: clamp(.9rem, 2.5vw, 1.35rem); }

.trainer-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-bottom: 1rem;
}

.trainer-stat {
  text-align: center;
  padding: .55rem .35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.trainer-stat b {
  display: block;
  font-size: clamp(1.05rem, 3vw, 1.35rem);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}
.trainer-stat span {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.trainer-stage {
  text-align: center;
  padding: 1.25rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .9rem;
}

.trainer-prompt { margin: 0 0 .75rem; color: var(--text-muted); font-size: .95rem; }

/* One big, obvious box for a single character. */
.trainer-stage input {
  width: 4.5rem;
  height: 4.5rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0;
}
.trainer-stage input:disabled { opacity: .5; }

.trainer-feedback {
  min-height: 1.5rem;
  margin: .75rem 0 0;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-muted);
}
.trainer-feedback.is-correct { color: var(--ok); }
.trainer-feedback.is-wrong { color: var(--warn); }

.trainer-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
  margin-bottom: .9rem;
}

.trainer-sets {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-bottom: .9rem;
}
.trainer-sets .btn[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.trainer-speed { max-width: 260px; }

@media (max-width: 520px) {
  .trainer-stats { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------------------------------------------------------ *
 * 17. Topic pages (SOS, audio, timing)
 * ------------------------------------------------------------------ */

/* SOS hero card — the answer, large and immediate. */
.sos-card { text-align: center; padding: clamp(1.25rem, 4vw, 2rem); }

.sos-code {
  font-family: var(--font-mono);
  font-size: clamp(1.6rem, 7vw, 2.6rem);
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--accent);
  margin: 0 0 1rem;
  word-break: break-word;
}

.sos-visual { justify-content: center; margin-bottom: 1rem; }
.sos-visual .sig { height: 12px; border-radius: 6px; }
.sos-visual .sig.dot { width: 12px; }
.sos-visual .sig.dash { width: 36px; }
.sig-gap { display: block; width: 18px; flex: none; }

.sos-caption { color: var(--text-muted); font-size: .92rem; margin: 0 0 1.15rem; }

.sos-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; }
.sos-actions .btn svg { width: 15px; height: 15px; }

/* Preset phrases under the audio player. */
.preset-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
  margin-top: .75rem;
}
.preset-label {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-right: .2rem;
}

/* Timing calculator. */
.timing-card { padding: clamp(.9rem, 2.5vw, 1.35rem); }
.timing-speed { max-width: 320px; margin-bottom: 1.1rem; }

.timing-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.timing-table th, .timing-table td {
  text-align: left;
  padding: .55rem .4rem;
  border-bottom: 1px solid var(--border);
}
.timing-table tbody tr:last-child th,
.timing-table tbody tr:last-child td {
  border-bottom: 0;
  font-weight: 700;
}
.timing-table thead th {
  font-size: .7rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.timing-table tbody th { font-weight: 600; }
.timing-table td:last-child {
  font-family: var(--font-mono);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timing-table td:nth-child(2) { color: var(--text-muted); width: 4em; }

/* ------------------------------------------------------------------ *
 * 18. Language switch
 * ------------------------------------------------------------------ */
.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  height: 40px;
  padding: 0 .65rem;
  flex: none;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.lang-switch:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.lang-switch svg { width: 15px; height: 15px; flex: none; }

/* On narrow phones the flag-less globe alone is enough. */
@media (max-width: 400px) {
  .lang-switch { padding: 0 .5rem; }
  .lang-switch span, .lang-switch { font-size: 0; }
  .lang-switch svg { width: 17px; height: 17px; }
}

/* ------------------------------------------------------------------ *
 * 19. Privacy badge — the one real differentiator, made visible
 * ------------------------------------------------------------------ */
.privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: 0 0 .7rem;
  padding: .35rem .7rem .35rem .55rem;
  font-size: .8rem;
  font-weight: 650;
  line-height: 1.3;
  color: var(--ok);
  background: var(--ok-soft);
  border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  border-radius: 999px;
  text-decoration: none;
}
.privacy-badge:hover {
  color: var(--ok);
  border-color: var(--ok);
}
.privacy-badge svg { width: 14px; height: 14px; flex: none; }
.privacy-badge .more {
  color: var(--text-muted);
  font-weight: 500;
  border-left: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
  padding-left: .45rem;
  margin-left: .1rem;
}

@media (max-width: 480px) {
  .privacy-badge .more { display: none; }
}

/* ------------------------------------------------------------------ *
 * 20. Daily puzzle
 * ------------------------------------------------------------------ */
.puzzle { padding: clamp(.9rem, 2.5vw, 1.35rem); }

.puzzle-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .9rem;
}
.puzzle-number { font-weight: 700; font-variant-numeric: tabular-nums; }
.puzzle-length { font-size: .85rem; color: var(--text-muted); }

.puzzle-listen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  padding: .75rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: .9rem;
}
.puzzle-listen .field { flex: 1 1 180px; max-width: 260px; }

.puzzle-code {
  width: 100%;
  margin: .5rem 0 0;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  letter-spacing: .08em;
  color: var(--accent);
  text-align: center;
  word-break: break-word;
}
.puzzle-code[hidden] { display: none; }

.puzzle-toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  font-size: .85rem;
  color: var(--text-muted);
  cursor: pointer;
}
.puzzle-toggle input { width: 16px; height: 16px; accent-color: var(--accent); }

/* Board -------------------------------------------------------------- */
.puzzle-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), 1fr);
  gap: 6px;
  max-width: 380px;
  margin: 0 auto 1rem;
}

.tile {
  position: relative;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  font-size: clamp(1.1rem, 5vw, 1.5rem);
  font-weight: 700;
  text-transform: uppercase;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}

/* State is never signalled by colour alone — every filled tile also carries
   a distinct glyph and a different border, for colour-blind players. */
.tile[data-state]::after {
  position: absolute;
  top: 1px;
  right: 3px;
  font-size: .6rem;
  font-weight: 700;
  line-height: 1;
  opacity: .85;
}
.tile[data-state="correct"] {
  background: var(--ok);
  border-color: var(--ok);
  color: #fff;
}
.tile[data-state="correct"]::after { content: "✓"; }
.tile[data-state="present"] {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}
.tile[data-state="present"]::after { content: "●"; }
.tile[data-state="absent"] {
  background: var(--surface-3);
  border-color: var(--border-strong);
  border-style: dashed;
  color: var(--text-muted);
}
.tile[data-state="absent"]::after { content: "×"; }

/* Input -------------------------------------------------------------- */
.puzzle-form {
  display: flex;
  gap: .5rem;
  max-width: 380px;
  margin: 0 auto .75rem;
}
.puzzle-form input {
  flex: 1;
  min-width: 0;
  min-height: 46px;
  padding: .5rem .75rem;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-align: center;
  color: var(--text);
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
.puzzle-form input:disabled { opacity: .5; }

.puzzle-message {
  min-height: 1.5rem;
  margin: 0 0 .9rem;
  text-align: center;
  font-size: .92rem;
  font-weight: 600;
  color: var(--text-muted);
}
.puzzle-message.is-correct { color: var(--ok); }
.puzzle-message.is-wrong { color: var(--warn); }

.puzzle-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-bottom: .9rem;
}

.puzzle-actions { display: flex; justify-content: center; gap: .5rem; flex-wrap: wrap; }

/* Archive list */
.archive-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: .4rem;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.archive-list li { margin: 0; }
.archive-list a {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: .5rem;
  padding: .5rem .7rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-decoration: none;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.archive-list a:hover { border-color: var(--accent); color: var(--accent); }
.archive-date { font-weight: 400; font-size: .8rem; color: var(--text-muted); }
