:root {
  --bg: #0b0d12;
  --surface: rgba(20, 24, 34, 0.85);
  --surface-strong: #171c28;
  --border: rgba(255, 255, 255, 0.09);
  --border-focus: rgba(255, 79, 100, 0.65);
  --text: #f3f5f9;
  --muted: #98a2b3;
  --accent: #ff4757;
  --accent-2: #ff6b81;
  --success: #22c55e;
  --danger: #f87171;
  --radius: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 71, 87, 0.16), transparent 45%),
    radial-gradient(circle at 85% 15%, rgba(99, 102, 241, 0.14), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(255, 71, 87, 0.08), transparent 50%);
  pointer-events: none;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 64px;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  margin-bottom: 18px;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.8);
}

h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.accent {
  background: linear-gradient(135deg, var(--accent), #ff8a65);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0 auto;
  max-width: 520px;
  color: var(--muted);
  font-size: 15px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px;
  backdrop-filter: blur(18px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.field-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 8px;
}

.inline-label {
  margin-bottom: 0;
  margin-right: 10px;
}

.input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}

.input-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 14px;
  width: 18px;
  height: 18px;
  color: var(--muted);
  pointer-events: none;
}

#url-input {
  width: 100%;
  height: 50px;
  padding: 0 40px 0 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(11, 13, 18, 0.78);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#url-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(255, 71, 87, 0.16);
}

#url-input::placeholder {
  color: #64748b;
}

.icon-btn {
  position: absolute;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text);
}

.secondary-btn {
  height: 50px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.secondary-btn:hover {
  background: rgba(255, 255, 255, 0.11);
  border-color: rgba(255, 255, 255, 0.2);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.quality-group {
  display: flex;
  align-items: center;
}

.pills {
  display: inline-flex;
  background: rgba(11, 13, 18, 0.72);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 4px;
  gap: 4px;
}

.pill {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

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

.pill.active {
  background: rgba(255, 71, 87, 0.18);
  color: #ff808e;
  box-shadow: inset 0 0 0 1px rgba(255, 71, 87, 0.45);
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 46px;
  padding: 0 22px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #e84158);
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 71, 87, 0.32);
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s;
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(255, 71, 87, 0.42);
}

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

.btn-icon {
  width: 18px;
  height: 18px;
}

.error-banner {
  margin-top: 18px;
  padding: 12px 15px;
  border-radius: 12px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  font-size: 14px;
}

.preview-card {
  margin-top: 22px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(11, 13, 18, 0.6);
  border: 1px solid var(--border);
  display: flex;
  gap: 16px;
  align-items: center;
}

.thumb-wrap {
  position: relative;
  width: 148px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  overflow: hidden;
  flex-shrink: 0;
  background: #0f172a;
}

.thumb-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.duration-chip {
  position: absolute;
  right: 6px;
  bottom: 6px;
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 6px;
}

.duration-chip.is-live {
  background: #dc2626;
  letter-spacing: 0.04em;
}

.live-controls {
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 12px;
  background: rgba(220, 38, 38, 0.09);
  border: 1px solid rgba(248, 113, 113, 0.28);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.live-controls-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.live-pill-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #fecaca;
  background: rgba(220, 38, 38, 0.35);
  border: 1px solid rgba(248, 113, 113, 0.4);
  padding: 2px 8px;
  border-radius: 999px;
}

.live-hint {
  font-size: 13px;
  color: #e2e8f0;
}

.live-duration-pills {
  width: fit-content;
  flex-wrap: wrap;
}

.live-pill {
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.live-pill:hover {
  color: var(--text);
}

.live-pill.active {
  background: rgba(255, 71, 87, 0.22);
  color: #ff808e;
  box-shadow: inset 0 0 0 1px rgba(255, 71, 87, 0.45);
}

.preview-meta {
  min-width: 0;
  flex: 1;
}

.preview-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.preview-channel {
  font-size: 13px;
  color: var(--muted);
}

.progress-panel {
  margin-top: 22px;
  padding: 16px;
  border-radius: 14px;
  background: rgba(11, 13, 18, 0.55);
  border: 1px solid var(--border);
}

.progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-size: 13.5px;
}

.progress-status {
  color: #e2e8f0;
  font-weight: 500;
}

.progress-percent {
  color: var(--accent-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

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

.stages {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 12px;
  color: #64748b;
  gap: 8px;
}

.stage.active {
  color: #fff;
  font-weight: 600;
}

.stage.completed {
  color: var(--success);
}

.result-panel {
  margin-top: 22px;
  padding: 18px;
  border-radius: 14px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.result-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.result-ready {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #4ade80;
  margin-bottom: 3px;
}

.result-filename {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.result-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border-radius: 11px;
  background: var(--success);
  color: #052e16;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  transition: filter 0.15s, transform 0.12s;
  flex-shrink: 0;
}

.download-btn:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.audio-player {
  width: 100%;
  margin-top: 14px;
  height: 40px;
  border-radius: 10px;
}

.history-section {
  margin-top: 32px;
}

.section-title {
  font-size: 14px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0 0 12px 4px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 13px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.history-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.history-thumb {
  width: 56px;
  height: 36px;
  border-radius: 7px;
  object-fit: cover;
  flex-shrink: 0;
}

.history-info {
  min-width: 0;
}

.history-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-sub {
  font-size: 12px;
  color: var(--muted);
}

.history-dl {
  padding: 8px 13px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s;
}

.history-dl:hover {
  background: rgba(255, 255, 255, 0.16);
}

.footer {
  margin-top: 36px;
  text-align: center;
  font-size: 12.5px;
  color: #64748b;
}

.footer code {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 6px;
}

.hidden {
  display: none !important;
}

@media (max-width: 560px) {
  .preview-card {
    flex-direction: column;
    align-items: stretch;
  }
  .thumb-wrap {
    width: 100%;
  }
  .controls-row {
    flex-direction: column;
    align-items: stretch;
  }
  .quality-group {
    justify-content: space-between;
  }
  .primary-btn {
    width: 100%;
  }
}
