:root {
  color-scheme: dark;
  --ink: #f7f3ff;
  --muted: #aaa3b7;
  --faint: #6f687b;
  --surface: #17141d;
  --surface-2: #211d29;
  --line: rgba(255, 255, 255, 0.09);
  --violet: #a87cff;
  --violet-2: #7847df;
  --coral: #ff6b62;
  --green: #64d8a2;
  --amber: #ffca67;
  --danger: #ff7c8e;
  --radius: 22px;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { overflow-x: hidden; background: #0d0b11; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 76% -10%, rgba(120, 71, 223, 0.22), transparent 36rem),
    radial-gradient(circle at 8% 30%, rgba(255, 107, 98, 0.09), transparent 28rem),
    #0d0b11;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.55; }
code { color: #d7c6ff; }
img { display: block; max-width: 100%; }
.main-column, .side-column, .panel, .result-copy { min-width: 0; }

.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;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 13px clamp(20px, 4vw, 64px);
  background: rgba(13, 11, 17, 0.82);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(18px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  color: white;
  font-family: Georgia, serif;
  font-size: 28px;
  background: linear-gradient(145deg, var(--violet), var(--violet-2));
  border-radius: 15px;
  box-shadow: 0 12px 32px rgba(120, 71, 223, 0.34);
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -0.02em; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.status-badge {
  padding: 8px 11px;
  color: var(--muted);
  font-size: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.status-badge::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 7px; background: var(--green); border-radius: 50%; }
.ghost-button, .text-button, .icon-button {
  color: var(--muted);
  background: transparent;
  border: 0;
}
.ghost-button { padding: 9px 12px; }
.ghost-button:hover, .text-button:hover { color: var(--ink); }
.icon-button { display: grid; place-items: center; width: 36px; height: 36px; font-size: 20px; border: 1px solid var(--line); border-radius: 50%; }

.page-shell { width: min(1440px, 100%); margin: 0 auto; padding: clamp(26px, 4vw, 58px) clamp(18px, 4vw, 64px) 72px; }
.hero-panel {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 36px;
  margin-bottom: 36px;
}
.eyebrow, .step-label {
  margin: 0 0 10px;
  color: var(--violet);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
h1, h2, p { margin-top: 0; }
h1 { max-width: 850px; margin-bottom: 18px; font-size: clamp(39px, 6vw, 76px); line-height: 0.98; letter-spacing: -0.06em; }
h1 span { color: var(--muted); }
.hero-copy { max-width: 660px; margin-bottom: 0; color: var(--muted); font-size: clamp(15px, 1.5vw, 18px); line-height: 1.65; }
.hero-note {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 150px;
  padding: 14px 18px;
  border-left: 1px solid var(--line);
}
.hero-note span { font-size: 36px; font-weight: 800; letter-spacing: -0.05em; }
.hero-note small { color: var(--muted); font-size: 11px; line-height: 1.25; text-transform: uppercase; }

.workspace-grid { display: grid; grid-template-columns: minmax(0, 1fr) 370px; gap: 24px; align-items: start; }
.main-column { display: grid; gap: 24px; }
.side-column { position: sticky; top: 102px; display: grid; gap: 16px; }
.panel {
  padding: clamp(20px, 3vw, 34px);
  background: linear-gradient(155deg, rgba(33, 29, 41, 0.98), rgba(22, 19, 28, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
.section-heading.compact { align-items: center; }
.section-heading h2 { margin: 0; font-size: 25px; letter-spacing: -0.035em; }
.queue-actions { display: flex; align-items: center; gap: 9px; }
.danger-text-button {
  min-height: 36px;
  padding: 6px 8px;
  color: var(--danger);
  font-size: 11px;
  background: transparent;
  border: 0;
}
.danger-text-button:hover { color: #ffb0ba; }
.search-form { display: grid; grid-template-columns: 1fr auto; gap: 12px; }
input, select {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  color: var(--ink);
  background: #100e14;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: none;
}
input:focus, select:focus { border-color: var(--violet); box-shadow: 0 0 0 3px rgba(168, 124, 255, 0.12); }
input::placeholder { color: var(--faint); }
.search-form input { min-height: 58px; padding-inline: 18px; font-size: 17px; }
.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  min-height: 50px;
  padding: 0 21px;
  color: white;
  font-weight: 750;
  background: linear-gradient(135deg, var(--violet-2), #9464f4);
  border: 0;
  border-radius: 13px;
  box-shadow: 0 12px 28px rgba(120, 71, 223, 0.26);
  transition: transform 130ms ease, filter 130ms ease;
}
.primary-button:hover { filter: brightness(1.1); transform: translateY(-1px); }
.primary-button:active { transform: translateY(1px); }
.inline-message { min-height: 22px; margin: 15px 0 0; color: var(--muted); font-size: 13px; }

.result-list { display: grid; gap: 10px; margin-top: 4px; }
.result-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: rgba(10, 9, 13, 0.45);
  border: 1px solid var(--line);
  border-radius: 16px;
  transition: border-color 140ms ease, background 140ms ease;
}
.result-card:hover { background: rgba(255, 255, 255, 0.025); border-color: rgba(168, 124, 255, 0.34); }
.result-thumb { position: relative; display: grid; place-items: center; overflow: hidden; aspect-ratio: 16 / 9; background: #08070a; border-radius: 10px; }
.result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.fallback-note { color: var(--violet); font-family: Georgia, serif; font-size: 25px; }
.duration { position: absolute; right: 5px; bottom: 5px; padding: 3px 6px; font-size: 10px; background: rgba(0, 0, 0, 0.85); border-radius: 5px; }
.selected-audio-mark {
  display: grid;
  place-items: center;
  color: var(--violet);
  background: rgba(120, 71, 223, 0.14);
  border: 1px solid rgba(168, 124, 255, 0.22);
  border-radius: 13px;
}
.result-copy { min-width: 0; }
.result-copy strong, .result-copy span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-copy strong { margin-bottom: 6px; font-size: 15px; }
.result-copy span { color: var(--muted); font-size: 12px; }
.result-actions { display: flex; gap: 8px; }
.select-source, .preview-source { padding: 10px 13px; color: var(--ink); background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; }
.preview-source { color: #d7c6ff; background: rgba(120, 71, 223, 0.1); }
.select-source:hover, .preview-source:hover { border-color: var(--violet); }
.preview-panel { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 48%); align-items: center; gap: 18px; margin-top: 18px; padding: 16px; background: rgba(120, 71, 223, 0.1); border: 1px solid rgba(168, 124, 255, 0.25); border-radius: 16px; }
.preview-panel[hidden] { display: none; }
.preview-panel p { margin-bottom: 5px; }
.preview-panel strong { display: block; overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.preview-panel iframe { width: 100%; aspect-ratio: 16 / 9; background: #08070a; border: 0; border-radius: 10px; }

.selected-source { display: grid; grid-template-columns: 150px 1fr; align-items: center; gap: 18px; margin-bottom: 28px; padding: 14px; background: rgba(10, 9, 13, 0.45); border-radius: 16px; }
.selected-source img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; }
.selected-audio-mark { width: 72px; height: 64px; font-family: Georgia, serif; font-size: 30px; }
.selected-source strong { display: block; margin: 8px 0 6px; }
.selected-source span { color: var(--muted); font-size: 13px; }
.import-form { display: grid; gap: 24px; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.field-grid label, .import-form legend { color: var(--muted); font-size: 12px; font-weight: 650; }
.field-grid input, .field-grid select { margin-top: 8px; color: var(--ink); }
.field-grid label:first-child, .field-grid label:nth-child(2) { grid-column: span 1; }
.compact-grid { align-items: end; }
.single-field { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.compact-grid small { color: var(--faint); font-weight: 500; }
fieldset { padding: 0; border: 0; }
legend { margin-bottom: 10px; }
.choice-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.choice-card { position: relative; display: block; }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card span { display: block; padding: 16px; background: #100e14; border: 1px solid var(--line); border-radius: 14px; }
.choice-card strong, .choice-card small { display: block; }
.choice-card strong { color: var(--ink); }
.choice-card small { margin-top: 5px; color: var(--muted); }
.choice-card input:checked + span { border-color: var(--violet); background: rgba(120, 71, 223, 0.13); box-shadow: inset 0 0 0 1px rgba(168, 124, 255, 0.2); }
.rights-check { display: flex; align-items: flex-start; gap: 10px; color: var(--muted); font-size: 13px; line-height: 1.45; }
.rights-check input { width: 18px; min-height: 18px; margin: 1px 0 0; accent-color: var(--violet); }
.submit-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding-top: 19px; border-top: 1px solid var(--line); }
.submit-row p { margin: 0; color: var(--muted); font-size: 12px; }
.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.queue-panel { padding: 24px; }
.job-list { display: grid; gap: 12px; max-height: 620px; overflow: auto; padding-right: 2px; }
.empty-state { margin: 20px 0; color: var(--faint); text-align: center; font-size: 13px; }
.job-card { padding: 15px; background: rgba(10, 9, 13, 0.45); border: 1px solid var(--line); border-radius: 15px; }
.job-head { display: flex; justify-content: space-between; gap: 10px; }
.job-head strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.job-state { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.job-state.done { color: var(--green); }
.job-state.error, .job-state.cancelled { color: var(--danger); }
.job-card p { margin: 9px 0 11px; color: var(--muted); font-size: 11px; line-height: 1.45; }
.progress-track { overflow: hidden; height: 5px; background: rgba(255, 255, 255, 0.07); border-radius: 9px; }
.progress-value { height: 100%; background: linear-gradient(90deg, var(--violet-2), var(--coral)); border-radius: inherit; transition: width 300ms ease; }
.job-foot { display: flex; justify-content: space-between; margin-top: 9px; color: var(--faint); font-size: 10px; }
.cancel-job { padding: 0; color: var(--danger); font-size: 10px; background: transparent; border: 0; }
.safety-card { display: flex; align-items: flex-start; gap: 13px; padding: 18px; background: rgba(100, 216, 162, 0.07); border: 1px solid rgba(100, 216, 162, 0.18); border-radius: 17px; }
.youtube-access-card { display: grid; gap: 12px; padding: 18px; background: rgba(255, 202, 103, 0.07); border: 1px solid rgba(255, 202, 103, 0.24); border-radius: 17px; }
.youtube-access-card.ready { background: rgba(100, 216, 162, 0.07); border-color: rgba(100, 216, 162, 0.2); }
.youtube-access-card strong { font-size: 14px; }
.youtube-access-card > p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.youtube-access-card form { display: grid; gap: 10px; }
.cookie-file { color: var(--muted); font-size: 11px; }
.cookie-file input { min-height: 42px; margin-top: 7px; padding: 8px; font-size: 11px; }
.youtube-access-card .primary-button { min-height: 42px; font-size: 12px; }
.youtube-access-card .text-button { justify-self: start; padding: 0; font-size: 11px; }
.safety-icon { display: grid; place-items: center; width: 28px; height: 28px; flex: 0 0 auto; color: var(--green); background: rgba(100, 216, 162, 0.11); border-radius: 50%; }
.safety-card strong { font-size: 13px; }
.safety-card p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: 360px; padding: 13px 16px; color: var(--ink); background: #292332; border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }

.login-body { display: grid; place-items: center; padding: 20px; }
.login-shell { width: min(100%, 430px); }
.login-card { padding: 38px; background: linear-gradient(155deg, var(--surface-2), var(--surface)); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--shadow); }
.login-card .brand-mark { margin-bottom: 24px; }
.login-card h1 { margin-bottom: 12px; font-size: 38px; line-height: 1.05; letter-spacing: -0.045em; }
.muted { color: var(--muted); line-height: 1.55; }
.stack-form { display: grid; gap: 12px; margin-top: 28px; }
.stack-form label { color: var(--muted); font-size: 12px; font-weight: 650; }
.stack-form input { min-height: 54px; }
.stack-form .primary-button { margin-top: 4px; }

@media (max-width: 1180px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; }
  .page-shell { padding-inline: clamp(18px, 3vw, 38px); }
}

@media (max-width: 980px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .side-column {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .queue-panel { grid-column: 1 / -1; }
  .job-list { max-height: 430px; }
  .hero-panel { margin-bottom: 28px; }
  h1 { font-size: clamp(42px, 8vw, 66px); }
}

@media (max-width: 700px) {
  .topbar { min-height: 66px; padding: 9px 14px; }
  .brand { gap: 9px; }
  .brand-mark { width: 42px; height: 42px; border-radius: 13px; }
  .brand strong { font-size: 14px; }
  .status-badge { display: none; }
  .ghost-button { min-height: 44px; padding-inline: 7px; font-size: 12px; }

  .page-shell { padding: 24px 13px 54px; }
  .hero-panel { align-items: flex-start; margin-bottom: 22px; }
  .hero-note { display: none; }
  h1 { margin-bottom: 13px; font-size: clamp(34px, 10.5vw, 48px); line-height: 1.01; }
  .hero-copy { font-size: 14px; line-height: 1.55; }

  .main-column { gap: 16px; }
  .panel { padding: 19px 15px; border-radius: 17px; }
  .section-heading { flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .section-heading h2 { font-size: 22px; }
  .text-button { min-height: 38px; padding: 6px 0; }

  .search-form { grid-template-columns: 1fr; }
  .search-form input { min-height: 54px; font-size: 16px; }
  .search-form .primary-button { width: 100%; }

  .result-card { grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 10px; }
  .result-copy strong { line-height: 1.35; white-space: normal; }
  .result-actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(2, 1fr); }
  .result-actions button { min-height: 44px; }

  .preview-panel { grid-template-columns: 1fr; padding: 12px; }
  .preview-panel strong { white-space: normal; }
  .selected-source { grid-template-columns: 104px minmax(0, 1fr); gap: 13px; margin-bottom: 20px; padding: 11px; }
  .selected-source strong { overflow-wrap: anywhere; }

  .field-grid, .choice-row, .single-field, .side-column { grid-template-columns: 1fr; }
  .field-grid { gap: 13px; }
  input, select { min-height: 50px; font-size: 16px; }
  input[type="file"] { max-width: 100%; min-height: 48px; overflow: hidden; }
  .choice-card span { padding: 15px; }
  .rights-check input { min-height: 20px; }
  .submit-row { align-items: stretch; flex-direction: column; }
  .submit-row .primary-button { width: 100%; }

  .side-column { gap: 13px; }
  .queue-panel { padding: 18px 15px; }
  .queue-actions { margin-left: auto; }
  .job-list { max-height: none; }
  .job-card p { overflow-wrap: anywhere; }
  .youtube-access-card .primary-button { width: 100%; }

  .toast { right: 13px; bottom: 13px; left: 13px; max-width: none; }
  .login-card { padding: 29px 24px; }
}

@media (max-width: 430px) {
  .brand small { display: none; }
  .brand-mark { width: 40px; height: 40px; }
  .top-actions { gap: 2px; }
  .page-shell { padding-inline: 10px; }
  .eyebrow { margin-bottom: 8px; }
  h1 { font-size: clamp(32px, 10vw, 40px); letter-spacing: -0.045em; }
  .panel { padding-inline: 13px; }
  .queue-panel .section-heading { align-items: center; flex-wrap: nowrap; }
  .danger-text-button { max-width: 86px; line-height: 1.2; }
  .result-card { grid-template-columns: 80px minmax(0, 1fr); gap: 10px; }
  .result-copy strong { font-size: 14px; }
  .selected-source { grid-template-columns: 88px minmax(0, 1fr); }
  .submit-row p { line-height: 1.45; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
