:root {
  --bg-obsidian: #090a0f;
  --bg-surface: #11131c;
  --bg-elevated: #171a26;
  --bg-glass: rgba(17, 19, 28, 0.84);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-gold: rgba(245, 158, 11, 0.42);
  --text-primary: #f3f4f8;
  --text-secondary: #9ca3b8;
  --text-muted: #646b82;
  --gold-primary: #f59e0b;
  --gold-warm: #fbbf24;
  --gold-ember: #d97706;
  --gold-glow: rgba(245, 158, 11, 0.25);
  --danger: #ef4444;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: radial-gradient(circle at 50% 0%, rgba(217, 119, 6, 0.12), transparent 55%), var(--bg-obsidian);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

/* Pantalla de Login */
.login-screen {
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem 1.6rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 40px rgba(245, 158, 11, 0.06);
  text-align: center;
}

.brand-emblem {
  width: 52px;
  height: 52px;
  margin: 0 auto 1rem;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(217, 119, 6, 0.05));
  border: 1px solid var(--border-gold);
  color: var(--gold-warm);
}

.brand-emblem svg {
  width: 28px;
  height: 28px;
}

.login-title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 0.88rem;
  margin-top: 0.25rem;
  margin-bottom: 1.5rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.input-field {
  width: 100%;
  padding: 0.78rem 0.95rem;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.input-field:focus {
  border-color: var(--gold-primary);
  box-shadow: 0 0 0 3px var(--gold-glow);
}

.alert-error {
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
  font-size: 0.85rem;
  text-align: left;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-ember));
  color: #090a0f;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.08);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.48rem 0.85rem;
  font-size: 0.84rem;
  cursor: pointer;
}

.btn-secondary:hover {
  border-color: var(--border-gold);
}

.btn-full {
  width: 100%;
}

/* Estructura Principal */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  max-width: 920px;
  margin: 0 auto;
  border-left: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  background: rgba(9, 10, 15, 0.75);
  backdrop-filter: blur(16px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-glass);
  gap: 0.5rem;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
}

.brand-compact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.volcano-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--gold-primary);
  box-shadow: 0 0 10px var(--gold-primary);
  flex-shrink: 0;
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-weight: 600;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.session-subtitle {
  font-size: 0.74rem;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

/* Selector STT Superior */
.stt-selector {
  display: inline-flex;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px;
  flex-shrink: 0;
}

.stt-option {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.76rem;
  font-weight: 500;
  padding: 0.3rem 0.72rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.stt-option.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.24), rgba(217, 119, 6, 0.16));
  color: var(--gold-warm);
  box-shadow: inset 0 0 0 1px var(--border-gold);
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--text-primary);
  background: var(--bg-elevated);
  border-color: var(--border-subtle);
}

/* Barra de Pestañas */
.tabbar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  padding: 0.62rem 0.5rem;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-btn.active {
  color: var(--gold-warm);
  border-bottom-color: var(--gold-primary);
}

/* Panel Principal de Chat */
.main-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.readonly-banner {
  background: rgba(245, 158, 11, 0.12);
  border-bottom: 1px solid var(--border-gold);
  color: var(--gold-warm);
  padding: 0.48rem 0.9rem;
  font-size: 0.8rem;
  text-align: center;
}

.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.empty-state {
  margin: auto;
  text-align: center;
  max-width: 290px;
  color: var(--text-secondary);
}

.empty-title {
  color: var(--gold-warm);
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.empty-desc {
  font-size: 0.84rem;
}

.msg-bubble {
  max-width: 85%;
  padding: 0.72rem 0.95rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  word-wrap: break-word;
  white-space: pre-wrap;
  position: relative;
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.2), rgba(217, 119, 6, 0.12));
  border: 1px solid var(--border-gold);
  color: var(--text-primary);
  border-bottom-right-radius: 4px;
}

.msg-assistant {
  align-self: flex-start;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-badge-audio {
  display: inline-block;
  font-size: 0.7rem;
  color: var(--gold-warm);
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: 99px;
  padding: 0.08rem 0.48rem;
  margin-bottom: 0.35rem;
}

/* Escenario Central del Micrófono */
.voice-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1rem 0.7rem;
  border-top: 1px solid var(--border-subtle);
  background: radial-gradient(circle at 50% 60%, rgba(245, 158, 11, 0.12), transparent 65%);
}

.voice-status-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-bottom: 0.45rem;
}

.voice-status-text {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.btn-chip {
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid var(--border-gold);
  color: var(--gold-warm);
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
}

.mic-orb-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-orb {
  position: relative;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-primary);
  background: radial-gradient(circle at 35% 30%, #fbbf24, #d97706 72%, #92400e 100%);
  color: #090a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(245, 158, 11, 0.32), inset 0 1px 2px rgba(255, 255, 255, 0.45);
  transition: transform 0.16s ease, box-shadow 0.2s ease;
}

.mic-orb:hover:not(:disabled) {
  transform: scale(1.04);
  box-shadow: 0 10px 34px rgba(245, 158, 11, 0.46);
}

.mic-orb:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.mic-orb.recording {
  animation: volcano-pulse 1.35s infinite ease-in-out;
  background: radial-gradient(circle at 35% 30%, #fde68a, #f59e0b 65%, #dc2626 100%);
}

@keyframes volcano-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.55), 0 0 28px rgba(245, 158, 11, 0.5);
    transform: scale(1);
  }
  50% {
    box-shadow: 0 0 0 14px rgba(245, 158, 11, 0), 0 0 40px rgba(245, 158, 11, 0.8);
    transform: scale(1.06);
  }
}

/* Compositor de Texto */
.chat-composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
}

.composer-textarea {
  flex: 1;
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  padding: 0.6rem 0.85rem;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  resize: none;
  max-height: 110px;
  outline: none;
}

.composer-textarea:focus {
  border-color: var(--gold-primary);
}

.btn-send {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: none;
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-ember));
  color: #090a0f;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

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

/* Cajón Lateral (Sesiones) */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.drawer-panel {
  position: relative;
  z-index: 51;
  width: 300px;
  max-width: 84vw;
  height: 100%;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-actions {
  padding: 0.8rem 1rem;
}

.sessions-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  padding: 0 0.6rem 1rem;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  margin-bottom: 0.25rem;
  border: 1px solid transparent;
}

.session-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.session-item.active {
  background: rgba(245, 158, 11, 0.12);
  border-color: var(--border-gold);
  color: var(--gold-warm);
}

.badge-ntfy {
  font-size: 0.66rem;
  padding: 0.1rem 0.42rem;
  border-radius: 99px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid var(--border-gold);
  color: var(--gold-warm);
  flex-shrink: 0;
}

/* Paneles Secundarios (Archivos y Tareas) */
.Secondary-panel {
  overflow-y: auto;
}

.panel-inner {
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.upload-card {
  background: var(--bg-surface);
  border: 1px dashed var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  text-align: center;
}

.upload-dropzone {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  cursor: pointer;
}

.upload-title {
  color: var(--gold-warm);
  font-weight: 600;
  font-size: 0.92rem;
}

.upload-hint {
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.upload-status {
  margin-top: 0.65rem;
  font-size: 0.82rem;
  color: var(--gold-warm);
}

.files-columns {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 680px) {
  .files-columns {
    grid-template-columns: 1fr 1fr;
  }
}

.files-group {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.group-title {
  font-size: 0.86rem;
  color: var(--gold-warm);
  margin-bottom: 0.65rem;
}

.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--bg-obsidian);
  border: 1px solid var(--border-subtle);
}

.file-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.file-name {
  font-weight: 500;
  font-size: 0.86rem;
  word-break: break-all;
}

.file-path {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-secondary);
  word-break: break-all;
}

.file-actions {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.2rem;
}

.link-btn {
  font-size: 0.75rem;
  color: var(--gold-warm);
  text-decoration: none;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid var(--border-gold);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.jobs-grid {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.job-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.job-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.job-name {
  font-weight: 600;
  color: var(--text-primary);
}

.job-cron {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--gold-warm);
  background: rgba(245, 158, 11, 0.12);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-sm);
}
