/* ============================================================
   EXPLAINER — "The Scholarly Forge"
   Dark Academic · Warm Amber · Playfair + Crimson + Syne
   ============================================================ */

/* ── Custom Properties ── */
:root {
  --bg-base: #0d1117;
  --bg-surface: #161b22;
  --bg-elevated: #1f2937;
  --bg-hover: #263040;

  --border: #2d3748;
  --border-light: #374151;

  --amber: #f59e0b;
  --amber-light: #fbbf24;
  --amber-dim: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.25);

  --emerald: #10b981;
  --emerald-dim: rgba(16, 185, 129, 0.12);

  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);

  --text-primary: #f0ece3;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;

  --font-display: 'Playfair Display', Georgia, serif;
  --font-body: 'Crimson Pro', 'Georgia', serif;
  --font-ui: 'Syne', system-ui, sans-serif;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.6);
  --shadow-amber: 0 0 40px rgba(245, 158, 11, 0.08);

  --sidebar-w: 280px;
  --header-h: 60px;
  --offline-banner-h: 0px;
  --mobile-header-h: 49px;
  --mobile-toolbar-h: 41px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.7;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Views ── */
.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ── Auth view ── */
#view-auth {
  position: relative;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

#view-auth.active {
  display: flex;
}

.auth-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.auth-logo {
  justify-content: center;
  margin-bottom: 8px;
}

.auth-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 24px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 16px;
  cursor: pointer;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
}

.auth-tab:hover {
  color: var(--text-primary);
}

.auth-tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}

.auth-form .form-group {
  margin-bottom: 16px;
}

.auth-form .form-error {
  margin-bottom: 12px;
  min-height: 20px;
}

.auth-checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 12px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1.4;
  cursor: pointer;
}

.auth-checkbox-row input {
  width: 15px;
  height: 15px;
  accent-color: var(--amber);
  flex: 0 0 auto;
}

.auth-checkbox-row:hover {
  color: var(--text-primary);
}

.btn-block {
  width: 100%;
  justify-content: center;
  margin-top: 8px;
}

#btn-logout {
  margin-top: 12px;
}

/* ── Buttons ── */
.btn-primary {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--amber);
  color: #0d1117;
  border: none;
  border-radius: var(--radius-md);
  padding: 12px 28px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: var(--amber-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(245, 158, 11, 0.45);
}

.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-primary.btn-sm {
  padding: 8px 18px;
  font-size: 13px;
}

.btn-ghost {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 8px 18px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s;
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-secondary);
}

.btn-back {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  transition: color 0.2s;
}

.btn-back:hover {
  color: var(--amber);
}

.btn-danger-sm {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  color: var(--red);
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.btn-danger-sm:hover {
  background: var(--red-dim);
}

/* ── Logo ── */
.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
}

.logo-mark {
  font-size: 22px;
  color: var(--amber);
  line-height: 1;
}

.logo-text {
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

/* ============================================================
   LANDING VIEW
   ============================================================ */
#view-landing {
  position: relative;
  overflow: hidden;
}

.landing-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.bg-glow {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.18;
}

.bg-glow-1 {
  width: 700px;
  height: 700px;
  background: #f59e0b;
  top: -200px;
  right: -100px;
}

.bg-glow-2 {
  width: 500px;
  height: 500px;
  background: #7c3aed;
  bottom: -100px;
  left: -100px;
}

.grain-overlay {
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 512 512' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  opacity: 0.5;
}

.landing-header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 48px;
}

.landing-main {
  position: relative;
  z-index: 10;
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 48px;
}

.landing-hero {
  text-align: center;
}

.hero-eyebrow {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 20px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 64px);
  font-weight: 600;
  line-height: 1.15;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.hero-title em {
  font-style: italic;
  color: var(--amber);
}

.hero-subtitle {
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Upload Card */
.upload-card {
  width: 100%;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-shadow: var(--shadow-lg), var(--shadow-amber);
}

/* Source Tabs */
.source-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.source-tab {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

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

.source-tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
  background: transparent;
}

.source-tab .tab-icon {
  font-size: 16px;
}

/* Source Panels */
.source-panel {
  display: block;
}

.source-panel.hidden {
  display: none !important;
}

/* YouTube Input Section */
.youtube-input-section {
  padding: 8px 0;
}

.input-hint,
.youtube-input-section .input-hint {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}

.input-error,
.youtube-input-section .input-error {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--red);
  margin-top: 6px;
}

.upload-zone {
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--amber);
  background: var(--amber-dim);
}

.upload-zone .upload-icon {
  color: var(--text-muted);
  transition: color 0.2s;
}

.upload-zone:hover .upload-icon {
  color: var(--amber);
}

.upload-label {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
}

.upload-sub {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
}

.upload-file-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--amber-dim);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
}

.upload-file-preview.hidden {
  display: none;
}

.file-icon {
  font-size: 24px;
}

.file-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.file-name {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.file-size {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-secondary);
}

.file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 4px;
  transition: color 0.2s;
}

.file-remove:hover {
  color: var(--red);
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.label-hint {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 12px;
}

.form-input {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 16px;
  padding: 12px 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  width: 100%;
  resize: none;
}

.form-input::placeholder {
  color: var(--text-muted);
}

.form-input:focus {
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-dim);
}

.form-textarea {
  line-height: 1.6;
}

.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.provider-card {
  position: relative;
  display: flex;
  align-items: stretch;
  min-height: 90px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  /* transitions live in the prefers-reduced-motion block below */
}

.provider-card:hover:not(.disabled):not(.is-loading) {
  border-color: var(--border-light);
  background: var(--bg-hover);
  /* transform lives in the prefers-reduced-motion block below */
}

.provider-card.selected {
  border-color: var(--amber);
  background: var(--amber-dim);
  box-shadow: 0 0 0 2px var(--amber-border);
}

.provider-card.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  filter: grayscale(0.25);
}

/* ── API key status indicator ── */
.provider-card-status {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
}

.provider-card.needs-key {
  border-color: var(--amber-border);
}

.provider-card.needs-key .provider-card-status {
  color: var(--amber);
}

.provider-card input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.provider-card-main {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.provider-card-title {
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.provider-card-sub {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

.openrouter-model-panel {
  margin-top: 14px;
  padding: 14px;
  /* 3px left accent signals nesting; overrides the shorthand left border */
  border: 1px solid var(--border);
  border-left: 3px solid var(--amber-border);
  border-radius: var(--radius-md);
  background: var(--bg-surface);
}

.openrouter-model-panel .form-label {
  margin-bottom: 10px;
}

.openrouter-model-grid .provider-card {
  min-height: 72px;
}

/* ── Focus ring: radio is visually hidden, style the card via :has ── */
.provider-card:has(input:focus-visible) {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--amber-dim);
}

/* ── Motion-safe transitions and lift ── */
@media (prefers-reduced-motion: no-preference) {
  .provider-card {
    transition:
      border-color 0.2s ease,
      box-shadow 0.2s ease,
      background 0.2s ease,
      outline-color 0.1s ease,
      transform 0.15s ease;
  }
  .provider-card:hover:not(.disabled):not(.is-loading) {
    transform: translateY(-1px);
  }
}

/* ── Loading affordance ── */
.provider-card.is-loading {
  cursor: wait;
  pointer-events: none;
  border-color: var(--amber-border);
  background: var(--amber-dim);
}

@keyframes card-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

@media (prefers-reduced-motion: no-preference) {
  .provider-card.is-loading {
    animation: card-pulse 1.4s ease-in-out infinite;
  }
}

/* Provider-only toggle — replaces inline styles on checkbox label */
.provider-only-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  cursor: pointer;
}
.provider-only-toggle input[type="checkbox"] {
  accent-color: var(--amber);
}
.provider-only-toggle span {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Codex (ChatGPT) provider sub-panel link status ── */
.codex-panel-link-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
}

/* ── Codex device-code flow in Ajustes ── */
.codex-verification-link {
  margin: -8px 0 16px;
}
.codex-verification-link a {
  color: var(--amber);
  text-decoration: none;
  word-break: break-all;
}
.codex-verification-link a:hover {
  text-decoration: underline;
}

/* Auto-title toggle (IA) — same visual language as provider-only-toggle */
.auto-title-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  cursor: pointer;
  user-select: none;
}
.auto-title-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--amber);
  flex: 0 0 auto;
  cursor: pointer;
}
.auto-title-toggle span {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-secondary);
  transition: color 0.15s ease;
}
.auto-title-toggle:hover span {
  color: var(--text-primary);
}
.auto-title-toggle input:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Custom panel — third-level inset panel (deepest surface, compact) */
.openrouter-custom-panel {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-base);
}
.openrouter-custom-panel .form-group + .form-group {
  margin-top: 10px;
}
.openrouter-custom-panel .form-group:first-child {
  margin-top: 0;
}
#openrouter-provider-fetch-error {
  margin-top: 6px;
}
#openrouter-custom-loading,
#openrouter-custom-fetch-error {
  margin-top: 8px;
}

/* ── Loading spinner for custom panel ── */
#openrouter-custom-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
}
#openrouter-custom-loading::before {
  content: "";
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border: 2px solid var(--amber-border);
  border-top-color: var(--amber);
  border-radius: 50%;
}
@keyframes spin-loader {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: no-preference) {
  #openrouter-custom-loading::before {
    animation: spin-loader 0.8s linear infinite;
  }
}

.upload-note {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--red);
  text-align: center;
  min-height: 16px;
}

/* Feature pills */
.feature-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.pill {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill-icon {
  color: var(--amber);
  font-size: 10px;
}

/* ============================================================
   APP HEADER (Projects + Project views)
   ============================================================ */
.app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: var(--offline-banner-h);
  z-index: 50;
}

/* ============================================================
   PROJECTS LIST VIEW
   ============================================================ */
.projects-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 32px;
}

.projects-header {
  margin-bottom: 32px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.section-sub {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-muted);
}

.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* Projects loading skeleton */
.projects-loading {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

.projects-loading.hidden {
  display: none;
}

.project-card-skeleton {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.project-card-skeleton .skeleton-line {
  display: block;
  height: 14px;
  width: 45%;
  background: linear-gradient(90deg, var(--bg-elevated), var(--border-light), var(--bg-elevated));
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.8s infinite;
}

.project-card-skeleton .skeleton-line.skeleton-wide {
  width: 85%;
  animation-delay: 0.15s;
}

/* Project Card */
.project-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: fadeInUp 0.3s ease both;
}

.project-card:hover {
  border-color: var(--amber-border);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-name {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-desc {
  font-family: var(--font-ui);
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-date {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
}

.card-status-badge {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  padding: 4px 10px;
  border-radius: 100px;
}

.status-pending {
  background: var(--bg-elevated);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.status-processing,
.status-uploading,
.status-segmenting {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid var(--amber-border);
}

.status-completed {
  background: var(--emerald-dim);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-error {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.card-progress {
  height: 3px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.card-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--amber), var(--amber-light));
  border-radius: 3px;
  transition: width 0.5s ease;
}

.card-parts {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-muted);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 48px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.empty-title {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--text-primary);
}

.empty-sub {
  font-family: var(--font-body);
  font-size: 16px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ============================================================
   PROJECT DETAIL VIEW — "The Deep Scholar" Redesign
   ============================================================ */

/* ── New design tokens (project reading only) ── */
:root {
  --ink-900: #0c0e14;
  --ink-800: #13151d;
  --ink-700: #1a1d28;
  --ink-600: #232638;
  --ink-500: #2d3147;

  --gold: #e8b86d;
  --gold-dim: rgba(232, 184, 109, 0.08);
  --gold-soft: rgba(232, 184, 109, 0.14);
  --gold-border: rgba(232, 184, 109, 0.22);
  --gold-glow: rgba(232, 184, 109, 0.12);

  --indigo: #818cf8;
  --indigo-dim: rgba(129, 140, 248, 0.1);
  --indigo-border: rgba(129, 140, 248, 0.25);

  --reading-side: 300px;
  --reading-width: 72ch;
  --reading-font-size: 19px;
  --reading-line: 1.9;

  --font-reading: 'Source Serif 4', 'Crimson Pro', Georgia, serif;
  --font-display-r: 'Fraunces', 'Playfair Display', Georgia, serif;
  --font-ui-r: 'DM Sans', 'Syne', system-ui, sans-serif;
}

/* ── Reading Progress Bar ── */
#reading-progress-bar {
  position: fixed;
  top: var(--offline-banner-h);
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold) 0%, var(--indigo) 100%);
  z-index: 9999;
  transition: width 0.1s linear;
  pointer-events: none;
}

#view-project {
  display: none;
}

#view-project.active {
  display: block;
}

.project-layout {
  display: flex;
  min-height: 100vh;
  background: var(--ink-900);
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 39;
}

.sidebar-overlay.active {
  display: block;
}

/* ─────────────────────────────────────────────
   SIDEBAR
───────────────────────────────────────────── */
.project-sidebar {
  width: var(--reading-side);
  flex-shrink: 0;
  background: var(--ink-800);
  border-right: 1px solid rgba(255, 255, 255, 0.055);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--offline-banner-h);
  left: 0;
  height: calc(100vh - var(--offline-banner-h));
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 40;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.project-sidebar.collapsed {
  width: 0;
  overflow: hidden;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  flex-shrink: 0;
}

.sidebar-back-btn {
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  letter-spacing: 0.03em;
  transition: color 0.2s;
}

.sidebar-back-btn:hover {
  color: var(--gold);
}

.sidebar-collapse-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color 0.2s, background 0.2s;
}

.sidebar-collapse-btn:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}

.project-sidebar.collapsed+.project-main {
  margin-left: 0;
}

/* Expand sidebar button — shown only when sidebar is collapsed on desktop */
.sidebar-expand-btn {
  display: none;
  /* hidden by default */
  position: fixed;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 22px;
  height: 52px;
  background: var(--ink-700);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-left: none;
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  z-index: 41;
  transition: background 0.2s, color 0.2s, width 0.2s;
}

.sidebar-expand-btn:hover {
  background: var(--ink-600);
  color: var(--gold);
  width: 28px;
}

/* Show only when sidebar-hidden is applied on the layout */
.project-layout.sidebar-hidden .sidebar-expand-btn {
  display: flex;
}



/* Sidebar project info */
.sidebar-project-info {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  flex-shrink: 0;
}

.sidebar-project-name {
  font-family: var(--font-display-r);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  margin-bottom: 10px;
  letter-spacing: -0.01em;
}

.sidebar-status {
  font-family: var(--font-ui-r);
  font-size: 12px;
}

/* Sidebar parts header */
.sidebar-parts-header {
  display: flex;
  align-items: center;
  padding: 14px 18px 6px;
  flex-shrink: 0;
}

.sidebar-section-title {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  padding: 4px 8px;
  overflow-y: auto;
}

.sidebar-part {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 1px;
  border-left: 2px solid transparent;
  position: relative;
  text-decoration: none;
  color: inherit;
}

.sidebar-part:hover {
  background: rgba(255, 255, 255, 0.04);
}

.sidebar-part.active {
  background: var(--gold-dim);
  border-left-color: var(--gold);
}

.sidebar-part.active .part-num {
  color: var(--gold);
}

.sidebar-part.active .part-label {
  color: var(--text-primary);
}

.part-num {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  width: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.part-label {
  font-family: var(--font-ui-r);
  font-size: 12.5px;
  color: var(--text-secondary);
  flex: 1;
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.part-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.dot-pending {
  background: rgba(255, 255, 255, 0.12);
}

.dot-processing {
  background: var(--gold);
  animation: pulse 1.5s infinite;
}

.dot-completed {
  background: var(--emerald);
}

.dot-error {
  background: var(--red);
}

.part-read-check {
  font-size: 12px;
  color: var(--emerald);
  margin-left: 6px;
  flex-shrink: 0;
}

.part-read-toggle {
  font-size: 14px;
  width: 22px;
  height: 22px;
  padding: 0;
  margin-left: 6px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.part-read-toggle:hover {
  color: var(--emerald);
  border-color: var(--emerald);
  background: var(--emerald-dim);
}

.part-read-toggle.is-read {
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.4);
}

.part-read-toggle:disabled,
.btn-toggle-complete:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: none;
}

.sidebar-part.part-read .part-label {
  color: var(--text-secondary);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 16px 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
  flex-shrink: 0;
}

.sidebar-usage-mini {
  background: var(--ink-700);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.usage-mini-label {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.usage-mini-value {
  font-family: var(--font-ui-r);
  font-size: 16px;
  font-weight: 700;
  color: var(--gold);
}

.btn-export-project {
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
  background: transparent;
  border: 1px solid var(--gold-border);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.btn-export-project:hover {
  background: var(--gold-dim);
  border-color: var(--gold);
}

/* ─────────────────────────────────────────────
   MAIN CONTENT
───────────────────────────────────────────── */
.project-main {
  flex: 1;
  margin-left: var(--reading-side);
  min-height: 100vh;
  position: relative;
  background: var(--ink-900);
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  max-height: 100vh;
}

.project-sidebar.collapsed~.project-main,
.project-layout.sidebar-hidden .project-main {
  margin-left: 0;
}

/* Mobile Header */
.mobile-header {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--ink-800);
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
  position: sticky;
  top: var(--offline-banner-h);
  z-index: 30;
}

.sidebar-hamburger {
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}

.sidebar-hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all 0.2s;
}

.mobile-project-name {
  font-family: var(--font-ui-r);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────
   PROJECT BOOT SHELL
───────────────────────────────────────────── */
.project-boot-shell {
  min-height: 100vh;
  padding: 42px 40px 56px;
}

.project-boot-shell.hidden {
  display: none;
}

.project-boot-shell-inner {
  max-width: 880px;
  margin: 0 auto;
}

.project-boot-kicker {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 22px;
}

.project-boot-title-skeleton,
.project-boot-pill,
.project-boot-tab,
.project-boot-line {
  position: relative;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.project-boot-title-skeleton::after,
.project-boot-pill::after,
.project-boot-tab::after,
.project-boot-line::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.project-boot-title-skeleton {
  height: 36px;
  width: min(620px, 90%);
  border-radius: 12px;
  margin-bottom: 18px;
}

.project-boot-meta-row {
  display: flex;
  gap: 12px;
  margin-bottom: 26px;
}

.project-boot-pill {
  height: 30px;
  width: 140px;
  border-radius: 999px;
}

.project-boot-pill.short {
  width: 92px;
}

.project-boot-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 22px;
}

.project-boot-tab {
  height: 38px;
  width: 140px;
  border-radius: 10px 10px 0 0;
}

.project-boot-tab.active {
  background: rgba(232, 184, 109, 0.12);
  border-color: rgba(232, 184, 109, 0.18);
}

.project-boot-body {
  padding: 30px 28px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.project-boot-line {
  height: 14px;
  border-radius: 999px;
  margin-bottom: 14px;
}

.project-boot-line:last-child {
  margin-bottom: 0;
}

.project-boot-line.w-100 { width: 100%; }
.project-boot-line.w-96 { width: 96%; }
.project-boot-line.w-92 { width: 92%; }
.project-boot-line.w-88 { width: 88%; }
.project-boot-line.w-78 { width: 78%; }
.project-boot-line.w-65 { width: 65%; }

@keyframes skeleton-shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* ─────────────────────────────────────────────
   WELCOME STATE
───────────────────────────────────────────── */
.main-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 14px;
  text-align: center;
  padding: 40px;
}

.main-welcome.hidden {
  display: none;
}

.welcome-icon {
  font-size: 44px;
  color: rgba(232, 184, 109, 0.2);
  margin-bottom: 4px;
}

.welcome-title {
  font-family: var(--font-display-r);
  font-size: 26px;
  font-weight: 400;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.welcome-sub {
  font-family: var(--font-reading);
  font-size: 16px;
  color: var(--text-muted);
  max-width: 38ch;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────
   PART CONTENT
───────────────────────────────────────────── */
.part-content {
  padding: 0;
}

.part-content.hidden {
  display: none;
}

/* Reformat Banner */
.reformat-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  margin: 0 0 0 0;
  background: color-mix(in srgb, var(--accent, #7c6fcd) 8%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--accent, #7c6fcd) 20%, transparent);
  font-size: 0.82rem;
  flex-shrink: 0;
}

.reformat-banner.hidden {
  display: none;
}

.reformat-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.reformat-banner-icon {
  flex-shrink: 0;
  color: var(--accent, #7c6fcd);
  opacity: 0.85;
}

.reformat-banner-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.reformat-banner-text strong {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  white-space: nowrap;
}

.reformat-banner-text span {
  font-size: 0.78rem;
  color: var(--text-secondary, #94a3b8);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reformat-banner-btn {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--accent, #7c6fcd) 40%, transparent);
  background: color-mix(in srgb, var(--accent, #7c6fcd) 12%, transparent);
  color: var(--accent, #7c6fcd);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.reformat-banner-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--accent, #7c6fcd) 22%, transparent);
  border-color: color-mix(in srgb, var(--accent, #7c6fcd) 60%, transparent);
}

.reformat-banner-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Also style rendered markdown inside explainer panels */
.explainer-text p,
.explainer-section-intro p,
.explainer-intro p,
.explainer-conclusion p {
  margin-bottom: 0.65em;
}

.explainer-text ul,
.explainer-text ol,
.explainer-section-intro ul,
.explainer-section-intro ol {
  margin: 0.5em 0 0.65em 1.3em;
}

.explainer-text li,
.explainer-section-intro li {
  margin-bottom: 0.25em;
}

.explainer-text strong,
.explainer-section-intro strong {
  font-weight: 600;
}

.explainer-text code,
.explainer-section-intro code {
  font-family: monospace;
  font-size: 0.88em;
  background: rgba(255,255,255,0.07);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Reading Toolbar */
.reading-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 40px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: var(--ink-800);
  position: sticky;
  top: 0;
  z-index: 20;
}

.reading-nav-btn {
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
  letter-spacing: 0.02em;
}

.reading-nav-btn:hover:not(:disabled) {
  color: var(--gold);
  background: var(--gold-dim);
}

.reading-nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.reading-toolbar-center {
  display: flex;
  align-items: center;
}

.reading-toolbar-partnum {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* Part Header */
.part-header {
  padding: 40px 40px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  max-width: calc(var(--reading-width) + 80px);
}

.part-title {
  font-family: var(--font-display-r);
  font-size: clamp(28px, 3.5vw, 44px);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
  letter-spacing: -0.025em;
  margin-bottom: 12px;
}

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

.part-meta {
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.part-actions {
  display: flex;
  align-items: center;
}

.part-actions-desktop {
  display: flex;
  align-items: center;
  gap: 8px;
}

.part-actions-mobile {
  display: none;
}

.btn-export-inline {
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  padding: 5px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  white-space: nowrap;
}

.btn-export-inline:hover {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

.btn-toggle-complete.is-read:hover {
  color: var(--emerald);
  border-color: var(--emerald);
}

.btn-toggle-complete .toggle-complete-icon {
  flex-shrink: 0;
}

/* Mobile overflow menu */
.part-actions-overflow {
  position: relative;
}

.part-actions-overflow-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.part-actions-overflow-trigger::-webkit-details-marker {
  display: none;
}

.part-actions-overflow-trigger:hover {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

.part-actions-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 180px;
  padding: 6px;
  background: var(--ink-800);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  z-index: 50;
}

.part-action-item {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font-ui-r);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: color 0.2s, background 0.2s;
}

.part-action-item:hover {
  color: var(--gold);
  background: var(--gold-dim);
}

.part-description-wrap {
  position: relative;
}

.part-description {
  font-family: var(--font-reading);
  font-size: 17px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.7;
  max-width: 60ch;
  margin: 0;
}

.part-description-expand {
  display: none;
  margin-top: 8px;
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 500;
  color: var(--gold);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: color 0.2s, opacity 0.2s;
}

.part-description-expand:hover {
  color: var(--amber-light);
  text-decoration: underline;
}

/* Legacy badge (used elsewhere) */
.badge {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 100px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.03);
}

/* ── Tabs Bar ── */
.tabs-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  padding: 0 40px;
  background: var(--ink-900);
  position: sticky;
  top: 41px;
  z-index: 19;
}

.tab-btn {
  font-family: var(--font-ui-r);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: -1px;
  transition: color 0.2s, border-color 0.2s;
  letter-spacing: 0.01em;
}

.tab-btn:hover {
  color: var(--text-primary);
}

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

.tab-svg {
  opacity: 0.7;
  transition: opacity 0.2s;
}

.tab-btn.active .tab-svg {
  opacity: 1;
}

/* Tab panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.tab-panel.hidden {
  display: none;
}

/* Panel loading skeletons */
.panel-loading {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 40px;
  max-width: calc(var(--reading-width) + 80px);
}

.panel-loading.hidden {
  display: none;
}

/* Placeholder shown when a part has some agents ready but this tab is still generating */
.panel-preparing {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 56px 24px;
  color: var(--text-muted);
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 13px;
  opacity: 0.75;
}

.panel-preparing-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--gold-dim, rgba(232, 184, 109, 0.2));
  border-top-color: var(--gold, #e8b86d);
  border-radius: 50%;
  animation: panelPreparingSpin 0.9s linear infinite;
}

@keyframes panelPreparingSpin {
  to {
    transform: rotate(360deg);
  }
}

.skeleton-block {
  height: 18px;
  background: linear-gradient(90deg, var(--ink-700), var(--ink-600), var(--ink-700));
  background-size: 200% 100%;
  border-radius: 4px;
  animation: shimmer 1.8s infinite;
}

.skeleton-short {
  width: 55%;
}

.skeleton-med {
  width: 75%;
}

/* Reading column */
.reading-column {
  max-width: var(--reading-width);
  margin-left: 40px;
}



/* ============================================================
   EXPLAINER PANEL — Reading Typography
   ============================================================ */

/* Panel padding */
#panel-explicacion .reading-column,
#panel-recorrido .reading-column {
  padding: 40px 0 80px;
}

#panel-recursos .panel-content {
  padding: 40px 40px 80px;
}

.explainer-intro {
  font-family: var(--font-reading);
  font-size: var(--reading-font-size);
  color: var(--text-secondary);
  line-height: var(--reading-line);
  padding: 22px 24px;
  background: var(--ink-700);
  border-radius: 10px;
  border-left: 3px solid var(--gold);
  margin-bottom: 40px;
}

.explainer-intro p {
  margin: 0;
}

.explainer-intro p+p {
  margin-top: 1em;
}

.explainer-section {
  margin-bottom: 48px;
}

.explainer-section-title {
  font-family: var(--font-display-r);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 14px;
  letter-spacing: -0.02em;
}

.explainer-section-intro {
  font-family: var(--font-reading);
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: 24px;
  padding-left: 18px;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.explainer-subsection {
  margin-bottom: 32px;
}

.explainer-subsection-title {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 12px;
}

.explainer-text {
  font-family: var(--font-reading);
  font-size: var(--reading-font-size);
  color: #ddd8c9;
  line-height: var(--reading-line);
}

.explainer-text p {
  margin: 0 0 1.2em;
}

.explainer-text p:last-child {
  margin-bottom: 0;
}

.explainer-conclusion {
  font-family: var(--font-reading);
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.85;
  padding: 22px 24px;
  background: var(--ink-700);
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-left: 3px solid var(--indigo);
  margin-top: 48px;
}

.explainer-conclusion p {
  margin: 0;
}

.explainer-conclusion p+p {
  margin-top: 1em;
}

.explainer-conclusion-label {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--indigo);
  margin-bottom: 12px;
  opacity: 0.8;
}

/* ============================================================
   RECORRIDO PANEL — Annotated Journey
   ============================================================ */

.recorrido-entry {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding-bottom: 36px;
  margin-bottom: 36px;
  animation: fadeInUp 0.3s ease both;
}

.recorrido-entry:last-child {
  border-bottom: none;
}

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

.recorrido-ubicacion {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.recorrido-tipo {
  font-family: var(--font-ui-r);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  padding: 3px 10px;
  letter-spacing: 0.04em;
}

.recorrido-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.recorrido-cita {
  font-family: var(--font-reading);
  font-size: 18px;
  font-style: italic;
  color: #e8e0d0;
  line-height: 1.8;
  padding: 18px 22px;
  border-left: 3px solid var(--indigo);
  background: var(--ink-700);
  border-radius: 0 8px 8px 0;
  margin: 0;
}

.recorrido-traduccion {
  font-family: var(--font-reading);
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.75;
  padding: 14px 18px;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 8px;
}

.recorrido-traduccion p {
  margin: 0;
}

.recorrido-traduccion-label {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  display: block;
}

.recorrido-apuntes {
  font-family: var(--font-reading);
  font-size: 14px;
  font-style: italic;
  color: var(--text-muted);
  padding: 8px 14px;
  border-left: 2px solid rgba(255, 255, 255, 0.08);
}

.recorrido-anotacion {
  font-family: var(--font-reading);
  font-size: 17px;
  color: #cfc8b8;
  line-height: 1.85;
}

.recorrido-anotacion p {
  margin: 0 0 1em;
}

.recorrido-anotacion p:last-child {
  margin-bottom: 0;
}

.recorrido-anotacion-label {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: block;
}

.recorrido-sintesis {
  background: var(--ink-700);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 24px;
  margin-top: 40px;
}

.recorrido-sintesis h4 {
  font-family: var(--font-ui-r);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.sintesis-field {
  margin-bottom: 14px;
}

.sintesis-field-label {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.sintesis-field-value {
  font-family: var(--font-reading);
  font-size: 15px;
  color: var(--text-primary);
  line-height: 1.65;
}

/* ============================================================
   RESOURCES PANEL — Thematic Map
   ============================================================ */
.resources-header {
  margin-bottom: 36px;
  max-width: 72ch;
}

.resources-title {
  font-family: var(--font-display-r);
  font-size: 30px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  letter-spacing: -0.02em;
}

.resources-vision {
  font-family: var(--font-reading);
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.8;
  padding: 16px 20px;
  background: var(--ink-700);
  border-radius: 8px;
  border-left: 3px solid var(--gold);
}

.resources-vision p {
  margin: 0;
}

.resources-eje {
  margin-bottom: 48px;
}

.resources-eje-title {
  font-family: var(--font-display-r);
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  letter-spacing: -0.01em;
}

/* Resource cards grid */
.resources-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.resource-card {
  background: var(--ink-800);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 20px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.resource-card:hover {
  border-color: var(--gold-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 0 20px var(--gold-glow);
}

.resource-top {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 12px;
}

.resource-format-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 2px;
  opacity: 0.85;
}

.resource-info {
  flex: 1;
  min-width: 0;
}

.resource-title {
  font-family: var(--font-display-r);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  line-height: 1.35;
}

.resource-author {
  font-family: var(--font-ui-r);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 3px;
}

.resource-datos {
  font-family: var(--font-ui-r);
  font-size: 11px;
  color: var(--text-muted);
}

.resource-conexion {
  font-family: var(--font-reading);
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.65;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 6px;
  margin-bottom: 10px;
}

.resource-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.resource-nivel {
  font-family: var(--font-ui-r);
  font-size: 11px;
  color: var(--text-secondary);
}

.resource-idioma {
  font-family: var(--font-ui-r);
  font-size: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 100px;
  padding: 2px 9px;
  color: var(--text-muted);
}

.resource-nota {
  font-family: var(--font-ui-r);
  font-size: 11px;
  color: var(--gold);
  font-style: italic;
  width: 100%;
  margin-top: 4px;
}

/* Actionable resource URL (secondary-style small button, gold palette) */
.resource-url {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}

.resource-url-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-decoration: none;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 100px;
  padding: 4px 12px;
  transition: background 0.2s, border-color 0.2s;
}

.resource-url-link:hover {
  background: var(--gold-soft);
  border-color: rgba(232, 184, 109, 0.4);
}

.resource-url-host {
  font-family: var(--font-ui-r);
  font-size: 11px;
  color: var(--text-muted);
  word-break: break-all;
}

.resources-integridad {
  font-family: var(--font-reading);
  font-size: 14px;
  color: var(--text-muted);
  padding: 16px 20px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  margin-top: 36px;
  font-style: italic;
}

/* ============================================================
   ERROR STATE
   ============================================================ */
.error-state {
  padding: 28px;
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 10px;
  color: var(--red);
  font-family: var(--font-ui-r);
  font-size: 14px;
}

.error-state-title {
  font-weight: 700;
  margin-bottom: 6px;
}

/* ============================================================
   RESPONSIVE — Project Reading View
   ============================================================ */

/* 1440px: add comfortable inner margins */
@media (min-width: 1440px) {

  .part-header,
  .tabs-bar,
  .reading-toolbar {
    padding-left: 64px;
    padding-right: 64px;
  }

  .reading-column {
    margin-left: 64px;
  }

  #panel-recursos .panel-content {
    padding-left: 64px;
    padding-right: 64px;
  }
}

/* 1024px: narrow sidebar */
@media (max-width: 1024px) {
  :root {
    --reading-side: 260px;
    --reading-font-size: 18px;
  }
}

/* 768px: mobile drawer */
@media (max-width: 768px) {
  :root {
    --reading-font-size: 17px;
    --reading-width: 100%;
  }

  .project-main {
    margin-left: 0;
  }

  .mobile-header {
    display: flex;
  }

  /* Sidebar becomes a drawer */
  .project-sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .project-sidebar.open {
    transform: translateX(0);
  }

  /* Hide desktop collapse/expand btns on mobile */
  .sidebar-collapse-btn,
  .sidebar-expand-btn {
    display: none;
  }


  .reading-toolbar {
    padding: 8px 20px;
    top: calc(var(--offline-banner-h) + var(--mobile-header-h));
  }

  .tabs-bar {
    padding: 0 20px;
    top: calc(var(--offline-banner-h) + var(--mobile-header-h) + var(--mobile-toolbar-h));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tabs-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    white-space: nowrap;
    padding: 12px 16px;
  }

  .part-header {
    padding: 24px 20px 20px;
  }

  .part-header-row {
    flex-wrap: wrap;
    margin-bottom: 16px;
  }

  .part-actions-desktop {
    display: none;
  }

  .part-actions-mobile {
    display: block;
    margin-left: auto;
  }

  .project-boot-shell {
    padding: 28px 18px 40px;
    min-height: calc(100vh - 54px);
  }

  .project-boot-title-skeleton,
  .project-boot-tab {
    width: 100%;
  }

  .project-boot-tabs {
    gap: 8px;
  }

  .project-boot-body {
    padding: 22px 18px;
  }

  .part-title {
    font-size: clamp(24px, 7vw, 32px);
    margin-bottom: 10px;
  }

  .part-description {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .part-description-wrap.expanded .part-description {
    display: block;
    -webkit-line-clamp: unset;
    line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: visible;
  }

  .part-description-wrap.has-description .part-description-expand {
    display: inline-block;
  }

  .part-description-wrap:not(.has-description) .part-description-expand {
    display: none !important;
  }

  .reading-column {
    margin-left: 20px;
    margin-right: 20px;
  }

  #panel-recursos .panel-content {
    padding: 28px 20px 60px;
  }

  .resources-grid {
    grid-template-columns: 1fr;
  }
}

/* 480px: extra-small */
@media (max-width: 480px) {
  :root {
    --reading-font-size: 16px;
  }

  .reading-toolbar {
    padding: 6px 14px;
  }

  .reading-nav-btn {
    font-size: 11px;
  }

  .tab-btn {
    font-size: 12px;
    padding: 10px 12px;
    gap: 5px;
  }
}

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

  /* Sub-panels: tighter padding and thinner accent on narrow viewports */
  .openrouter-model-panel {
    border-left-width: 2px;
    padding: 10px 10px 10px 12px;
  }

  /* Custom panel: reduce padding, keep content readable */
  .openrouter-custom-panel {
    padding: 10px;
  }

  /* Cap combobox listbox height so it doesn't overflow on small screens */
  .combobox-listbox {
    max-height: 200px;
  }
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  font-family: var(--font-ui);
  font-size: 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
  animation: slideInRight 0.3s ease;
  pointer-events: all;
  max-width: 320px;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.4);
}

.toast.error {
  border-color: rgba(239, 68, 68, 0.4);
  color: var(--red);
}

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes coreSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden {
  display: none !important;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================================
   API KEY WARNING
   ============================================================ */
.api-key-warning {
  background: var(--red-dim);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}

.warning-icon {
  font-size: 24px;
  flex-shrink: 0;
}

.warning-content {
  flex: 1;
}

.warning-title {
  font-family: var(--font-ui);
  font-weight: 600;
  margin-bottom: 4px;
}

.warning-sub {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 24px 0;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  transition: color 0.2s;
}

.modal-close:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

/* ============================================================
   SETTINGS
   ============================================================ */
.settings-section {
  margin-bottom: 32px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section-title {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--amber);
  margin-bottom: 16px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-label {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-secondary);
}

.settings-value {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
}

.settings-description {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
  line-height: 1.6;
}

.settings-description a {
  color: var(--amber);
  text-decoration: none;
}

.settings-description a:hover {
  text-decoration: underline;
}

.settings-item-row {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: none;
  padding-top: 8px;
}

.settings-toggle-labels {
  flex: 1;
  min-width: 0;
}

.settings-toggle-hint {
  display: block;
  margin-top: 6px;
  margin-bottom: 0;
  font-size: 13px;
}

.settings-switch {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-base);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}

.settings-switch.is-on {
  background: var(--amber-dim);
  border-color: var(--amber-border);
}

.settings-switch:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.settings-switch-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.2s, background 0.2s;
  pointer-events: none;
}

.settings-switch.is-on .settings-switch-thumb {
  transform: translateX(20px);
  background: var(--amber);
}

.api-key-status {
  background: var(--bg-base);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 20px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
}

.status-success {
  background: var(--emerald-dim);
  color: var(--emerald);
}

.status-warning {
  background: var(--red-dim);
  color: var(--red);
}

.status-neutral {
  background: rgba(255,255,255,0.06);
  color: var(--text-secondary);
}

.settings-badge-optional {
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-ui);
  color: var(--text-muted);
  background: rgba(255,255,255,0.07);
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}

.settings-form .form-group {
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.btn-danger {
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  color: var(--red);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 10px 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger:hover {
  background: var(--red-dim);
}

/* ============================================================
   HEADER ACTIONS
   ============================================================ */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Shared responsive for landing / non-project views */
@media (max-width: 768px) {
  .landing-header {
    padding: 20px 24px;
  }

  .header-actions {
    gap: 8px;
  }

  .btn-ghost {
    padding: 8px 12px;
    font-size: 13px;
  }
}

/* ============================================================
   FLOATING PROCESSING INDICATOR (non-blocking)
   ============================================================ */
.floating-indicator {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: rgba(13, 17, 23, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 16px;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.1),
    0 12px 40px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(245, 158, 11, 0.1);
  z-index: 1001;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s;
  max-width: 320px;
  backdrop-filter: blur(8px);
}

.floating-indicator:hover {
  transform: translateY(-2px);
  box-shadow:
    0 0 0 1px rgba(245, 158, 11, 0.2),
    0 16px 48px rgba(0, 0, 0, 0.7),
    0 0 40px rgba(245, 158, 11, 0.15);
}

.floating-indicator.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.floating-indicator.collapsed .fi-content {
  display: none;
}

.floating-indicator.collapsed .fi-toggle {
  transform: rotate(-90deg);
}

.fi-core {
  position: relative;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.fi-ring {
  position: absolute;
  inset: 0;
  border: 2px solid transparent;
  border-radius: 50%;
}

.fi-ring-1 {
  border-top-color: var(--amber);
  border-right-color: rgba(245, 158, 11, 0.25);
  animation: coreSpin 2.5s linear infinite;
}

.fi-ring-2 {
  inset: 8px;
  border-bottom-color: rgba(139, 92, 246, 0.5);
  animation: coreSpin 1.8s linear infinite reverse;
}

.fi-content {
  flex: 1;
  min-width: 0;
}

.fi-title {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fi-agents {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.fi-agent {
  font-size: 16px;
  opacity: 0.4;
  transition: all 0.3s ease;
  filter: grayscale(0.8);
}

.fi-agent.active {
  opacity: 1;
  filter: grayscale(0);
  animation: agentPulse 1.5s ease-in-out infinite;
}

.fi-agent.completed {
  opacity: 1;
  filter: grayscale(0) brightness(1.2);
}

@keyframes agentPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.fi-stream {
  font-family: var(--font-ui);
  font-size: 11px;
  color: var(--text-secondary);
  max-height: 60px;
  overflow: hidden;
}

.fi-line {
  padding: 2px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: fiLineIn 0.2s ease;
}

@keyframes fiLineIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.fi-toggle {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px;
  transition: transform 0.2s, color 0.2s;
  flex-shrink: 0;
}

.fi-toggle:hover {
  color: var(--amber);
}

@media (max-width: 640px) {
  .floating-indicator {
    bottom: 16px;
    right: 16px;
    left: 16px;
    max-width: none;
    padding: 12px 14px;
  }

  .fi-core {
    width: 36px;
    height: 36px;
  }

  .fi-title {
    font-size: 12px;
  }
}

/* ── Full Project Export ── */
.export-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--amber-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-secondary);
}

.export-summary-icon {
  color: var(--amber);
  flex-shrink: 0;
}

.export-section-list {
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 0;
  margin-bottom: 16px;
}

.export-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  font-family: var(--font-ui);
}

.export-section-row.ready {
  color: var(--text-primary);
}

.export-section-row .row-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-light);
  flex-shrink: 0;
}

.export-section-row.ready .row-dot {
  background: var(--emerald);
}

/* ============================================================
   PROC STAGE — Immersive non-blocking loading experience
   The Scholarly Forge aesthetic: sections emerge from darkness
   into golden amber as AI agents complete their work.
   ============================================================ */

/* Container: fills project-main, scrollable */
.proc-stage {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  background: var(--ink-900, #0c0e14);
  animation: procStageIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.proc-stage.hidden {
  display: none !important;
}

@keyframes procStageIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Phase Banner (sticky top strip) ── */
.proc-phase-banner {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 40px;
  background: rgba(12, 14, 20, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(232, 184, 109, 0.15);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.proc-phase-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

/* Pulsing status orb */
.proc-phase-orb {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber, #f59e0b);
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
  animation: procOrbPulse 2s ease-in-out infinite;
}

.proc-phase-orb.orb-upload {
  background: #60a5fa;
  box-shadow: 0 0 0 0 rgba(96, 165, 250, 0.4);
}

.proc-phase-orb.orb-segment {
  background: #a78bfa;
  box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.4);
}

.proc-phase-orb.orb-generate {
  background: var(--amber, #f59e0b);
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4);
}

.proc-phase-orb.orb-done {
  background: #10b981;
  animation: none;
}

@keyframes procOrbPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5);
  }

  60% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

.proc-phase-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.proc-phase-label {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary, #f0ece3);
  letter-spacing: 0.03em;
}

.proc-phase-sub {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 11px;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.01em;
}

.proc-phase-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.proc-cost-label {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted, #6b7280);
}

.proc-cost-badge {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--gold, #e8b86d);
  letter-spacing: -0.01em;
  transition: color 0.3s ease;
}

/* ── 3-step Timeline ── */
.proc-timeline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 20px 40px 0;
}

.proc-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  position: relative;
}

.proc-step-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.1);
  background: var(--ink-700, #1a1d28);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
  font-size: 12px;
  box-shadow: 0 0 0 0 transparent;
}

.proc-step-label {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.05em;
  white-space: nowrap;
  transition: color 0.4s ease;
}

.proc-step-line {
  flex: 1;
  min-width: 40px;
  max-width: 120px;
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin-bottom: 20px;
  /* aligns with dot center */
  position: relative;
  overflow: hidden;
}

/* Active step styles */
.proc-step.active .proc-step-dot {
  border-color: var(--gold, #e8b86d);
  background: rgba(232, 184, 109, 0.12);
  box-shadow: 0 0 16px rgba(232, 184, 109, 0.3);
}

.proc-step.active .proc-step-dot::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--gold, #e8b86d);
  animation: dotPulse 1.4s ease-in-out infinite;
}

@keyframes dotPulse {

  0%,
  100% {
    transform: scale(1);
    opacity: 1;
  }

  50% {
    transform: scale(0.7);
    opacity: 0.6;
  }
}

.proc-step.active .proc-step-label {
  color: var(--gold, #e8b86d);
  font-weight: 600;
}

/* Done step styles */
.proc-step.done .proc-step-dot {
  border-color: var(--emerald, #10b981);
  background: rgba(16, 185, 129, 0.12);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.2);
}

.proc-step.done .proc-step-dot::after {
  content: '✓';
  position: absolute;
  font-size: 12px;
  color: var(--emerald, #10b981);
  font-weight: 700;
}

.proc-step.done .proc-step-label {
  color: var(--emerald, #10b981);
}

/* Active line sweep animation */
.proc-step-line.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, transparent, var(--gold, #e8b86d), transparent);
  animation: lineSweep 2s ease-in-out infinite;
}

.proc-step-line.done {
  background: rgba(16, 185, 129, 0.35);
}

@keyframes lineSweep {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }

  20% {
    opacity: 1;
  }

  80% {
    opacity: 1;
  }

  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* ── Forge Animation (pre-segmentation) ── */
.proc-forge {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 60px 40px;
  position: relative;
}

.proc-forge.hidden {
  display: none !important;
}

.forge-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid transparent;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%);
  /* shift up from center since hint text is below */
}

.forge-ring-1 {
  width: 120px;
  height: 120px;
  border-top-color: var(--gold, #e8b86d);
  border-right-color: rgba(232, 184, 109, 0.2);
  animation: forgeRing1 3s linear infinite;
}

.forge-ring-2 {
  width: 180px;
  height: 180px;
  border-bottom-color: rgba(129, 140, 248, 0.5);
  border-left-color: rgba(129, 140, 248, 0.15);
  animation: forgeRing2 5s linear infinite;
}

.forge-ring-3 {
  width: 240px;
  height: 240px;
  border-top-color: rgba(232, 184, 109, 0.18);
  border-right-color: rgba(232, 184, 109, 0.06);
  animation: forgeRing3 8s linear infinite;
}

@keyframes forgeRing1 {
  to {
    transform: translate(-50%, -60%) rotate(360deg);
  }
}

@keyframes forgeRing2 {
  to {
    transform: translate(-50%, -60%) rotate(-360deg);
  }
}

@keyframes forgeRing3 {
  to {
    transform: translate(-50%, -60%) rotate(360deg);
  }
}

.forge-core {
  position: relative;
  z-index: 2;
  font-size: 42px;
  color: var(--gold, #e8b86d);
  line-height: 1;
  margin-top: 120px;
  /* push below the rings */
  animation: forgeCoreBreath 3s ease-in-out infinite;
  filter: drop-shadow(0 0 20px rgba(232, 184, 109, 0.4));
}

@keyframes forgeCoreBreath {

  0%,
  100% {
    transform: scale(1);
    filter: drop-shadow(0 0 20px rgba(232, 184, 109, 0.35));
  }

  50% {
    transform: scale(1.06);
    filter: drop-shadow(0 0 32px rgba(232, 184, 109, 0.6));
  }
}

.forge-hint {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 13px;
  color: var(--text-muted, #6b7280);
  letter-spacing: 0.04em;
  text-align: center;
  position: relative;
  z-index: 2;
}

/* ── Parts Grid ── */
.proc-parts-grid {
  padding: 28px 40px 60px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-content: start;
}

.proc-parts-grid.hidden {
  display: none !important;
}

/* Individual part cards */
.proc-part-card {
  background: var(--ink-800, #13151d);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 20px;
  cursor: default;
  position: relative;
  overflow: hidden;
  transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.25s ease;
  animation: procCardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes procCardIn {
  from {
    opacity: 0;
    transform: translateY(18px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Skeleton shimmer for pending cards */
.proc-part-card.pending::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg,
      transparent 0%,
      rgba(255, 255, 255, 0.025) 50%,
      transparent 100%);
  animation: procShimmer 2.2s ease-in-out infinite;
}

@keyframes procShimmer {
  0% {
    left: -60%;
  }

  100% {
    left: 160%;
  }
}

/* Processing card: amber border pulse */
.proc-part-card.processing {
  border-color: rgba(232, 184, 109, 0.3);
  box-shadow: 0 0 0 1px rgba(232, 184, 109, 0.08), 0 0 20px rgba(232, 184, 109, 0.06);
}

.proc-part-card.processing::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 14px;
  border: 1px solid rgba(232, 184, 109, 0.2);
  animation: cardBorderPulse 2s ease-in-out infinite;
  pointer-events: none;
}

@keyframes cardBorderPulse {

  0%,
  100% {
    opacity: 0.3;
  }

  50% {
    opacity: 1;
  }
}

/* Completed card: golden reveal */
.proc-part-card.completed {
  border-color: rgba(16, 185, 129, 0.3);
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(16, 185, 129, 0.06);
}

.proc-part-card.completed:hover {
  border-color: rgba(16, 185, 129, 0.55);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.4), 0 0 24px rgba(16, 185, 129, 0.08);
}

.proc-part-card.completed .proc-card-num {
  color: var(--emerald, #10b981);
}

/* Failed card: red accent (uses the .status-error / .error-state palette) */
.proc-part-card.failed {
  border-color: rgba(239, 68, 68, 0.35);
  cursor: default;
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.08), 0 0 20px rgba(239, 68, 68, 0.05);
}

.proc-part-card.failed .proc-card-num {
  color: var(--red, #ef4444);
}

.proc-part-card.failed .proc-card-status-dot {
  background: var(--red, #ef4444);
  animation: none;
}

.proc-part-error {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--red-dim, rgba(239, 68, 68, 0.12));
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  color: var(--red, #ef4444);
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 12px;
  line-height: 1.5;
}

/* Clickable while still processing (explainer ready, progressive unlock) */
.proc-part-card.clickable {
  cursor: pointer;
}

.proc-part-card.clickable:hover .proc-card-cta {
  opacity: 1;
}

/* Card number chip */
.proc-card-num {
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.proc-card-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  transition: background 0.4s ease;
  flex-shrink: 0;
}

.proc-part-card.processing .proc-card-status-dot {
  background: var(--gold, #e8b86d);
  animation: dotPulse 1.4s ease-in-out infinite;
}

.proc-part-card.completed .proc-card-status-dot {
  background: var(--emerald, #10b981);
  animation: none;
}

/* Card title */
.proc-card-title {
  font-family: var(--font-display-r, 'Fraunces', Georgia, serif);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary, #f0ece3);
  line-height: 1.35;
  margin-bottom: 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.proc-part-card.pending .proc-card-title {
  color: var(--text-secondary, #9ca3af);
}

/* Agent badges row */
.proc-agent-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.proc-agent-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--text-muted, #6b7280);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 100px;
  padding: 4px 9px 4px 6px;
  opacity: 0.45;
  filter: grayscale(0.8);
  transition: opacity 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    filter 0.4s cubic-bezier(0.22, 1, 0.36, 1),
    background 0.4s ease,
    border-color 0.4s ease,
    transform 0.3s ease;
}

.proc-agent-badge .badge-icon {
  font-size: 13px;
  line-height: 1;
}

.proc-agent-badge.active {
  opacity: 0.7;
  filter: grayscale(0.3);
  border-color: rgba(232, 184, 109, 0.2);
  background: rgba(232, 184, 109, 0.06);
  animation: badgeActive 1.8s ease-in-out infinite;
}

@keyframes badgeActive {

  0%,
  100% {
    opacity: 0.7;
  }

  50% {
    opacity: 0.9;
  }
}

.proc-agent-badge.done {
  opacity: 1;
  filter: grayscale(0);
  color: var(--text-secondary, #9ca3af);
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.25);
  animation: badgeLightUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes badgeLightUp {
  from {
    opacity: 0.4;
    transform: scale(0.92);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Click-to-open hint on completed cards */
.proc-card-cta {
  display: none;
  margin-top: 12px;
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--emerald, #10b981);
  opacity: 0.8;
  transition: opacity 0.2s;
}

.proc-part-card.completed .proc-card-cta {
  display: block;
  animation: procCardIn 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.proc-part-card.completed:hover .proc-card-cta {
  opacity: 1;
}

/* Section count header above the grid */
.proc-grid-header {
  grid-column: 1 / -1;
  font-family: var(--font-ui-r, 'DM Sans', system-ui, sans-serif);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  margin-bottom: 4px;
}

/* ── Responsive ── */
@media (max-width: 1024px) {
  .proc-parts-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    padding: 24px 28px 52px;
  }

  .proc-phase-banner {
    padding: 12px 28px;
  }

  .proc-timeline {
    padding: 16px 28px 0;
  }
}

@media (max-width: 768px) {

  /* Banner stacks on mobile */
  .proc-phase-banner {
    padding: 10px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .proc-phase-right {
    align-self: flex-end;
  }

  /* Timeline: hide labels, tighter */
  .proc-timeline {
    padding: 12px 16px 0;
  }

  .proc-step-label {
    display: none;
  }

  .proc-step-line {
    min-width: 24px;
  }

  /* single-column grid */
  .proc-parts-grid {
    grid-template-columns: 1fr;
    padding: 20px 16px 48px;
    gap: 12px;
  }

  .proc-forge {
    padding: 48px 24px;
  }

  .forge-ring-1 {
    width: 90px;
    height: 90px;
  }

  .forge-ring-2 {
    width: 140px;
    height: 140px;
  }

  .forge-ring-3 {
    width: 190px;
    height: 190px;
  }

  .forge-core {
    font-size: 32px;
    margin-top: 92px;
  }
}

@media (max-width: 480px) {
  .proc-phase-label {
    font-size: 12px;
  }

  .proc-cost-badge {
    font-size: 13px;
  }

  .proc-part-card {
    padding: 16px;
  }

  .proc-card-title {
    font-size: 14px;
  }
}

/* ── Share Modal ── */
.share-link-row {
  display: flex;
  gap: 12px;
  margin-top: 1rem;
  align-items: stretch;
}
.share-link-input {
  flex: 1;
  font-family: var(--font-ui);
  font-size: 14px;
}
.share-actions {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ── Shared View CTA (sidebar) ── */
.shared-cta {
  margin-top: 1rem;
  padding: 1.25rem 1rem;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  position: relative;
  animation: sharedCtaEnter 0.4s ease-out;
}
.shared-cta.hidden {
  display: none !important;
}
@keyframes sharedCtaEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.shared-cta-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.shared-cta-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.shared-cta-mark {
  display: block;
  font-size: 14px;
  color: var(--gold);
  margin-bottom: 0.5rem;
  opacity: 0.9;
}
.shared-cta-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.3;
}
.shared-cta-sub {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
}
.shared-cta .btn-primary {
  width: 100%;
  justify-content: center;
}

/* ── Shared View CTA (floating bar) ── */
.shared-cta-floating {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  padding: 12px 20px;
  background: rgba(19, 21, 29, 0.97);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--gold-border);
  align-items: center;
  justify-content: center;
  gap: 16px;
  animation: sharedCtaFloatingEnter 0.4s ease-out;
}
.shared-cta-floating.visible {
  display: flex;
}
.shared-cta-floating.hidden {
  display: none !important;
}
@keyframes sharedCtaFloatingEnter {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.shared-cta-floating-close {
  position: absolute;
  top: 50%;
  right: 16px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.shared-cta-floating-close:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.06);
}
.shared-cta-floating-text {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0;
}
.shared-cta-floating .btn-primary {
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .shared-cta-floating {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 10px;
  }
  .shared-cta-floating-text {
    flex: 1 1 100%;
    font-size: 13px;
    padding-right: 28px;
  }
  .shared-cta-floating .btn-primary {
    flex: 1 1 auto;
  }
}

/* ============================================================
   PWA — Offline Banner
   ============================================================ */

.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 60;
  background: #7c3aed;
  color: #fff;
  text-align: center;
  padding: 0.5rem 0.9rem;
  font-size: 0.8125rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans, 'DM Sans', sans-serif);
  letter-spacing: 0.01em;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4);
}

.offline-banner.hidden {
  display: none;
}

.offline-banner-icon {
  flex-shrink: 0;
  opacity: 0.9;
}

body.is-prefer-offline .offline-banner {
  background: linear-gradient(90deg, #b45309, var(--amber));
  box-shadow: 0 2px 10px rgba(180, 83, 9, 0.45);
}

/* Push content down when banner is visible */
body:not(.is-offline) .offline-banner {
  display: none;
}

@media (max-width: 768px) {
  .offline-banner {
    justify-content: flex-start;
    text-align: left;
    font-size: 0.75rem;
    line-height: 1.3;
    padding: 0.45rem 0.75rem;
  }

  .offline-banner #offline-banner-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ============================================================
   PWA — Install Button
   ============================================================ */

.btn-install-pwa {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.75rem;
  background: transparent;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn-install-pwa:hover {
  color: var(--text-primary);
  border-color: #7c3aed;
  background: rgba(124, 58, 237, 0.08);
}

.btn-install-pwa.hidden {
  display: none;
}

/* ============================================================
   PWA — Offline Pin Button on Project Cards
   ============================================================ */

.offline-pin-btn {
  background: none;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding: 0.2rem 0.45rem;
  line-height: 1.4;
  transition: color 0.15s, border-color 0.15s, background 0.15s, opacity 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0.55;
}

.offline-pin-btn:hover {
  color: var(--text-secondary);
  border-color: var(--border);
  background: var(--bg-hover);
  opacity: 1;
}

.offline-pin-btn.pinned {
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
  opacity: 1;
}

.offline-pin-btn.pinned:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
  background: rgba(239, 68, 68, 0.08);
}

/* ============================================================
   PWA — Offline Badge on Cards
   ============================================================ */

.offline-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 4px;
  padding: 1px 6px;
  line-height: 1.5;
}

/* ============================================================
   PWA — SW Update Toast
   ============================================================ */

.toast-update {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 260px;
}

.toast-action-btn {
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 5px;
  padding: 0.25rem 0.65rem;
  font-size: 0.8125rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
  flex-shrink: 0;
}

.toast-action-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ============================================================
   PWA — Offline state on project cards
   ============================================================ */

/* Dim non-pinned cards when offline */
body.is-offline .project-card:not([data-pinned="true"]) {
  opacity: 0.5;
  cursor: not-allowed;
}

body.is-offline .project-card:not([data-pinned="true"]):hover {
  transform: none;
  box-shadow: none;
}

body.is-offline .project-card[data-pinned="true"] {
  border-color: rgba(16, 185, 129, 0.3);
}

/* ============================================================
   GHOST RAIL — Desktop subsection navigation
   ============================================================ */

.ghost-rail {
  position: absolute;
  right: 0;
  top: 0;
  width: 40px;
  height: 100%;
  pointer-events: auto;
  z-index: 5;
  opacity: 0;
  animation: ghostRailFadeIn 400ms ease forwards;
}

@keyframes ghostRailFadeIn {
  to { opacity: 1; }
}

.ghost-rail-line {
  position: absolute;
  left: 50%;
  top: 24px;
  bottom: 24px;
  width: 2px;
  background: #21262d;
  transform: translateX(-50%);
}

.ghost-rail-node {
  position: absolute;
  left: 50%;
  width: 6px;
  height: 6px;
  background: #30363d;
  border-radius: 50%;
  transform: translateX(-50%);
  transition: all 250ms cubic-bezier(0.22, 1, 0.36, 1);
  cursor: pointer;
  border: none;
  padding: 0;
  pointer-events: auto;
}

.ghost-rail-node.active {
  width: 10px;
  height: 10px;
  background: transparent;
  border: 2px solid #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.25);
}

.ghost-rail-node.is-read {
  background: #8b949e;
}

.ghost-rail-node:hover {
  transform: translateX(-50%) translateX(-8px);
}

.ghost-rail-label {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-ui);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8b949e;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 250ms ease;
  pointer-events: none;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ghost-rail:hover .ghost-rail-label {
  opacity: 1;
}

.ghost-rail-label.active {
  color: #f0ece3;
}

/* ============================================================
   SMART BAR — Mobile subsection navigation
   ============================================================ */

:root {
  --mobile-subsection-nav-h: 68px;
}

.smart-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: var(--mobile-subsection-nav-h);
  background: rgba(12, 14, 20, 0.94);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid rgba(232, 184, 109, 0.16);
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  box-shadow: 0 -18px 42px rgba(0, 0, 0, 0.28);
  animation: smartBarDockIn 260ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes smartBarDockIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.smart-bar-progress {
  position: absolute;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--gold, #e8b86d), var(--indigo, #818cf8));
  transition: width 150ms linear;
}

.smart-bar-prev,
.smart-bar-next {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 8px;
  color: #f0ece3;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.94;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}

.smart-bar-prev:hover:not(:disabled),
.smart-bar-next:hover:not(:disabled) {
  background: var(--gold-dim, rgba(232, 184, 109, 0.08));
  border-color: var(--gold-border, rgba(232, 184, 109, 0.22));
}

.smart-bar-prev:disabled,
.smart-bar-next:disabled {
  opacity: 0.25;
  cursor: default;
}

.smart-bar-title {
  flex: 1;
  min-width: 0;
  height: 42px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 8px;
  color: #f0ece3;
  font-family: var(--font-reading);
  font-size: 15px;
  text-align: center;
  cursor: pointer;
  padding: 0 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 160ms ease, border-color 160ms ease;
}

.smart-bar-title:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(232, 184, 109, 0.18);
}

.smart-bar-title-text {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ============================================================
   SUBSECTION SHEET — Mobile list
   ============================================================ */

.subsection-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.64);
  z-index: 150;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: sheetOverlayIn 250ms ease forwards;
}

@keyframes sheetOverlayIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.subsection-sheet {
  width: 100%;
  max-height: 70vh;
  background: #13151d;
  border-top: 1px solid rgba(232, 184, 109, 0.14);
  border-radius: 14px 14px 0 0;
  padding: 10px 0 calc(18px + env(safe-area-inset-bottom, 0px));
  animation: sheetSlideUp 300ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
  overflow-y: auto;
  box-shadow: 0 -24px 60px rgba(0, 0, 0, 0.42);
}

@keyframes sheetSlideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.subsection-sheet-handle {
  width: 36px;
  height: 4px;
  background: #30363d;
  border-radius: 2px;
  margin: 0 auto 10px;
}

.subsection-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.subsection-sheet-title {
  font-family: var(--font-ui-r);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold, #e8b86d);
}

.subsection-sheet-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.subsection-sheet-close:hover,
.subsection-sheet-close:focus-visible {
  color: var(--text-primary);
  background: var(--gold-dim, rgba(232, 184, 109, 0.08));
  border-color: var(--gold-border, rgba(232, 184, 109, 0.22));
}

.subsection-sheet-list {
  padding-top: 6px;
}

.subsection-sheet-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 18px;
  background: none;
  border: none;
  color: #c9d1d9;
  font-family: var(--font-reading);
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: background 150ms ease;
}

.subsection-sheet-item.active {
  color: var(--gold, #e8b86d);
  background: rgba(232, 184, 109, 0.08);
}

.subsection-sheet-item:hover,
.subsection-sheet-item:focus-visible {
  background: rgba(240, 236, 227, 0.04);
  outline: none;
}

.subsection-sheet-num {
  font-family: var(--font-ui-r);
  font-size: 11px;
  color: #8b949e;
  min-width: 24px;
}

@media (min-width: 769px) {
  .smart-bar {
    display: none !important;
  }
}

@media (max-width: 768px) {
  .ghost-rail {
    display: none;
  }

  .smart-bar {
    display: flex;
  }

  .project-main {
    scroll-padding-bottom: calc(var(--mobile-subsection-nav-h) + 28px + env(safe-area-inset-bottom, 0px));
  }

  .part-content.has-mobile-subsection-nav #panel-explicacion .reading-column {
    padding-bottom: calc(112px + env(safe-area-inset-bottom, 0px));
  }

  body.has-mobile-subsection-nav .shared-cta-floating.visible {
    bottom: calc(var(--mobile-subsection-nav-h) + env(safe-area-inset-bottom, 0px));
  }
}

@media (max-width: 420px) {
  .smart-bar {
    gap: 8px;
    padding-left: 10px;
    padding-right: 10px;
  }

  .smart-bar-prev,
  .smart-bar-next {
    width: 38px;
    height: 40px;
    flex-basis: 38px;
  }

  .smart-bar-title {
    height: 40px;
    font-size: 14px;
    padding: 0 10px;
  }
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   ESQUEMA VISUAL (MERMAID)
   ============================================================ */

.esquema-container {
  padding: 1.75rem 1.5rem 2.5rem;
  max-width: 100%;
}

/* Metadata blocks (analysis, reading guide, synthesis) */
.esquema-meta {
  margin-bottom: 1.25rem;
}

.esquema-meta-label {
  font-size: 0.7rem;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-3, #888);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.esquema-meta-text {
  font-size: 0.88rem;
  color: var(--text-2, #b0a898);
  line-height: 1.65;
  white-space: pre-wrap;
}

/* Diagram wrapper */
.esquema-diagram-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  background: var(--bg-2, #141414);
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.07));
  padding: 1.75rem 1.5rem;
  margin: 1.25rem 0 1rem;
  position: relative;
}

.esquema-diagram-wrap svg {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Loading placeholder inside diagram wrap */
.mermaid-loading {
  text-align: center;
  color: var(--text-3, #888);
  font-size: 0.85rem;
  padding: 2rem 0;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
}

/* Action buttons row */
.esquema-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1.75rem;
}

.btn-download-svg,
.btn-download-png,
.btn-regenerate-esquema {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 1rem;
  border: 1px solid var(--gold, #c9a84c);
  color: var(--gold, #c9a84c);
  background: transparent;
  border-radius: 6px;
  font-size: 0.82rem;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}

.btn-download-svg:hover,
.btn-download-png:hover,
.btn-regenerate-esquema:hover:not(:disabled) {
  background: var(--gold, #c9a84c);
  color: #000;
}

.btn-regenerate-esquema:disabled {
  opacity: 0.6;
  cursor: default;
}

.btn-download-svg svg,
.btn-download-png svg,
.btn-regenerate-esquema svg {
  flex-shrink: 0;
}

/* Generate / empty state */
.esquema-generate-section {
  text-align: center;
  padding: 4rem 1.5rem 5rem;
}

.esquema-generate-section p {
  color: var(--text-2, #b0a898);
  margin: 0 auto 1.75rem;
  font-size: 0.92rem;
  max-width: 440px;
  line-height: 1.7;
}

.esquema-gen-error {
  display: inline-block;
  max-width: 480px;
  margin: 0 auto 1.25rem;
  padding: 0.75rem 1rem;
  background: rgba(200, 60, 60, 0.1);
  border: 1px solid rgba(200, 60, 60, 0.3);
  border-radius: 8px;
  color: #e07070;
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: left;
}

.btn-generate-esquema {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.75rem;
  background: var(--gold, #c9a84c);
  color: #000;
  border: none;
  border-radius: 8px;
  font-size: 0.92rem;
  font-family: var(--font-sans, 'DM Sans', system-ui, sans-serif);
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.btn-generate-esquema:hover:not(:disabled) {
  opacity: 0.88;
  transform: translateY(-1px);
}

.btn-generate-esquema:active:not(:disabled) {
  transform: translateY(0);
}

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

/* Error state (render failure) */
.esquema-error {
  padding: 1.25rem 1.5rem;
  border: 1px solid rgba(200, 60, 60, 0.35);
  border-radius: 8px;
  margin: 1.25rem 0;
  background: rgba(200, 60, 60, 0.05);
}

.esquema-error-title {
  color: #e07070;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.esquema-error p {
  color: var(--text-2, #b0a898);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

.esquema-error pre {
  background: var(--bg-2, #141414);
  padding: 0.875rem 1rem;
  border-radius: 6px;
  overflow-x: auto;
  font-size: 0.78rem;
  color: var(--text-2, #b0a898);
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.55;
  border: 1px solid var(--border-subtle, rgba(255,255,255,0.07));
}

/* Shared view empty state */
.esquema-empty-shared {
  padding: 4rem 2rem;
  text-align: center;
  color: var(--text-3, #888);
  font-size: 0.9rem;
}

/* Mobile adjustments */
@media (max-width: 768px) {
  .esquema-container {
    padding: 1.25rem 1rem 2rem;
  }

  .esquema-diagram-wrap {
    padding: 1rem 0.75rem;
    border-radius: 0;
    border-left: none;
    border-right: none;
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .esquema-generate-section {
    padding: 3rem 1rem 4rem;
  }

  .btn-generate-esquema {
    width: 100%;
    justify-content: center;
  }

  .esquema-actions {
    justify-content: center;
  }
}

/* ========================================================================
   COMBOBOX COMPONENT — Selector de modelos/proveedores OpenRouter
   Scholarly Forge dark academic, sin nuevos tokens de color.
   ======================================================================== */

.combobox-wrapper {
  position: relative;
  width: 100%;
}

.combobox-input {
  width: 100%;
  padding-right: 40px;
  cursor: pointer;
}

/* Chevron */
.combobox-chevron {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.combobox-wrapper.open .combobox-chevron {
  transform: translateY(-50%) rotate(180deg);
}

/* Listbox (dropdown) */
.combobox-listbox {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 320px;
  overflow-y: auto;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 4px 0;
  margin: 0;
  list-style: none;

  /* Opcional: motion (se respeta prefers-reduced-motion) */
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
}

.combobox-wrapper.open .combobox-listbox {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (prefers-reduced-motion: no-preference) {
  .combobox-listbox {
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 0.1s ease, transform 0.1s ease;
  }

  .combobox-wrapper.open .combobox-listbox {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }
}

/* Option */
.combobox-option {
  display: flex;
  flex-direction: column;
  padding: 10px 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.08s ease, border-color 0.08s ease;
}

.combobox-option:hover,
.combobox-option.active {
  background: var(--amber-dim);
  border-left-color: var(--amber);
}

.combobox-option.selected {
  background: var(--amber-dim);
  border-left-color: var(--amber);
}

.combobox-option-name {
  display: block;
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.3;
}

.combobox-option.selected .combobox-option-name::before {
  content: "✓ ";
  color: var(--amber);
}

.combobox-option-id {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  font-family: SFMono-Regular, Consolas, Monaco, "Liberation Mono", monospace;
  line-height: 1.3;
  margin-top: 1px;
}

.combobox-option-meta {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  line-height: 1.3;
  margin-top: 2px;
}

/* Cap hint */
.combobox-cap-hint {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--font-ui);
}

/* No results */
.combobox-no-results {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  padding: 20px 14px;
  font-family: var(--font-ui);
  list-style: none;
}

/* ── Chosen-model summary (custom OpenRouter picker) ── */
.openrouter-custom-model-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 12px;
}

.model-summary-name {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
  margin-right: 2px;
}

.model-summary-chip {
  font-family: SFMono-Regular, Consolas, Monaco, 'Liberation Mono', monospace;
  font-size: 11px;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* Label chip distinguishes the data source: aggregate model data vs an
   exact endpoint row matched by tag. */
.model-summary-chip--label {
  color: var(--amber);
  background: var(--amber-dim);
  border-color: var(--amber);
  font-family: var(--font-ui);
  font-weight: 600;
}

@media (max-width: 680px) {
  .openrouter-custom-model-summary {
    padding: 8px 10px;
    gap: 4px;
  }
  .model-summary-chip {
    font-size: 10px;
    padding: 2px 5px;
  }
}

/* ── Personalizado card (custom OpenRouter model) ── */
.provider-card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.provider-card-desc {
  font-family: var(--font-ui);
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ========================================================================
   REPASO ACTIVO — Self-assessment flashcards (on-demand, dark academic)
   Scholarly Forge: solo tokens del tema (ink / gold / fonts).
   ======================================================================== */

/* ── Panel ── */
#panel-repaso .panel-content {
  padding: 40px 40px 80px;
}

.review-container {
  max-width: 760px;
}

/* ── Header ── */
.review-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.review-head-mark {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  margin-top: 2px;
}

.review-head-text {
  min-width: 0;
}

.review-kicker {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 4px;
}

.review-title {
  font-family: var(--font-display-r);
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0 0 6px;
}

.review-subtitle {
  font-family: var(--font-ui-r);
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin: 0;
}

/* ── Cards (stacked flashcards) ── */
.review-cards {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.review-card {
  position: relative;
  background: linear-gradient(180deg, var(--ink-700) 0%, var(--ink-800) 100%);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 12px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 28px rgba(0, 0, 0, 0.28);
  transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.review-card:hover {
  border-color: var(--gold-border);
  transform: translateY(-2px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 16px 36px rgba(0, 0, 0, 0.35), 0 0 24px var(--gold-glow);
}

.review-card-front {
  padding: 22px 24px 20px;
}

.review-card-num {
  display: inline-block;
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.review-card-question {
  font-family: var(--font-display-r);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-primary);
  margin: 0 0 16px;
  letter-spacing: -0.01em;
}

/* Reveal button */
.review-reveal {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  color: var(--gold);
  font-family: var(--font-ui-r);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.review-reveal:hover {
  background: var(--gold-soft);
  border-color: var(--gold);
}

.review-reveal:active {
  transform: scale(0.98);
}

.review-reveal .review-reveal-chevron {
  transition: transform 0.3s ease;
}

.review-card.revealed .review-reveal-chevron {
  transform: rotate(180deg);
}

/* Answer accordion (grid-rows animation for a smooth reveal) */
.review-card-answer {
  display: grid;
  grid-template-rows: 0fr;
  opacity: 0;
  transition: grid-template-rows 0.38s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.review-card.revealed .review-card-answer {
  grid-template-rows: 1fr;
  opacity: 1;
}

.review-answer-inner {
  overflow: hidden;
  min-height: 0;
}

.review-answer-text {
  font-family: var(--font-reading);
  font-size: 16px;
  line-height: 1.75;
  color: var(--text-secondary);
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  margin: 0 24px;
  padding: 18px 0 4px;
}

.review-answer-text p {
  margin: 0 0 0.9em;
}

.review-answer-text p:last-child {
  margin-bottom: 0;
}

.review-answer-ref {
  margin: 0 24px;
  padding: 10px 0 20px;
}

.review-ref-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: 999px;
  color: var(--gold);
  font-family: SFMono-Regular, Consolas, Monaco, 'Liberation Mono', monospace;
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

/* ── Study note ── */
.review-note {
  margin-top: 28px;
  padding: 18px 22px;
  background: var(--ink-700);
  border-left: 3px solid var(--gold);
  border-radius: 10px;
}

.review-note-label {
  font-family: var(--font-ui-r);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
}

.review-note-text {
  font-family: var(--font-reading);
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  font-style: italic;
}

.review-note-text p {
  margin: 0 0 0.8em;
}

.review-note-text p:last-child {
  margin-bottom: 0;
}

/* ── Actions (regenerate) ── */
.review-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
}

.btn-regenerate-review {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--text-muted);
  font-family: var(--font-ui-r);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn-regenerate-review:hover:not(:disabled) {
  color: var(--gold);
  border-color: var(--gold-border);
  background: var(--gold-dim);
}

/* ── Empty / invitation state ── */
.review-empty {
  max-width: 640px;
  margin: 0 auto;
  padding: 72px 24px 84px;
  text-align: center;
}

.review-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  box-shadow: 0 0 32px var(--gold-glow);
  margin-bottom: 22px;
}

.review-empty-title {
  font-family: var(--font-display-r);
  font-size: 26px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0 0 10px;
}

.review-empty-text {
  font-family: var(--font-ui-r);
  font-size: 14px;
  line-height: 1.7;
  color: var(--text-muted);
  margin: 0 auto 26px;
  max-width: 380px;
}

.review-empty-hint {
  font-family: var(--font-ui-r);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  opacity: 0.7;
  margin: 18px auto 0;
  max-width: 340px;
}

.review-empty-error {
  max-width: 480px;
  margin: 0 auto 20px;
  padding: 12px 16px;
  background: rgba(200, 60, 60, 0.1);
  border: 1px solid rgba(200, 60, 60, 0.3);
  border-radius: 8px;
  color: #e07070;
  font-family: var(--font-ui-r);
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
}

/* ── Primary CTA ── */
.btn-review-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 30px;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: 10px;
  font-family: var(--font-ui-r);
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 0 24px var(--gold-glow);
  transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.btn-review-primary:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.4), 0 0 30px var(--gold-glow);
}

.btn-review-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-review-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ── In-button spinner ── */
.btn-review-spinner {
  display: none;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: reviewSpin 0.8s linear infinite;
}

.btn-regenerate-review .btn-review-spinner {
  border-color: rgba(232, 184, 109, 0.25);
  border-top-color: var(--gold);
}

.btn-review-primary.is-loading .btn-review-spinner,
.btn-regenerate-review.is-loading .btn-review-spinner {
  display: inline-block;
}

.btn-regenerate-review.is-loading .review-regen-icon {
  display: none;
}

@keyframes reviewSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Shared view (read-only) ── */
.review-shared-empty {
  padding: 64px 24px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-ui-r);
  font-size: 13.5px;
}

/* ── Focus visibility ── */
.btn-review-primary:focus-visible,
.btn-regenerate-review:focus-visible,
.review-reveal:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .review-card-answer,
  .review-reveal .review-reveal-chevron,
  .review-card,
  .btn-review-primary,
  .btn-regenerate-review,
  .review-reveal {
    transition: none;
  }

  .btn-review-spinner {
    animation-duration: 1.2s;
  }
}

/* ── Mobile ── */
@media (max-width: 768px) {
  #panel-repaso .panel-content {
    padding: 24px 16px 56px;
  }

  .review-head {
    gap: 12px;
    margin-bottom: 24px;
    padding-bottom: 18px;
  }

  .review-card-front {
    padding: 18px 18px 16px;
  }

  .review-answer-text {
    margin: 0 18px;
  }

  .review-answer-ref {
    margin: 0 18px;
  }

  .review-empty {
    padding: 48px 16px 60px;
  }

  .btn-review-primary {
    width: 100%;
  }

  .review-actions {
    justify-content: stretch;
  }

  .btn-regenerate-review {
    justify-content: center;
    width: 100%;
  }
}
