/* Morse Lens: minimal style. Light = round 3 design 1, dark = round 3 design 2. */
:root {
  --bg: #fff;
  --card: #fff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --faint: #86868b;
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --link: #0066cc;
  --paper: #f5f5f7;
  --paper-hover: #ebebef;
  --line: #d2d2d7;
  --hair: #e8e8ed;
  --head: rgba(255, 255, 255, 0.82);
  --alert: #d70015;
  --cta-bg: #1d1d1f;
  --cta-ink: #fff;
  /* Signal trace colours, read by js/trace.js */
  --lamp: #0071e3;
  --scope-grid: rgba(0, 0, 0, 0.06);
  --scope-line: rgba(29, 29, 31, 0.35);
  --beam: 0;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #000; --card: #1d1d1f; --ink: #f5f5f7; --muted: #a1a1a6; --faint: #86868b;
    --blue: #0071e3; --blue-hover: #0077ed; --link: #2997ff;
    --paper: #161617; --paper-hover: #232325; --line: #424245; --hair: #232325;
    --head: rgba(0, 0, 0, 0.72); --alert: #ff6961; --cta-bg: #f5f5f7; --cta-ink: #000;
    --lamp: #f5f5f7; --scope-grid: rgba(255, 255, 255, 0.07); --scope-line: rgba(245, 245, 247, 0.4);
    --beam: 1; color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #000; --card: #1d1d1f; --ink: #f5f5f7; --muted: #a1a1a6; --faint: #86868b;
  --blue: #0071e3; --blue-hover: #0077ed; --link: #2997ff;
  --paper: #161617; --paper-hover: #232325; --line: #424245; --hair: #232325;
  --head: rgba(0, 0, 0, 0.72); --alert: #ff6961; --cta-bg: #f5f5f7; --cta-ink: #000;
  --lamp: #f5f5f7; --scope-grid: rgba(255, 255, 255, 0.07); --scope-line: rgba(245, 245, 247, 0.4);
  --beam: 1; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 80px; background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.5 var(--font); letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 4px; border-radius: 6px; }
img, video, canvas, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
.wrap { width: min(100% - 40px, 1080px); margin-inline: auto; }
@media (min-width: 576px) { .wrap { width: min(100% - 64px, 1080px); } }

/* Header */
.site-head { border-bottom: 1px solid var(--hair); background: var(--head); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); position: sticky; top: 0; z-index: 10; }
.site-head .wrap { height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 19px; font-weight: 650; letter-spacing: -0.04em; }
.brand-mark { display: flex; align-items: center; gap: 3px; }
.brand-mark i { width: 5px; height: 5px; border-radius: 5px; background: currentColor; }
.brand-mark i:nth-child(3) { width: 15px; }
.nav { display: flex; align-items: center; gap: 24px; font-size: 13px; }
.nav a:hover { color: var(--link); }
.nav a[aria-current='page'] { color: var(--muted); }
.nav .nav-cta { background: var(--cta-bg); color: var(--cta-ink); padding: 8px 15px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.nav .nav-cta:hover { color: var(--cta-ink); opacity: 0.85; }
.theme-toggle { appearance: none; border: 0; background: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.theme-toggle:hover { color: var(--ink); background: var(--paper); }
.theme-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-toggle .moon { display: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .theme-toggle .sun { display: none; } :root:not([data-theme='light']) .theme-toggle .moon { display: block; } }
:root[data-theme='dark'] .theme-toggle .sun { display: none; }
:root[data-theme='dark'] .theme-toggle .moon { display: block; }
@media (max-width: 860px) { .nav .nav-link { display: none; } }

/* Hero / page intro. In dark mode a beam of light runs behind the headline. */
.intro { position: relative; text-align: center; padding: 64px 0 40px; isolation: isolate; }
.display, .intro h1:not(.eyebrow) { position: relative; }
.display::before, .display::after, .intro h1:not(.eyebrow)::before, .intro h1:not(.eyebrow)::after { content: ''; position: absolute; left: 50%; transform: translateX(-50%); pointer-events: none; z-index: -1; opacity: var(--beam); transition: opacity 0.4s; }
.display::before, .intro h1:not(.eyebrow)::before { top: calc(100% + 0.18em); width: min(86vw, 1060px); height: 1px; background: linear-gradient(90deg, transparent, rgba(190, 206, 225, 0.1) 15%, rgba(221, 232, 246, 0.75) 45%, #fff 50%, rgba(221, 232, 246, 0.75) 55%, rgba(190, 206, 225, 0.1) 85%, transparent); box-shadow: 0 0 6px rgba(220, 236, 255, 0.2); }
.display::after, .intro h1:not(.eyebrow)::after { top: 10%; width: 120%; height: 120%; background: radial-gradient(ellipse at 50% 90%, rgba(220, 232, 248, 0.14), transparent 60%); }
.eyebrow { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 0 18px; letter-spacing: 0; }
.display { font-size: clamp(46px, 8.6vw, 104px); line-height: 1.035; letter-spacing: -0.062em; font-weight: 750; margin: 0 auto; max-width: 14ch; }
.display span { display: block; }
.intro h1:not(.eyebrow) { font-size: clamp(40px, 6.4vw, 72px); line-height: 1.05; letter-spacing: -0.055em; font-weight: 750; margin: 0 auto; max-width: 16ch; }
.lede { font-size: clamp(18px, 2vw, 23px); line-height: 1.45; letter-spacing: -0.02em; color: var(--muted); margin: 20px auto 0; max-width: 34ch; }
.actions { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; gap: 26px; margin-top: 28px; }
.note { font-size: 12px; color: var(--faint); margin: 14px 0 0; }

/* Buttons */
.btn { appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-size: 15px; font-weight: 500; cursor: pointer; transition: background 0.2s, border-color 0.2s, transform 0.2s; }
.btn:hover { border-color: var(--faint); }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; padding: 0 24px; }
.btn-primary:hover { background: var(--blue-hover); border-color: var(--blue-hover); transform: translateY(-1px); }
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.link { display: inline-flex; align-items: center; gap: 4px; color: var(--link); font-size: 15px; background: none; border: 0; padding: 6px 0; cursor: pointer; }
.link:hover { text-decoration: underline; }
.link::after { content: '›'; font-size: 1.2em; line-height: 1; transform: translateY(-1px); }
.is-live .when-idle, .tool:not(.is-live) .when-live { display: none; }
select.btn { padding: 0 14px; }

/* CSS iPhone (homepage) */
.product { margin: 52px auto 0; width: 300px; }
.phone { position: relative; width: 300px; height: 606px; padding: 8px; border-radius: 50px; background: linear-gradient(110deg, #8c8b88 0%, #292a2b 7%, #717271 22%, #161717 45%, #424443 88%, #93948e 97%, #262727); box-shadow: 0 0 0 1px #747572, 0 0 0 3px #d8d8d6, 0 40px 60px -40px rgba(0, 0, 0, 0.35); text-align: left; }
:root[data-theme='dark'] .phone { box-shadow: 0 0 0 1px #747572, 0 0 0 3px #3a3a3c, 0 0 80px rgba(220, 232, 248, 0.08); }
.phone .screen { height: 100%; border: 2px solid #080909; border-radius: 42px; overflow: hidden; position: relative; color: #fff; background: radial-gradient(ellipse at 55% 38%, #293132 0%, #1a2021 26%, #111617 54%, #080b0c 100%); }
.phone .screen::after { content: ''; position: absolute; inset: 58% -20% 0; background: #0c1011; clip-path: polygon(0 13%, 12% 14%, 20% 10%, 30% 8%, 42% 7%, 52% 9%, 64% 11%, 79% 13%, 92% 16%, 100% 14%, 100% 100%, 0 100%); }
.island { position: absolute; top: 11px; left: 50%; transform: translateX(-50%); width: 86px; height: 25px; border-radius: 20px; background: #030404; z-index: 2; }
.phone .bar { display: flex; justify-content: space-between; padding: 15px 26px 0; font-size: 11px; font-weight: 600; }
.phone .title { text-align: center; font-size: 12px; font-weight: 600; margin-top: 20px; }
.target { position: absolute; width: 116px; height: 116px; top: 190px; left: 50%; transform: translateX(-50%); z-index: 1; }
.target i { position: absolute; width: 18px; height: 18px; border: 2px solid rgba(255, 255, 255, 0.75); }
.target i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.target i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.target i:nth-child(3) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }
.target i:nth-child(4) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.target b { position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: #fff; box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.6), 0 0 18px 6px rgba(215, 233, 249, 0.5), 0 0 40px 12px rgba(240, 246, 255, 0.15); animation: blink 4.3s infinite; }
@keyframes blink { 0%, 7%, 15%, 22%, 35%, 49%, 70%, 82%, 100% { opacity: 0.15; } 2%, 5%, 17%, 20%, 37%, 47%, 72%, 80% { opacity: 1; } }
.phone .message { position: absolute; left: 22px; right: 22px; bottom: 74px; z-index: 1; }
.phone .message small { display: block; font-size: 9px; letter-spacing: 0.08em; color: #989e9f; margin-bottom: 10px; }
.phone .message p { margin: 0; font-size: 28px; font-weight: 600; letter-spacing: -0.03em; }
.phone .message code { display: block; margin-top: 10px; font: 12px var(--mono); letter-spacing: 0.12em; color: #b7babb; }
.phone .home { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); width: 96px; height: 4px; border-radius: 4px; background: #f1f1f1; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .target b, .placeholder .lamp { animation: none; } html { scroll-behavior: auto; } }

/* Grey band sections */
.band { background: var(--paper); padding: 80px 0; text-align: center; }
.band h2, .section-title { font-size: clamp(34px, 4.6vw, 48px); line-height: 1.08; letter-spacing: -0.045em; font-weight: 650; margin: 0; }
.band .sub { color: var(--muted); font-size: 19px; margin: 12px 0 0; }

/* Tool panel */
.tool { text-align: left; background: var(--card); border-radius: 28px; padding: 20px; display: grid; gap: 18px; }
main > .tool { border: 1px solid var(--hair); }
.band .tool { margin-top: 44px; }
.tool-main { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 20px; }
.stage { position: relative; background: #0b0d0e; border-radius: 18px; overflow: hidden; aspect-ratio: 4 / 3; max-height: 70vh; width: 100%; }
.stage video { width: 100%; height: 100%; object-fit: fill; }
.stage canvas.overlay { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: manipulation; }
.placeholder { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px; color: rgba(255, 255, 255, 0.72); font-size: 15px; }
.is-live .placeholder { display: none; }
.placeholder p { margin: 14px 0 0; max-width: 28ch; }
.placeholder .lamp { width: 8px; height: 8px; margin-inline: auto; border-radius: 50%; background: #fff; box-shadow: 0 0 8px 3px rgba(255, 255, 255, 0.6), 0 0 26px 10px rgba(215, 233, 249, 0.35); animation: blink 4.3s infinite; }

.readout { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.status { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; min-height: 20px; margin: 0; }
.status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--line); flex: none; }
.status[data-tone='ok']::before { background: #30d158; }
.status[data-tone='error'] { color: var(--alert); }
.status[data-tone='error']::before { background: var(--alert); }
.decoded { flex: 1; min-height: 150px; border-radius: 18px; background: var(--paper); padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.out-text { font-size: clamp(28px, 3.4vw, 40px); font-weight: 650; line-height: 1.1; letter-spacing: -0.035em; word-break: break-word; margin: 0; }
.out-text.is-empty::before { content: attr(data-empty); color: var(--faint); font-weight: 400; font-size: 17px; letter-spacing: -0.01em; }
.out-morse { font: 14px/1.6 var(--mono); letter-spacing: 0.08em; color: var(--muted); word-break: break-word; margin: 0; }
.out-morse .pending { color: var(--link); }
.stats { display: flex; gap: 20px; font-size: 13px; color: var(--muted); margin: 0; }
.stats div { display: flex; gap: 6px; }
.stats dt::after { content: ':'; }
.stats dd { margin: 0; color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.scope { margin: 0; background: var(--paper); border-radius: 18px; position: relative; }
.scope canvas { width: 100%; height: 76px; }
.scope figcaption { position: absolute; left: 16px; top: 10px; font-size: 11px; color: var(--faint); pointer-events: none; }
.drop { border: 1.5px dashed var(--line); border-radius: 18px; padding: 20px; text-align: center; color: var(--muted); font-size: 15px; }
.drop.is-over { border-color: var(--blue); background: rgba(0, 113, 227, 0.06); }
.drop label { color: var(--link); cursor: pointer; }
.drop label:hover { text-decoration: underline; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

/* Translator */
.translator { grid-template-columns: 1fr 1fr; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-head { min-height: 32px; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.field-head strong { color: var(--ink); font-weight: 600; }
textarea { width: 100%; min-height: 180px; resize: vertical; border: 1px solid var(--line); border-radius: 16px; background: var(--card); padding: 16px; font-size: 19px; line-height: 1.45; letter-spacing: -0.01em; }
textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.18); }
textarea.mono { background: var(--paper); border-color: transparent; font: 17px/1.6 var(--mono); letter-spacing: 0.08em; }
.range { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.range input { accent-color: var(--blue); width: 120px; }
.small-btn { min-height: 32px; padding: 0 12px; font-size: 13px; }
.flash { position: fixed; inset: 0; z-index: 50; background: #000; display: grid; place-items: end center; padding: 32px; color: #777; font-size: 14px; cursor: pointer; }
.flash.is-on { background: #fff; }

/* Tool links grid */
.tools-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 44px 32px; margin-top: 56px; text-align: center; }
.content .tools-grid a { display: flex; flex-direction: column; align-items: center; height: 100%; max-width: 280px; margin: 0 auto; color: var(--ink); text-decoration: none; }
.tools-grid span { margin-top: auto; }
.tools-grid svg { width: 38px; height: 38px; margin: 0 auto 18px; fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tools-grid h3 { font-size: 21px; font-weight: 600; letter-spacing: -0.03em; margin: 0 0 8px; }
.tools-grid p { font-size: 15px; color: var(--muted); margin: 0 0 10px; }
.tools-grid span { color: var(--link); font-size: 15px; }
.content .tools-grid a, .content .tools-grid a:hover, .content .tools-grid a:hover span { text-decoration: none; }
.tools-grid a { transition: opacity 0.2s; }
.tools-grid a:hover { opacity: 0.7; }

/* Long-form content */
.content { padding: 80px 0 24px; display: grid; gap: 64px; justify-items: center; }
.content section { width: 100%; max-width: 680px; }
.content section.wide { max-width: none; }
.content h2 { font-size: clamp(28px, 3.4vw, 36px); line-height: 1.1; letter-spacing: -0.04em; font-weight: 650; margin: 0 0 18px; }
.content p, .content li { color: var(--muted); }
.content ol, .content ul { padding-left: 1.2em; margin: 0; }
.content li + li { margin-top: 8px; }
.content a { color: var(--link); }
.content a:hover { text-decoration: underline; }
.content .tools-grid a:hover { text-decoration: none; }
details { border-bottom: 1px solid var(--hair); padding: 18px 0; }
details:first-of-type { border-top: 1px solid var(--hair); }
summary { font-weight: 600; cursor: pointer; list-style: none; display: flex; justify-content: space-between; gap: 16px; letter-spacing: -0.02em; color: var(--ink); }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; color: var(--faint); font-weight: 300; font-size: 24px; line-height: 0.9; }
details[open] summary::after { content: '−'; }
details p { margin: 10px 0 0; }

/* Alphabet chart */
.chart { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.chart button { appearance: none; border: 0; background: var(--paper); border-radius: 14px; padding: 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; text-align: left; transition: background 0.2s; }
.chart button:hover { background: var(--paper-hover); }
.chart .ch { font-size: 26px; font-weight: 650; letter-spacing: -0.03em; min-width: 1.2em; }
.chart-title { font-size: 19px; font-weight: 600; letter-spacing: -0.02em; margin: 8px 0 0; }
.morse { --dot: 7px; display: inline-flex; align-items: center; flex-wrap: nowrap; gap: calc(var(--dot) * 0.6) calc(var(--dot) * 1.6); }
.morse .l { display: inline-flex; align-items: center; gap: calc(var(--dot) * 0.5); }
.morse i { display: block; height: var(--dot); width: var(--dot); border-radius: 999px; background: var(--ink); }
.morse i.d { width: calc(var(--dot) * 3); }
.morse b.w { display: block; width: calc(var(--dot) * 1.6); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--hair); }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
td { color: var(--ink); }
td code { font-family: var(--mono); letter-spacing: 0.08em; }

/* SOS */
.sos-code { font: 600 clamp(40px, 7vw, 72px)/1 var(--mono); letter-spacing: 0.12em; text-align: center; margin: 12px 0 8px; }
.tool.center { justify-items: center; text-align: center; }

.site-foot { border-top: 1px solid var(--hair); margin-top: 80px; padding: 26px 0 36px; font-size: 12px; color: var(--faint); }
.site-foot .wrap { display: flex; justify-content: space-between; align-items: center; gap: 16px 28px; flex-wrap: wrap; }
.site-foot nav { display: flex; gap: 8px 20px; flex-wrap: wrap; }
.site-foot a:hover { color: var(--ink); }
.site-foot .brand { font-size: 14px; color: var(--muted); }
.site-foot .brand-mark i { width: 3px; height: 3px; }
.site-foot .brand-mark i:nth-child(3) { width: 9px; }

@media (max-width: 880px) {
  .tool-main, .translator { grid-template-columns: 1fr; }
  .tool { padding: 14px; border-radius: 22px; }
  .intro { padding: 44px 0 28px; }
  .band { padding: 60px 0; }
  .decoded { min-height: 110px; }
}
