/* ═══════════════════════════════════════════════════════════
   TuvaLLM — Tuvaluan Speech Recognition
   Sophisticated Dark Ocean Theme
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=Outfit:wght@300;400;500;600;700;800;900&display=swap');

:root {
  /* ── Clean Light Palette ─────────────────────────────── */
  --bg-dark: #f8fafc;
  --bg-panel: #ffffff;
  --glass-border: #e2e8f0;
  --glass-shine: transparent;

  /* Tuvaluan flag blue (#418FDE) */
  --neon-cyan: #418FDE;
  --neon-cyan-dim: #e8f0fc;
  --neon-coral: #e11d48;
  --neon-coral-dim: #ffe4e6;
  --neon-purple: #3576be;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dark: #1e293b;
  --white: #ffffff;

  /* ── Typography ─────────────────────────────────────── */
  --font-display: 'Outfit', system-ui, -apple-system, sans-serif;
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;

  /* ── Sizing ─────────────────────────────────────────── */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 999px;

  /* ── Transitions ────────────────────────────────────── */
  --ease-elastic: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Reset ─────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-size: 18px;
  /* Increased base font size */
  line-height: 1.6;
  overflow-x: hidden;
}

/* CRITICAL: Ensure hidden attributes are respected even with flexbox */
[hidden] {
  display: none !important;
}

a {
  color: var(--neon-cyan);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  text-decoration: underline;
  color: #2d6abf;
}

/* ── Utility ───────────────────────────────────────────── */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.5rem;
  position: relative;
  z-index: 2;
}

/* ── Subtle Ambient Background ──────────────────────────── */
.ocean-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--bg-dark);
  overflow: hidden;
}

.ocean-bg::before,
.ocean-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.4;
  animation: float 30s infinite ease-in-out alternate;
  pointer-events: none;
}

.ocean-bg::before {
  width: 60vw;
  height: 60vh;
  background: radial-gradient(circle, #dbeafe, transparent 70%);
  /* Light blue */
  top: -10vh;
  left: -10vw;
}

.ocean-bg::after {
  width: 50vw;
  height: 50vh;
  background: radial-gradient(circle, #e0e7ff, transparent 70%);
  /* Light purple */
  bottom: -10vh;
  right: -10vw;
  animation-duration: 40s;
  animation-delay: -5s;
}

@keyframes float {
  0% {
    transform: translate(0, 0) scale(1);
  }

  100% {
    transform: translate(2vw, -2vh) scale(1.05);
  }
}

/* ── Clean Card Mixin ───────────────────────── */
.glass-panel {
  background: var(--white);
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  border-radius: var(--radius-lg);
}

/* ══════════════════════════════════════════════════════════
   HEADER
   ══════════════════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 1.5rem;
  z-index: 30;
  margin: 0 1rem;
}

.header-row {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  padding: 0 2rem;
}

.brand-lockup {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.1;
  text-decoration: none;
  background: none;
}

.brand-lockup:hover {
  background: none;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--text-dark) 0%, var(--text-muted) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-title em {
  font-style: normal;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, var(--neon-purple) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ── Tab navigation ────────────────────────────────────── */
.section-tabs {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.35rem;
  border-radius: var(--radius-pill);
  border: 1px solid var(--glass-border);
  flex-wrap: nowrap;
  overflow-x: auto;
  /* Prevent wrapping but allow scrolling on very small screens */
  scrollbar-width: none;
}

.section-tabs::-webkit-scrollbar {
  display: none;
}

.section-tab {
  background: transparent;
  color: var(--text-muted);
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.6rem 1.2rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.3s var(--ease-elastic);
}

.section-tab:hover {
  color: var(--text-main);
}

.section-tab.is-active {
  background: var(--neon-cyan-dim);
  color: var(--neon-cyan);
  font-weight: 700;
}

/* ══════════════════════════════════════════════════════════
   MAIN CONTENT
   ══════════════════════════════════════════════════════════ */
.app-main {
  padding: 3rem 0;
  position: relative;
  z-index: 10;
}

.app-section {
  display: none;
}

.app-section.is-active {
  display: block;
  animation: sectionReveal 0.6s var(--ease-smooth) forwards;
}

@keyframes sectionReveal {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.99);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ══════════════════════════════════════════════════════════
   ONBOARDING CARD
   ══════════════════════════════════════════════════════════ */
.onboarding-card {
  padding: 4rem 3rem;
  text-align: center;
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
}

.onboarding-title {
  font-family: var(--font-display);
  color: var(--text-main);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 1.2rem;
}

.onboarding-desc {
  font-size: 1.15rem;
  color: var(--text-muted);
  max-width: 540px;
  margin: 0 auto 3rem;
  line-height: 1.7;
}

.onboarding-name-row {
  margin-bottom: 2.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.onboarding-name-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.onboarding-name-input {
  width: 100%;
  max-width: 320px;
  padding: 1rem 1.5rem;
  background: var(--white);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-pill);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 1.1rem;
  text-align: center;
  transition: all 0.3s;
}

.onboarding-name-input:focus {
  outline: none;
  border-color: var(--neon-cyan);
  background: var(--white);
}

.onboarding-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* ══════════════════════════════════════════════════════════
   PREMIUM BUTTONS
   ══════════════════════════════════════════════════════════ */
.contribute-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 1.1rem 2.2rem;
  /* Larger buttons */
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 1.15rem;
  /* Larger font size */
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease-out;
  border: 1px solid transparent;
  position: relative;
  white-space: nowrap;
}

.contribute-btn.primary {
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #2d6abf 100%);
  color: var(--white);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.contribute-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.contribute-btn.ghost {
  background: var(--white);
  color: var(--text-main);
  border: 2px solid var(--glass-border);
}

.contribute-btn.ghost:hover {
  background: var(--bg-dark);
}

/* ══════════════════════════════════════════════════════════
   PROMPT CARD
   ══════════════════════════════════════════════════════════ */
.prompt-card {
  padding: 2.5rem;
  margin-bottom: 2rem;
  position: relative;
}

.prompt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.prompt-badge {
  padding: 0.4rem 1rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.prompt-badge.talk {
  background: var(--neon-coral-dim);
  color: var(--neon-coral);
  border: 1px solid var(--neon-coral);
}

.prompt-badge.read-aloud {
  background: var(--neon-cyan-dim);
  color: var(--neon-cyan);
  border: 1px solid var(--neon-cyan);
}

.prompt-shuffle {
  background: var(--white);
  border: 2px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.2s;
}

.prompt-shuffle:hover {
  background: var(--bg-dark);
  border-color: var(--text-muted);
}

.prompt-text {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.4;
}

/* ══════════════════════════════════════════════════════════
   MICROPHONE 
   ══════════════════════════════════════════════════════════ */
.mic-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  margin: 4rem 0;
}

.mic-btn {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #2d6abf 100%);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3), inset 0 2px 4px rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  z-index: 10;
}

.mic-btn svg {
  width: 50px;
  height: 50px;
  fill: var(--white);
  transition: transform 0.2s;
}

.mic-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

.mic-btn:hover svg {
  transform: scale(1.1);
}

.mic-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.3);
}

/* Recording State */
.mic-btn.recording {
  background: linear-gradient(135deg, var(--neon-coral) 0%, #be123c 100%);
  box-shadow: 0 4px 20px rgba(225, 29, 72, 0.4), inset 0 2px 4px rgba(255, 255, 255, 0.2);
  animation: pulsePulse 1.5s infinite alternate;
}

.mic-btn.recording svg {
  fill: var(--white);
}

@keyframes pulsePulse {
  from {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(225, 29, 72, 0.4);
  }

  to {
    transform: scale(1.08);
    box-shadow: 0 4px 30px rgba(225, 29, 72, 0.6);
  }
}

/* Connecting State — immediate feedback while mic/WS initializes */
.mic-btn.connecting {
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #2d6abf 100%);
  box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
  animation: connectingPulse 0.8s infinite alternate;
  pointer-events: none;
  opacity: 0.85;
}

@keyframes connectingPulse {
  from {
    transform: scale(1);
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.3);
  }
  to {
    transform: scale(1.06);
    box-shadow: 0 4px 30px rgba(37, 99, 235, 0.6);
  }
}

/* Mic label (the big instruction text above mic-status) */
.mic-label {
  font-weight: 600;
  color: var(--neon-cyan);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.mic-label.recording-active {
  color: var(--neon-coral);
  font-size: 1.3rem;
  font-weight: 800;
  animation: stopLabelPulse 1.5s infinite alternate;
}

@keyframes stopLabelPulse {
  from { opacity: 1; }
  to { opacity: 0.7; }
}

.mic-status {
  font-family: var(--font-main);
  font-size: 1.1rem;
  color: var(--text-muted);
}

.mic-status.active {
  color: var(--neon-coral);
  font-size: 1.25rem;
  font-weight: 600;
}

/* ══════════════════════════════════════════════════════════
   TRANSCRIPT BOX
   ══════════════════════════════════════════════════════════ */
.transcript-box {
  min-height: 160px;
  padding: 2rem;
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--text-main);
  transition: all 0.3s;
  position: relative;
  margin-bottom: 2rem;
  border: 2px solid var(--glass-border);
}

.transcript-box.active {
  border-color: var(--neon-cyan);
  background: var(--neon-cyan-dim);
}

.transcript-box.editing {
  border-color: var(--neon-purple);
  background: #e0e7ff;
}

.transcript-placeholder {
  color: var(--text-muted);
  font-style: italic;
  font-weight: 300;
}

#transcript-content[contenteditable="true"] {
  outline: none;
  background: var(--bg-dark);
  padding: 1.5rem;
  border-radius: var(--radius-sm);
  border: 2px solid var(--glass-border);
  caret-color: var(--neon-cyan);
  min-height: 100px;
}

.transcript-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}

.correction-meta {
  color: var(--text-dark);
  font-size: 0.9rem;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════
   READ ALOUD & UPLOAD
   ══════════════════════════════════════════════════════════ */
.ra-step-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 2rem;
  counter-reset: none;
}

.ra-step-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1rem;
  color: var(--text-main);
  padding: 0.25rem 0;
}

.ra-step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--neon-cyan);
  color: var(--white);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ra-upload-zone {
  text-align: center;
  padding: 4rem 2rem;
  border: 2px dashed var(--text-muted);
  border-radius: var(--radius-lg);
  margin-top: 2rem;
  transition: all 0.2s;
  background: var(--bg-dark);
}

.ra-upload-zone:hover {
  border-color: var(--neon-cyan);
  background: var(--neon-cyan-dim);
}

.ra-upload-icon svg {
  fill: var(--text-muted);
  margin-bottom: 1rem;
}

.ra-upload-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

/* ── Read Aloud OCR Panel ──────────────────────────────── */
.ra-ocr-panel {
  padding: 2rem;
  margin-top: 2rem;
  position: relative;
}

.ra-processing {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  z-index: 5;
  font-size: 1rem;
  color: var(--text-muted);
}

.ra-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--glass-border);
  border-top-color: var(--neon-cyan);
  border-radius: 50%;
  animation: raSpin 0.8s linear infinite;
}

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

.ra-ocr-image {
  margin-bottom: 1.5rem;
}

.ra-ocr-image img {
  max-width: 100%;
  max-height: 200px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.ra-ocr-label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.ra-ocr-text {
  display: block;
  width: 100%;
  padding: 1rem;
  font-family: var(--font-main);
  font-size: 1.1rem;
  line-height: 1.6;
  color: var(--text-main);
  background: #fffbeb;
  border: 2px solid #d97706;
  border-radius: var(--radius-sm);
  resize: vertical;
  outline: none;
}

.ra-ocr-text:focus {
  border-color: #b45309;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.ra-syllable-hints {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ── Read Aloud Read Prompt ───────────────────────────── */
.ra-read-prompt {
  padding: 2rem;
  margin-bottom: 1rem;
}

.ra-read-prompt-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--neon-cyan);
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.ra-read-prompt-text {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.5;
}

/* ── Read Aloud Image Preview ─────────────────────────── */
.ra-image-preview {
  position: relative;
  margin-top: 1.5rem;
}

.ra-image-preview img {
  max-width: 100%;
  max-height: 300px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
}

.image-remove-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: var(--white);
  font-size: 1.2rem;
  line-height: 28px;
  text-align: center;
  cursor: pointer;
}

/* General Upload Area (Record Tab) */
.upload-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin: 2rem 0;
}

.upload-divider {
  color: var(--text-dark);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--white);
  border: 2px solid var(--glass-border);
  border-radius: var(--radius-pill);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-btn:hover {
  background: var(--bg-dark);
  border-color: var(--text-muted);
}

.upload-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════
   SECTIONS & PANELS
   ══════════════════════════════════════════════════════════ */
.section-title {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.section-desc {
  color: var(--text-muted);
  font-size: 1.1rem;
  max-width: 650px;
  line-height: 1.6;
}

.section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--neon-cyan);
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.5rem;
  margin: 3rem 0;
}

.stat-item {
  text-align: center;
  padding: 2.5rem 1rem;
  border-radius: var(--radius-lg);
  background: var(--bg-panel);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02);
  transition: transform 0.3s;
}

.stat-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.stat-value .accent {
  color: var(--neon-cyan);
}

.stat-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.about-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 2.5rem;
}

.about-card,
.contributor-card {
  padding: 2.5rem;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--glass-border);
  transition: all 0.3s;
}

.about-card:hover,
.contributor-card:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.1);
  transform: translateY(-2px);
}

.about-card h3 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  margin: 0.5rem 0 1rem;
  color: var(--text-dark);
}

.card-accent {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--neon-purple);
  font-weight: 600;
}

/* Word Game section */
.help-train-panel {
  padding: 3rem;
  margin-top: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.parliament-pw-label {
  display: block;
  margin-bottom: 1rem;
  color: var(--text-main);
  font-weight: 500;
}

.parliament-pw-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.parliament-pw-input {
  padding: 0.75rem 1.5rem;
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  color: var(--text-main);
  outline: none;
}

.parliament-pw-input:focus {
  border-color: var(--neon-cyan);
}

/* ══════════════════════════════════════════════════════════
   FOOTER
   ══════════════════════════════════════════════════════════ */
.site-footer {
  padding: 3rem 0;
  text-align: center;
  color: var(--text-dark);
  font-size: 0.9rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  margin-top: 4rem;
}

.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.footer-inner a {
  color: var(--text-muted);
}

.footer-inner a:hover {
  color: var(--white);
}

.footer-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text-dark);
}


/* ── In-app browser warning ─────────────────────────────── */
.inapp-banner {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.inapp-banner-inner {
  max-width: 420px;
  text-align: center;
}

.inapp-banner-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 1rem;
}

.inapp-banner-desc {
  color: var(--text-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.inapp-banner-actions {
  margin-bottom: 1.5rem;
}

.inapp-banner-fallback {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

/* ── Island nudge (gentle prompt when island not set) ───── */
.island-nudge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  background: var(--white);
}

.island-nudge-label {
  font-size: 0.9rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.island-nudge-input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.9rem;
  outline: none;
}

.island-nudge-input:focus {
  border-color: var(--neon-cyan);
}

/* ══════════════════════════════════════════════════════════
   KARAOKE PLAYBACK
   ══════════════════════════════════════════════════════════ */
.karaoke-word {
  transition: background-color 0.15s ease, color 0.15s ease;
  border-radius: 3px;
  padding: 0 2px;
}

.karaoke-word.karaoke-active {
  background: var(--neon-cyan);
  color: var(--white);
}

.karaoke-play-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1.2rem;
  margin-bottom: 1rem;
  border: 2px solid var(--neon-cyan);
  border-radius: var(--radius-pill);
  background: var(--white);
  color: var(--neon-cyan);
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.karaoke-play-btn:hover {
  background: var(--neon-cyan-dim);
}

.karaoke-play-btn.playing {
  background: var(--neon-cyan);
  color: var(--white);
}

/* ══════════════════════════════════════════════════════════
   SUMMARY / TRY AGAIN PANEL
   ══════════════════════════════════════════════════════════ */
.summary-panel {
  padding: 3rem 2rem;
  text-align: center;
  animation: sectionReveal 0.6s var(--ease-smooth) forwards;
}

.summary-panel h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.75rem;
}

.summary-panel .summary-stats {
  color: var(--text-muted);
  font-size: 1.05rem;
  margin-bottom: 2rem;
}

.summary-panel .try-again-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: 1.3rem 3rem;
  border-radius: var(--radius-pill);
  font-family: var(--font-main);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #2d6abf 100%);
  color: var(--white);
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.3);
  transition: all 0.2s ease-out;
}

.summary-panel .try-again-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.4);
}

/* Various small fixes */
.progress-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.settings-panel {
  background: var(--bg-panel);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  padding: 1.5rem;
  margin-top: 1rem;
}

.settings-check {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
  cursor: pointer;
}

.settings-name-row {
  margin: 1.5rem 0;
}

.settings-name-input {
  display: block;
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  margin-top: 0.5rem;
  outline: none;
}

.settings-decode-row {
  margin-top: 1.5rem;
}

.decode-toggle {
  display: inline-flex;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 0.25rem;
  margin-top: 0.5rem;
}

.decode-option {
  background: transparent;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.9rem;
  cursor: pointer;
}

.decode-option.is-active {
  background: var(--neon-cyan);
  color: var(--white);
}

/* Progress strip hiding */
#file-input {
  display: none;
}

/* Ensure all app sections inherit glass panel styles automatically if needed */
.app-section>.container>.glass-panel {
  margin-bottom: 2rem;
}

/* ══════════════════════════════════════════════════════════
   SAUTALA CHAT
   ══════════════════════════════════════════════════════════ */
.sautala-messages {
  max-height: 50vh;
  min-height: 120px;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
  scroll-behavior: smooth;
}

.sautala-msg {
  max-width: 85%;
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  line-height: 1.6;
  font-size: 1.05rem;
  position: relative;
  animation: sectionReveal 0.3s var(--ease-smooth) forwards;
}

.sautala-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--neon-cyan) 0%, #2d6abf 100%);
  color: var(--white);
  border-bottom-right-radius: 4px;
}

.sautala-msg-bot {
  align-self: flex-start;
  background: var(--white);
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  border-bottom-left-radius: 4px;
}

.sautala-msg-bot .sautala-msg-tuvaluan {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.sautala-msg-bot .sautala-msg-english {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
}

.sautala-msg-thinking {
  align-self: flex-start;
  background: var(--white);
  border: 1px solid var(--glass-border);
  color: var(--text-muted);
  font-style: italic;
}

.sautala-msg-thinking::after {
  content: '...';
  animation: thinkingDots 1.5s infinite;
}

@keyframes thinkingDots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* Clickable word spans */
.sautala-word {
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.15s;
  display: inline;
}

.sautala-word:hover {
  background: rgba(37, 99, 235, 0.15);
}

.sautala-msg-user .sautala-word:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Dictionary tooltip */
.sautala-tooltip {
  position: fixed;
  z-index: 100;
  background: var(--white);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  padding: 1rem 1.25rem;
  max-width: 320px;
  min-width: 200px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.sautala-tooltip-word {
  font-weight: 700;
  color: var(--neon-cyan);
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

.sautala-tooltip-pos {
  color: var(--text-muted);
  font-size: 0.8rem;
  font-style: italic;
  margin-bottom: 0.5rem;
}

.sautala-tooltip-def {
  color: var(--text-main);
}

.sautala-tooltip-fuzzy {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--glass-border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.sautala-tooltip-fuzzy-label {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

/* Correction prompts */
.sautala-correction-prompt {
  background: var(--neon-cyan-dim);
  border: 1px solid var(--neon-cyan);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.sautala-correction-urgent {
  background: #fef9c3;
  border: 2px solid #eab308;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
  font-size: 0.95rem;
  font-weight: 500;
}

/* Always-visible edit pencil on user messages */
.sautala-msg-edit-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: rgba(255, 255, 255, 0.85);
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 13px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s, background 0.15s;
  color: #2d6abf;
  padding: 0;
}

.sautala-msg-edit-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 1);
}

/* Click-to-edit affordance on user messages */
.sautala-msg-user .sautala-msg-tuvaluan,
.sautala-msg-user .sautala-word {
  cursor: text;
}

/* Editable user message */
.sautala-msg-editing {
  border: 2px solid var(--neon-purple);
  background: #e0e7ff;
  color: var(--text-main);
}

.sautala-msg-editing [contenteditable] {
  outline: none;
  min-height: 1.5em;
}

.sautala-edit-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
  justify-content: flex-end;
}

.sautala-edit-btn {
  background: var(--neon-cyan);
  color: var(--white);
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.sautala-edit-cancel {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-pill);
  padding: 0.35rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
}

/* "Correcting..." indicator (shown during regeneration) */
.sautala-msg-correcting {
  background: #e0e7ff;
  border: 1px solid #818cf8;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  font-style: italic;
  color: #4338ca;
  font-size: 0.95rem;
}

.sautala-msg-correcting::after {
  content: '';
  animation: thinkingDots 1.5s infinite;
}

/* Regenerated bot response marker */
.sautala-msg-regenerated {
  border-left: 3px solid var(--neon-purple);
}

@media (max-width: 768px) {
  .site-header {
    top: 0.5rem;
    margin: 0 0.5rem;
  }

  .header-row {
    flex-direction: column;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    gap: 0.5rem;
    min-height: auto;
  }

  .brand-lockup {
    align-items: center;
  }

  .brand-title {
    font-size: 1.4rem;
  }

  .section-tabs {
    flex-wrap: wrap;
    justify-content: center;
    overflow-x: visible;
    gap: 0.35rem;
  }

  .section-tab {
    padding: 0.5rem 0.9rem;
    font-size: 0.85rem;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .onboarding-card {
    padding: 2.5rem 1.5rem;
  }

  .app-main {
    padding: 1.5rem 0;
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 1rem;
  }

  .header-row {
    padding: 0.5rem;
  }

  .brand-title {
    font-size: 1.2rem;
  }

  .section-tabs {
    gap: 0.25rem;
  }

  .section-tab {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
  }

  .contribute-btn {
    padding: 0.9rem 1.5rem;
    font-size: 1rem;
  }

  .stats-row {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
  }

  .stat-value {
    font-size: 2rem;
  }

  .stat-item {
    padding: 2rem 0.75rem;
  }
}