/* ============================================================
   Sixth Veil — app pages (login, onboarding, characters, chat,
   history, session). Shares visual system with landing.css but
   tuned for functional UI rather than marketing presentation:
   no corner frames, calmer nebula bg, denser layouts.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600&family=Cormorant+Garamond:ital,wght@1,300;1,400&family=Raleway:wght@200;300;400;500&display=swap');

:root {
  /* ---- color ---- */
  --bg-1: #070d18;
  --bg-2: #0a1525;
  --bg-3: #0d1a2a;
  --gold: #c9a84c;
  --gold-light: #e8d48b;
  --gold-dim: #7a6530;
  --gold-glow: rgba(201, 168, 76, 0.15);
  --gold-border: rgba(201, 168, 76, 0.12);
  --gold-border-strong: rgba(201, 168, 76, 0.28);
  --text-1: #e8e2d4;
  --text-2: #9a9484;
  --text-3: #5a5448;
  --error: #d49a9a;
  /* ---- typography ---- */
  --font-display: 'Cinzel', Georgia, serif;
  --font-body: 'Cormorant Garamond', Georgia, serif;
  --font-ui: 'Raleway', system-ui, sans-serif;
}

/* ---- reset / base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-ui);
  font-weight: 300;
  background: var(--bg-1);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--gold); text-decoration: none; }
img { display: block; max-width: 100%; }

/* ---- fixed sacred-geometry texture overlay ---- */
.sacred-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.03;
  background-image: url('/img/sacred-geometry-1.png');
  background-size: 700px;
  background-position: center;
}

/* ---- subtle nebula behind centered card pages ---- */
.page-bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.35;
  z-index: 0;
  pointer-events: none;
}
.page-bg-hero { background-image: url('/img/nebula-hero.png'); }
.page-bg-mid  { background-image: url('/img/nebula-mid.png'); }
.page-bg-cta  { background-image: url('/img/nebula-cta.png'); }

/* ============================================================
   Top-corner navigation buttons (sign out, my readings)
   ============================================================ */
.corner-btn {
  position: fixed;
  top: 18px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text-2);
  background: rgba(7, 13, 24, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--gold-border);
  border-radius: 0;
  padding: 9px 16px;
  cursor: pointer;
  z-index: 10;
  text-transform: uppercase;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.corner-btn:hover {
  color: var(--gold);
  border-color: var(--gold-border-strong);
  background: rgba(7, 13, 24, 0.75);
}
.corner-btn.right { right: 18px; }
.corner-btn.left  { left: 18px; }

/* Multi-button nav strips — use these when a page has more than one button
   per side. Each side is a fixed flex container, buttons flow naturally
   inside with gap, so no overlap on any screen width. */
.top-nav {
  position: fixed;
  top: 18px;
  display: flex;
  gap: 6px;
  z-index: 10;
  flex-wrap: wrap;
}
.top-nav-left  { left: 18px; }
.top-nav-right { right: 18px; }
.top-nav .corner-btn {
  /* Override the standalone fixed positioning when inside a top-nav strip */
  position: static;
  top: auto; left: auto; right: auto;
}

@media (max-width: 720px) {
  .top-nav { top: 12px; gap: 4px; }
  .top-nav-left  { left: 12px; }
  .top-nav-right { right: 12px; }
  .corner-btn {
    font-size: 8px;
    padding: 6px 10px;
    letter-spacing: 2px;
  }
}

/* ============================================================
   Centered card (login, onboarding)
   ============================================================ */
.page-wrap {
  position: relative;
  z-index: 5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 50px 20px;
}
.card {
  width: 100%;
  max-width: 460px;
  background: rgba(7, 13, 24, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--gold-border-strong);
  padding: 48px 40px 40px;
  position: relative;
}
.card::before, .card::after {
  content: '';
  position: absolute;
  width: 28px;
  height: 28px;
  border: 1px solid var(--gold);
  opacity: 0.5;
}
.card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.card::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* ---- brand / heading area ---- */
.brand {
  text-align: center;
  margin-bottom: 32px;
}
.brand-eyebrow {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 4px;
  color: var(--gold);
  text-transform: uppercase;
  margin-bottom: 16px;
}
.brand-eyebrow::before, .brand-eyebrow::after {
  content: '◆';
  font-size: 7px;
  margin: 0 12px;
  color: var(--gold);
  vertical-align: middle;
}
.brand-title {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 26px;
  letter-spacing: 2px;
  line-height: 1.25;
  text-transform: uppercase;
  color: var(--text-1);
}
.brand-title em {
  font-style: normal;
  /* Solid gold (was a gradient-text trick using background-clip + text-fill-
     color: transparent). The gradient version rendered as invisible text in
     the TikTok in-app webview and some older Android browsers — same root-
     cause bug we hit on the landing-page hero title. Fixed in tandem so the
     signup card never shows a broken "The ___" title to webview visitors. */
  color: var(--gold-light);
  text-shadow: 0 1px 0 var(--gold), 0 0 14px rgba(201, 168, 76, 0.3);
}
.brand-sub {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  color: var(--text-2);
  margin-top: 14px;
  line-height: 1.5;
}

/* ============================================================
   Tab switcher (login)
   ============================================================ */
.tabs {
  display: flex;
  gap: 0;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--gold-border);
}
.tab {
  flex: 1;
  padding: 12px 0;
  text-align: center;
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-2);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.25s, border-color 0.25s;
}
.tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}
.tab:hover:not(.active) { color: var(--text-1); }

/* ============================================================
   Form fields
   ============================================================ */
.field {
  margin-bottom: 20px;
}
.field label {
  display: block;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.field input,
.field textarea,
.field select {
  width: 100%;
  background: rgba(7, 13, 24, 0.5);
  border: 1px solid var(--gold-border-strong);
  border-radius: 0;
  padding: 13px 16px;
  font-size: 14px;
  font-family: var(--font-ui);
  font-weight: 400;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.25s, background 0.25s;
  letter-spacing: 0.5px;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: var(--gold);
  background: rgba(7, 13, 24, 0.7);
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--text-3);
}
.field textarea {
  resize: vertical;
  min-height: 108px;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  line-height: 1.5;
}
.field-hint {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 13px;
  color: var(--text-3);
  margin-top: 6px;
}

/* Three-dropdown birthday picker — used in onboarding + settings.
   Solves Android's painful native date picker for old dates. */
.date-picker {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1.3fr;
  gap: 8px;
}
.date-picker select {
  text-align-last: center;
  padding-left: 10px;
  padding-right: 10px;
}
@media (max-width: 380px) {
  .date-picker { grid-template-columns: 1fr; }
}

/* ============================================================
   Mobile thumb-friendliness — applies to all phones (<=720px).
   Three changes:
     1. Form inputs jump from 14px to 16px font. iOS Safari aggressively
        zooms into any focused input under 16px which yanks the page
        sideways and breaks layout — easy to lose users on the spot.
     2. Tabs (Sign In / Create Account) grow from ~36px to 48px tall so
        they're a proper thumb target per Material guidelines.
     3. Card padding shrinks slightly so more vertical content fits above
        the fold without the user having to scroll to find the button.
   ============================================================ */
@media (max-width: 720px) {
  .field input,
  .field textarea,
  .field select {
    font-size: 16px;
    padding: 14px 14px;
  }
  .tab {
    padding: 16px 0;
    font-size: 11px;
  }
  .card {
    padding: 28px 22px;
  }
  /* Make sure no clickable element is smaller than 44px */
  .btn-gold,
  .btn-ghost,
  .btn-google {
    min-height: 48px;
  }
}

/* ============================================================
   Buttons
   ============================================================ */
.btn-gold {
  display: block;
  width: 100%;
  background: rgba(7, 13, 24, 0.6);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 0;
  padding: 14px 22px;
  font-size: 11px;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 8px;
  transition: background 0.35s, color 0.35s, box-shadow 0.35s;
}
.btn-gold:hover {
  background: var(--gold);
  color: var(--bg-1);
  box-shadow: 0 0 24px var(--gold-glow);
}
.btn-gold:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Google OAuth button — Google's official brand guideline says light surface,
   dark text, the four-color "G" icon on the left. Sits visually distinct from
   our gold buttons so users instantly recognize "this is the third-party
   shortcut" rather than confusing it with our primary CTA. Full-width and
   tall (48px+) so it's a comfortable thumb target on mobile. */
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  background: #ffffff;
  color: #3c4043;
  border: 1px solid #dadce0;
  border-radius: 4px;
  padding: 12px 18px;
  font-family: 'Roboto', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.25px;
  cursor: pointer;
  transition: background 0.2s, box-shadow 0.2s;
  margin-bottom: 8px;
}
.btn-google:hover {
  background: #f8f9fa;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.btn-google:active {
  background: #f1f3f4;
}
.btn-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* "or sign in with email" divider — horizontal lines with text centered.
   Separates the OAuth button from the email form so users see it as an
   alternative, not a required step. */
.oauth-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 18px 0;
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
}
.oauth-divider::before,
.oauth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid var(--gold-border);
}
.oauth-divider span {
  padding: 0 14px;
}

.btn-ghost {
  display: block;
  width: 100%;
  background: transparent;
  color: var(--text-2);
  border: 1px solid var(--gold-border);
  border-radius: 0;
  padding: 12px 22px;
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  margin-top: 14px;
  transition: color 0.25s, border-color 0.25s;
}
.btn-ghost:hover {
  color: var(--gold);
  border-color: var(--gold-border-strong);
}

/* ============================================================
   Message area (error / success)
   ============================================================ */
.message-area { min-height: 22px; margin-top: 16px; text-align: center; }
.error-text {
  color: var(--error);
  font-family: var(--font-ui);
  font-size: 12px;
  letter-spacing: 1px;
  line-height: 1.5;
}
.success-text {
  color: var(--gold);
  font-family: var(--font-body);
  font-style: italic;
  font-size: 15px;
}

/* ============================================================
   Back-to-site link
   ============================================================ */
.back-link {
  display: block;
  text-align: center;
  margin-top: 28px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text-3);
  text-transform: uppercase;
  transition: color 0.25s;
}
.back-link:hover { color: var(--gold); }

/* ============================================================
   Character selection page
   ============================================================ */
.choose-wrap {
  position: relative;
  z-index: 5;
  max-width: 1000px;
  margin: 0 auto;
  padding: 90px 24px 80px;
}
.choose-header {
  text-align: center;
  margin-bottom: 60px;
}
.choose-header .brand-title {
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: 3px;
}
.choose-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}
.reader-card {
  position: relative;
  background: rgba(7, 13, 24, 0.55);
  border: 1px solid var(--gold-border);
  padding: 26px;
  display: flex;
  gap: 22px;
  align-items: flex-start;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.4s, background 0.4s, transform 0.4s;
  cursor: pointer;
}
.reader-card.live:hover {
  border-color: var(--gold);
  background: rgba(7, 13, 24, 0.75);
  transform: translateY(-3px);
}
.reader-card.coming {
  cursor: default;
  opacity: 0.55;
}
.reader-card-diamond {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 9px;
  height: 9px;
  background: var(--gold);
  transform: rotate(45deg);
  box-shadow: 0 0 12px var(--gold-glow);
}
.coming-badge {
  position: absolute;
  top: 12px;
  right: 14px;
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: 2px;
  color: var(--gold);
  border: 1px solid var(--gold-dim);
  padding: 4px 9px;
}
.reader-card-portrait {
  flex-shrink: 0;
  width: 130px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--gold-border-strong);
}
.reader-card-body { flex: 1; min-width: 0; }
.reader-card-numeral {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 8px;
  text-transform: uppercase;
}
.reader-card-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 18px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-1);
  margin-bottom: 6px;
}
.reader-card-archetype {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold-dim);
  margin-bottom: 14px;
  text-transform: uppercase;
}
.reader-card-desc {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  color: var(--text-2);
  line-height: 1.6;
  margin-bottom: 18px;
}

/* ---- Card action buttons (Voice / Text) ---- */
.reader-card-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.btn-card {
  background: rgba(7, 13, 24, 0.6);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 0;
  padding: 10px 18px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s, color 0.3s, box-shadow 0.3s;
}
.btn-card:hover {
  background: var(--gold);
  color: var(--bg-1);
  box-shadow: 0 0 20px var(--gold-glow);
}
.btn-card-secondary {
  border-color: var(--gold-border-strong);
  color: var(--text-2);
}
.btn-card-secondary:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(7, 13, 24, 0.6);
  box-shadow: none;
}
.btn-card-note {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ============================================================
   Chat
   ============================================================ */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 5;
}
.chat-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--gold-border);
  background: rgba(7, 13, 24, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.chat-header-portrait {
  width: 44px;
  height: 44px;
  border: 1px solid var(--gold-border-strong);
  object-fit: cover;
  flex-shrink: 0;
}
.chat-header-info { flex: 1; line-height: 1.2; min-width: 0; }
.chat-header-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--text-1);
  text-transform: uppercase;
}
.chat-header-arch {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--gold);
  margin-top: 4px;
  text-transform: uppercase;
}
.chat-header-back {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text-2);
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--gold-border);
  border-radius: 0;
  padding: 9px 14px;
  text-transform: uppercase;
  transition: color 0.3s, border-color 0.3s;
}
.chat-header-back:hover {
  color: var(--gold);
  border-color: var(--gold);
}

.chat-stream {
  flex: 1;
  overflow-y: auto;
  padding: 36px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  max-width: 760px;
  width: 100%;
  margin: 0 auto;
}
.msg {
  max-width: 88%;
  line-height: 1.75;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.msg.assistant {
  align-self: flex-start;
  color: var(--text-1);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 21px;
  line-height: 1.8;
}
.msg.assistant .msg-author {
  display: block;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 10px;
  text-transform: uppercase;
}
.msg.user {
  align-self: flex-end;
  background: rgba(7, 13, 24, 0.7);
  border: 1px solid var(--gold-border-strong);
  border-radius: 0;
  padding: 14px 18px;
  color: var(--text-1);
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0.3px;
  position: relative;
}
.msg.user::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: rotate(45deg);
  opacity: 0.5;
}
.msg.typing {
  align-self: flex-start;
  color: var(--text-3);
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
}
.typing-dot {
  display: inline-block;
  animation: dot-pulse 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

.chat-input-bar {
  padding: 16px 24px 22px;
  border-top: 1px solid var(--gold-border);
  background: rgba(7, 13, 24, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.chat-input-row {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: stretch;
}
.chat-input-row input {
  flex: 1;
  background: rgba(7, 13, 24, 0.6);
  border: 1px solid var(--gold-border-strong);
  border-radius: 0;
  padding: 13px 18px;
  font-size: 14px;
  font-family: var(--font-ui);
  color: var(--text-1);
  outline: none;
  letter-spacing: 0.3px;
}
.chat-input-row input:focus { border-color: var(--gold); }
.chat-input-row input::placeholder { color: var(--text-3); }
.chat-input-row button {
  background: rgba(7, 13, 24, 0.7);
  color: var(--gold);
  border: 1px solid var(--gold);
  border-radius: 0;
  padding: 12px 24px;
  font-size: 10px;
  font-family: var(--font-display);
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.3s, color 0.3s;
}
.chat-input-row button:hover {
  background: var(--gold);
  color: var(--bg-1);
}
.chat-input-row button:disabled { opacity: 0.5; cursor: not-allowed; }

.disclaimer {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 8px;
  letter-spacing: 2.5px;
  color: var(--text-3);
  margin-top: 12px;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  text-transform: uppercase;
}

/* Foot of the chat input bar: disclaimer + secondary "End Reading" button.
   Saves the user from scrolling all the way up to the header to end. */
.chat-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: 760px;
  margin: 12px auto 0;
  flex-wrap: wrap;
}
.chat-foot .disclaimer {
  margin: 0;
  text-align: left;
  flex: 1;
  min-width: 220px;
}
.chat-end-link {
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--text-2);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.3s, border-color 0.3s, background 0.3s;
  white-space: nowrap;
}
.chat-end-link:hover {
  color: var(--gold);
  border-color: var(--gold);
  background: rgba(7, 13, 24, 0.4);
}

/* ============================================================
   Voice page
   ============================================================ */
.voice-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  z-index: 5;
  padding: 20px 24px 24px;
}
.voice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}
.voice-timer {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--gold);
  background: rgba(7, 13, 24, 0.6);
  border: 1px solid var(--gold-border);
  padding: 8px 16px;
  transition: color 0.4s, border-color 0.4s, background 0.4s;
}
/* Warning zone: 8:00–9:00 elapsed, ~2 min remaining */
.voice-timer.warn {
  color: var(--gold-light);
  border-color: var(--gold);
  background: rgba(122, 101, 48, 0.25);
}
/* Critical zone: 9:00+ elapsed, ~1 min remaining — pulse */
.voice-timer.critical {
  color: #ffd9a8;
  border-color: #d6824a;
  background: rgba(168, 90, 32, 0.3);
  animation: timer-critical-pulse 1.4s ease-in-out infinite;
}
@keyframes timer-critical-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(214, 130, 74, 0); }
  50% { box-shadow: 0 0 16px rgba(214, 130, 74, 0.6); }
}

/* ============================================================
   Modal — used by voice (time-up) and chat (out of free text)
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(7, 13, 24, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-card {
  background: var(--bg-2);
  border: 1px solid var(--gold-border-strong);
  padding: 40px 32px 32px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  position: relative;
}
.modal-card::before, .modal-card::after {
  content: '';
  position: absolute;
  width: 24px;
  height: 24px;
  border: 1px solid var(--gold);
  opacity: 0.5;
}
.modal-card::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.modal-card::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }
.modal-title {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-1);
  margin-bottom: 14px;
}
.modal-body {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-2);
  margin-bottom: 28px;
}
.modal-actions { display: flex; flex-direction: column; gap: 10px; }

/* ============================================================
   Modal sticky behaviors — applied via body.modal-open class
   ============================================================
   Locks the page underneath so users can't accidentally scroll past
   the modal on mobile (a common reason modals feel "dismissable").
   Combined with backdrop-filter:blur on .modal-backdrop, the
   underlying voice page completely disappears from the visitor's
   attention until they make a decision.
   ============================================================ */
body.modal-open {
  overflow: hidden;
  touch-action: none;     /* prevents pull-to-refresh + rubber band on iOS */
}

/* Gentle entrance animation so the modal feels intentional, not
   an abrupt page-takeover. Backdrop fades in; card slides up + fades. */
.modal-backdrop {
  animation: modal-backdrop-in 250ms ease-out;
}
.modal-backdrop .modal-card {
  animation: modal-card-in 350ms cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes modal-backdrop-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes modal-card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);    }
}

/* Subtle gold glow pulse on the primary modal CTA — draws the eye
   without being aggressive. Repeats every 2.5s so it nudges
   attention but doesn't strobe. Only applied when the .modal-cta-pulse
   class is set, so we can control which CTAs get this treatment. */
.btn-gold.modal-cta-pulse {
  animation: modal-cta-glow 2.5s ease-in-out infinite;
}
@keyframes modal-cta-glow {
  0%, 100% { box-shadow: 0 0 0 rgba(201, 168, 76, 0);   }
  50%      { box-shadow: 0 0 28px rgba(201, 168, 76, 0.55); }
}

/* Default focus ring is browser-ugly; use our gold for visibility */
.modal-card .btn-gold:focus-visible,
.modal-card .btn-ghost:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
}

.voice-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 20px;
  min-height: 0;
}

/* ============================================================
   Microphone-denied recovery panel
   ============================================================
   Shown inside .voice-center when navigator.mediaDevices.getUserMedia
   throws NotAllowedError — i.e., the user clicked Block on the mic
   permission prompt. Browsers do not let us programmatically re-prompt
   after a denial, so this panel walks them through the URL-bar permission
   icon AND offers a one-tap fallback to text reading so we never lose a
   visitor to "I don't know how to fix this." Auto-detects when permission
   is re-granted (Permissions API) and retries the session automatically.
   ============================================================ */
.mic-denied {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  max-width: 520px;
  margin: 0 auto;
  padding: 12px;
}
.mic-denied-icon {
  font-size: 56px;
  margin-bottom: 14px;
  opacity: 0.6;
  line-height: 1;
}
.mic-denied-title {
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: 2px;
  color: var(--gold);
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 12px;
}
.mic-denied-body {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  line-height: 1.55;
  color: var(--text-1);
  margin-bottom: 22px;
}
.mic-denied-howto {
  background: rgba(7,13,24,0.5);
  border: 1px solid var(--gold-border);
  padding: 16px 20px;
  text-align: left;
  margin-bottom: 24px;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-2);
  width: 100%;
}
.mic-denied-howto strong { color: var(--gold); font-weight: 500; }
.mic-denied-howto-title {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  display: block;
}
.mic-denied-howto ol {
  margin: 0;
  padding-left: 20px;
}
.mic-denied-howto li { margin-bottom: 6px; }
.mic-denied-howto li:last-child { margin-bottom: 0; }
.mic-denied-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 320px;
}
.mic-denied-actions .btn-gold,
.mic-denied-actions .btn-ghost {
  width: 100%;
  display: block;
  text-align: center;
  text-decoration: none;
}
.voice-orb-wrap {
  position: relative;
  width: 260px;
  height: 260px;
  margin-bottom: 36px;
}
.voice-portrait {
  position: absolute;
  inset: 30px;
  width: calc(100% - 60px);
  height: calc(100% - 60px);
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--gold-border-strong);
  z-index: 2;
}
.voice-orb {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--gold);
  opacity: 0.4;
  z-index: 1;
  transition: opacity 0.4s, box-shadow 0.6s;
  box-shadow: 0 0 0 var(--gold-glow);
}
.voice-orb::before, .voice-orb::after {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 1px solid var(--gold);
  opacity: 0;
  transition: opacity 0.4s;
}
.voice-orb::after { inset: -18px; }

.voice-orb-connecting {
  animation: orb-pulse 2s ease-in-out infinite;
  opacity: 0.5;
}
.voice-orb-idle {
  opacity: 0.3;
}
.voice-orb-listening {
  opacity: 0.5;
  box-shadow: 0 0 40px var(--gold-glow);
}
.voice-orb-listening::before { opacity: 0.4; }
.voice-orb-speaking {
  opacity: 0.85;
  box-shadow: 0 0 60px rgba(201, 168, 76, 0.45);
  animation: orb-breathe 2.4s ease-in-out infinite;
}
.voice-orb-speaking::before { opacity: 0.6; animation: orb-breathe 2.4s ease-in-out infinite 0.4s; }
.voice-orb-speaking::after  { opacity: 0.35; animation: orb-breathe 2.4s ease-in-out infinite 0.8s; }
.voice-orb-error {
  border-color: var(--error);
  opacity: 0.6;
}

@keyframes orb-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.7; box-shadow: 0 0 30px var(--gold-glow); }
}
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.05); opacity: 1; }
}

.voice-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--text-1);
  text-transform: uppercase;
  margin-bottom: 8px;
  text-shadow: 0 2px 16px rgba(7, 13, 24, 0.8);
}
.voice-archetype {
  font-family: var(--font-display);
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--gold);
  margin-bottom: 28px;
  text-transform: uppercase;
}
.voice-status {
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  color: var(--text-2);
  text-shadow: 0 2px 12px rgba(7, 13, 24, 0.85);
}

/* User's transcribed speech — appears as a single subtitle below the orb so
   the caller can verify "she heard me right" without spoilers of her reply. */
.voice-subtitle {
  max-width: 640px;
  margin: 28px auto 0;
  min-height: 1.7em;
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-1);
  text-align: center;
  text-shadow: 0 2px 14px rgba(7, 13, 24, 0.9);
  opacity: 0;
  transition: opacity 0.6s ease;
}
.voice-subtitle.visible {
  opacity: 0.88;
}

.voice-transcript {
  flex-shrink: 0;
  max-height: 28vh;
  overflow-y: auto;
  border-top: 1px solid var(--gold-border);
  padding: 16px 8px 8px;
}
.voice-transcript-stream {
  max-width: 700px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.voice-msg {
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.voice-msg-assistant {
  align-self: flex-start;
  max-width: 90%;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 16px;
  color: var(--text-1);
}
.voice-msg-assistant .voice-msg-author {
  display: block;
  font-family: var(--font-display);
  font-style: normal;
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--gold);
  margin-bottom: 4px;
  text-transform: uppercase;
}
.voice-msg-user {
  align-self: flex-end;
  max-width: 90%;
  background: rgba(7, 13, 24, 0.7);
  border: 1px solid var(--gold-border-strong);
  padding: 8px 14px;
  font-family: var(--font-ui);
  color: var(--text-1);
}

.voice-controls {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--gold-border);
}
.voice-mute-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: rgba(7, 13, 24, 0.7);
  border: 1px solid var(--gold-border-strong);
  color: var(--gold);
  font-size: 20px;
  cursor: pointer;
  transition: border-color 0.3s, background 0.3s;
}
.voice-mute-btn:hover {
  border-color: var(--gold);
  background: rgba(7, 13, 24, 0.85);
}

/* mobile tweaks for voice */
@media (max-width: 720px) {
  .voice-orb-wrap { width: 220px; height: 220px; margin-bottom: 24px; }
  .voice-name { font-size: 18px; letter-spacing: 3px; }
  .voice-transcript { max-height: 24vh; }
}

/* ============================================================
   History list
   ============================================================ */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.history-card {
  position: relative;
  background: rgba(7, 13, 24, 0.55);
  border: 1px solid var(--gold-border);
  transition: border-color 0.4s, background 0.4s, transform 0.4s;
}
.history-card:hover {
  border-color: var(--gold);
  background: rgba(7, 13, 24, 0.75);
  transform: translateX(2px);
}
.history-card-link {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  padding: 20px 22px;
  text-decoration: none;
  color: inherit;
}
.history-card-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 28px;
  height: 28px;
  background: transparent;
  border: 1px solid var(--gold-border);
  color: var(--text-3);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.25s, border-color 0.25s, background 0.25s;
  padding: 0;
}
.history-card-delete:hover {
  color: #d49a9a;
  border-color: rgba(212, 154, 154, 0.5);
  background: rgba(212, 154, 154, 0.08);
}
.history-card-portrait {
  width: 56px;
  height: 56px;
  border: 1px solid var(--gold-border-strong);
  object-fit: cover;
  flex-shrink: 0;
}
.history-card-body { flex: 1; min-width: 0; }
.history-card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 6px;
}
.history-card-name {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--text-1);
  text-transform: uppercase;
}
.history-card-date {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-3);
  white-space: nowrap;
  text-transform: uppercase;
}
.history-card-summary {
  font-family: var(--font-body);
  font-style: italic;
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-1);
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.history-card-meta {
  font-family: var(--font-display);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
}
.history-card-meta .in-progress { color: var(--gold); }

/* ============================================================
   Mobile
   ============================================================ */
@media (max-width: 720px) {
  .choose-wrap { padding: 80px 18px 60px; }
  .choose-grid { grid-template-columns: 1fr; gap: 18px; }
  .reader-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 22px;
  }
  .reader-card-portrait { width: 150px; }
  .reader-card-actions { justify-content: center; }
  .card { padding: 36px 24px 28px; }
  .corner-btn { font-size: 9px; padding: 8px 12px; }
  .chat-header { padding: 12px 16px; gap: 12px; }
  .chat-header-portrait { width: 38px; height: 38px; }
  .chat-header-name { font-size: 12px; }
  .chat-stream { padding: 24px 16px 16px; }
  .msg.assistant { font-size: 19px; }
  .msg.user { font-size: 15px; }
  .chat-input-bar { padding: 12px 16px 16px; }
  .history-card { padding: 16px; gap: 14px; }
  .history-card-portrait { width: 48px; height: 48px; }
}
