/* ─── Variables & Tokens ─── */
:root {
  --bg-main: #070709;
  --bg-card: #0f0f14;
  --bg-card-hover: #15151c;
  --bg-subtle: #1a1a23;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(245, 158, 11, 0.5);

  --ink-primary: #f4f4f6;
  --ink-secondary: #a1a1aa;
  --ink-muted: #71717a;

  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.18);
  --accent-red: #ef4444;
  --accent-green: #22c55e;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Geist Mono", Menlo, Consolas, monospace;
  --font-sanskrit: "Noto Serif Devanagari", "Rozha One", "Martel", Georgia, serif;
}

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

body {
  background-color: var(--bg-main);
  color: var(--ink-primary);
  font-family: var(--font-ui);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: clamp(20px, 4vw, 36px) clamp(16px, 4vw, 24px) 80px;
  flex: 1;
}

/* ─── Top Nav / Breadcrumbs ─── */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(20px, 4vw, 32px);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-secondary);
  font-size: 0.85rem;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
  min-height: 36px;
}

.back-link:hover {
  color: var(--ink-primary);
}

.back-link svg {
  flex-shrink: 0;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 9999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
  white-space: nowrap;
  flex-shrink: 0;
}

.status-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ink-muted);
  flex-shrink: 0;
}

.status-badge .dot.green {
  background: var(--accent-green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
}

/* ─── Header ─── */
.app-header {
  margin-bottom: clamp(24px, 4vw, 36px);
}

.header-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.header-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.22);
  border-radius: 9999px;
  font-size: 0.74rem;
  color: #fbbf24;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.tag-accent-glow {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-amber);
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
}

.offline-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  font-size: 0.72rem;
  color: var(--ink-secondary);
  font-family: var(--font-mono);
}

.offline-badge svg {
  color: var(--accent-green);
}

.title-wrap {
  margin-bottom: 8px;
}

h1 {
  font-size: clamp(1.85rem, 6vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--ink-primary);
  display: flex;
  align-items: baseline;
  gap: clamp(8px, 2vw, 14px);
  flex-wrap: wrap;
  line-height: 1.15;
  margin: 0;
}

.dev-glyph {
  font-family: var(--font-sanskrit);
  color: var(--accent-amber);
  font-weight: 700;
  text-shadow: 0 0 24px rgba(245, 158, 11, 0.18);
}

.title-sep {
  color: var(--border-medium);
  font-weight: 300;
}

.title-en {
  font-family: var(--font-sans);
  color: var(--ink-primary);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.invoc-callout {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding: 6px 12px;
  background: rgba(245, 158, 11, 0.04);
  border-left: 2px solid var(--accent-amber);
  border-radius: 0 6px 6px 0;
  font-size: 0.84rem;
}

.invoc-shloka {
  font-family: var(--font-sanskrit);
  color: var(--accent-amber);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.invoc-sep {
  color: var(--ink-muted);
}

.invoc-meaning {
  color: var(--ink-muted);
  font-style: italic;
  font-size: 0.78rem;
}

.subtitle {
  color: var(--ink-secondary);
  font-size: clamp(0.88rem, 2.2vw, 0.98rem);
  max-width: 650px;
  line-height: 1.6;
  margin-top: 14px;
}

.tech-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tech-pill {
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
  transition: border-color 0.15s ease;
}

.card:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

/* ─── Load Model Card ─── */
.load-card-content {
  text-align: center;
  padding: 16px 8px;
}

.load-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-amber-glow);
  border-radius: 12px;
}

.load-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.load-desc {
  font-size: 0.875rem;
  color: var(--ink-secondary);
  max-width: 480px;
  margin: 0 auto 20px;
}

.progress-container {
  margin-top: 16px;
}

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-subtle);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-amber);
  border-radius: 4px;
  transition: width 0.2s ease;
}

.progress-text {
  font-size: 0.8rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
}

.cache-status-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.cache-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 999px;
  font-size: 0.76rem;
  color: #34d399;
  font-family: var(--font-mono);
}

.cache-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.btn-text-sm {
  background: transparent;
  border: none;
  color: var(--ink-muted);
  font-size: 0.75rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 6px;
  font-family: inherit;
  transition: color 0.15s ease;
}

.btn-text-sm:hover {
  color: #ef4444;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.btn-primary {
  background: var(--accent-amber);
  color: #000;
}

.btn-primary:hover:not(:disabled) {
  background: #d97706;
}

.btn-secondary {
  background: var(--bg-subtle);
  color: var(--ink-primary);
  border-color: var(--border-subtle);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

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

/* ─── Recording Controls ─── */
.record-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 12px 0 20px;
}

.btn-record {
  font-size: 1rem;
  padding: 14px 28px;
  border-radius: 9999px;
  background: var(--bg-subtle);
  color: var(--ink-primary);
  border: 1.5px solid var(--border-subtle);
}

.btn-record:hover:not(:disabled) {
  background: var(--bg-card-hover);
  border-color: var(--accent-amber);
}

.btn-record.recording {
  background: rgba(239, 68, 68, 0.15);
  border-color: var(--accent-red);
  color: #fca5a5;
}

.rec-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-red);
  animation: blink 1s infinite ease-in-out;
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.record-meta {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.waveform-canvas {
  width: 100%;
  height: 60px;
  background: #09090c;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-top: 4px;
}

/* ─── Sample Audio Chips ─── */
.section-heading {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-bottom: 12px;
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.sample-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.sample-chip:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-amber);
}

.sample-icon {
  font-size: 1.2rem;
}

.sample-info {
  display: flex;
  flex-direction: column;
}

.sample-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.sample-sub {
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-family: var(--font-sanskrit);
}

.sample-chip.processing {
  border-color: var(--accent-amber);
  background: rgba(245, 158, 11, 0.08);
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.2);
  position: relative;
  overflow: hidden;
}

.sample-chip.processing::after {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 200%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(245, 158, 11, 0.12) 50%,
    transparent 100%
  );
  animation: shimmerSweep 1.4s infinite linear;
  pointer-events: none;
}

@keyframes shimmerSweep {
  0% { transform: translateX(0); }
  100% { transform: translateX(100%); }
}

.sample-chip.playing {
  border-color: rgba(245, 158, 11, 0.5);
  background: rgba(245, 158, 11, 0.04);
}

.sample-chip.processing .sample-icon {
  animation: pulseIcon 1.2s infinite ease-in-out;
}

@keyframes pulseIcon {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 2px rgba(245, 158, 11, 0.4)); }
  50% { transform: scale(1.15); filter: drop-shadow(0 0 8px rgba(245, 158, 11, 0.8)); }
}

.sample-eq {
  display: flex;
  align-items: flex-end;
  gap: 2.5px;
  height: 14px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sample-chip.processing .sample-eq,
.sample-chip.playing .sample-eq {
  opacity: 1;
}

.sample-eq-bar {
  width: 2.5px;
  background: var(--accent-amber);
  border-radius: 2px;
  height: 4px;
  transition: height 0.1s ease;
}

.sample-chip.processing .sample-eq-bar:nth-child(1),
.sample-chip.playing .sample-eq-bar:nth-child(1) {
  animation: eqBounce1 0.7s infinite ease-in-out;
}

.sample-chip.processing .sample-eq-bar:nth-child(2),
.sample-chip.playing .sample-eq-bar:nth-child(2) {
  animation: eqBounce2 0.7s infinite ease-in-out 0.2s;
}

.sample-chip.processing .sample-eq-bar:nth-child(3),
.sample-chip.playing .sample-eq-bar:nth-child(3) {
  animation: eqBounce3 0.7s infinite ease-in-out 0.4s;
}

@keyframes eqBounce1 {
  0%, 100% { height: 4px; }
  50% { height: 14px; }
}

@keyframes eqBounce2 {
  0%, 100% { height: 7px; }
  50% { height: 12px; }
}

@keyframes eqBounce3 {
  0%, 100% { height: 3px; }
  50% { height: 14px; }
}

/* ─── Drag & Drop Zone ─── */
.drop-zone {
  border: 1.5px dashed var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s ease;
  background: rgba(255, 255, 255, 0.01);
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-amber);
  background: var(--accent-amber-glow);
}

.drop-text {
  font-size: 0.875rem;
  color: var(--ink-secondary);
}

.drop-sub {
  font-size: 0.75rem;
  color: var(--ink-muted);
  margin-top: 4px;
}

/* ─── Transcription Result ─── */
.result-card {
  border-color: rgba(245, 158, 11, 0.25);
  background: #0c0c10;
}

.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.result-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 6px;
}

.dev-output-box {
  font-family: var(--font-sanskrit);
  font-size: 1.75rem;
  line-height: 1.7;
  color: #fff;
  min-height: 60px;
  margin-bottom: 12px;
  word-break: break-word;
}

.iast-output-box {
  font-size: 1.05rem;
  line-height: 1.6;
  color: #d4d4d8;
  font-style: italic;
  font-family: var(--font-ui);
  margin-bottom: 20px;
  word-break: break-word;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.loading-pulse {
  color: var(--accent-amber);
  animation: pulse 1.2s infinite ease-in-out;
  font-size: 1.2rem;
  font-family: var(--font-sanskrit);
}

/* ─── Stats Bar ─── */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  padding: 12px 16px;
  background: var(--bg-subtle);
  border-radius: 8px;
  margin-bottom: 18px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  color: var(--ink-muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.stat-val {
  color: var(--ink-primary);
  font-weight: 600;
}

.stat-val.highlight {
  color: var(--accent-amber);
}

.action-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

audio {
  width: 100%;
  height: 38px;
  margin-top: 14px;
}

/* ─── History Drawer ─── */
.history-empty {
  font-size: 0.875rem;
  color: var(--ink-muted);
  padding: 12px 0;
}

.history-card {
  padding: 12px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  margin-bottom: 10px;
}

.history-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  margin-bottom: 4px;
}

.history-dev {
  font-family: var(--font-sanskrit);
  font-size: 1.15rem;
  color: var(--ink-primary);
}

.history-iast {
  font-size: 0.85rem;
  color: var(--ink-secondary);
  font-style: italic;
}

.mini-audio {
  height: 28px;
  margin-top: 6px;
}

/* ─── Architecture Info ─── */
.arch-card {
  font-size: 0.875rem;
  color: var(--ink-secondary);
  line-height: 1.65;
}

.arch-card h3 {
  font-size: 1rem;
  color: var(--ink-primary);
  margin-bottom: 8px;
}

.arch-card p {
  margin-bottom: 12px;
}

.arch-card a {
  color: var(--accent-amber);
  text-decoration: none;
  font-weight: 500;
}

.arch-card a:hover {
  text-decoration: underline;
}

/* ─── Footer ─── */
footer {
  margin-top: auto;
  border-top: 1px solid var(--border-subtle);
  padding: 24px 0 32px;
  text-align: center;
  font-size: 0.825rem;
  color: var(--ink-muted);
  line-height: 1.7;
}

footer p {
  margin-bottom: 6px;
}

footer p:last-child {
  margin-bottom: 0;
}

footer strong {
  color: var(--ink-secondary);
}

footer em {
  font-style: italic;
}

footer a {
  color: var(--ink-secondary);
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
}

footer a:hover {
  color: var(--accent-amber);
}

/* ─── Responsive & Mobile Refinements ─── */
@media (max-width: 640px) {
  .container {
    padding: 16px 14px 60px;
  }

  .top-nav {
    margin-bottom: 18px;
  }

  .back-link {
    font-size: 0.8rem;
  }

  .status-badge {
    font-size: 0.7rem;
    padding: 4px 8px;
  }

  .header-meta {
    gap: 8px;
  }

  .header-tag {
    font-size: 0.7rem;
    padding: 3px 8px;
  }

  .offline-badge {
    font-size: 0.68rem;
    padding: 3px 7px;
  }

  h1 {
    font-size: 1.7rem;
    gap: 8px;
  }

  .invoc-callout {
    font-size: 0.78rem;
    padding: 5px 10px;
    gap: 6px;
    width: 100%;
  }

  .invoc-meaning {
    font-size: 0.74rem;
  }

  .tech-pills {
    gap: 5px;
  }

  .tech-pill {
    font-size: 0.68rem;
    padding: 2px 7px;
  }

  .card {
    padding: 18px 14px;
    border-radius: 12px;
    margin-bottom: 16px;
  }

  .dev-output-box {
    font-size: 1.35rem;
    min-height: 70px;
  }

  .iast-output-box {
    font-size: 0.85rem;
  }

  .samples-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .sample-chip {
    padding: 10px 12px;
    min-height: 48px;
  }

  .stats-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 10px 12px;
  }

  .action-bar {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .action-bar .btn {
    width: 100%;
    justify-content: center;
  }

  .mic-btn {
    width: 64px;
    height: 64px;
  }

  .mic-btn svg {
    width: 26px;
    height: 26px;
  }
}

@media (max-width: 380px) {
  .back-text {
    display: none;
  }

  .back-link::after {
    content: "Experiments";
  }

  h1 {
    font-size: 1.5rem;
  }

  .status-badge {
    font-size: 0.65rem;
  }
}
