:root {
  --bg: #0f1115;
  --surface: #181c23;
  --surface-2: #21262f;
  --border: #2a313c;
  --text: #e6e8eb;
  --text-dim: #9aa3b2;
  --accent: #4f8cff;
  --accent-hover: #6aa0ff;
  --error: #ff6b6b;
  --success: #4ade80;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

h1 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: 600;
}

h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  color: var(--text-dim);
}

.subtitle {
  margin: 0 0 2rem;
  color: var(--text-dim);
}

form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

input[type="url"] {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
}

input[type="url"]:focus {
  border-color: var(--accent);
}

button {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}

button:hover:not(:disabled) {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.error {
  padding: 1rem;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid var(--error);
  border-radius: 8px;
  color: var(--error);
  margin-bottom: 1rem;
}

.output {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.output-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.output-header span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-header button {
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

textarea {
  width: 100%;
  min-height: 400px;
  padding: 1rem;
  background: var(--surface);
  color: var(--text);
  border: none;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.history ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.history li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.history a {
  color: var(--accent);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history a:hover {
  text-decoration: underline;
}

.timestamp {
  color: var(--text-dim);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ============================================================
   Lock modal — full-screen overlay while transcription runs.
   No close button, no cancel, no way out except completion.
   ============================================================ */

.lock-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadein 0.2s ease-out;
}

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

.lock-card {
  width: 100%;
  max-width: 520px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 1.75rem 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(79, 140, 255, 0.06);
  text-align: center;
}

/* Orbit animation visual */
.lock-visual {
  display: flex;
  justify-content: center;
  margin-bottom: 1.25rem;
}

.orbit {
  position: relative;
  width: 96px;
  height: 96px;
}

.orbit-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: orbit-spin 1.6s linear infinite;
}

.orbit-ring.delay-1 {
  inset: 10px;
  border-top-color: rgba(79, 140, 255, 0.5);
  animation-duration: 2.4s;
  animation-direction: reverse;
}

.orbit-ring.delay-2 {
  inset: 20px;
  border-top-color: rgba(79, 140, 255, 0.25);
  animation-duration: 3.2s;
}

.orbit-core {
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
}

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

.lock-title {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lock-sub {
  margin: 0 0 1.25rem;
  color: var(--text-dim);
  font-size: 0.95rem;
  min-height: 1.4em;
}

.lock-video {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin-bottom: 1.25rem;
  text-align: left;
}

.lock-video-title {
  font-size: 0.92rem;
  font-weight: 500;
  margin-bottom: 0.2rem;
  word-break: break-word;
  line-height: 1.35;
}

.lock-video-meta {
  font-size: 0.8rem;
  color: var(--text-dim);
}

.lock-progress {
  position: relative;
  width: 100%;
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.lock-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  border-radius: 3px;
  transition: width 0.25s ease;
}

.lock-progress.indeterminate .lock-progress-fill {
  width: 35% !important;
  animation: indeterminate-slide 1.4s ease-in-out infinite;
}

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

.lock-meter {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.82rem;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  margin-bottom: 1.25rem;
  min-height: 1.2em;
}

.lock-pct {
  color: var(--text);
  font-weight: 500;
}

.lock-stages {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.lock-stages li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0;
  font-size: 0.88rem;
  color: var(--text-dim);
}

.lock-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 0.7rem;
  flex-shrink: 0;
  color: var(--text-dim);
  font-weight: bold;
}

.lock-stages li.active {
  color: var(--text);
}

.lock-stages li.active .lock-check {
  background: var(--accent);
  color: white;
  animation: lock-pulse 1.4s ease-in-out infinite;
}

.lock-stages li.done {
  color: var(--success);
}

.lock-stages li.done .lock-check {
  background: var(--success);
  color: white;
  animation: none;
}

.lock-stage-detail {
  margin-left: auto;
  font-size: 0.78rem;
  opacity: 0.7;
}

@keyframes lock-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(79, 140, 255, 0.5); }
  50%      { box-shadow: 0 0 0 4px rgba(79, 140, 255, 0.0); }
}

.lock-warn {
  padding: 0.7rem 0.9rem;
  background: rgba(255, 196, 0, 0.08);
  border: 1px solid rgba(255, 196, 0, 0.3);
  border-radius: 8px;
  color: #ffc848;
  font-size: 0.78rem;
  line-height: 1.4;
}

/* Error block — slightly nicer with structure */
.error strong { display: block; margin-bottom: 0.3rem; }
.error p { margin: 0; font-size: 0.88rem; opacity: 0.9; }

@media (max-width: 600px) {
  form { flex-direction: column; }
  .container { padding: 2rem 1rem; }
  .lock-card { padding: 1.5rem 1.25rem 1.25rem; }
  .orbit { width: 80px; height: 80px; }
  .orbit-core { inset: 24px; }
}

/* ============================================================
   Unified source input — URL paste OR file drag&drop
   ============================================================ */

.source-zone {
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: var(--surface);
  transition: border-color 0.15s, background 0.15s;
}

.source-zone.dragover {
  border-color: var(--accent);
  border-style: dashed;
  background: rgba(79, 140, 255, 0.06);
}

.source-zone .source-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.source-zone input[type="text"] {
  flex: 1;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  outline: none;
  min-width: 0;
}

.source-zone input[type="text"]:focus {
  border-color: var(--accent);
}

.source-zone input[type="text"]:disabled {
  opacity: 0.5;
}

.source-zone .source-hint {
  margin-top: 0.6rem;
  font-size: 0.8rem;
  color: var(--text-dim);
  text-align: center;
}

.source-zone .source-hint .file-pick {
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.source-zone .file-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  flex: 1;
  min-width: 0;
}

.source-zone .file-pill .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.source-zone .file-pill .file-size {
  color: var(--text-dim);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.source-zone .file-pill .file-remove {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.2rem;
}

.source-zone .file-pill .file-remove:hover {
  color: var(--error);
}

.source-zone input[type="file"] {
  display: none;
}

@media (max-width: 600px) {
  .source-zone .source-row { flex-direction: column; }
}
