/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --border: rgba(15, 118, 110, 0.15);
  --border-hi: rgba(15, 118, 110, 0.5);
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #0d9488;
  --accent-hi: #0f766e;
  --success: #10b981;
  --error: #f43f5e;
  --radius: 1.25rem;
  --transition: 180ms ease;
}

html,
body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

/* ── Background orbs ─────────────────────────────────────────────────────── */
.bg-orbs {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.35;
}

.orb-1 {
  width: 600px;
  height: 600px;
  background: #ccfbf1;
  /* very light teal */
  top: -200px;
  left: -150px;
}

.orb-2 {
  width: 500px;
  height: 500px;
  background: #dcfce7;
  /* very light green */
  bottom: -150px;
  right: -100px;
  animation: float 8s ease-in-out infinite alternate;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: #e0f2fe;
  /* very light blue */
  top: 40%;
  left: 55%;
  animation: float 11s ease-in-out infinite alternate-reverse;
}

@keyframes float {
  to {
    transform: translateY(-40px) scale(1.04);
  }
}

/* ── Layout ──────────────────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

.sidebar {
  width: 280px;
  background: rgba(255, 255, 255, 0.4);
  border-right: 1px solid var(--border);
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  z-index: 10;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: width var(--transition), padding var(--transition);
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: 88px;
  padding: 2rem 1rem;
}

.sidebar.collapsed .sidebar-brand span,
.sidebar.collapsed .link-text {
  display: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  margin-bottom: 1rem;
  min-width: max-content;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
}

.sidebar-toggle:hover {
  background: rgba(13, 148, 136, 0.1);
  color: var(--accent-hi);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 0.6rem;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  transition: all var(--transition);
  white-space: nowrap;
}

.sidebar-link:hover {
  background: rgba(13, 148, 136, 0.06);
  color: var(--accent-hi);
}

.sidebar-link.active {
  background: rgba(13, 148, 136, 0.1);
  color: var(--accent-hi);
  font-weight: 600;
}

.sidebar-link svg {
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  position: relative;
}

.container {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 3rem 1rem;
  gap: 2rem;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.header {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.logo {
  margin-bottom: 0.25rem;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #e2e8f0 30%, #14b8a6);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.card {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: 0 8px 32px rgba(15, 118, 110, 0.1);
}

/* ── Drop Zone ───────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--border);
  border-radius: 1rem;
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition), transform var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  position: relative;
  outline: none;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--accent-hi);
  background: rgba(13, 148, 136, 0.06);
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(13, 148, 136, 0.12);
  transform: scale(1.01);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-icon {
  margin-bottom: 0.25rem;
}

.drop-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.drop-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.drop-formats {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.drop-formats strong {
  color: var(--accent-hi);
}

/* ── File Preview ────────────────────────────────────────────────────────── */
.file-preview {
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.25);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  animation: fadeIn 200ms ease;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.file-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}

.file-name {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
}

.file-size {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.4rem;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.clear-btn:hover {
  color: var(--error);
  background: rgba(244, 63, 94, 0.1);
}

/* ── Progress ────────────────────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: fadeIn 200ms ease;
}

.progress-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hi));
  border-radius: 99px;
  transition: width 100ms linear;
}

.progress-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  width: 3ch;
  text-align: right;
}

/* ── Feedback ────────────────────────────────────────────────────────────── */
.feedback {
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 0.88rem;
  font-weight: 500;
  animation: fadeIn 200ms ease;
  line-height: 1.5;
}

.feedback.success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
}

.feedback.error {
  background: rgba(244, 63, 94, 0.1);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
}

/* ── Upload Button ───────────────────────────────────────────────────────── */
.upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.85rem;
  border: none;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
  box-shadow: 0 4px 20px rgba(13, 148, 136, 0.35);
}

.upload-btn:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(13, 148, 136, 0.5);
}

.upload-btn:active:not(:disabled) {
  transform: translateY(0);
}

.upload-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  box-shadow: none;
}

.upload-btn.loading .btn-text::after {
  content: '…';
  animation: dots 1.2s steps(3, end) infinite;
}

@keyframes dots {
  0% {
    content: '';
  }

  33% {
    content: '.';
  }

  66% {
    content: '..';
  }

  100% {
    content: '...';
  }
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.footer {
  font-size: 0.78rem;
  color: rgba(148, 163, 184, 0.45);
  text-align: center;
}

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Transcription Panel ─────────────────────────────────────────────────── */
.transcription-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.t-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(13, 148, 136, 0.12);
  border: 1px solid rgba(13, 148, 136, 0.25);
  flex-shrink: 0;
}

.t-icon.pulse {
  animation: iconPulse 1.8s ease-in-out infinite;
}

@keyframes iconPulse {

  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.4);
  }

  50% {
    box-shadow: 0 0 0 8px rgba(13, 148, 136, 0);
  }
}

.t-meta {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.t-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-step {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Transcription Result ────────────────────────────────────────────────── */
.t-result {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  animation: fadeIn 300ms ease;
}

.t-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.t-result-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.copy-btn {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  border-radius: 0.4rem;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.copy-btn:hover {
  color: var(--text);
  border-color: var(--accent-hi);
  background: rgba(13, 148, 136, 0.08);
}

.t-text {
  padding: 1rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.t-text::-webkit-scrollbar {
  width: 6px;
}

.t-text::-webkit-scrollbar-track {
  background: transparent;
}

.t-text::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

/* ── Diarização — Blocos de Falante ──────────────────────────────────────── */

/* Container de todos os turnos de fala (substitui o <pre> quando diarizado) */
.t-diarized {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 420px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.t-diarized::-webkit-scrollbar {
  width: 6px;
}

.t-diarized::-webkit-scrollbar-track {
  background: transparent;
}

.t-diarized::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 99px;
}

/* Bloco individual de um turno de fala */
.speaker-block {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.65rem 0.85rem;
  border-radius: 0.6rem;
  border-left: 3px solid;
  background: rgba(0, 0, 0, 0.03);
  animation: fadeIn 250ms ease;
}

/* Label do falante */
.speaker-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.85;
}

/* Texto do turno de fala */
.speaker-text {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* Timestamp ao fim do turno */
.speaker-timestamp {
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.45;
  align-self: flex-end;
  margin-top: 0.1rem;
}

/* Paleta de cores por falante (A → F, ciclica depois) */
.speaker-color-0 {
  border-color: #0d9488;
}

.speaker-color-0 .speaker-label {
  color: #14b8a6;
}

.speaker-color-1 {
  border-color: #0ea5e9;
}

.speaker-color-1 .speaker-label {
  color: #38bdf8;
}

.speaker-color-2 {
  border-color: #10b981;
}

.speaker-color-2 .speaker-label {
  color: #34d399;
}

.speaker-color-3 {
  border-color: #f59e0b;
}

.speaker-color-3 .speaker-label {
  color: #fbbf24;
}

.speaker-color-4 {
  border-color: #ef4444;
}

.speaker-color-4 .speaker-label {
  color: #f87171;
}

.speaker-color-5 {
  border-color: #ec4899;
}

.speaker-color-5 .speaker-label {
  color: #f472b6;
}


/* Textarea de edição da transcrição */
.t-text-edit {
  width: 100%;
  resize: vertical;
  min-height: 160px;
  border: none;
  border-top: 2px solid rgba(13, 148, 136, 0.5);
  background: rgba(13, 148, 136, 0.04);
  outline: none;
  border-radius: 0;
  border-bottom-left-radius: 0.75rem;
  border-bottom-right-radius: 0.75rem;
  font-family: 'Inter', sans-serif;
  transition: background var(--transition), border-color var(--transition);
}

.t-text-edit:focus {
  background: rgba(13, 148, 136, 0.07);
  border-top-color: var(--accent-hi);
}

/* Botão editar no estado ativo (salvar) */
.edit-btn--active {
  color: #6ee7b7 !important;
  border-color: rgba(16, 185, 129, 0.5) !important;
  background: rgba(16, 185, 129, 0.08) !important;
}

/* ── Outline Button variant ──────────────────────────────────────────────── */
.upload-btn.outline {
  background: none;
  border: 1px solid rgba(13, 148, 136, 0.4);
  color: var(--accent-hi);
  box-shadow: none;
}

.upload-btn.outline:hover:not(:disabled) {
  background: rgba(13, 148, 136, 0.08);
  border-color: var(--accent-hi);
  box-shadow: none;
}

/* ── Analysis Panel ──────────────────────────────────────────────────────── */
.analysis-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: fadeIn 250ms ease;
}

.analysis-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.analysis-divider::before,
.analysis-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Prompt Textarea ─────────────────────────────────────────────────────── */
.prompt-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.prompt-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.char-count {
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  transition: color var(--transition);
}

.char-count.char-limit {
  color: #f97316;
}

.prompt-textarea {
  width: 100%;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  line-height: 1.65;
  resize: vertical;
  min-height: 120px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.prompt-textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

.prompt-textarea:focus {
  border-color: rgba(13, 148, 136, 0.5);
  background: rgba(13, 148, 136, 0.04);
}

/* ── Analysis Result — Markdown ──────────────────────────────────────────── */
.analysis-md {
  font-size: 0.88rem;
  line-height: 1.75;
  color: var(--text);
  white-space: normal;
}

.analysis-md h1,
.analysis-md h2,
.analysis-md h3 {
  font-weight: 600;
  margin: 0.6rem 0 0.3rem;
  color: var(--text);
}

.analysis-md h1 {
  font-size: 1.05rem;
}

.analysis-md h2 {
  font-size: 0.97rem;
}

.analysis-md h3 {
  font-size: 0.9rem;
  color: var(--accent-hi);
}

.analysis-md p {
  margin-bottom: 0.5rem;
}

.analysis-md ul {
  padding-left: 1.2rem;
  margin-bottom: 0.5rem;
}

.analysis-md li {
  margin-bottom: 0.25rem;
}

.analysis-md strong {
  color: var(--text);
  font-weight: 600;
}

.analysis-md em {
  color: var(--text-muted);
  font-style: italic;
}

/* ── Tab Switcher ────────────────────────────────────────────────────────── */
.tab-switcher {
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.3rem;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.75rem;
  border: none;
  border-radius: 0.55rem;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.tab-btn:hover:not(.tab-active) {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text);
}

.tab-btn.tab-active {
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.25), rgba(79, 70, 229, 0.25));
  color: var(--accent-hi);
  box-shadow: 0 0 0 1px rgba(13, 148, 136, 0.35);
}

/* ── Recorder: Waveform Canvas ───────────────────────────────────────────── */
.recorder-wave-wrap {
  position: relative;
  width: 100%;
  border-radius: 0.75rem;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.recorder-wave-wrap:has(.rec-idle-msg:not(.hidden)) .rec-canvas {
  display: none;
}

.rec-canvas {
  display: block;
  width: 100%;
  height: 80px;
}

.rec-idle-msg {
  position: static;
  padding: 0.85rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.8;
  text-align: center;
}

/* ── Recorder: Timer ─────────────────────────────────────────────────────── */
.rec-timer {
  text-align: center;
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
  color: var(--text);
  line-height: 1;
}

/* ── Recorder: Controls ──────────────────────────────────────────────────── */
.rec-controls {
  display: flex;
  gap: 0.6rem;
  justify-content: center;
  margin-top: 5%;
}

.rec-btn {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.65rem 1.25rem;
  border-radius: 2rem;
  border: none;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition);
}

.rec-btn-record {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: var(--text);
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.4);
}

.rec-btn-record:hover {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(239, 68, 68, 0.55);
}

.rec-btn-stop {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text);
  border: 1px solid var(--border);
}

.rec-btn-stop:hover {
  background: rgba(255, 255, 255, 0.13);
  transform: translateY(-1px);
}

.rec-btn-discard {
  background: rgba(244, 63, 94, 0.1);
  color: #fda4af;
  border: 1px solid rgba(244, 63, 94, 0.25);
}

.rec-btn-discard:hover {
  background: rgba(244, 63, 94, 0.18);
  transform: translateY(-1px);
}

/* Pulsing red recording dot */
.rec-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: recPulse 1.1s ease-in-out infinite;
  flex-shrink: 0;
}

@keyframes recPulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }

  50% {
    opacity: 0.4;
    transform: scale(0.75);
  }
}

/* ── Recorder: Preview ───────────────────────────────────────────────────── */
.rec-preview {
  background: rgba(13, 148, 136, 0.07);
  border: 1px solid rgba(13, 148, 136, 0.22);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  animation: fadeIn 220ms ease;
}

.rec-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.rec-preview-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.rec-preview-dur {
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.rec-audio-player {
  width: 100%;
  height: 36px;
  border-radius: 0.5rem;
  accent-color: var(--accent);
  outline: none;
}

.rec-audio-player::-webkit-media-controls-panel {
  background: rgba(0, 0, 0, 0.05);
}

/* ── Settings Link (header) ──────────────────────────────────────────────── */
.settings-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 2rem;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.settings-link:hover {
  color: var(--accent-hi);
  border-color: rgba(13, 148, 136, 0.45);
  background: rgba(13, 148, 136, 0.07);
}

/* ── Back Link (prompt page) ─────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.back-link:hover {
  color: var(--accent-hi);
}

/* ── Prompt Info Box ─────────────────────────────────────────────────────── */
.prompt-info-box {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  background: rgba(13, 148, 136, 0.07);
  border: 1px solid rgba(13, 148, 136, 0.2);
  border-radius: 0.75rem;
  padding: 0.85rem 1rem;
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--text-muted);
}

.prompt-info-box strong {
  color: var(--text);
}

/* ── Prompt Textarea — tall variant (prompt settings page) ───────────────── */
.prompt-textarea--lg {
  min-height: 260px;
}

/* ── Warn link (inside feedback) ─────────────────────────────────────────── */
.warn-link {
  color: var(--accent-hi);
  text-decoration: underline;
  text-decoration-color: rgba(168, 85, 247, 0.45);
  transition: opacity var(--transition);
}

.warn-link:hover {
  opacity: 0.75;
}

/* ── Last saved label ────────────────────────────────────────────────────── */
.last-saved {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  opacity: 0.7;
}

/* ── No-prompt warning (index.html) ─────────────────────────────────────── */
#no-prompt-warn {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fcd34d;
}

/* ── Prompt Section Header ───────────────────────────────────────────────── */
.prompt-section-header {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding-bottom: 0.25rem;
}

.prompt-section-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.prompt-section-desc {
  font-size: 0.83rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

/* ── Prompt Type Badges ──────────────────────────────────────────────────── */
.prompt-section-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.65rem;
  border-radius: 2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  width: fit-content;
}

.prompt-section-badge--transcript {
  background: rgba(13, 148, 136, 0.15);
  color: #0d9488;
  border: 1px solid rgba(13, 148, 136, 0.3);
}

.prompt-section-badge--medical {
  background: rgba(52, 211, 153, 0.12);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.28);
}

/* ── Info box — Medical (green) variant ──────────────────────────────────── */
.prompt-info-box--medical {
  background: rgba(52, 211, 153, 0.06);
  border-color: rgba(52, 211, 153, 0.2);
}

/* ── Inline code in info boxes ───────────────────────────────────────────── */
.inline-code {
  font-family: 'Fira Mono', 'Consolas', monospace;
  font-size: 0.8em;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 0.25rem;
  padding: 0.1em 0.4em;
  color: var(--text);
}

/* ── Medical button variant (green gradient) ─────────────────────────────── */
.upload-btn--medical {
  background: linear-gradient(135deg, #059669, #047857);
  box-shadow: 0 4px 20px rgba(5, 150, 105, 0.35);
}

.upload-btn--medical:hover:not(:disabled) {
  box-shadow: 0 6px 28px rgba(5, 150, 105, 0.5);
}

/* ── Step Cards ───────────────────────────────────────────────────────────── */
.step-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.5rem;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .2);
  transition: opacity .2s ease, border-color .2s ease;
}

.step-card.step-done {
  opacity: .72;
}

.step-card.step-done:hover {
  opacity: .9;
}

.step-card.step-active {
  border-color: rgba(13, 148, 136, .35);
}

.step-card-header {
  display: flex;
  align-items: center;
  gap: .85rem;
  cursor: default;
}

.step-card.step-done .step-card-header {
  cursor: pointer;
}

.step-card-body {
  margin-top: 1.4rem;
  border-top: 1px solid var(--border);
  padding-top: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.step-card.step-done .step-card-body {
  display: none;
}

.step-card.step-done.step-open .step-card-body {
  display: flex;
}

.step-indicator {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(13, 148, 136, .18);
  border: 1.5px solid rgba(13, 148, 136, .4);
  color: #14b8a6;
}

.step-card.step-done .step-indicator {
  background: rgba(52, 211, 153, .15);
  border-color: rgba(52, 211, 153, .4);
  color: #6ee7b7;
}

.step-num {
  font-size: .85rem;
  font-weight: 700;
}

.step-check {
  display: inherit;
}

.step-label-wrap {
  flex: 1;
  min-width: 0;
}

.step-label {
  display: block;
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
}

.step-summary {
  display: block;
  font-size: .78rem;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: .15rem;
}

.step-toggle-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: .3rem;
  border-radius: .4rem;
  display: flex;
  align-items: center;
  transition: color .15s, background .15s;
}

.step-toggle-btn:hover {
  color: var(--text);
  background: rgba(0, 0, 0, .06);
}

.step-toggle-btn .chevron {
  transition: transform .2s ease;
}

.step-card.step-open .step-toggle-btn .chevron {
  transform: rotate(180deg);
}

/* ── File Attach Zone ─────────────────────────────────────────────────────── */
.attach-zone {
  background: rgba(0, 0, 0, .03);
  border: 1.5px dashed var(--border);
  border-radius: .75rem;
  padding: 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.attach-zone-top {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
}

.attach-info {
  font-size: .8rem;
  color: var(--text-muted);
}

.attach-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .48rem 1rem;
  background: rgba(13, 148, 136, .12);
  border: 1px solid rgba(13, 148, 136, .3);
  border-radius: .5rem;
  color: #0d9488;
  font-family: inherit;
  font-size: .82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.attach-btn:hover {
  background: rgba(13, 148, 136, .22);
  border-color: rgba(13, 148, 136, .5);
}

.attach-list {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.attach-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  background: rgba(0, 0, 0, .04);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .42rem .75rem;
  font-size: .8rem;
  color: var(--text-muted);
}

.attach-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attach-item-size {
  font-size: .72rem;
  opacity: .6;
  flex-shrink: 0;
}

.attach-remove {
  background: none;
  border: none;
  color: #fda4af;
  cursor: pointer;
  padding: .1rem;
  line-height: 1;
  opacity: .7;
  flex-shrink: 0;
  transition: opacity .15s;
}

.attach-remove:hover {
  opacity: 1;
}

/* ── Analysis loading spinner ─────────────────────────────────────────────── */
.analysis-loading-wrap {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 0;
  color: var(--text-muted);
  font-size: .88rem;
}

.analysis-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(13, 148, 136, .25);
  border-top-color: #0d9488;
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Markdown result ──────────────────────────────────────────────────────── */
.analysis-md h1,
.analysis-md h2,
.analysis-md h3 {
  color: var(--text);
  margin: .75rem 0 .3rem;
  font-weight: 600;
}

.analysis-md h1 {
  font-size: 1.1rem;
}

.analysis-md h2 {
  font-size: 1rem;
}

.analysis-md h3 {
  font-size: .92rem;
  color: var(--text-muted);
}

.analysis-md p {
  margin: .4rem 0;
  line-height: 1.65;
}

.analysis-md ul {
  padding-left: 1.4rem;
  margin: .4rem 0;
}

.analysis-md li {
  margin: .25rem 0;
  line-height: 1.6;
}

.analysis-md strong {
  color: var(--text);
}

/* ── Medical Chat UI ──────────────────────────────────────────────────────── */
.medical-chat {
  margin-top: 1.5rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  padding-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.medical-chat-history {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  padding: 0.8rem 1rem;
  border-radius: 0.75rem;
  font-size: 0.88rem;
  line-height: 1.5;
  animation: fadeIn 250ms ease;
}

.chat-msg--user {
  background: rgba(13, 148, 136, 0.08);
  border: 1px solid rgba(13, 148, 136, 0.2);
  align-self: flex-end;
  border-bottom-right-radius: 0.2rem;
  color: var(--text);
  max-width: 85%;
}

.chat-msg--ai {
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.2);
  align-self: flex-start;
  border-bottom-left-radius: 0.2rem;
  color: var(--text);
  max-width: 95%;
}

.chat-msg-role {
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  opacity: 0.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chat-msg-content {
  white-space: pre-wrap;
}

.medical-chat-input-wrap {
  position: relative;
  width: 95%;
  display: flex;
  align-self: center;
  bottom: 20px;
}

.medical-chat-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  border-radius: 1.2rem;
  padding: 0.85rem 3.5rem 0.85rem 1.25rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  min-height: 54px;
  max-height: 150px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
  width: 100%;
}

.medical-chat-input:focus {
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.04);
}

.medical-chat-send-btn {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0ea5e9, #0284c7);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
}

.medical-chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.4);
}

.medical-chat-send-btn:active {
  transform: scale(0.95);
}

.medical-chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Auth Card ───────────────────────────────────────────────────────────────── */
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: 0 8px 32px rgba(15, 118, 110, 0.1);
}

/* ── Form Inputs ─────────────────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.form-label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.form-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid var(--border);
  border-radius: .65rem;
  padding: .75rem 1rem;
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: .9rem;
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.form-input::placeholder {
  color: var(--text-muted);
  opacity: .5;
}

.form-input:focus {
  border-color: rgba(13, 148, 136, .5);
  background: rgba(13, 148, 136, .04);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .1);
}

.form-select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 4.5l3 3 3-3' stroke='%2394a3b8' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.5rem;
}

.form-select option {
  background: #f1f5f9;
  color: var(--text);
}

/* ── User Header Bar ─────────────────────────────────────────────────────────── */
.user-bar {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .85rem;
  background: rgba(0, 0, 0, .03);
  border: 1px solid var(--border);
  border-radius: 2rem;
  font-size: .8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.user-bar-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-bar-name {
  font-weight: 500;
  color: var(--text);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-bar-role {
  font-size: .68rem;
  padding: .1rem .5rem;
  border-radius: 2rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.user-bar-role--medico,
.user-bar-role--nutricionista {
  background: rgba(13, 148, 136, .15);
  color: #0d9488;
  border: 1px solid rgba(13, 148, 136, .3);
}

.user-bar-role--sysadmin {
  background: rgba(239, 68, 68, .12);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, .3);
}

.user-bar-role--admin_clinica {
  background: rgba(251, 191, 36, .12);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, .3);
}

.logout-btn {
  background: none;
  border: 1px solid rgba(244, 63, 94, .3);
  color: #fda4af;
  font-family: inherit;
  font-size: .72rem;
  font-weight: 600;
  cursor: pointer;
  padding: .25rem .65rem;
  border-radius: 2rem;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}

.logout-btn:hover {
  background: rgba(244, 63, 94, .12);
  border-color: rgba(244, 63, 94, .5);
}

/* ── Admin Blocked Message ───────────────────────────────────────────────────── */
.admin-blocked {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  font-size: .95rem;
  line-height: 1.7;
}

.admin-blocked-icon {
  font-size: 2.5rem;
  margin-bottom: .75rem;
}

/* ── Sysadmin User Selector ──────────────────────────────────────────────────── */
.sysadmin-user-selector {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem 1rem;
  background: rgba(239, 68, 68, .06);
  border: 1px solid rgba(239, 68, 68, .2);
  border-radius: .65rem;
  margin-bottom: .5rem;
}

.sysadmin-user-selector label {
  font-size: .8rem;
  font-weight: 600;
  color: #fca5a5;
  white-space: nowrap;
}

.sysadmin-user-selector select {
  flex: 1;
  background: rgba(0, 0, 0, .04);
  border: 1px solid var(--border);
  border-radius: .5rem;
  padding: .4rem .7rem;
  color: var(--text);
  font-family: inherit;
  font-size: .82rem;
  outline: none;
  cursor: pointer;
}

.sysadmin-user-selector select option {
  background: #f1f5f9;
  color: var(--text);
}