/* ============================================================================
   PTX — Persian Transcription
   Minimal English chrome + traditional Naskh (Markazi Text) for Persian text.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Markazi+Text:wght@400;500;600;700&display=swap');

:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --text: #18181b;
  --text-muted: #71717a;
  --text-subtle: #a1a1aa;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --accent: #18181b;
  --accent-fg: #fafafa;
  --danger: #b91c1c;
  --warn: #b45309;
  --success: #15803d;
  --radius: 6px;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0a0a;
    --surface: #111111;
    --text: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-subtle: #71717a;
    --border: #27272a;
    --border-strong: #3f3f46;
    --accent: #fafafa;
    --accent-fg: #18181b;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* ---- Top bar ------------------------------------------------------------- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.logo-text {
  font-weight: 600; font-size: 13px; letter-spacing: 1.5px;
  color: var(--text);
}
.topbar-right {
  display: flex; align-items: center; gap: 12px;
}
.quota-pill {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}
.quota-pill.warn { color: var(--warn); }
.quota-pill.danger { color: var(--danger); }
.user-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.user-chip img { width: 20px; height: 20px; border-radius: 50%; }
.user-chip a { color: var(--text-muted); }
.btn-ghost {
  font-size: 12px; font-weight: 500;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 5px 10px; border-radius: var(--radius);
  background: var(--surface);
  transition: border-color .15s ease;
}
.btn-ghost:hover { border-color: var(--text); text-decoration: none; }

/* ---- App layout ---------------------------------------------------------- */
.app {
  max-width: 880px;
  margin: 18px auto;
  padding: 0 18px;
  display: flex; flex-direction: column;
  gap: 12px;
}

/* ---- Mic bar (outside the transcript) ----------------------------------- */
.mic-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mic-button {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--accent-fg);
  border: none; padding: 7px 16px;
  border-radius: var(--radius);
  font: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: opacity .15s ease;
}
.mic-button:hover { opacity: .9; }
.mic-button.recording { background: var(--danger); color: #fff; }
.mic-button.disabled { background: var(--text-subtle); cursor: not-allowed; }
.mic-button .mic-icon { font-size: 10px; }
.mic-button.recording .mic-icon { animation: ptx-pulse 1.2s ease-in-out infinite; }
@keyframes ptx-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: .3; }
}
.mic-meter {
  flex: 1; height: 3px;
  background: var(--border);
  border-radius: 999px; overflow: hidden;
  min-width: 80px;
}
.mic-meter-fill {
  height: 100%; width: 0;
  background: var(--text);
  transition: width 80ms linear;
}
.elapsed {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  min-width: 42px; text-align: center;
}
.mic-actions { display: flex; gap: 4px; }
.ctrl-btn {
  background: transparent; border: 1px solid var(--border);
  width: 28px; height: 28px; border-radius: var(--radius);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--text-muted);
  transition: all .15s ease;
}
.ctrl-btn:hover { border-color: var(--text); color: var(--text); }

/* ---- Transcript --------------------------------------------------------- */
.transcript-area {
  min-height: 360px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}
.placeholder {
  text-align: center; padding: 60px 16px;
  color: var(--text-subtle); font-size: 13px;
}
.placeholder.hidden { display: none; }

.transcript-segment {
  margin-bottom: 14px;
  display: flex; align-items: baseline; gap: 10px;
  /* Persian text — RTL within an LTR page chrome */
  direction: rtl;
}
.transcript-segment .speaker {
  flex-shrink: 0;
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.5px;
  color: var(--text-subtle);
  text-transform: uppercase;
  direction: ltr; /* labels stay LTR */
  min-width: 32px;
}
.transcript-segment .speaker.s2 { color: var(--success); }
.transcript-segment .speaker.s3 { color: var(--warn); }
.transcript-segment .speaker.s4 { color: var(--danger); }
.transcript-segment .ts {
  flex-shrink: 0;
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  min-width: 36px;
}
.transcript-segment .text {
  flex: 1;
  font-family: 'Markazi Text', 'Vazirmatn', 'Tahoma', serif;
  font-size: 22px;
  font-weight: 500;
  line-height: 1.7;
  color: var(--text);
}
.interim {
  font-family: 'Markazi Text', 'Vazirmatn', 'Tahoma', serif;
  color: var(--text-subtle);
  font-size: 20px;
  direction: rtl;
  min-height: 1em;
  padding: 0 36px;
  font-style: normal;
}

/* ---- Footer (privacy/terms only) ---------------------------------------- */
.site-footer {
  margin: 24px auto 18px;
  text-align: center;
  font-size: 11px;
  color: var(--text-subtle);
}
.site-footer a { color: var(--text-subtle); }
.site-footer a:hover { color: var(--text-muted); }

/* ---- Modal -------------------------------------------------------------- */
.modal-bg {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  max-width: 380px; width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(0,0,0,.12);
}
.modal h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.modal p  { color: var(--text-muted); margin: 0 0 16px; font-size: 13px; line-height: 1.55; }
.modal-actions { display: flex; gap: 6px; justify-content: flex-end; }
.modal-actions button {
  padding: 6px 14px; border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  font-family: inherit; font-size: 12px; font-weight: 500;
  cursor: pointer;
}
.modal-actions button:hover { border-color: var(--text); }
.modal-actions .primary {
  background: var(--accent); color: var(--accent-fg);
  border-color: var(--accent);
}

/* ---- Responsive --------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar { padding: 8px 12px; }
  .topbar-right { gap: 8px; }
  .app { padding: 0 12px; margin: 12px auto; }
  .mic-bar { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
  .mic-meter { min-width: 60px; }
  .transcript-area { padding: 14px 16px; min-height: 280px; }
  .transcript-segment .text { font-size: 20px; }
  .interim { font-size: 18px; padding: 0 24px; }
}
