/* ============================================================
   Eloquent Web — On-Device AI Dictation
   Material Design 3 · Light & Dark Theme
   ============================================================ */


/* ── M3 Design Tokens — Light (default) ─────────────────── */
:root {
  --surface:               #ffffff;
  --surface-dim:           #f8f9fa;
  --surface-container:     #f1f3f4;
  --surface-container-high:#e8eaed;
  --on-surface:            #1f1f1f;
  --on-surface-variant:    #444746;
  --outline:               #747775;
  --outline-variant:       #c4c7c5;
  --primary:               #6750A4;
  --on-primary:            #ffffff;
  --primary-container:     #EADDFF;
  --on-primary-container:  #21005D;
  --secondary-container:   #E8DEF8;
  --error:                 #B3261E;
  --error-container:       #F9DEDC;
  --success:               #1e8e3e;

  /* Shape scale */
  --radius-xs:   4px;
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   16px;
  --radius-xl:   28px;
  --radius-full: 9999px;

  /* Motion */
  --transition: 150ms ease;

  color-scheme: light;
}


/* ── M3 Design Tokens — Dark ────────────────────────────── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface:               #141317;
    --surface-dim:           #141317;
    --surface-container:     #201f23;
    --surface-container-high:#2b292d;
    --on-surface:            #e5e1e7;
    --on-surface-variant:    #cac4d0;
    --outline:               #948f9a;
    --outline-variant:       #49454f;
    --primary:               #D0BCFF;
    --on-primary:            #381E72;
    --primary-container:     #4F378B;
    --on-primary-container:  #EADDFF;
    --secondary-container:   #4A4458;
    --error:                 #F2B8B5;
    --error-container:       #8C1D18;
    --success:               #81C995;

    color-scheme: dark;
  }
}

/* Manual dark override via data attribute */
[data-theme="dark"] {
  --surface:               #141317;
  --surface-dim:           #141317;
  --surface-container:     #201f23;
  --surface-container-high:#2b292d;
  --on-surface:            #e5e1e7;
  --on-surface-variant:    #cac4d0;
  --outline:               #948f9a;
  --outline-variant:       #49454f;
  --primary:               #D0BCFF;
  --on-primary:            #381E72;
  --primary-container:     #4F378B;
  --on-primary-container:  #EADDFF;
  --secondary-container:   #4A4458;
  --error:                 #F2B8B5;
  --error-container:       #8C1D18;
  --success:               #81C995;

  color-scheme: dark;
}


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

html, body {
  height: 100%;
  background: var(--surface);
  color: var(--on-surface);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

h1, h2, h3 {
  font-weight: 600;
  color: var(--on-surface);
}

/* Text selection */
::selection {
  background: var(--primary-container);
  color: var(--on-primary-container);
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--outline-variant) transparent;
}
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--outline-variant);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--outline);
}


/* ── App Root ────────────────────────────────────────────── */
#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}


/* ════════════════════════════════════════════════════════════
   Splash / Loading Screen
   ════════════════════════════════════════════════════════════ */
.splash {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  transition: opacity 600ms ease, visibility 600ms ease;
  overflow: hidden;
}
.splash.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Ambient glow orb behind content */
.splash::before {
  content: '';
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(
    circle,
    color-mix(in srgb, var(--primary) 18%, transparent) 0%,
    color-mix(in srgb, var(--primary) 6%, transparent) 40%,
    transparent 70%
  );
  animation: splashOrb 6s ease-in-out infinite;
  pointer-events: none;
  filter: blur(40px);
}

@keyframes splashOrb {
  0%, 100% { transform: scale(1) translate(0, 0); opacity: 0.7; }
  33%      { transform: scale(1.15) translate(10px, -15px); opacity: 1; }
  66%      { transform: scale(0.95) translate(-8px, 10px); opacity: 0.8; }
}

.splash-content {
  text-align: center;
  padding: 40px 24px;
  max-width: 360px;
  width: 100%;
  position: relative;
  z-index: 1;
}

.splash-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  animation: splashFadeUp 800ms cubic-bezier(0.16, 1, 0.3, 1) both;
}
.splash-brand h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: -0.02em;
}

/* Pulsing + slow rotate on the magic wand icon */
.splash-icon {
  flex-shrink: 0;
  animation: splashIconPulse 3s ease-in-out infinite;
}

@keyframes splashIconPulse {
  0%, 100% { transform: scale(1) rotate(0deg); filter: drop-shadow(0 0 0px var(--primary)); }
  50%      { transform: scale(1.12) rotate(8deg); filter: drop-shadow(0 0 12px var(--primary)); }
}

.splash-tagline {
  color: var(--on-surface-variant);
  font-size: 0.875rem;
  margin-top: 4px;
  animation: splashFadeUp 800ms 150ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Progress ── */
.splash-progress {
  margin-top: 48px;
  animation: splashFadeUp 800ms 300ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.progress-bar-track {
  width: 100%;
  height: 4px;
  background: var(--surface-container-high);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 70%, #fff));
  border-radius: var(--radius-full);
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
  position: relative;
}

/* Shimmer sweep on progress bar */
.progress-bar-fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.35) 50%,
    transparent 100%
  );
  animation: progressShimmer 2s ease-in-out infinite;
}

@keyframes progressShimmer {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

.progress-percentage {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 20px;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  animation: splashBreath 3s ease-in-out infinite;
}

@keyframes splashBreath {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}

.progress-status {
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
  margin-top: 4px;
}
.progress-detail {
  font-size: 0.75rem;
  color: var(--outline);
  margin-top: 4px;
  font-family: 'Inter', monospace;
  font-variant-numeric: tabular-nums;
}

/* Entrance animation */
@keyframes splashFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Error ── */
.splash-error {
  margin-top: 48px;
}
.splash-error h3 {
  font-size: 1rem;
  margin-top: 12px;
  color: var(--error);
  font-weight: 600;
}
.splash-error p {
  font-size: 0.875rem;
  color: var(--on-surface-variant);
  margin-top: 8px;
  line-height: 1.6;
}


/* ════════════════════════════════════════════════════════════
   Main App Shell
   ════════════════════════════════════════════════════════════ */
.main-app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--surface);
}
.main-app.hidden {
  display: none;
}


/* ── Header ──────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--outline-variant);
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-brand svg {
  color: var(--primary);
}
.header-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: -0.01em;
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  border: none;
  background: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}
.theme-toggle .material-symbols-outlined {
  font-size: 20px;
}


/* ════════════════════════════════════════════════════════════
   Tab Content — shared
   ════════════════════════════════════════════════════════════ */
.tab-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
}
.tab-content.hidden {
  display: none;
}


/* ── Status Pill (Listening / Polishing) ──────────────────── */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 16px 20px 0;
  padding: 8px 16px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--on-surface);
  width: fit-content;
  position: relative;
  overflow: hidden;
}
.pill-icon {
  font-size: 16px;
  color: var(--primary);
}

/* Subtle sweep — restrained animation */
.listening-sweep {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 40%;
  background: linear-gradient(
    90deg,
    transparent,
    color-mix(in srgb, var(--primary) 8%, transparent),
    transparent
  );
  animation: sweep 2.5s ease-in-out infinite;
}

@keyframes sweep {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(350%); }
}

/* ── Stats Card ──────────────────────────────────────────── */
.stats-card {
  margin: 12px 20px 0;
  padding: 16px 24px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-lg);
  text-align: center;
}
.stats-row {
  display: flex;
  justify-content: center;
  gap: 48px;
}
.stat-item {
  display: flex;
  align-items: baseline;
  gap: 4px;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--on-surface);
  font-variant-numeric: tabular-nums;
}
.stat-unit {
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--on-surface-variant);
}
.stats-label {
  font-size: 0.75rem;
  color: var(--outline);
  margin-top: 4px;
}

/* ── Recording Panel ─────────────────────────────────────── */
.recording-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 20px 16px;
  flex-shrink: 0;
}

/* ── Large Mic Button ────────────────────────────────────── */
.mic-button-container {
  display: flex;
  justify-content: center;
  padding: 12px 0 16px;
  flex-shrink: 0;
}
.mic-button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: var(--on-surface);
  color: var(--surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}
.mic-button:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
}
.mic-button:active {
  transform: scale(0.95);
}
.mic-button .material-symbols-outlined {
  font-size: 28px;
}

/* ── Transform Chips (inside text card) ──────────────────── */
.transform-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--outline-variant);
}
.transform-chips .transform-chip {
  padding: 8px 16px;
  font-size: 0.8125rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--outline-variant);
  background: none;
  color: var(--on-surface);
  cursor: pointer;
  font-weight: 500;
  font-family: inherit;
  transition: background var(--transition), border-color var(--transition);
}
.transform-chips .transform-chip:hover {
  background: var(--surface-container-high);
}
.transform-chips .transform-chip.active {
  background: var(--on-surface);
  color: var(--surface);
  border-color: var(--on-surface);
}

/* ── Original Text Panel ─────────────────────────────────── */
.original-text-panel {
  margin-top: 16px;
  background: var(--surface-container);
  border-radius: var(--radius-md);
  border: 1px solid var(--outline-variant);
}


/* ── Text Area (hero element) ────────────────────────────── */
.text-area {
  flex: 1;
  padding: 20px 20px;
  overflow-y: auto;
  min-height: 0;
}

/* When text area is empty, don't let it hog all space */
.text-area:has(.text-content:empty) {
  flex: 0 1 auto;
  min-height: 80px;
}

.text-content {
  min-height: 120px;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 1.125rem;
  line-height: 1.75;
  color: var(--on-surface);
  outline: none;
  white-space: pre-wrap;
  word-wrap: break-word;
  caret-color: var(--primary);
  padding: 4px 0;
}

/* Placeholder for contenteditable */
.text-content[data-placeholder]:empty::before {
  content: attr(data-placeholder);
  color: var(--outline);
  pointer-events: none;
  font-style: normal;
}

/* ── Text Area Header (Cleaned up text + copy) ───────────── */
.text-area-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 8px;
}
.text-area-header.hidden {
  display: none;
}
.text-area-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--on-surface);
  letter-spacing: -0.01em;
}
.copy-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: none;
  background: none;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.copy-btn:hover {
  background: var(--surface-container);
  color: var(--on-surface);
}
.copy-btn .material-symbols-outlined {
  font-size: 18px;
}
.copy-btn.copied .material-symbols-outlined {
  color: var(--primary);
}

/* ── Copy Toast ──────────────────────────────────────────── */
.copy-toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  margin: 0 20px 8px;
  background: var(--inverse-surface, #303030);
  color: var(--inverse-on-surface, #f0f0f0);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 500;
  animation: toastSlide 0.3s ease-out;
}
.copy-toast .material-symbols-outlined {
  font-size: 18px;
  color: #4ade80;
}
.copy-toast.hidden {
  display: none;
}
@keyframes toastSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ── Transcription Panel (inline card in text area) ──────── */
.transcription-panel {
  margin-top: auto;
  background: var(--surface-container);
  border-radius: var(--radius-md);
  border: 1px solid var(--outline-variant);
}

.transcription-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  cursor: pointer;
  transition: color var(--transition);
}
.transcription-toggle:hover {
  color: var(--on-surface);
}

.toggle-arrow {
  font-size: 20px;
  color: var(--on-surface-variant);
  transition: transform var(--transition);
}
.transcription-panel.collapsed .toggle-arrow {
  transform: rotate(180deg);
}

.transcription-body {
  padding: 0 20px 16px;
  max-height: 140px;
  overflow-y: auto;
  transition:
    max-height var(--transition),
    padding var(--transition),
    opacity var(--transition);
}
.transcription-panel.collapsed .transcription-body {
  max-height: 0;
  height: 0;
  padding: 0 20px;
  opacity: 0;
  overflow: hidden;
}

.transcription-text {
  font-style: italic;
  color: var(--outline);
  font-size: 0.8125rem;
  line-height: 1.6;
}


/* ── Timer ────────────────────────────────────────────────── */
.timer {
  text-align: center;
  font-family: 'Inter', monospace;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  padding: 4px 0;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
}
.timer.hidden {
  display: none;
}


/* ── Waveform ────────────────────────────────────────────── */
.waveform-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 4px 20px;
  min-height: 0;
  transition: opacity var(--transition);
}

.waveform {
  width: 280px;
  height: 36px;
  border-radius: var(--radius-sm);
}


/* ── Recording Controls ──────────────────────────────────── */
.recording-controls {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 12px 0 8px;
}

.control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid var(--outline-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-container);
  color: var(--on-surface);
  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition);
}
.control-btn:hover:not(:disabled) {
  background: var(--surface-container-high);
  border-color: var(--outline);
}
.control-btn:active:not(:disabled) {
  transform: scale(0.96);
}
.control-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}
.control-btn .material-symbols-outlined {
  font-size: 24px;
}

/* Stop button — primary accent */
#stop-btn-rec {
  background: var(--primary-container);
  border-color: transparent;
  color: var(--on-primary-container);
}
#stop-btn-rec:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary-container) 85%, var(--primary));
}

/* Record button — prominent primary accent */


.transform-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  border: 1px solid var(--outline-variant);
  background: var(--surface);
  color: var(--on-surface-variant);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition);
}
.transform-chip:hover {
  background: var(--surface-container);
  border-color: var(--outline);
  color: var(--on-surface);
}
.transform-chip:active {
  background: var(--surface-container-high);
}
.transform-chip:disabled {
  opacity: 0.4;
  pointer-events: none;
}
.transform-chip .material-symbols-outlined {
  font-size: 16px;
}

/* Processing state — pulsing opacity, no shimmer */
.transform-chip.processing {
  border-color: var(--primary);
  color: var(--primary);
  pointer-events: none;
  animation: chipPulse 1.5s ease-in-out infinite;
}

@keyframes chipPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}


/* ════════════════════════════════════════════════════════════
   History Tab
   ════════════════════════════════════════════════════════════ */
.history-header {
  padding: 24px 20px 12px;
}
.history-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--on-surface);
}

.history-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 20px 16px;
  padding: 10px 16px;
  background: var(--surface-container);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-full);
  transition: border-color var(--transition);
}
.history-search:focus-within {
  border-color: var(--primary);
}
.history-search .material-symbols-outlined {
  font-size: 20px;
  color: var(--outline);
}
.history-search input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--on-surface);
}
.history-search input::placeholder {
  color: var(--outline);
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px;
}

.history-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  margin-bottom: 2px;
  border: 1px solid transparent;
}
.history-item:hover {
  background: var(--surface-container);
}
.history-item.active {
  background: var(--primary-container);
  border-color: transparent;
}
.history-item.active .history-item-title {
  color: var(--on-primary-container);
}
.history-item.active .history-item-preview,
.history-item.active .history-item-date {
  color: color-mix(in srgb, var(--on-primary-container) 70%, transparent);
}

.history-item-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--on-surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-item-preview {
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.5;
}
.history-item-date {
  font-size: 0.75rem;
  color: var(--outline);
  margin-top: 4px;
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 8px;
  padding: 48px;
  text-align: center;
}
.history-empty .material-symbols-outlined {
  color: var(--outline-variant) !important;
}
.history-empty p {
  font-size: 0.875rem;
  color: var(--on-surface-variant);
}
.history-empty span {
  font-size: 0.8125rem;
  color: var(--outline);
}


/* ════════════════════════════════════════════════════════════
   Settings Tab
   ════════════════════════════════════════════════════════════ */
.settings-page {
  padding: 24px 20px;
}
.settings-page h2 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 24px;
  color: var(--on-surface);
}

.setting-section {
  padding: 16px 0;
  border-bottom: 1px solid var(--outline-variant);
}
.setting-section:last-child {
  border-bottom: none;
}

.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.setting-label {
  font-size: 0.875rem;
  color: var(--on-surface);
}
.setting-val {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--on-surface-variant);
  font-variant-numeric: tabular-nums;
}

/* Model status */
.model-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--on-surface-variant);
}
.model-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--outline);
  transition: background var(--transition);
}
.model-dot.ready {
  background: var(--success);
}

/* Range sliders */
.setting-section input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--surface-container-high);
  border-radius: var(--radius-full);
  outline: none;
  cursor: pointer;
  margin-top: 16px;
}
.setting-section input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
  transition: transform var(--transition);
}
.setting-section input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}
.setting-section input[type="range"]::-webkit-slider-thumb:active {
  transform: scale(1.1);
}

/* Firefox */
.setting-section input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  cursor: pointer;
}
.setting-section input[type="range"]::-moz-range-track {
  height: 4px;
  background: var(--surface-container-high);
  border-radius: var(--radius-full);
  border: none;
}


/* ════════════════════════════════════════════════════════════
   Bottom Tab Bar
   ════════════════════════════════════════════════════════════ */
.tab-bar {
  display: flex;
  border-top: 1px solid var(--outline-variant);
  background: var(--surface);
  padding: 4px 0 env(safe-area-inset-bottom, 4px);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--outline);
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 500;
  transition: color var(--transition);
  position: relative;
}
.tab .material-symbols-outlined {
  font-size: 24px;
  transition: color var(--transition);
}
.tab:hover {
  color: var(--on-surface-variant);
}

/* Active tab — primary color text + thin indicator */
.tab.active {
  color: var(--primary);
}
.tab.active .material-symbols-outlined {
  color: var(--primary);
}
.tab.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 2px;
  background: var(--primary);
  border-radius: 0 0 var(--radius-xs) var(--radius-xs);
}

.tab-label {
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
}



/* ════════════════════════════════════════════════════════════
   Utility Classes
   ════════════════════════════════════════════════════════════ */
.hidden {
  display: none !important;
}

.fade-in {
  animation: fadeIn 300ms ease both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ════════════════════════════════════════════════════════════
   New Elements — Mobile defaults (hidden on mobile)
   ════════════════════════════════════════════════════════════ */

/* Desktop header nav — hidden on mobile */
.header-nav {
  display: none;
}

/* Editor and Controls panels — no special treatment on mobile */
.editor-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}



/* ════════════════════════════════════════════════════════════
   Responsive — Desktop (768px+)
   Two-column layout: editor left, controls right
   Header tabs replace bottom tab bar
   ════════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  #app {
    height: 100dvh;
  }

  /* ── Header: full-width bar with inline tabs ────────── */
  .header {
    padding: 0 32px;
    height: 56px;
    border-bottom: 1px solid var(--outline-variant);
  }

  .header-brand {
    gap: 10px;
  }
  .header-title {
    font-size: 1rem;
  }

  /* Show desktop nav tabs in header */
  .header-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-inline-start: auto;
    margin-inline-end: 16px;
  }

  .header-tab {
    padding: 8px 20px;
    border: none;
    background: none;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--on-surface-variant);
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: background var(--transition), color var(--transition);
    position: relative;
  }
  .header-tab:hover {
    background: var(--surface-container);
    color: var(--on-surface);
  }
  .header-tab.active {
    color: var(--primary);
    background: var(--primary-container);
  }

  /* ── Hide bottom tab bar on desktop ─────────────────── */
  .tab-bar {
    display: none;
  }

  /* ── Main app fills viewport ────────────────────────── */
  .main-app {
    max-inline-size: none;
    margin: 0;
    border: none;
    box-shadow: none;
  }

  /* ── Record tab: single centered column ──────────────── */
  #tab-record {
    display: flex;
    flex-direction: column;
    max-width: 720px;
    margin: 0 auto;
    width: 100%;
  }

  /* ── Editor panel ──────────────────────────────────────── */
  .editor-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .text-area {
    flex: 1;
    padding: 32px 48px;
    overflow-y: auto;
  }
  .text-content {
    font-size: 1.25rem;
    line-height: 1.8;
    max-inline-size: none;
  }

  /* Status pills on desktop */
  .status-pill {
    margin: 16px 48px 0;
  }

  /* Stats card on desktop */
  .stats-card {
    margin: 12px 48px 0;
  }

  /* Recording panel on desktop */
  .recording-panel {
    padding: 16px 48px 20px;
  }

  .recording-controls {
    gap: 24px;
  }
  .control-btn {
    inline-size: 64px;
    block-size: 64px;
  }

  .waveform {
    inline-size: 300px;
    block-size: 40px;
  }

  .timer {
    font-size: 1rem;
  }

  /* Mic button on desktop */
  .mic-button {
    width: 72px;
    height: 72px;
  }
  .mic-button .material-symbols-outlined {
    font-size: 32px;
  }

  /* Transcription panel on desktop */
  .transcription-panel {
    margin: 12px 48px 0;
  }

  /* ── History & Settings — proper desktop widths ─────── */
  #tab-history,
  #tab-settings {
    padding: 0;
  }

  .settings-page {
    padding: 32px 48px;
    max-inline-size: 560px;
  }
  .history-header {
    padding: 24px 48px 12px;
  }
  .history-search {
    margin: 0 48px 16px;
  }
  .history-list {
    padding: 0 36px;
  }
}


/* ════════════════════════════════════════════════════════════
   Responsive — Large Desktop (1200px+)
   Wider sidebar, bigger editor
   ════════════════════════════════════════════════════════════ */
@media (min-width: 1200px) {
  .header {
    padding-inline: 48px;
    height: 60px;
  }
  .header-title {
    font-size: 1.0625rem;
  }

  #tab-record {
    grid-template-columns: 1fr 380px;
  }

  .text-area {
    padding: 48px 64px;
  }
  .text-content {
    font-size: 1.375rem;
    line-height: 1.85;
  }

  .transform-bar {
    padding-inline: 64px;
    gap: 10px;
  }
  .transform-chip {
    padding: 10px 20px;
    font-size: 0.875rem;
  }

  .controls-panel {
    padding: 40px 32px;
    gap: 20px;
  }

  .control-btn {
    inline-size: 72px;
    block-size: 72px;
  }
  .control-btn .material-symbols-outlined {
    font-size: 28px;
  }

  .waveform {
    inline-size: 300px;
    block-size: 44px;
  }

  .settings-page {
    padding: 40px 64px;
    max-inline-size: 640px;
  }
  .history-header {
    padding: 32px 64px 16px;
  }
  .history-search {
    margin: 0 64px 16px;
  }
  .history-list {
    padding: 0 52px;
  }
}


/* ════════════════════════════════════════════════════════════
   Responsive — Ultra-wide (1600px+)
   ════════════════════════════════════════════════════════════ */
@media (min-width: 1600px) {
  #tab-record {
    grid-template-columns: 1fr 420px;
  }

  .text-area {
    padding: 56px 96px;
  }

  .transform-bar {
    padding-inline: 96px;
  }

  .controls-panel {
    padding: 48px 40px;
  }
}


/* ════════════════════════════════════════════════════════════
   Small Mobile (max-width: 360px)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .splash-brand h1 {
    font-size: 1.25rem;
  }
  .text-content {
    font-size: 1rem;
  }
  .transform-chip {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
  .control-btn {
    inline-size: 48px;
    block-size: 48px;
  }
  .control-btn .material-symbols-outlined {
    font-size: 20px;
  }
  .recording-controls {
    gap: 16px;
  }
}


/* ════════════════════════════════════════════════════════════
   Landscape Mobile
   ════════════════════════════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
  .splash-progress {
    margin-block-start: 24px;
  }
  .text-area {
    padding-block: 12px;
  }
  .recording-controls {
    padding-block: 4px;
  }
  .waveform-container {
    padding-block: 2px;
  }
  .tab {
    padding-block: 4px;
  }
  .tab .material-symbols-outlined {
    font-size: 20px;
  }
  .tab-label {
    display: none;
  }
}


/* ════════════════════════════════════════════════════════════
   Reduced Motion
   ════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .listening-sweep {
    display: none;
  }

  .fade-in {
    animation: none;
    opacity: 1;
  }
}
