:root {
  --amber: #FFB347;
  --amber-deep: #E59324;
  --amber-light: #FFD27A;
  --ink: #1a140b;
  --ink-soft: #5c5344;
  --bg: #ffffff;
  --bg-soft: #fdf8f0;
  --bg-warm: #fff6e6;
  --card: #ffffff;
  --border: rgba(26, 20, 11, 0.08);
  --glyph: #E59324;
  --thumb: #ffffff;
  --shadow-amber: 0 18px 44px -18px rgba(229, 147, 36, 0.55);
  --radius: 22px;
  --maxw: 1080px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f7f1e6; --ink-soft: #b3aa99; --bg: #0e0b07; --bg-soft: #16110a;
    --bg-warm: #1c1509; --card: #1a1510; --border: rgba(255,255,255,0.09); --glyph: #FFC46B; --thumb: #2b2419;
  }
}
:root[data-theme="dark"] {
  --ink: #f7f1e6; --ink-soft: #b3aa99; --bg: #0e0b07; --bg-soft: #16110a;
  --bg-warm: #1c1509; --card: #1a1510; --border: rgba(255,255,255,0.09); --glyph: #FFC46B; --thumb: #2b2419;
}
:root[data-theme="light"] {
  --ink: #1a140b; --ink-soft: #5c5344; --bg: #ffffff; --bg-soft: #fdf8f0;
  --bg-warm: #fff6e6; --card: #ffffff; --border: rgba(26,20,11,0.08); --glyph: #E59324; --thumb: #ffffff;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg); line-height: 1.6; -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===== Header ===== */
.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: saturate(180%) blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 21px; letter-spacing: -0.02em; }
.brand img { width: 32px; height: 32px; border-radius: 9px; }
.brand .mors { background: linear-gradient(135deg, var(--amber-light), var(--amber-deep)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.nav-right { display: flex; align-items: center; gap: 12px; }
.lang-select {
  appearance: none; border: 1px solid var(--border); background: var(--bg-soft);
  color: var(--ink); border-radius: 999px; padding: 8px 32px 8px 14px; font-size: 14px; font-weight: 600;
  font-family: inherit; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235c5344' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
/* the arrow is a data URI, so the theme swap needs its own rule */
@media (prefers-color-scheme: dark) {
  .lang-select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b3aa99' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>"); }
}
:root[data-theme="dark"] .lang-select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23b3aa99' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>"); }
[dir="rtl"] .lang-select { padding: 8px 14px 8px 32px; background-position: left 12px center; }

/* ===== App Store badge ===== */
.appstore-badge {
  display: inline-flex; align-items: center; gap: 11px;
  background: #000; color: #fff; border-radius: 13px; padding: 10px 18px;
  transition: transform .15s ease, box-shadow .2s ease; border: 1px solid rgba(255,255,255,0.16);
}
.appstore-badge:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -12px rgba(0,0,0,0.5); }
.appstore-badge svg { width: 26px; height: 26px; flex: none; }
.appstore-badge .txt { display: flex; flex-direction: column; line-height: 1.05; text-align: start; }
.appstore-badge .small { font-size: 11px; font-weight: 500; opacity: 0.92; }
.appstore-badge .big { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; margin-top: 1px; }
.appstore-badge.sm { padding: 7px 13px; border-radius: 10px; }
.appstore-badge.sm svg { width: 19px; height: 19px; }
.appstore-badge.sm .small { font-size: 8.5px; }
.appstore-badge.sm .big { font-size: 15px; }

/* ===== Hero: compact, tool sits high ===== */
.hero { text-align: center; padding: 34px 0 26px; position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -30% 0 auto 0; height: 460px;
  background: radial-gradient(ellipse 55% 60% at 50% 0%, rgba(255,179,71,0.20), transparent 70%);
  z-index: -1;
}
h1 { font-size: clamp(30px, 5vw, 50px); font-weight: 900; line-height: 1.06; letter-spacing: -0.025em; text-wrap: balance; max-width: 780px; margin: 0 auto; }
h1 .hl { background: linear-gradient(135deg, var(--amber-light), var(--amber-deep)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero-cta { display: flex; justify-content: center; margin-top: 26px; }
.social { margin-top: 14px; font-size: 13.5px; color: var(--ink-soft); display: flex; gap: 8px; align-items: center; justify-content: center; }
.social .stars { color: var(--amber-deep); letter-spacing: 1px; }

/* ===== Avatar Morse animation: soft glow, no ring ===== */
.morse-convo { position: relative; height: 104px; max-width: 440px; margin: 18px auto 20px; }
.mc-avatar {
  position: absolute; top: 50%; width: 66px; height: 66px; border-radius: 50%;
  object-fit: cover; transform: translateY(-50%); z-index: 2;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,0.35);
  transition: transform .3s cubic-bezier(.2,1.2,.5,1), box-shadow .35s ease;
}
.mc-avatar.left { left: 4px; }
.mc-avatar.right { right: 4px; }
.mc-avatar.speaking {
  transform: translateY(-50%) scale(1.04);
  box-shadow: 0 0 20px 1px color-mix(in srgb, var(--amber) 26%, transparent), 0 6px 18px -8px rgba(0,0,0,0.35);
}
.mc-beat {
  position: absolute; top: 50%; transform: translate(-50%, -50%); z-index: 1;
  background: var(--amber); box-shadow: 0 0 8px 1px color-mix(in srgb, var(--amber) 65%, transparent);
  will-change: left, opacity;
}
.mc-beat.dot { width: 9px; height: 9px; border-radius: 50%; }
.mc-beat.dash { width: 24px; height: 8px; border-radius: 999px; }

/* ===== Translator ===== */
.tool { margin: 0 auto; max-width: 700px; }
.tool-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 30px 60px -34px rgba(26,20,11,0.3); overflow: hidden; text-align: start; }
.tool-seg {
  display: flex; gap: 4px; margin: 12px 14px 0; padding: 4px;
  background: var(--bg-soft); border: 1px solid var(--border); border-radius: 13px;
}
.tool-seg button {
  flex: 1; font-family: inherit; font-weight: 700; font-size: 13.5px; padding: 9px 8px; border: none;
  cursor: pointer; background: transparent; color: var(--ink-soft); border-radius: 9px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.tool-seg button:hover { color: var(--ink); }
.tool-seg button.active {
  background: var(--thumb); color: var(--ink);
  box-shadow: 0 1px 3px rgba(26,20,11,.16), 0 0 0 1px rgba(26,20,11,.05);
}
.field-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .7px; color: var(--ink-soft); padding: 15px 20px 6px; }
.tool-io textarea {
  width: 100%; border: none; resize: none; min-height: 60px; padding: 0 20px 12px;
  font-family: inherit; font-size: 19px; font-weight: 600; background: transparent; color: var(--ink);
  outline: none; line-height: 1.45;
}
.tool-io textarea::placeholder { color: var(--ink-soft); opacity: .48; font-weight: 500; }
.tool-divider { height: 1px; background: var(--border); }

/* Morse glyph row */
.morse-out {
  min-height: 66px; padding: 8px 20px 14px;
  display: flex; flex-wrap: wrap; align-items: center; align-content: center; gap: 12px 0;
}
.morse-out .letter { display: inline-flex; align-items: center; gap: 5px; margin-inline-end: 13px; }
.morse-out .space { width: 16px; height: 1px; }
.g-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--glyph); flex: none; transition: transform .12s, box-shadow .12s, background .12s; }
.g-dash { width: 23px; height: 9px; border-radius: 999px; background: var(--glyph); flex: none; transition: transform .12s, box-shadow .12s, background .12s; }
.g-dot.lit, .g-dash.lit { background: var(--amber); box-shadow: 0 0 11px 2px color-mix(in srgb, var(--amber) 75%, transparent); transform: scale(1.3); }
.text-out { min-height: 60px; padding: 8px 20px 14px; font-size: 19px; font-weight: 600; color: var(--ink); word-break: break-word; display: flex; align-items: center; }
.out-empty { color: var(--ink-soft); opacity: .45; font-weight: 500; font-size: 15px; }
.tool-actions { display: flex; gap: 8px; padding: 12px 16px 15px; flex-wrap: wrap; align-items: center; border-top: 1px solid var(--border); }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-family: inherit; font-weight: 700; font-size: 13.5px;
  border: 1px solid var(--border); background: var(--bg-soft); color: var(--ink); border-radius: 999px;
  padding: 9px 15px; cursor: pointer; transition: background .15s, transform .1s;
}
.chip:hover { background: var(--bg-warm); }
.chip:active { transform: scale(0.96); }
.chip[disabled] { opacity: .4; pointer-events: none; }
.chip.play { background: linear-gradient(135deg, var(--amber), var(--amber-deep)); color: #1a140b; border: none; }
.chip.play.playing { background: var(--bg-soft); color: var(--ink); border: 1px solid var(--border); }
.chip .ico { font-size: 14px; line-height: 1; }
.chip.copied-flash { background: linear-gradient(135deg, var(--amber), var(--amber-deep)); color: #1a140b; border-color: transparent; }

/* ===== Sections ===== */
section.block { padding: 58px 0; }
section.block.alt { background: var(--bg-soft); }
.sec-head { text-align: center; max-width: 640px; margin: 0 auto 40px; }
.sec-head h2 { font-size: clamp(25px, 3.8vw, 36px); font-weight: 900; letter-spacing: -0.015em; text-wrap: balance; }
.sec-head p { color: var(--ink-soft); margin-top: 12px; font-size: 16.5px; text-wrap: pretty; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.feature { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; }
.feature .ic {
  width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; margin-bottom: 16px;
  background: linear-gradient(135deg, var(--amber), var(--amber-deep)); color: #1a140b;
  box-shadow: 0 8px 18px -10px rgba(229,147,36,.75);
}
.feature .ic svg { width: 25px; height: 25px; }
.feature h3 { font-size: 17.5px; font-weight: 800; margin-bottom: 8px; letter-spacing: -0.01em; }
.feature p { color: var(--ink-soft); font-size: 15px; }

/* ===== Alphabet: glyphs must never overflow ===== */
.alpha { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.alpha .cell { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 13px 10px; text-align: center; overflow: hidden; }
.alpha .cell .ch { font-size: 19px; font-weight: 900; line-height: 1.1; }
.alpha .cell .glyphs { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 3px; margin-top: 9px; min-height: 8px; }
.alpha .cell .glyphs .d1 { width: 5px; height: 5px; border-radius: 50%; background: var(--glyph); flex: none; }
.alpha .cell .glyphs .d3 { width: 12px; height: 5px; border-radius: 999px; background: var(--glyph); flex: none; }

/* ===== FAQ ===== */
.faq { max-width: 720px; margin: 0 auto; }
.faq details { border: 1px solid var(--border); border-radius: 16px; padding: 4px 20px; margin-bottom: 12px; background: var(--card); }
.faq summary { font-weight: 800; font-size: 16.5px; padding: 16px 0; cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-size: 24px; color: var(--amber-deep); font-weight: 400; flex: none; }
.faq details[open] summary::after { content: "\2013"; }
.faq details p { color: var(--ink-soft); padding: 0 0 18px; font-size: 15px; }

/* ===== CTA band ===== */
.cta-band { text-align: center; }
.cta-band .inner { background: linear-gradient(135deg, var(--amber), var(--amber-deep)); border-radius: 30px; padding: 52px 30px; }
.cta-band h2 { color: #1a140b; font-size: clamp(25px, 3.8vw, 38px); font-weight: 900; text-wrap: balance; }
.cta-band p { color: rgba(26,20,11,0.72); margin: 12px auto 24px; max-width: 480px; font-weight: 500; }
.cta-band .appstore-badge { background: #1a140b; }

/* ===== Footer ===== */
footer { border-top: 1px solid var(--border); padding: 38px 0; background: var(--bg-soft); }
footer .wrap { display: flex; flex-wrap: wrap; gap: 20px; justify-content: space-between; align-items: center; }
footer .links { display: flex; gap: 20px; flex-wrap: wrap; font-size: 14px; color: var(--ink-soft); }
footer .copy { font-size: 13px; color: var(--ink-soft); }
.langs { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 18px; font-size: 14px; }
.langs a { color: var(--ink-soft); }
.langs a:hover { color: var(--amber-deep); }
:focus-visible { outline: 2px solid var(--amber-deep); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 640px) {
  .hero { padding: 24px 0 20px; }
  section.block { padding: 42px 0; }
  .nav-right .appstore-badge { display: none; }
  .morse-convo { max-width: 320px; height: 92px; }
  .mc-avatar { width: 56px; height: 56px; }
  .alpha { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
}

/* ===== Content pages ===== */
.page-hero { text-align: center; padding: 30px 0 8px; position: relative; }
.page-hero h1 { font-size: clamp(28px, 4.4vw, 44px); margin-bottom: 12px; }
.page-hero .lede { color: var(--ink-soft); font-size: 17.5px; max-width: 620px; margin: 0 auto; text-wrap: pretty; }
.crumbs { font-size: 13px; color: var(--ink-soft); padding: 14px 0 0; }
.crumbs a:hover { color: var(--amber-deep); }
.crumbs span { opacity: .5; margin: 0 6px; }

.prose { max-width: 720px; margin: 0 auto; }
.prose h2 { font-size: clamp(21px, 2.8vw, 27px); font-weight: 900; letter-spacing: -0.015em; margin: 40px 0 12px; text-wrap: balance; }
.prose h3 { font-size: 18px; font-weight: 800; margin: 26px 0 8px; }
.prose p { color: var(--ink-soft); font-size: 16.5px; margin-bottom: 14px; }
.prose ul, .prose ol { color: var(--ink-soft); font-size: 16.5px; margin: 0 0 16px; padding-inline-start: 22px; }
.prose li { margin-bottom: 8px; }
.prose li::marker { color: var(--amber-deep); font-weight: 700; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose .note {
  background: var(--bg-warm); border: 1px solid var(--border); border-radius: 16px;
  padding: 18px 20px; margin: 22px 0;
}
.prose .note p:last-child { margin-bottom: 0; }

.timing-table { width: 100%; border-collapse: collapse; margin: 6px 0 20px; font-size: 15.5px; }
.timing-table th, .timing-table td { text-align: start; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.timing-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .6px; color: var(--ink-soft); font-weight: 800; }
.timing-table td:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-scroll { overflow-x: auto; }
.mono-morse { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--amber-deep); font-weight: 700; letter-spacing: 1px; }

.related { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.related a {
  display: block; background: var(--card); border: 1px solid var(--border); border-radius: 18px;
  padding: 20px; transition: transform .15s ease, border-color .15s ease;
}
.related a:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--amber) 55%, transparent); }
.related .rt { font-weight: 800; font-size: 16px; margin-bottom: 5px; }
.related .rd { color: var(--ink-soft); font-size: 14px; }

.inline-cta { text-align: center; margin: 34px 0 8px; }
.inline-cta .hint { color: var(--ink-soft); font-size: 14.5px; margin-top: 10px; }
