/* Check One Two: dark theme carried over from the original site (cyan accent on near-black). */
:root {
  color-scheme: dark;
  --bg: #1a1a1a;
  --surface: #212121;
  --surface-2: #2a2a2a;
  --border: #333;
  --fg: #fafafa;
  --muted: #a3a3a3;
  --primary: #00bfff;
  --primary-hover: #33ccff;
  --on-primary: #06141a;   /* dark text on cyan: white on #00bfff fails contrast */
  --danger: #b42318;
  --danger-hover: #c9372c;
  --ok: #22c55e;
  --warn: #eab308;
  --radius: .6rem;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--fg); font-family: var(--font); line-height: 1.6; }
main { flex: 1; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
h1, h2, h3 { line-height: 1.25; }
h1, h2 { color: var(--primary); }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }

.container { width: 100%; max-width: 64rem; margin: 0 auto; padding: 1.5rem 1rem 3rem; }

/* --- Header / footer --- */
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; max-width: 64rem; width: 100%; margin: 0 auto; padding: .75rem 1rem; }
.brand { display: inline-flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; color: var(--fg); text-decoration: none; }
.brand img { filter: invert(1); }  /* logo is black line art */
.brand:hover { color: var(--primary); }
.site-header nav, .site-footer nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--primary); }

.site-footer { border-top: 1px solid var(--border); padding: 1.25rem 1rem; color: var(--muted); font-size: .9rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--primary); }

/* --- Content --- */
.hero { text-align: center; margin: 1rem 0 2rem; }
.hero h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); margin: 0 0 .25rem; }
.hero p { margin: 0; color: var(--muted); }

.prose { max-width: 56rem; margin: 2.5rem auto; }
.prose p, .prose li { color: var(--muted); }
.prose h3 { color: var(--fg); font-size: 1.1rem; margin: 0 0 .5rem; }
.howto-grid { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); }
.howto-grid ol { margin: 0; padding-left: 1.25rem; }
.howto-grid li + li { margin-top: .35rem; }

.faq details { border-bottom: 1px solid var(--border); padding: .75rem 0; }
.faq summary { cursor: pointer; font-weight: 600; color: var(--fg); }
.faq summary:hover { color: var(--primary); }
.faq details p { margin: .5rem 0 0; }

.not-found { text-align: center; }
.not-found h1 { font-size: 4rem; margin-bottom: 0; }

/* --- Audio tools (light-DOM custom elements: tone-generator, input-meter, pitch-tuner) --- */
tone-generator, input-meter, pitch-tuner { display: block; }
.tools { display: grid; gap: 1.5rem; }
.tools-pair { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); }
.tool { display: flex; flex-direction: column; gap: .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
.tool h2 { margin: 0; font-size: 1.4rem; }
.tool-lead { margin: 0; color: var(--muted); }
.tool-field { display: flex; flex-direction: column; gap: .35rem; font-size: .9rem; }
.tool select, .tool input[type=range] { width: 100%; font: inherit; }
.tool select { padding: .5rem; border: 1px solid var(--border); border-radius: .4rem; background: var(--bg); color: var(--fg); }
.tool input[type=range] { accent-color: var(--primary); }
.tool-action { margin-top: auto; padding: .7rem 1rem; font: inherit; font-weight: 600; border: 0; border-radius: .5rem; background: var(--primary); color: var(--on-primary); cursor: pointer; }
.tool-action:hover { background: var(--primary-hover); }
.tool-action:disabled { opacity: .6; cursor: wait; }
.tool-action.is-active { background: var(--danger); color: #fff; }
.tool-action.is-active:hover { background: var(--danger-hover); }
.tool-status { margin: 0; font-size: .9rem; font-family: var(--mono); padding: .4rem .6rem; border-radius: .4rem; background: var(--surface-2); color: var(--muted); }
.tool-status[data-tone=ok] { color: var(--ok); }
.tool-status[data-tone=error] { color: #f97066; }

/* Tone generator */
.tone-body { display: flex; gap: 1.25rem; }
.tone-volume { display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: .75rem .5rem; border-radius: .5rem; background: var(--surface-2); font-size: .85rem; }
.tone-volume input[type=range] { writing-mode: vertical-lr; direction: rtl; width: auto; height: 11rem; }
.tone-volume output { font-family: var(--mono); }
.tone-controls { flex: 1; display: flex; flex-direction: column; gap: .9rem; min-width: 0; }
.tone-controls output { font-family: var(--mono); }
.tone-notes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .35rem; }
@media (max-width: 30rem) { .tone-notes { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.tone-notes button { padding: .5rem 0; font: inherit; font-size: .85rem; font-weight: 600; border: 1px solid var(--border); border-radius: .4rem; background: var(--bg); color: var(--fg); cursor: pointer; }
.tone-notes button:hover { border-color: var(--primary); }
.tone-notes button[aria-pressed=true] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }

/* Input meter */
.meter { --level: 0; --peak: 0; position: relative; height: 1.1rem; border-radius: .4rem; background: var(--surface-2); overflow: hidden; }
.meter-fill { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--level)); will-change: transform;
  background: linear-gradient(to right, var(--ok) 0 66%, var(--warn) 66% 90%, #ef4444 90%); }
.meter-peak { position: absolute; top: 0; bottom: 0; width: 2px; left: calc(var(--peak) * 100% - 2px); background: var(--fg); opacity: .8; }
.meter-scale { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: -.5rem; font-family: var(--mono); }
.meter-readout { margin: 0; text-align: right; font-family: var(--mono); font-size: .9rem; }

/* Pitch tuner */
.tuner-status { display: flex; justify-content: space-between; gap: 1rem; }
.tuner[data-tune=in] [data-cents] { color: var(--ok); font-weight: 600; }
.tuner-dial { position: relative; max-width: 32rem; width: 100%; margin: 0 auto; padding-top: 1.6rem; }
.tuner-dial svg { display: block; width: 100%; height: auto; }
.tuner-hint { position: absolute; top: 0; left: 0; right: 0; margin: 0; text-align: center; font-size: .85rem; color: var(--muted); min-height: 1.2em; }
.tuner-arc { fill: none; stroke: var(--border); stroke-width: 4; }
.tuner-ticks line { stroke: #555; stroke-width: 2; }
.tuner-ticks .tick-center { stroke: var(--primary); stroke-width: 3; }
.tuner-note, .tuner-freq { paint-order: stroke; stroke: var(--surface); stroke-width: 6px; stroke-linejoin: round; }
.tuner-note { font-size: 28px; font-weight: 700; fill: var(--fg); }
.tuner-octave { font-size: 12px; font-weight: 600; fill: var(--muted); }
.tuner-freq { font-size: 7px; fill: var(--muted); font-family: var(--mono); }
.tuner-needle line { stroke: var(--primary); stroke-width: 2; }
.tuner-needle polygon { fill: var(--primary); }
.tuner[data-tune=in] .tuner-needle line { stroke: var(--ok); }
.tuner[data-tune=in] .tuner-needle polygon { fill: var(--ok); }
.tuner-hub { fill: var(--bg); stroke: var(--border); }

/* --- Ads --- */
/* AdKit wraps creatives in a light frame via inline styles. Our creatives are styled for a dark,
   transparent container (as on the old site), so blend the frame and label into the theme. */
.ad-slot { max-width: 48rem; width: 100%; margin: 0 auto; }
.ad-slot[hidden] { display: none; }
.ad-slot .adkit-ad { background: transparent !important; border-color: var(--border) !important; }
.ad-slot .adkit-label { background: transparent !important; border-color: var(--border) !important; color: var(--muted) !important; }

/* --- Audio News --- */
.news-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 1.5rem; }
.news-head h1 { margin: .5rem 0; }
.news-grid { display: grid; gap: 1.25rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr)); }
.news-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; content-visibility: auto; contain-intrinsic-size: auto 14rem; }
.news-card:hover { border-color: var(--primary); }
.news-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: .8rem; color: var(--muted); }
.news-source { font-weight: 600; color: var(--primary); }
.news-card h2 { font-size: 1.05rem; line-height: 1.35; margin: .6rem 0; color: var(--fg); }
.news-card h2 a { color: inherit; text-decoration: none; }
.news-card h2 a:hover { color: var(--primary); }
.news-card p { margin: 0; color: var(--muted); font-size: .95rem; line-height: 1.5; }
.news-empty, .news-updated { color: var(--muted); }
.news-updated { font-size: .85rem; margin-top: 1.5rem; }
.news-sentinel { height: 1px; }

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