/* Havencast — Hi-Fi Console
 * Dark, premium audio-equipment aesthetic: tube-amp glow, amber VFD readouts,
 * tactile recessed preset pads. Prototype UI (Phase 5 web UI, US-07 PWA).
 * No CDN; fonts are a characterful system stack pending a vendored display face. */

:root {
  /* Panel blacks — layered, slightly warm */
  --void: #0b1020;
  --panel: #141c2f;
  --panel-2: #1b2740;
  --panel-3: #0f172a; /* deepest panel — the bottom of the speaker-module gradient */
  --panel-edge: #2d3b57;
  --hairline: rgba(255, 255, 255, 0.06);

  /* Tube-amp amber (the signature accent) */
  --amber: #f28c72;
  --amber-bright: #ffb09b;
  --amber-dim: #a75e4b;
  --amber-glow: rgba(242, 140, 114, 0.48);

  /* Cool cyan — "online / playing" status */
  --cyan: #74d8c3;
  --cyan-glow: rgba(116, 216, 195, 0.42);

  /* Ink. --ink-3 lifted from #6b7480 (~4.2:1) to clear WCAG AA 4.5:1 on the dark surfaces. */
  --ink: #f1f4fb;
  --ink-2: #b4bfd1;
  --ink-3: #8996ad;
  --red: #f06b62;

  /* accent-text is the amber used as TEXT (links, active tab, headings). Separated from --amber
     (button/glow fills) so the light theme can darken it for contrast without dulling the fills. */
  --accent-text: var(--amber);
  /* Page background washes (overridable per theme). */
  --bg-wash-1: rgba(242, 140, 114, 0.10);
  --bg-wash-2: rgba(116, 216, 195, 0.05);
  --grain-opacity: 0.035;
  --bar-bg: rgba(12, 13, 16, 0.72); /* bottom tab bar — flat translucent over the blur */

  --radius: 16px;
  --radius-sm: 10px;
  --pad: clamp(16px, 5vw, 24px);

  --display: "Futura", "Avenir Next", "Century Gothic", "Trebuchet MS", sans-serif;
  --body: "Avenir Next", "Segoe UI", Roboto, Helvetica, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;
}

/* ---------- Light theme ----------
 * Havencast's aesthetic is a hi-fi console: the SPEAKER cards/VFD/preset pads are physical "device"
 * hardware and stay dark in both themes (like a car dashboard). The light theme flips the app CHROME
 * — page, cards, text, nav, forms — and darkens the amber/cyan used as TEXT so they clear WCAG AA on
 * a light background. The device modules are re-asserted dark at the end of this block. */
:root[data-theme="light"] {
  --void: #eceef1;
  --panel: #ffffff;
  --panel-2: #f6f7f9;
  --panel-3: #e8eaef; /* subtle light depth (was a hardcoded near-black in the module gradient) */
  --panel-edge: #d2d7de;
  --hairline: rgba(0, 0, 0, 0.06);

  --ink: #1b1e23;
  --ink-2: #475059;
  --ink-3: #626b75;          /* dark grey on light: ~5.8:1 */

  --accent-text: #8a5712;    /* darkened amber for text on light (~5.2:1) */
  --cyan: #0b8d7e;           /* darkened cyan for text/borders on light */
  --cyan-glow: rgba(11, 141, 126, 0.25);
  --amber-glow: rgba(231, 161, 61, 0.30);
  --red: #c03521;

  --bg-wash-1: rgba(231, 161, 61, 0.10);
  --bg-wash-2: rgba(11, 141, 126, 0.06);
  --grain-opacity: 0;        /* the film grain reads as dirt on a light surface */
  --bar-bg: rgba(248, 249, 251, 0.82);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--void);
  /* atmospheric depth: warm radial pool top, cool fade bottom */
  background-image:
    radial-gradient(120% 80% at 50% -10%, var(--bg-wash-1), transparent 60%),
    radial-gradient(100% 60% at 50% 120%, var(--bg-wash-2), transparent 60%);
  background-attachment: fixed;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Fine film grain over everything for analogue texture */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* The "device" shell — a phone-width console */
.shell {
  width: min(440px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  /* Keep the final content clear of the fixed tab bar. The bar is taller on
     devices with a home indicator, so leave room for both the controls and
     the safe-area inset. */
  padding: 0 0 calc(136px + env(safe-area-inset-bottom));
  position: relative;
}

/* The same console language scales to desktop: retain the compact phone rhythm on small screens,
   then give account/device management room to breathe on tablets and wide browsers. */
@media (min-width: 760px) {
  /* Keep the console intentionally narrower than the viewport. A fixed
     reading width makes account, support and device pages feel like one
     product instead of stretched forms on a large monitor. */
  .shell { width: min(960px, 100%); padding-top: 62px; padding-bottom: 64px; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .modules { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 18px 24px 0; gap: 20px; }
  .modules .module { min-width: 0; }
  .group-card { margin-left: 24px; margin-right: 24px; }
  .subhead { padding-left: 24px; }
}

@media (min-width: 1040px) {
  .account-shell > .group-card { max-width: 100%; }
  .account-shell .group-card { padding: 22px; }
}

/* ---------- Top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) var(--pad) 14px;
  background: linear-gradient(180deg, var(--void) 60%, transparent);
}

.wordmark {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: 0.34em;
  font-size: 15px;
  text-transform: uppercase;
  color: var(--ink);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.wordmark .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 10px 1px var(--amber-glow);
}
.topbar .actions { display: flex; gap: 8px; }

.iconbtn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--panel-edge);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  color: var(--ink-2);
  text-decoration: none;
  font-size: 16px;
  cursor: pointer;
}
.iconbtn:active { transform: translateY(1px); }

/* Visible sign-out in the top bar (the account gear also has one, but it was undiscoverable). */
.topbar .actions .signout {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
  padding: 0 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
}
.topbar .actions .signout:hover { color: var(--accent-text); border-color: var(--accent-text); }
.topbar .actions .signout:active { transform: translateY(1px); }

.subhead {
  padding: 0 var(--pad) 6px;
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.section-label { margin-top: 22px; }
.account-overview {
  margin: 10px var(--pad) 0;
  padding: 20px;
  border: 1px solid var(--panel-edge);
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--panel-2), var(--panel));
  box-shadow: inset 0 1px 0 var(--hairline), 0 16px 36px -28px rgba(0,0,0,.8);
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
}
.account-overview h1 { margin: 7px 0 6px; font-family: var(--display); font-size: clamp(20px, 3vw, 28px); letter-spacing: .02em; }
.account-overview p { margin: 0; max-width: 58ch; color: var(--ink-2); font-size: 13px; line-height: 1.5; }
.eyebrow { color: var(--accent-text); font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; }
.overview-actions { display: flex; flex-wrap: wrap; gap: 8px; flex: 0 0 auto; }
@media (max-width: 620px) { .account-overview { align-items: stretch; flex-direction: column; gap: 16px; } .overview-actions .btn { flex: 1; } }
@media (min-width: 760px) { .account-overview { margin-left: 24px; margin-right: 24px; padding: 26px 28px; } }

/* ---------- Speaker module (rack-unit card) ---------- */
.modules { display: flex; flex-direction: column; gap: 18px; padding: 10px var(--pad) 0; }

.module {
  position: relative;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--panel-2), var(--panel) 55%, var(--panel-3));
  border: 1px solid var(--panel-edge);
  /* top hairline highlight + deep drop shadow = machined panel */
  box-shadow:
    inset 0 1px 0 var(--hairline),
    0 1px 0 rgba(0,0,0,0.6),
    0 18px 40px -22px rgba(0,0,0,0.9);
  padding: 16px;
  overflow: hidden;
  animation: rise 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.modules .module:nth-child(2) { animation-delay: 0.06s; }
.modules .module:nth-child(3) { animation-delay: 0.12s; }
.modules .module:nth-child(4) { animation-delay: 0.18s; }

/* the playing module gets a warm glow bleed from the top-right */
.module.is-playing::before {
  content: "";
  position: absolute;
  top: -40%; right: -30%;
  width: 70%; height: 90%;
  background: radial-gradient(circle, var(--amber-glow), transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}

.module-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
  position: relative;
}
.module-name {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-size: 18px;
  display: inline-flex; align-items: center; gap: 11px;
  color: var(--ink);
  text-decoration: none;
}
/* the name is the link into the device — a trailing chevron marks the row as tappable */
.module-name::after {
  content: "\203A";
  font-family: var(--body); font-weight: 400; font-size: 20px; line-height: 1;
  color: var(--ink-3); margin-left: 1px;
  transition: transform 0.12s ease, color 0.12s ease;
}
.module-name:hover { color: var(--accent-text); }
.module-name:hover::after { color: var(--accent-text); transform: translateX(2px); }

/* device identity glyph — a little speaker driver (cone + dust cap), in place of the old
   accent bar. It is "hardware": fixed dark surfaces in both themes (a black cone on a white
   unit in light mode). The dust cap glows amber when the speaker is playing. */
.dev-ico {
  width: 24px; height: 24px; flex: 0 0 auto; border-radius: 50%;
  background: radial-gradient(circle at 50% 42%, #23272e, #0b0d10 65%);
  border: 1px solid var(--panel-edge);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.6);
  position: relative;
}
.dev-ico::after {
  content: ""; position: absolute; inset: 33%; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #444b54, #181b20);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.10);
}
.module.is-playing .dev-ico::after {
  background: radial-gradient(circle at 50% 38%, var(--amber-bright), #6e4a17);
  box-shadow: 0 0 8px -1px var(--amber-glow);
}

/* Standby/empty modules are quieter — a flat panel, no gradient, a dimmer driver. */
.module.is-standby { background: var(--panel); }
.module.is-standby .dev-ico { opacity: 0.7; }

/* a gentle lift signals the card is interactive (desktop; touch ignores hover) */
.module { transition: transform 0.14s ease; }
.module:hover { transform: translateY(-1px); }

/* ---------- Empty state — get-started panel ---------- */
.module.empty-state {
  text-align: center;
  padding: 34px 24px 30px;
  display: flex; flex-direction: column; align-items: center;
}
.module.empty-state:hover { transform: none; }
/* a larger speaker driver with a soft amber halo behind it — inviting, not a dead screen */
.es-ico {
  width: 64px; height: 64px; border-radius: 50%; position: relative;
  margin-bottom: 18px;
  background: radial-gradient(circle at 50% 42%, #23272e, #0b0d10 65%);
  border: 1px solid var(--panel-edge);
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.6);
}
.es-ico::before {
  content: ""; position: absolute; inset: -16px; border-radius: 50%; z-index: -1;
  background: radial-gradient(circle, var(--amber-glow), transparent 70%);
  opacity: 0.5;
}
.es-ico::after {
  content: ""; position: absolute; inset: 32%; border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, #444b54, #181b20);
  box-shadow: inset 0 1px 1px rgba(255,255,255,0.10);
}
.es-title {
  font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: 0.04em;
  color: var(--ink); margin: 0 0 8px;
}
.es-text {
  font-size: 13px; line-height: 1.5; color: var(--ink-2);
  max-width: 32ch; margin: 0 0 20px;
}

.status {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3);
  display: inline-flex; align-items: center; gap: 7px;
}
.led { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.status.online .led { background: var(--cyan); box-shadow: 0 0 10px 1px var(--cyan-glow); animation: pulse 2.6s ease-in-out infinite; }
.status.online { color: var(--cyan); }

/* ---------- VFD display (the signature screen) ---------- */
.vfd {
  border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, #0a0b0d, #060708);
  border: 1px solid #000;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.9), inset 0 0 0 1px rgba(255,255,255,0.02);
  padding: 14px 15px;
  position: relative;
  overflow: hidden;
}
/* faint scanline texture on the glass */
.vfd::after {
  content: "";
  position: absolute; inset: 0;
  background: repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 3px);
  pointer-events: none;
}
.vfd .now-src {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--amber-dim);
  margin-bottom: 7px;
}
.vfd .now-title {
  font-family: var(--mono);
  font-weight: 600;
  font-size: 16px;
  color: var(--amber);
  text-shadow: 0 0 12px var(--amber-glow);
  letter-spacing: 0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.vfd .now-title.flicker { animation: flicker 6s steps(1) infinite; }
.vfd .now-meta {
  font-family: var(--mono);
  font-size: 11px; color: var(--ink-3); margin-top: 4px;
}
.vfd.idle .now-title { color: var(--ink-3); text-shadow: none; }
.vfd.idle .now-src { color: var(--ink-3); }

/* transport line */
.transport { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.scrub { flex: 1; height: 3px; border-radius: 3px; background: #000; overflow: hidden; }
.scrub > span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber-dim), var(--amber)); box-shadow: 0 0 8px var(--amber-glow); }
.vu { display: flex; align-items: flex-end; gap: 2px; height: 14px; }
.vu i { width: 3px; background: var(--amber); border-radius: 1px; opacity: 0.8; animation: vu 0.9s ease-in-out infinite; }
.vu i:nth-child(2){ animation-delay: 0.15s; height: 60%; }
.vu i:nth-child(3){ animation-delay: 0.3s; height: 90%; }
.vu i:nth-child(4){ animation-delay: 0.45s; height: 40%; }

/* ---------- Preset pad (the hero) ---------- */
.presets-label {
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.22em; text-transform: uppercase;
  color: var(--ink-3);
  margin: 16px 2px 9px;
}
/* Default .pad = the compact "glance" grid (dashboard): 6 across, glyph-led, no name. */
.pad {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}
/* The pads are device hardware: dark in BOTH themes (see design doc s3). Their inner text
   uses FIXED dark-surface colours, not the flip-on-light --ink tokens, so it never goes
   invisible on the dark pad in light mode (the recurring light-mode bug). */
/* The device page's pads are <button>s (UIP-4a: they open the editor, so they must be focusable);
   undo the browser's button styling so they look exactly like the dashboard's link pads. */
button.preset {
  -webkit-appearance: none; appearance: none;
  font: inherit; color: inherit; padding: 0; margin: 0; width: 100%; text-align: inherit;
}
.preset {
  aspect-ratio: 1;
  border-radius: 12px;
  border: 1px solid var(--panel-edge);
  background: linear-gradient(180deg, #1c2026, #0e1013);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 2px 6px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.06s ease, box-shadow 0.1s ease, border-color 0.12s ease;
  position: relative;
  overflow: hidden;
}
/* pad index — small silkscreen numeral in the top-left corner, like a real unit's label */
.preset .pn {
  position: absolute; top: 5px; left: 7px;
  font-family: var(--mono); font-size: 9px; font-weight: 600; letter-spacing: 0.04em;
  color: #6b7480;
}
/* centred source glyph — the at-a-glance identity of the pad */
.preset .pg { font-size: 18px; line-height: 1; color: #7c8693; }
.preset .pg::before { content: "\266A"; }                              /* default: music note */
.preset[data-kind="radio"]   .pg::before { content: "\263C"; }        /* sun: internet radio  */
.preset[data-kind="podcast"] .pg::before { content: "\25C9"; }        /* fisheye: podcast      */
.preset[data-kind="library"] .pg::before { content: "\266B"; }        /* beamed notes: library */
.preset[data-kind="stream"]  .pg::before { content: "\223F"; }        /* sine wave: stream URL */
.preset.empty .pg::before { content: "+"; font-weight: 400; }
/* per-kind glyph tint when set — fixed colours that read on the dark pad in both themes */
.preset.set[data-kind="radio"]   .pg { color: #38d6c4; }
.preset.set[data-kind="podcast"] .pg { color: #b48ce0; }
.preset.set[data-kind="library"] .pg { color: var(--amber); }
.preset.set[data-kind="stream"]  .pg { color: #aab2bd; }
.preset.set[data-kind="other"]   .pg { color: #aab2bd; }
/* Pad names stay visible in the dashboard glance grid; hiding them made populated presets look like
   loading placeholders on wide screens. */
.preset .pname {
  display: block;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.03em;
  line-height: 1.25; color: #d7dce2;
  max-width: 100%; word-break: break-word;
}
.preset.empty .pname { color: #6b7480; }
.preset:active { transform: translateY(2px); box-shadow: inset 0 2px 6px rgba(0,0,0,0.8); }
.preset.empty { border-style: dashed; }
/* the currently-playing preset is lit */
.preset.lit {
  border-color: var(--amber);
  background: linear-gradient(180deg, #2a2113, #18120a);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 16px -2px var(--amber-glow);
}
.preset.lit .pn { color: var(--amber); }
.preset.lit .pg, .preset.lit[data-kind] .pg { color: var(--amber-bright); }
/* the pad currently open in the editor (device page) — a clear cyan selection ring */
.preset.active-edit {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px var(--cyan), 0 0 16px -4px var(--cyan-glow);
}

/* Roomy "manage" grid (device page): 3 across, taller pads with a readable 2-line name.
   Number sits top-left, glyph top-right, name anchored at the bottom. */
.pad.manage { grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad.manage .preset {
  aspect-ratio: auto;
  min-height: 78px;
  padding: 22px 11px 12px;
  flex-direction: column; align-items: flex-start; justify-content: flex-end;
  gap: 7px;
}
.pad.manage .preset .pg { position: absolute; top: 9px; right: 11px; font-size: 19px; }
.pad.manage .preset .pname {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  text-align: left; width: 100%;
}

/* ---------- Buttons / CTA ---------- */
.cta {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  margin: 18px var(--pad) 0;
  padding: 15px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--panel-edge);
  background: transparent;
  color: var(--ink-2);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
  text-decoration: none; cursor: pointer; width: calc(100% - 2 * var(--pad));
}
.cta:active { transform: translateY(1px); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 15px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--amber);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber));
  color: #1a1206;
  font-family: var(--display); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  font-size: 13px; cursor: pointer; text-decoration: none;
  box-shadow: 0 0 24px -6px var(--amber-glow);
}
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.ghost {
  background: transparent; color: var(--ink);
  border-color: var(--panel-edge); box-shadow: none;
}

/* ---------- Login ---------- */
.login {
  min-height: 100dvh;
  display: flex; flex-direction: column; justify-content: center;
  padding: var(--pad);
  gap: 26px;
  width: min(520px, 100%);
  margin: 0 auto;
}
.login .brand {
  font-family: var(--display);
  font-weight: 700; letter-spacing: 0.4em; text-transform: uppercase;
  font-size: 22px; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
.login .tagline { text-align: center; color: var(--ink-3); font-size: 13px; margin-top: -16px; letter-spacing: 0.04em; }
.login-card {
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-edge);
  box-shadow: inset 0 1px 0 var(--hairline), 0 30px 60px -30px rgba(0,0,0,0.9);
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.login-intro { text-align: center; margin: -2px 0 4px; }
.login-intro h1 { margin: 0; font-family: var(--display); font-size: 24px; letter-spacing: 0.02em; }
.login-intro p { margin: 7px 0 0; color: var(--ink-2); font-size: 13px; }
.login-secondary { margin-top: 8px; }
.login-divider { display: flex; align-items: center; gap: 12px; color: var(--ink-3); font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; flex: 1; background: var(--panel-edge); }
.login-recovery { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink-3); }
.input {
  width: 100%;
  padding: 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: #0a0b0d;
  box-shadow: inset 0 2px 6px rgba(0,0,0,0.7);
  color: var(--ink);
  font-family: var(--mono); font-size: 15px;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--amber); box-shadow: inset 0 2px 6px rgba(0,0,0,0.7), 0 0 0 1px var(--amber-dim); }
.login .fineprint { text-align: center; color: var(--ink-3); font-size: 12px; }
.login .fineprint a { color: var(--accent-text); text-decoration: none; }

.sent {
  border-radius: var(--radius-sm);
  border: 1px solid var(--cyan);
  background: rgba(56,214,196,0.07);
  color: var(--cyan);
  padding: 14px; text-align: center; font-family: var(--mono); font-size: 13px;
}

/* ---------- Device detail ---------- */
.back {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--ink-3); text-decoration: none;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 0 var(--pad);
}
.detail { padding: 12px var(--pad) 0; }
.detail .hero-name { font-family: var(--display); font-weight: 700; font-size: 28px; letter-spacing: 0.02em; margin: 8px 0 2px; }

/* preset editor source tabs (UIP-4d) */
.src-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; }
.src-tab {
  -webkit-appearance: none; appearance: none; cursor: pointer;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-3); background: transparent;
  border: 1px solid var(--panel-edge); border-radius: 999px; padding: 8px 14px; min-height: 36px;
}
.src-tab:hover { color: var(--ink); background: var(--panel-2); }
.src-tab[aria-selected="true"] { color: var(--accent-text); border-color: var(--amber-dim); background: var(--panel-2); }
.src-tab:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.src-panel[hidden] { display: none; }

/* copy presets to another speaker (UIP-4e) */
.copy-presets { margin-top: 20px; }
.copy-form { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.copy-form select { flex: 1; min-width: 0; }
.copy-confirm, .shell .copy-confirm { margin: 12px 0 0; }
.copy-confirm .row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.copy-confirm form { margin: 0; }

/* speaker details (task 2.21) */
.speaker-details { margin-top: 20px; }
.speaker-details dl { margin: 8px 0 0; }
.speaker-details dl > div {
  display: grid; grid-template-columns: minmax(8em, 38%) 1fr; gap: 12px;
  padding: 8px 0; border-top: 1px solid var(--panel-edge);
}
.speaker-details dt { color: var(--ink-3); font-size: 12px; }
.speaker-details dd { margin: 0; font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

.hint {
  margin-top: 12px;
  font-size: 12px; color: var(--ink-3); line-height: 1.5;
  border-left: 2px solid var(--panel-edge); padding-left: 12px;
}

/* preset editor (HTMX-swapped panel) */
.editor {
  margin-top: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--amber-dim);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  box-shadow: inset 0 1px 0 var(--hairline), 0 0 30px -10px var(--amber-glow);
  padding: 18px;
  animation: rise 0.3s cubic-bezier(0.2,0.8,0.2,1) both;
}
.editor h3 { font-family: var(--display); margin: 0 0 14px; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent-text); }
.source-list { display: flex; flex-direction: column; gap: 8px; }
.source {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: #0d0f12;
  color: var(--ink);
  text-decoration: none; cursor: pointer;
}
.source:active { transform: translateY(1px); }
.source .glyph { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-family: var(--mono); font-size: 13px; font-weight: 700; color: #1a1206; background: var(--amber); }
.source .glyph.sp { background: var(--cyan); }
.source .glyph.rb { background: #b48ce0; }
.source .label { display: block; font-size: 14px; }
.source .sub { display: block; font-size: 11px; color: var(--ink-3); font-family: var(--mono); }
.editor .row { display: flex; gap: 10px; margin-top: 16px; }

/* ---------- Groups ---------- */
.group-card {
  margin: 0 var(--pad) 16px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-edge);
  box-shadow: inset 0 1px 0 var(--hairline);
  padding: 18px;
}
.device-cloud-note { display:flex; flex-direction:column; gap:6px; margin:0 0 18px; padding:16px 18px; border:1px solid var(--panel-edge); border-radius:var(--radius-sm); background:var(--panel-2); color:var(--ink-2); font-size:13px; line-height:1.45; }
.device-cloud-note strong { color:var(--accent-text); font-family:var(--display); font-size:14px; letter-spacing:.04em; }
.group-card .gtitle { font-family: var(--display); font-size: 16px; letter-spacing: 0.04em; display: flex; align-items: center; gap: 10px; }
.group-card .members { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.chip {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.06em;
  padding: 8px 12px; border-radius: 20px;
  border: 1px solid var(--panel-edge); background: #0d0f12; color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 7px;
}
.chip.master { border-color: var(--amber); color: var(--accent-text); }
.chip .led { width: 6px; height: 6px; }
.linkwave { color: var(--accent-text); }

/* ---------- Bottom tab bar ---------- */
.tabbar {
  position: fixed;
  bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(440px, 100%);
  /* flex (was a hardcoded 3-column grid) so the bar adapts to however many tabs render. */
  display: flex;
  /* Flat translucent over the blur (was a gradient with a hardcoded dark top stop that looked muddy
     in dark and wrong in light). Themed via --bar-bg. */
  background: var(--bar-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--panel-edge);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
  z-index: 60;
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--ink-3); text-decoration: none;
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  min-height: 44px; justify-content: center; /* a11y: comfortable tap target */
}
.tab .ti { font-size: 18px; line-height: 1; }
.tab.active { color: var(--accent-text); }
.tab.active .ti { filter: drop-shadow(0 0 8px var(--amber-glow)); }

/* Desktop: the tab bar becomes a compact top nav. This block MUST come after the base .tabbar/.tab
   rules above: at equal specificity the later rule wins, and when it sat in the earlier 760px block
   the phone bar's width, background, fixed position and centring transform overrode it, leaving a
   440px floating box with its tabs pushed right (fixed 2026-10-04). */
@media (min-width: 760px) {
  /* On the web, navigation belongs at the top. Keep the same labels and
     visual tokens as the phone bar, but present them as a compact browser
     nav instead of a floating control at the foot of every page. */
  .tabbar {
    position: absolute;
    top: 0;
    right: 0;
    bottom: auto;
    left: 0;
    transform: none;
    width: 100%;
    height: 58px;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    padding: 10px 16px;
    background: transparent;
    border: 0;
  }
  .tabbar .tab {
    flex: 0 0 auto;
    min-height: 38px;
    height: 38px;
    flex-direction: row;
    gap: 7px;
    padding: 0 12px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 10px;
  }
  .tabbar .tab:hover { color: var(--ink); border-color: var(--panel-edge); background: var(--panel-2); }
  .tabbar .tab.active { border-color: var(--panel-edge); background: var(--panel-2); }
  .tabbar .tab .ti { font-size: 14px; }
}

/* ---------- Animations ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@keyframes vu { 0%,100% { height: 30%; } 50% { height: 100%; } }
@keyframes flicker { 0%,97%,100% { opacity: 1; } 98% { opacity: 0.7; } 99% { opacity: 0.92; } }

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

/* ---------- A11y: visible keyboard focus ---------- */
/* Mouse/touch users see nothing extra; keyboard users get a clear ring on every interactive element. */
a:focus-visible, button:focus-visible, input:focus-visible,
.btn:focus-visible, .tab:focus-visible, .preset:focus-visible,
.source:focus-visible, .iconbtn:focus-visible, .cta:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Trial banner ---------- */
.trial-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 4px var(--pad) 0;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--cyan);
  background: rgba(56, 214, 196, 0.08);
  color: var(--ink);
  font-size: 13px;
}
.trial-banner.warn { border-color: var(--amber); background: rgba(231, 161, 61, 0.10); }
.trial-banner.expired { border-color: var(--red); background: rgba(229, 86, 63, 0.10); }
.trial-banner .tb-text { line-height: 1.4; }
.trial-banner .tb-text strong { font-family: var(--mono); }
.trial-banner .tb-cta {
  flex-shrink: 0;
  padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--amber);
  background: linear-gradient(180deg, var(--amber-bright), var(--amber));
  color: #1a1206; text-decoration: none;
  font-family: var(--display); font-weight: 700; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
}

/* ---------- Theme toggle (Appearance) ---------- */
.theme-toggle { display: flex; gap: 8px; margin-top: 12px; }
.theme-toggle button {
  flex: 1; padding: 11px; cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--panel-edge);
  background: var(--panel-2); color: var(--ink-2);
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase;
}
.theme-toggle button[aria-pressed="true"] {
  border-color: var(--accent-text); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--accent-text);
}

/* ---------- Light-theme component overrides ----------
 * Chrome surfaces that hardcode a dark fill flip to light here. The device modules (.module, .vfd,
 * .preset pads) keep their dark "hardware" look — only their text tokens are re-asserted light so
 * they stay readable on the dark cards. */
:root[data-theme="light"] body { color: var(--ink); }
:root[data-theme="light"] .input { background: #fff; box-shadow: inset 0 1px 2px rgba(0,0,0,0.12); }
:root[data-theme="light"] .chip,
:root[data-theme="light"] .source { background: var(--panel-2); }
:root[data-theme="light"] .group-card,
:root[data-theme="light"] .login-card { box-shadow: 0 1px 2px rgba(0,0,0,0.05), 0 10px 30px -20px rgba(0,0,0,0.4); }
:root[data-theme="light"] .sent { background: rgba(11,141,126,0.08); color: var(--cyan); border-color: var(--cyan); }

/* In light mode the speaker MODULE card is light (its name/status text themes dark via the tokens).
   But the VFD "screen" and the preset "pads" are hardcoded-dark surfaces — like a real device's
   display and buttons. The pad's inner text (.pn/.pg/.pname) already uses fixed dark-surface
   colours in the base rules, so it needs no light override here. */
/* VFD screen text (idle title/source + meta) stays light on the dark glass. */
:root[data-theme="light"] .vfd .now-src,
:root[data-theme="light"] .vfd.idle .now-title,
:root[data-theme="light"] .vfd.idle .now-src,
:root[data-theme="light"] .vfd .now-meta { color: #8b95a3; }

/* Logout is a POST form (GET /logout was CSRF-able); style its button like the old link. */
.topbar .actions .signout-form { display: inline-flex; margin: 0; }
.topbar .actions button.signout { cursor: pointer; }
