*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #22263a;
  --border: #2e3350;
  --accent: #6c7bff;
  --accent-glow: rgba(108, 123, 255, 0.25);
  --text: #e8eaf6;
  --text-muted: #7b82a8;
  --highlight-bg: #2a2f52;
  --highlight-text: #a5b0ff;
  --success: #4caf8a;
  --radius: 12px;
  --radius-sm: 8px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 40px 24px 48px;
}

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

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.header-logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 8px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ── Projects panel ── */
.projects-panel {
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.projects-header {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.projects-header:hover { background: var(--surface2); }

.projects-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.projects-count {
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 100px;
  padding: 1px 8px;
}

.projects-chevron {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.projects-header[aria-expanded="true"] .projects-chevron {
  transform: rotate(180deg);
}

.projects-list {
  border-top: 1px solid var(--border);
  max-height: 280px;
  overflow-y: auto;
}

.project-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.project-row:last-child { border-bottom: none; }
.project-row:hover { background: var(--surface2); }

.project-del-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.project-row:hover .project-del-btn {
  opacity: 1;
}

.project-del-btn:hover {
  color: #f87171;
}

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

.project-name {
  display: block;
  font-size: 0.88rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-date {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.project-sources {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 100px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.source-badge.whisper_local     { background: rgba(108,123,255,0.2); color: var(--accent); }
.source-badge.openai_whisper    { background: rgba(25,195,125,0.2);  color: #19c37d; }
.source-badge.elevenlabs_scribe { background: rgba(249,115,22,0.2);  color: #f97316; }
.source-badge.aligned           { background: rgba(34,211,238,0.2);  color: #22d3ee; }
.source-badge.user              { background: rgba(167,139,250,0.2); color: #a78bfa; }

.projects-list::-webkit-scrollbar { width: 4px; }
.projects-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Save status */
.save-status {
  font-size: 0.82rem;
  color: var(--success);
  font-weight: 600;
}

/* ── Step panels ── */
.step-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px 24px;
  margin-bottom: 16px;
}

.step-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
  margin-bottom: 18px;
}

.raw-transcription {
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 12px 14px;
  max-height: 160px;
  overflow-y: auto;
  font-family: "SF Mono", "Fira Mono", monospace;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

.raw-transcription::-webkit-scrollbar { width: 4px; }
.raw-transcription::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Input panel ── */
.input-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 640px) {
  .input-row { grid-template-columns: 1fr; }
  header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .step1-options { flex-wrap: wrap; }
  .step1-btn { width: 100%; }
}

/* Step 1 options row */
.step1-options {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.step1-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}

.step1-field--btn {
  flex: 0 0 auto;
}

.step1-field--btn .btn-primary {
  width: 100%;
  padding: 0 28px;
  font-size: 0.88rem;
  white-space: nowrap;
  height: 35px;   /* matches select: 0.88rem line-height + 2×7px padding + 2px border */
  line-height: 35px;
  box-sizing: border-box;
}

.lang-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.lang-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  padding: 0 10px;
  height: 35px;
  box-sizing: border-box;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.lang-select:focus {
  border-color: var(--accent);
}

.lang-select option {
  background: var(--surface2);
  color: var(--text);
}


/* Action row */
.action-row {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
}

.btn-secondary-large {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary-large:hover:not(:disabled) {
  background: var(--accent-glow);
}

.btn-secondary-large:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-openai {
  background: transparent;
  color: #19c37d;
  border: 2px solid #19c37d;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-openai:hover:not(:disabled) {
  background: rgba(25, 195, 125, 0.15);
}

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

.btn-eleven {
  background: transparent;
  color: #f97316;
  border: 2px solid #f97316;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-eleven:hover:not(:disabled) {
  background: rgba(249, 115, 22, 0.15);
}

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

/* Drop zone */
.drop-zone {
  background: var(--surface2);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 20px 24px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
  margin-bottom: 12px;
}

.drop-zone:hover,
.drop-zone.drag-over {
  border-color: var(--accent);
  background: rgba(108, 99, 255, 0.06);
}

.drop-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}

.drop-text {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.drop-text span {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.file-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--success);
  font-weight: 500;
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-status::before {
  content: "✓";
  font-weight: 700;
  flex-shrink: 0;
}

/* Lyrics textarea */
.lyrics-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lyrics-box label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.hint {
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.8rem;
}

.lyrics-box textarea {
  flex: 1;
  min-height: 200px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: "SF Mono", "Fira Mono", monospace;
  font-size: 0.85rem;
  line-height: 1.7;
  padding: 14px 16px;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.lyrics-box textarea:focus {
  border-color: var(--accent);
}

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 32px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5em;
  transition: opacity 0.15s, box-shadow 0.15s;
  box-shadow: 0 0 0 0 var(--accent-glow);
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 16px 4px var(--accent-glow);
}

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

.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-secondary:hover {
  background: var(--accent-glow);
}

.btn-icon {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px;
  height: 42px;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
}

.btn-icon:hover { opacity: 0.85; }

/* Progress bar */
.progress-bar {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-track {
  background: var(--surface);
  border-radius: 100px;
  height: 6px;
  overflow: hidden;
}

.progress-bar .progress-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 100px;
  animation: indeterminate 1.4s ease-in-out infinite;
  width: 40%;
}

/* Determinate mode — real or estimated % */
.progress-fill.determinate {
  animation: none;
  width: 0%;
  transition: width 0.35s ease;
}

@keyframes indeterminate {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Result panel */
.result-panel {
  margin-top: 36px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.video-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  max-height: 0;
  transition: max-height 0.35s ease, margin-bottom 0.35s ease;
}
.video-wrapper.has-video {
  aspect-ratio: 16 / 9;
  max-height: 9999px; /* let aspect-ratio drive height */
  margin-bottom: 12px;
}
.video-wrapper.has-video.portrait {
  aspect-ratio: 9 / 16;
  max-width: 320px;
  margin-left: auto;
  margin-right: auto;
}
.video-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(18px) brightness(0.45);
  transform: scale(1.05); /* hides blur edge fringe */
  pointer-events: none;
  z-index: 0;
}
#audioEl {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  z-index: 1;
}
.video-wrapper.has-video.portrait #audioEl {
  object-fit: cover;
}
.cover-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  z-index: 1;
}
.video-wrapper.has-video.portrait .cover-img {
  object-fit: cover;
}
.caption-overlay {
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  text-align: center;
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  text-shadow: 0 1px 6px rgba(0,0,0,0.85);
  padding: 4px 13%;
  pointer-events: none;
  z-index: 2;
  min-height: 1.4em;
}
.caption-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 0 4px;
}
/* ── Custom font picker ── */
.font-picker-wrap {
  position: relative;
  height: 38px;
  display: flex;
  align-items: center;
}
.font-picker-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 10px;
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s;
  min-width: 120px;
}
.font-picker-btn:hover,
.font-picker-btn.open { border-color: var(--accent); }
.font-picker-btn svg { flex-shrink: 0; color: var(--text-muted); transition: transform 0.15s; }
.font-picker-btn.open svg { transform: rotate(180deg); }

.font-picker-dropdown {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  min-width: 180px;
  max-height: 340px;
  overflow-y: auto;
}
.font-group-label {
  padding: 6px 12px 2px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.5;
}
.font-group-label:not(:first-child) {
  margin-top: 4px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.font-picker-option {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 15px;
  color: var(--text);
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
  line-height: 1.2;
}
.font-picker-option:hover { background: var(--surface2); }
.font-picker-option.active {
  background: rgba(99,102,241,0.15);
  color: var(--accent);
}
.font-size-btn {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 14px;
  height: 38px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1;
}
.font-size-btn:hover {
  border-color: var(--accent);
}
/* ── Color swatch button + popover ── */
.color-swatch-wrap {
  position: relative;
  height: 38px;
  display: flex;
  align-items: center;
}

.color-swatch-btn {
  width: 38px;
  height: 38px;
  border: 2px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  display: block;
  flex-shrink: 0;
  transition: border-color 0.15s;
}
.color-swatch-btn:hover { border-color: var(--accent); }

.color-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 164px;
}

.color-presets {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.color-preset {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s, border-color 0.1s;
}
.color-preset:hover { transform: scale(1.2); }
.color-preset.active { border-color: var(--accent); }

.color-custom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}

.caption-color-picker {
  width: 28px;
  height: 24px;
  padding: 1px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface2);
  cursor: pointer;
}
.caption-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.caption-color-picker::-webkit-color-swatch { border: none; border-radius: 2px; }


.player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.seek-bar {
  flex: 1;
  height: 6px;
  background: var(--surface2);
  border-radius: 100px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.seek-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  border-radius: 100px;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
}

.time-display {
  font-family: "SF Mono", "Fira Mono", monospace;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.time-sep { color: var(--border); }

/* Lyrics box in the result panel (post-transcription) */
.lyrics-box--post {
  margin-top: 20px;
}
.lyrics-box--post textarea {
  min-height: 120px;
}

.align-action-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.align-status {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Spinner on Polish / Retime buttons while aligning */
.btn-primary.aligning,
.btn-secondary.aligning {
  opacity: 0.75;
  cursor: not-allowed;
  pointer-events: none;
}
.btn-primary.aligning::before,
.btn-secondary.aligning::before {
  content: '';
  display: inline-block;
  width: 0.85em;
  height: 0.85em;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.5em;
  vertical-align: middle;
}

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

.lyrics-result-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* Edit mode line layout */
.edit-mode .lyric-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
}

.stamp-btn {
  flex-shrink: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  cursor: pointer;
  padding: 3px 8px;
  font-size: 0.78rem;
  font-weight: 600;
  transition: background 0.15s;
}

.stamp-btn:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.del-btn,
.add-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 3px 7px;
  font-size: 1rem;
  line-height: 1;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  margin-left: 2px;
}

.del-btn:hover {
  color: #f87171;
  border-color: #f87171;
  background: rgba(248, 113, 113, 0.1);
}

.add-btn:hover {
  color: var(--success);
  border-color: var(--success);
  background: rgba(76, 175, 138, 0.1);
}

.time-input {
  flex-shrink: 0;
  width: 66px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: "SF Mono", "Fira Mono", monospace;
  font-size: 0.78rem;
  padding: 3px 6px;
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
}

.time-input:focus {
  border-color: var(--accent);
  color: var(--text);
}

.end-input {
  color: #5a6080;
}

.end-input:focus {
  color: var(--text);
}

.time-sep-arrow {
  flex-shrink: 0;
  font-size: 0.7rem;
  color: var(--border);
  padding: 0 1px;
  user-select: none;
}

.line-text {
  flex: 1;
  outline: none;
  border-bottom: 1px solid transparent;
  padding-bottom: 1px;
  transition: border-color 0.15s;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.line-text:focus {
  border-bottom-color: var(--accent);
}

.edit-mode .lyric-line.active .line-text {
  color: var(--highlight-text);
}

.edit-mode .lyric-line.past .line-text {
  color: #454970;
}

/* Lyrics display */
.lyrics-display {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scroll-behavior: smooth;
}

.lyric-line {
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
  cursor: default;
}

.lyric-line.active {
  background: var(--highlight-bg);
  color: var(--highlight-text);
  font-weight: 600;
}

.lyric-line.past {
  color: #454970;
}

/* Scrollbar */
.lyrics-display::-webkit-scrollbar { width: 6px; }
.lyrics-display::-webkit-scrollbar-track { background: transparent; }
.lyrics-display::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── Auth modal ── */
.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  padding: 24px;
}

.auth-box {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 40px 32px;
  max-width: 400px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.auth-box h2 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

.auth-sub {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
}

#authStep1,
#authStep2 {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-box input[type="email"],
.auth-box input[type="text"] {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 1rem;
  padding: 11px 14px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

.auth-box input:focus {
  border-color: var(--accent);
}

.auth-box input[type="text"] {
  letter-spacing: 0.2em;
  font-family: "SF Mono", "Fira Mono", monospace;
  text-align: center;
  font-size: 1.3rem;
}

.auth-box .btn-primary {
  width: 100%;
  padding: 12px;
}

.auth-email-label {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
}

.auth-error {
  font-size: 0.84rem;
  color: #f87171;
  text-align: center;
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s;
}

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

/* ── Confirm dialog ── */
.confirm-box {
  max-width: 340px;
  gap: 20px;
}

.confirm-msg {
  font-size: 0.95rem;
  color: var(--text);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── New transcription button ── */
.btn-new {
  display: block;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: 100px;
  padding: 5px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

.btn-new:hover {
  background: var(--accent-glow);
}

/* ── Sign-in bar (guest state) ── */
.sign-in-bar { }

/* ── User bar ── */
.user-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  white-space: nowrap;
}

.user-email {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Link button ── */
.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  transition: opacity 0.15s;
}

.btn-link:hover { opacity: 0.75; }

/* ── Admin shell layout ────────────────────────────────────────────────────── */
.admin-body {
  height: 100%;
  overflow: hidden;
}

.admin-shell {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 28px 0 24px;
}

.admin-sidebar-top {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.admin-logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.01em;
  padding: 0 20px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.admin-nav-link:hover {
  color: var(--text);
  background: var(--surface2);
}

.admin-nav-link.active {
  color: var(--accent);
  background: var(--highlight-bg);
  border-left-color: var(--accent);
}

.admin-nav-icon {
  font-size: 1rem;
  line-height: 1;
  opacity: 0.8;
}

.admin-sidebar-bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0 20px;
}

.admin-sidebar-email {
  font-size: 0.78rem;
  color: var(--text-muted);
  word-break: break-all;
}

/* Main content area */
.admin-main {
  flex: 1;
  overflow-y: auto;
  padding: 36px 40px 60px;
}

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.admin-page-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
}

/* Access denied */
.admin-denied {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100vh;
  gap: 16px;
  color: #f87171;
  font-size: 1rem;
}

/* Loading */
.admin-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: var(--text-muted);
}

/* Responsive: collapse sidebar on small screens */
@media (max-width: 600px) {
  .admin-sidebar {
    width: 60px;
  }
  .admin-logo,
  .admin-nav-link span:not(.admin-nav-icon),
  .admin-sidebar-bottom { display: none; }
  .admin-nav-link { justify-content: center; padding: 12px; }
  .admin-main { padding: 24px 16px 40px; }
}

/* ── Admin render rows ─────────────────────────────────────────────────────── */
.admin-render-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.admin-render-row:last-child { border-bottom: none; }

.admin-render-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.admin-render-file {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}

.admin-render-user {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.admin-render-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-render-settings,
.admin-render-duration,
.admin-render-id {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.admin-render-duration { font-variant-numeric: tabular-nums; }

.admin-render-error {
  font-size: 0.75rem;
  color: #f87171;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-kill {
  margin-left: auto;
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
}

.btn-download-render {
  padding: 3px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.admin-user-row:last-child { border-bottom: none; }

.admin-user-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.admin-user-email {
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-user-email.blocked {
  color: var(--text-muted);
  text-decoration: line-through;
}

.admin-user-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.admin-user-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.token-balance-badge {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 3px 10px;
  white-space: nowrap;
}

/* Grant tokens modal */
.grant-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 380px;
  width: 100%;
}

.grant-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.grant-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.grant-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  padding: 9px 12px;
  font-family: inherit;
}
.grant-input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-danger {
  background: transparent;
  color: #f87171;
  border: 2px solid #f87171;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.15);
}

.badge-blocked {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  border-radius: 100px;
  padding: 3px 10px;
}

/* ── Render button busy state ───────────────────────────────── */
.btn-primary.rendering {
  opacity: 0.75;
  cursor: not-allowed;
}
.btn-primary.rendering::before {
  content: '';
  display: inline-block;
  width: 0.8em;
  height: 0.8em;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

/* ── Renders panel ──────────────────────────────────────────── */
.renders-panel {
  margin-top: 28px;
  border-top: 1px solid var(--border);
  padding-top: 18px;
}
.renders-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 12px;
}
.renders-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.render-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
}
.render-item .render-date {
  color: var(--text-muted);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.render-ratio {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: var(--surface1);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
  white-space: nowrap;
}
.render-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.render-badge.pending,
.render-badge.processing {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
}
.render-badge.processing::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.render-badge.done {
  background: rgba(52, 211, 153, 0.15);
  color: #34d399;
}
.render-badge.error {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}
.render-error-msg {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.render-download {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.render-download:hover { text-decoration: underline; }

.render-delete {
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
  font-size: 14px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  margin-left: 2px;
}
.render-delete:hover {
  color: #e05555;
  background: rgba(224, 85, 85, 0.1);
}

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

/* ── Feedback bubble + modal ────────────────────────────────────────────────── */
.feedback-bubble {
  position: fixed;
  bottom: 48px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  transition: background 0.15s, color 0.15s, transform 0.15s;
  z-index: 50;
}
.feedback-bubble:hover {
  background: var(--accent);
  color: #fff;
  transform: scale(1.07);
}

.feedback-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 420px;
  width: 100%;
}

.feedback-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.55;
  padding: 12px 14px;
  resize: vertical;
  font-family: inherit;
  transition: border-color 0.15s;
}
.feedback-textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.feedback-textarea::placeholder { color: var(--text-muted); }

.feedback-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.feedback-actions .btn-primary { flex: 1; }
.feedback-actions .btn-secondary { flex: 1; }

/* ── Beta badge ─────────────────────────────────────────────────────────────── */
.beta-badge {
  display: inline-block;
  font-size: 0.38em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--accent-glow);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 5px;
  padding: 2px 6px;
  vertical-align: middle;
  margin-left: 6px;
  position: relative;
  top: -0.2em;
}

/* ── SRT import ─────────────────────────────────────────────────────────────── */
.srt-import-row {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.srt-toggle-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 4px 0;
  transition: color 0.15s;
}
.srt-toggle-btn:hover { color: var(--accent); }

.srt-toggle-icon {
  font-size: 1rem;
  line-height: 1;
  color: var(--accent);
}

.srt-import-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.srt-drop-zone {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.srt-drop-zone:hover,
.srt-drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-glow);
  color: var(--text);
}
.srt-drop-zone.has-file {
  border-color: var(--success);
  background: rgba(76, 175, 138, 0.08);
}

.srt-drop-icon { font-size: 1.2rem; }

.srt-drop-text span {
  color: var(--accent);
  text-decoration: underline;
  cursor: pointer;
}

.srt-file-status {
  font-size: 0.82rem;
  color: var(--success);
  padding-left: 4px;
}

/* .app-footer removed — replaced by <site-footer> web component */
