/* ═══════════════════════════════════════════════════════
   PRESERVE THEIR VOICE — Master Stylesheet
   /includes/css/styles.css
   All values use CSS custom properties for whitelabel override
   via each subdomain's localstyle.css
═══════════════════════════════════════════════════════ */

/* ── CSS Custom Properties (Override in localstyle.css) ── */
/* Version: V1 */
:root {
  /* Layout Heights */
  --header-height: 20dvh;
  --main-height: 62dvh;
  --footer-height: 18dvh;
  --main-height-recording: 45dvh;
  --footer-height-recording: 35dvh;

  /* Colors — Primary */
  --color-primary: #2b5797;
  --color-primary-dark: #1e3f6f;
  --color-primary-light: #4a7bc5;
  --color-primary-pale: #e8f0fb;

  /* Colors — Header */
  --color-header-bg-start: var(--color-primary);
  --color-header-bg-end: var(--color-primary-dark);
  --color-header-title: #ffffff;
  --color-header-subtitle: rgba(255,255,255,.80);
  --color-header-sub-bg: #f2f5f8;
  --color-header-sub-text: var(--color-primary-dark);
  --color-header-sub-border: #d0d8e2;
  --color-home-btn-bg: var(--color-primary-dark);
  --color-home-btn-text: #ffffff;
  --color-home-btn-border: var(--color-primary-dark);

  /* Colors — Footer */
  --color-footer-bg: var(--color-white);
  --color-footer-border: var(--color-border);
  --color-record-btn-start: var(--color-primary);
  --color-record-btn-end: var(--color-primary-dark);
  --color-record-btn-text: #ffffff;

  /* Colors — Page Title Bar */
  --color-title-bar-bg: var(--color-white);
  --color-title-bar-text: var(--color-primary-dark);
  --color-title-bar-border: var(--color-border-light);

  /* Colors — Grid Buttons */
  --color-grid-btn-bg: var(--color-white);
  --color-grid-btn-border: var(--color-border-light);
  --color-grid-btn-text: var(--color-text);
  --color-grid-btn-icon-bg: var(--color-primary-pale);
  --color-grid-btn-icon: var(--color-primary);

  /* Colors — Accent */
  --color-accent: #8b3040;
  --color-accent-light: #b04050;
  --color-accent-pale: #f9eced;

  /* Colors — Action (green for safe-to-press buttons) */
  --color-action: #2d7d52;
  --color-action-light: #3a9e68;

  /* Colors — Neutral */
  --color-white: #ffffff;
  --color-bg: #f0f4f8;
  --color-bg-alt: #e4eaf0;
  --color-border: #c8d4e0;
  --color-border-light: #dde5ed;

  /* Colors — Text */
  --color-text: #1e2d40;
  --color-text-body: #374a5e;
  --color-text-muted: #6a7f96;
  --color-text-faint: #a0b0c0;

  /* Colors — Status */
  --color-success: #2d7d52;
  --color-warning: #a06820;
  --color-danger: #b82d20;

  /* Typography */
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-body: 'Roboto Condensed', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Source Serif 4', Georgia, serif;

  --fs-xs: 1rem;
  --fs-sm: 1.15rem;
  --fs-base: 1.2rem;
  --fs-lg: 1.25rem;
  --fs-xl: 1.35rem;
  --fs-2xl: 1.65rem;
  --fs-3xl: 2rem;
  --fs-footer-meta: 0.9rem;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;

  /* Border Radius */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 18px;
  --radius-round: 50%;
  --radius-pill: 99px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(30,45,64,.06);
  --shadow-md: 0 4px 16px rgba(30,45,64,.10);
  --shadow-lg: 0 6px 24px rgba(30,45,64,.14);

  /* Button Grid */
  --grid-gap: 10px;
  --btn-grid-radius: 12px;

  /* Safe Areas */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  /* Recording */
  --rec-btn-size: 72px;
  --rec-pulse-color: rgba(139, 48, 64, 0.15);

  /* Splash Screen */
  --splash-bg: #ffffff;
  --splash-duration: 2s;
}


/* ═══ TOAST NOTIFICATION ════════════════════════════ */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(30, 40, 55, 0.92);
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 600;
  padding: 10px 24px;
  border-radius: var(--radius-pill);
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  text-align: center;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}


/* ═══ SPLASH SCREEN ═════════════════════════════════ */
.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--splash-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 12px 20px;
  max-height: 100dvh;
  max-height: var(--real-vh, 100dvh);
  overflow: hidden;
  transition: opacity 0.5s ease;
}

.splash-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.splash-tagline {
  font-family: var(--font-heading);
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  line-height: 1.2;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.splash-hero {
  width: 90%;
  max-width: 450px;
  max-height: 38dvh;
  object-fit: contain;
  margin-bottom: 8px;
  flex-shrink: 1;
}

.splash-app-name {
  font-family: var(--font-heading);
  font-size: clamp(1.6rem, 7vw, 2.2rem);
  font-weight: 700;
  font-style: italic;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.splash-sponsored {
  font-family: var(--font-heading);
  font-size: clamp(1.1rem, 4.5vw, 1.4rem);
  font-weight: 600;
  color: var(--color-text-body);
  text-align: center;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.splash-logo {
  width: 80%;
  max-width: 400px;
  max-height: 22dvh;
  object-fit: contain;
  flex-shrink: 1;
}


/* ═══ RESET & BASE ═══════════════════════════════════ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  font-family: var(--font-body);
  color: var(--color-text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}


/* ═══ APP SHELL ══════════════════════════════════════ */
.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  height: var(--real-vh, 100dvh);
  max-width: 500px;
  margin: 0 auto;
  background: var(--color-bg);
  overflow: hidden;
  position: relative;
}


/* ═══ HEADER ═════════════════════════════════════════ */
.app-header {
  flex-shrink: 0;
  height: var(--header-height);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 20;
}

/* Top row: Title + Home button — 10dvh */
.header-title-area {
  flex-shrink: 0;
  height: 10dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--safe-top) 6px 0;
  text-align: center;
  background: linear-gradient(170deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  position: relative;
}

.header-title {
  font-family: var(--font-heading);
  font-size: clamp(1.2rem, 7vw, 2.5rem);
  font-weight: 700;
  color: var(--color-white);
  line-height: 1.05;
  text-shadow: 0 1px 3px rgba(0,0,0,.15);
  white-space: nowrap;
  margin-right: 9.5dvh;
}

.header-subtitle {
  font-family: var(--font-heading);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(0.6rem, 2.4vw, 0.8rem);
  color: rgba(255,255,255,.80);
  margin-top: 1px;
  line-height: 1.1;
  white-space: nowrap;
}

/* Bottom row: Logo fills subheader — white bg, no padding */
.header-sub {
  flex: 1;
  height: 10dvh;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #ffffff;
  border-left: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
  border-bottom: 1.5px solid var(--color-border);
  position: relative;
}

.header-logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  height: 100%;
}

.header-logo {
  height: 100%;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  border-radius: 0;
}

/* Home button — centered vertically in full header, not just title area */
.btn-home {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 9.5dvh;
  aspect-ratio: 1 / 1;
  padding: 0;
  background: var(--color-grid-btn-bg);
  border: 2px solid var(--color-home-btn-border);
  border-radius: var(--radius-sm);
  color: var(--color-home-btn-text);
  font-family: var(--font-body);
  font-size: 0.6rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  z-index: 25;
}

.btn-home:hover {
  opacity: 0.85;
}

.btn-home:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-home svg {
  width: 38px;
  height: 38px;
  fill: none;
  stroke: var(--color-grid-btn-icon);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}


/* ═══ MAIN CONTENT AREA ═════════════════════════════ */
.app-main {
  flex: 1;
  min-height: 0;
  height: var(--main-height);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: height 0.4s cubic-bezier(.32,.72,0,1);
  border-left: 1.5px solid var(--color-border);
  border-right: 1.5px solid var(--color-border);
}

/* Page title bar */
.page-title-bar {
  flex-shrink: 0;
  text-align: center;
  padding: 4px var(--space-lg) 3px;
  background: var(--color-title-bar-bg);
  border-bottom: 1.5px solid var(--color-title-bar-border);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
}

.page-title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-title-bar-text);
}

/* Back button for sub-pages — dark bg, white text (opposite of Home) */
.btn-back {
  position: absolute;
  left: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: linear-gradient(135deg, var(--color-record-btn-start), var(--color-record-btn-end));
  border: 2px solid var(--color-record-btn-end);
  cursor: pointer;
  padding: 0px 6px 0px 4px;
  color: #ffffff;
  line-height: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: var(--radius-sm);
  z-index: 2;
  box-shadow: var(--shadow-sm);
}

.btn-back:hover {
  opacity: 0.85;
}

.btn-back:active {
  transform: translateY(-50%) scale(0.95);
}

.btn-back svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #ffffff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-back-text {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #ffffff;
}


/* ═══ BUTTON GRID ════════════════════════════════════ */
.btn-grid-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: safe center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Fallback for browsers that don't support 'safe center' */
@supports not (align-items: safe center) {
  .btn-grid-wrap {
    align-items: flex-start;
  }
}

.btn-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--grid-gap);
  width: 100%;
  max-width: 420px;
}

.grid-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  aspect-ratio: 1 / 1;
  background: var(--color-grid-btn-bg);
  border: 2px solid var(--color-grid-btn-border);
  border-radius: var(--btn-grid-radius);
  cursor: pointer;
  transition: all 0.18s;
  padding: 4px;
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  color: var(--color-grid-btn-text);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
}

.grid-btn:hover {
  border-color: var(--color-primary-light);
  background: var(--color-primary-pale);
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.grid-btn:active {
  transform: scale(0.97);
}

.grid-btn.hidden {
  display: none;
}

.grid-btn-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-grid-btn-icon-bg);
  border-radius: var(--radius-sm);
  color: var(--color-grid-btn-icon);
}

/* Icon image — replaces SVG when provided */
.grid-btn-img {
  width: 100%;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.grid-btn-icon svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: var(--color-grid-btn-icon);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.grid-btn-label {
  font-size: 1.125rem;
  font-weight: 700;
  text-align: center;
  line-height: .95;
  color: var(--color-text);
  word-break: break-word;
  hyphens: auto;
}


/* ═══ TOPIC GRID (rectangular buttons) ═══════════════ */
.btn-grid.topic-grid .grid-btn {
  aspect-ratio: 3 / 2.3;
  padding: var(--space-sm) var(--space-xs);
  min-height: 0;
}

.btn-grid.topic-grid {
  /* Let items be smaller rectangles */
  align-content: center;
}

.btn-grid.topic-grid .grid-btn-icon {
  width: 28px;
  height: 28px;
}

.btn-grid.topic-grid .grid-btn-icon svg {
  width: 18px;
  height: 18px;
}

.btn-grid.topic-grid .grid-btn-label {
  font-size: 1.125rem;
}

/* Topic emoji icon (used instead of SVG) */
.grid-btn-emoji {
  font-size: 1.5rem;
  line-height: 1;
}


/* ═══ INDIVIDUAL TOPIC PROMPTS ═══════════════════════ */

/* Page content containers must fill available space for scrolling */
.page-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.prompts-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 2px var(--space-sm) var(--space-sm);
}

.prompts-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.prompts-list li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--color-white);
  border: 1.5px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: var(--fs-lg);
  color: var(--color-text-body);
  line-height: 1.3;
  font-family: var(--font-serif);
}

.prompts-list li::before {
  content: '•';
  color: var(--color-primary);
  font-weight: 700;
  font-size: var(--fs-xl);
  flex-shrink: 0;
  line-height: 1.15;
}

.prompts-tap-hint {
  display: none;
}


/* ═══ SCROLL FADE INDICATOR ══════════════════════════
   Shows a gradient fade + chevron at the bottom of scrollable areas
   to hint there's more content below. Hidden via JS when scrolled to bottom.
*/
.scroll-fade {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 44px;
  background: linear-gradient(transparent 0%, rgba(240,244,248,.85) 50%, var(--color-bg) 100%);
  pointer-events: none;
  z-index: 5;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 4px;
  transition: opacity 0.3s;
}

.scroll-fade.hidden {
  opacity: 0;
}

.scroll-fade-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  pointer-events: none;
}

.scroll-fade-label svg {
  width: 14px;
  height: 14px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  animation: scrollBounce 1.5s ease-in-out infinite;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

/* Make page-content containers position:relative for the fade overlay */
.page-content {
  position: relative;
}

/* The btn-grid-wrap and prompts-area need to be the scroll parent */
.btn-grid-wrap,
.prompts-area {
  position: relative;
}


/* ═══ FOOTER ═════════════════════════════════════════ */
.app-footer {
  flex-shrink: 0;
  height: var(--footer-height);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: var(--color-footer-bg);
  border-top: 2px solid var(--color-footer-border);
  box-shadow: 0 -3px 16px rgba(30,45,64,.08);
  padding: var(--space-md) var(--space-lg) calc(var(--space-md) + var(--safe-bottom));
  transition: height 0.4s cubic-bezier(.32,.72,0,1);
  position: relative;
  z-index: 10;
}

/* Large Record Stories button */
.btn-record-stories {
  width: 100%;
  max-width: 400px;
  height: 56px;
  background: linear-gradient(135deg, var(--color-record-btn-start), var(--color-record-btn-end));
  border: none;
  border-radius: var(--radius-sm);
  color: var(--color-record-btn-text);
  font-family: var(--font-body);
  font-size: var(--fs-xl);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 16px rgba(43,87,151,.35);
  transition: transform 0.14s, box-shadow 0.14s;
  letter-spacing: 0.02em;
}

.btn-record-stories:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(43,87,151,.45);
}

.btn-record-stories:active {
  transform: scale(0.98);
}

.btn-record-stories svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: white;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Footer meta bar — copyright, version, about */
.footer-meta {
  position: absolute;
  bottom: calc(16px + var(--safe-bottom));
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: var(--fs-footer-meta);
  font-weight: 700;
  color: var(--color-text-faint);
}

.footer-meta-sep {
  color: var(--color-border);
}

.footer-about-btn {
  background: none;
  border: none;
  font-family: var(--font-body);
  font-size: var(--fs-footer-meta);
  font-weight: 800;
  color: var(--color-primary);
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}


/* ═══ RECORDING FOOTER ═══════════════════════════════ */
.rec-footer {
  flex-shrink: 0;
  height: var(--footer-height-recording);
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  border-top: 2px solid var(--color-border);
  box-shadow: 0 -3px 16px rgba(30,45,64,.08);
  overflow: hidden;
  position: relative;
  z-index: 10;
  padding-bottom: var(--safe-bottom);
}

.rec-footer-body {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: auto;
}

/* State panels */
.rec-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: var(--space-sm) var(--space-lg) calc(var(--space-sm) + var(--safe-bottom));
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  transform: translateY(6px);
  z-index: 1;
}

.rec-state.active {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}

/* ── Idle (Tap to Record) ── */
.btn-record {
  width: var(--rec-btn-size);
  height: var(--rec-btn-size);
  border-radius: var(--radius-round);
  background: linear-gradient(145deg, var(--color-accent-light), var(--color-accent));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 10px var(--rec-pulse-color), 0 5px 20px rgba(139,48,64,.35);
  transition: transform 0.14s, box-shadow 0.14s;
  margin-bottom: 8px;
}

.btn-record:active {
  transform: scale(0.92);
}

.btn-record:hover {
  box-shadow: 0 0 0 16px var(--rec-pulse-color), 0 5px 20px rgba(139,48,64,.40);
}

.btn-record svg {
  width: 50px;
  height: 50px;
}

.idle-title {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--color-text);
  margin-top: 2px;
}

.idle-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 0px;
  text-align: center;
  line-height: 1;
  max-width: 240px;
}

.video-info-link {
  display: inline-block;
  margin-top: 10px;
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-style: italic;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 3px;
  cursor: pointer;
  opacity: 0.75;
}
.video-info-link:hover { opacity: 1; }

/* ── Countdown ── */
.cd-num {
  font-family: var(--font-heading);
  font-size: 4.5rem;
  font-weight: 700;
  color: var(--color-accent);
  line-height: 1;
  animation: cPulse 1s ease-in-out infinite;
  margin-bottom: 4px;
}

@keyframes cPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.cd-sub {
  font-size: var(--fs-sm);
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

.btn-cancel {
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-pill);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  padding: 6px 22px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-cancel:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* ── Recording ── */
.rec-badge-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 2px;
}

.rec-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-round);
  background: var(--color-accent);
  animation: blink 1.1s ease-in-out infinite;
  box-shadow: 0 0 5px rgba(139,48,64,.55);
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.08; }
}

.rec-badge {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-accent);
}

.rec-time {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 9vw, 2.6rem);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
  letter-spacing: 0.03em;
  margin-bottom: 0px;
  margin-top: -5px;
}

.rec-remain {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: 700;
  margin-bottom: 0px;
}

/* Canvas visualizer */
.viz-wrap {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0px;
}

#vizCanvas {
  display: block;
  border-radius: 5px;
  background: transparent;
  width: min(220px, 65%);
  height: 32px;
}

/* Recording controls — each button + label in a centered column */
.rec-controls-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  width: 100%;
  align-items: flex-end;
}

.rec-control {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 78px;
}

.rec-control-lbl {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  white-space: nowrap;
}

.btn-rnd {
  border: none;
  border-radius: var(--radius-round);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.14s;
  flex-shrink: 0;
}

.btn-rnd:active {
  transform: scale(0.87);
}

.btn-pause {
  width: 68px;
  height: 68px;
  background: var(--color-bg);
  border: 2px solid var(--color-border) !important;
}

.btn-pause svg {
  width: 26px;
  height: 26px;
  fill: var(--color-text);
}

.btn-stop {
  width: 78px;
  height: 78px;
  border-radius: var(--radius-round);
  background: linear-gradient(145deg, var(--color-accent-light), var(--color-accent));
  box-shadow: 0 4px 16px rgba(139,48,64,.38);
}

.btn-stop:hover {
  box-shadow: 0 5px 22px rgba(139,48,64,.52);
}

.btn-stop svg {
  width: 28px;
  height: 28px;
  fill: white;
}

.btn-trash {
  width: 60px;
  height: 60px;
  background: transparent;
  border: 2px solid var(--color-border) !important;
  color: var(--color-text-muted);
}

.btn-trash:hover {
  border-color: var(--color-accent) !important;
  color: var(--color-accent);
}

.btn-trash svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Paused ── */
.paused-time {
  font-family: var(--font-heading);
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  font-weight: 700;
  color: var(--color-warning);
  line-height: 1;
}

.paused-badge {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--color-warning);
  text-transform: uppercase;
  margin: 4px 0 10px;
  animation: fpulse 2s ease-in-out infinite;
  text-align: center;
}

@keyframes fpulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.25; }
}

.btn-resume-pill {
  height: 50px;
  padding: 0 2rem;
  background: linear-gradient(135deg, var(--color-text), var(--color-primary-dark));
  border: none;
  border-radius: var(--radius-pill);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-lg);
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(30,45,64,.32);
  transition: transform 0.14s, box-shadow 0.14s;
  margin-bottom: 10px;
}

.btn-resume-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 22px rgba(30,45,64,.42);
}

.btn-resume-pill svg {
  width: 18px;
  height: 18px;
  fill: white;
}

.paused-secondary-row {
  display: flex;
  gap: 36px;
  align-items: center;
  justify-content: center;
}

.paused-sec-lbl {
  font-size: 0.58rem;
  font-weight: 800;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  margin-top: 4px;
}

#state-paused .btn-stop {
  width: 68px;
  height: 68px;
}

#state-paused .btn-trash {
  width: 68px;
  height: 68px;
}

/* ── Encoding ── */
.encoding-ring {
  width: 46px;
  height: 46px;
  border-radius: var(--radius-round);
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  animation: spin 0.9s linear infinite;
  margin-bottom: 10px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.encoding-label {
  font-size: var(--fs-base);
  font-weight: 700;
  color: var(--color-text);
}

.encoding-sub {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  margin-top: 4px;
}

/* ── Done ── */
#state-done {
  justify-content: center;
  align-items: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  gap: 5px;
  padding: 6px 24px calc(10px + var(--safe-bottom)) 24px;
}

.done-section-label {
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  align-self: center;
  padding-left: 2px;
  margin-bottom: 1px;
}

.audio-player {
  width: 100%;
  max-width: 320px;
  background: var(--color-bg);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 5px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-play-pause {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-round);
  background: linear-gradient(145deg, var(--color-action-light), var(--color-action));
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(45,125,82,.3);
  transition: transform 0.14s;
}

.btn-play-pause:active {
  transform: scale(0.9);
}

.btn-play-pause svg {
  width: 16px;
  height: 16px;
  fill: white;
}

.player-time {
  font-family: var(--font-heading);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--color-text);
  min-width: 48px;
}

.player-progress {
  flex: 1;
  height: 6px;
  background: var(--color-border);
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
}

.player-progress-fill {
  height: 100%;
  background: var(--color-action);
  border-radius: 3px;
  width: 0%;
  transition: width 0.1s linear;
}

.player-total {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  font-weight: 700;
  min-width: 40px;
  text-align: right;
}

.done-btn-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.btn-share-big {
  flex: 1;
  height: 48px;
  background: linear-gradient(135deg, var(--color-action-light), var(--color-action));
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(45,125,82,.32);
  transition: transform 0.14s, box-shadow 0.14s;
}

.btn-share-big:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(45,125,82,.42);
}

.btn-share-big svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: white;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-dl {
  width: 48px;
  height: 48px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border) !important;
  color: var(--color-text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.18s;
}

.btn-dl:hover {
  background: var(--color-bg-alt);
  border-color: var(--color-primary) !important;
}

.btn-dl svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.done-action-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 320px;
}

.btn-start-new {
  flex: 1;
  height: 40px;
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.18s;
}

.btn-start-new:hover {
  background: var(--color-primary-dark);
}

.btn-start-new svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: white;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-delete-rec {
  height: 40px;
  padding: 0 14px;
  background: transparent;
  border: 2px solid var(--color-border) !important;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.18s;
  flex-shrink: 0;
}

.btn-delete-rec:hover {
  border-color: var(--color-accent) !important;
  color: var(--color-accent);
}

.btn-delete-rec svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* IDB Status indicator */
.idb-status {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--color-text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 5;
}

.idb-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--radius-round);
  background: var(--color-text-faint);
}

.idb-status.saving .idb-dot {
  background: var(--color-success);
  animation: blink2 1s infinite;
}

.idb-status.saved .idb-dot {
  background: var(--color-success);
}

.idb-status.error .idb-dot {
  background: var(--color-accent);
}

@keyframes blink2 {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}


/* ═══ MODALS ═════════════════════════════════════════ */
.modal-bd {
  position: fixed;
  inset: 0;
  background: rgba(30,45,64,.60);
  backdrop-filter: blur(5px);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
}

.modal-bd.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--color-white);
  border-radius: 22px;
  width: 100%;
  max-width: 360px;
  padding: 26px 22px 20px;
  transform: scale(0.94);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}

.modal-bd.open .modal {
  transform: scale(1);
}

.modal-icon {
  font-size: 2.4rem;
  text-align: center;
  display: block;
  margin-bottom: 8px;
}

.modal-title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
  margin-bottom: 8px;
}

.modal-body {
  font-size: var(--fs-sm);
  color: var(--color-text-body);
  line-height: 1.6;
  text-align: center;
  margin-bottom: 18px;
}

.modal-body strong {
  color: var(--color-text);
}

.modal-btns {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-modal-primary {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.14s;
}

.btn-modal-primary:hover {
  transform: scale(1.02);
}

.btn-modal-primary.danger {
  background: linear-gradient(135deg, #b82d20, var(--color-accent));
}

.btn-modal-primary.navy {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
}

.btn-modal-primary.gold {
  background: linear-gradient(135deg, var(--color-warning), #c8882a);
}

.btn-modal-cancel {
  width: 100%;
  height: 44px;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-modal-cancel:hover {
  border-color: var(--color-primary-light);
  color: var(--color-primary);
}

/* Recovery info rows */
.recovery-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.rec-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font-size: var(--fs-sm);
  color: var(--color-text-body);
}

.ri-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-round);
  flex-shrink: 0;
}

.ri-dot.green { background: var(--color-success); }
.ri-dot.gold { background: var(--color-warning); }
.ri-dot.rose { background: var(--color-accent); }

/* File name modal */
.name-input-wrap {
  width: 100%;
  margin-bottom: 12px;
}

.name-input-wrap label {
  display: block;
  font-size: var(--fs-xs);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 5px;
  text-align: left;
}

.name-input-row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.name-input {
  flex: 1;
  height: 48px;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  transition: border-color 0.2s;
}

.name-input:focus {
  border-color: var(--color-primary);
}

.btn-clear-name {
  height: 48px;
  width: 48px;
  background: transparent;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s;
}

.btn-clear-name:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-clear-name svg {
  width: 15px;
  height: 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}

.name-hint {
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  text-align: left;
  margin-top: 5px;
  font-style: italic;
}


/* ═══ BOTTOM SHEETS ══════════════════════════════════ */
.sheet-bd {
  position: fixed;
  inset: 0;
  background: rgba(30,45,64,.5);
  backdrop-filter: blur(3px);
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet-bd.open {
  opacity: 1;
  pointer-events: all;
}

.sheet {
  background: var(--color-white);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 500px;
  max-height: 88dvh;
  overflow-y: auto;
  padding-bottom: calc(16px + var(--safe-bottom));
  transform: translateY(40px);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
}

.sheet-bd.open .sheet {
  transform: translateY(0);
}

.sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: 2px;
  margin: 12px auto 0;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1.5px solid var(--color-bg-alt);
}

.sheet-title {
  font-family: var(--font-heading);
  font-size: var(--fs-xl);
  color: var(--color-text);
  font-weight: 700;
}

.btn-sx {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-round);
  background: var(--color-bg);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-sx svg {
  width: 16px;
  height: 16px;
  stroke: var(--color-text-muted);
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
}

.sheet-body {
  padding: 16px 18px 4px;
}

.i-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 6px;
}

.i-step {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.i-num {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-round);
  background: var(--color-primary);
  color: white;
  font-weight: 800;
  font-size: var(--fs-base);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.i-step p {
  font-size: var(--fs-base);
  color: var(--color-text-body);
  line-height: 1.45;
}

.i-step p strong {
  color: var(--color-text);
}

.offline-note {
  background: #fdf6e4;
  border: 1.5px solid rgba(160,104,32,.25);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  margin-top: 12px;
  font-size: var(--fs-sm);
  color: var(--color-warning);
  font-weight: 700;
  line-height: 1.5;
}


/* ═══ MIC DENIED ═════════════════════════════════════ */
.mic-denied-bd {
  position: fixed;
  inset: 0;
  background: rgba(240,244,248,.97);
  z-index: 95;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
}

.mic-denied-bd.show {
  display: flex;
}

.mic-denied-icon {
  font-size: 3rem;
  margin-bottom: 12px;
}

.mic-denied-title {
  font-family: var(--font-heading);
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: 8px;
}

.mic-denied-body {
  font-size: var(--fs-base);
  color: var(--color-text-body);
  line-height: 1.65;
  max-width: 320px;
  margin-bottom: 20px;
}

.mic-steps {
  background: var(--color-white);
  border: 2px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  text-align: left;
  width: 100%;
  max-width: 340px;
  margin-bottom: 16px;
}

.mic-steps p {
  font-size: var(--fs-sm);
  color: var(--color-text-body);
  line-height: 1.55;
  margin-bottom: 8px;
}

.mic-steps p:last-child {
  margin-bottom: 0;
}

.mic-steps strong {
  color: var(--color-text);
}

.btn-reload {
  height: 50px;
  padding: 0 2rem;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  border: none;
  border-radius: var(--radius-pill);
  color: white;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  font-weight: 800;
  cursor: pointer;
}


/* ═══ QR SHARE MODAL ═════════════════════════════════ */
.qr-share-modal .qr-big {
  width: clamp(160px, 50vw, 220px);
  height: clamp(160px, 50vw, 220px);
  border-radius: 12px;
  cursor: pointer;
  border: 3px solid var(--color-white);
  box-shadow: var(--shadow-lg);
  transition: transform 0.18s;
}

.qr-share-modal .qr-big:hover {
  transform: scale(1.04);
}

.qr-share-modal .qr-url {
  font-size: var(--fs-xs);
  color: var(--color-text-muted);
  word-break: break-all;
  text-align: center;
  background: var(--color-bg);
  border-radius: 8px;
  padding: 7px 12px;
  margin-top: 2px;
}

/* ═══ VIDEO MODAL ════════════════════════════════════ */
.video-modal .modal {
  max-width: 98vw;
  width: 500px;
  padding: 8px 8px 12px;
  border-radius: 14px;
}

.video-modal .video-wrap {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
  cursor: pointer;
}

.video-modal video {
  width: 100%;
  display: block;
  border-radius: var(--radius-sm);
  background: #000;
  max-height: 82dvh;
  object-fit: contain;
}

/* Poster/thumbnail overlay for iOS */
.video-poster-overlay {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: opacity 0.3s;
  border-radius: var(--radius-sm);
}

.video-poster-overlay.hide {
  opacity: 0;
  pointer-events: none;
}

.video-play-circle {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-round);
  background: rgba(255,255,255,.18);
  border: 2.5px solid rgba(255,255,255,.65);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, background 0.2s;
}

.video-play-circle:hover {
  transform: scale(1.1);
  background: rgba(255,255,255,.3);
}

.video-play-circle svg {
  width: 24px;
  height: 24px;
  fill: white;
  margin-left: 4px;
}

.video-modal .modal-title {
  font-size: var(--fs-lg);
  margin-bottom: 6px;
}

.video-modal .modal-btns {
  margin-top: 8px;
}


/* ═══ UTILITY ════════════════════════════════════════ */
.hidden { display: none !important; }
.visually-hidden { visibility: hidden; pointer-events: none; }