:root {
  color-scheme: dark;
  --bg: #080a0f;
  --panel: #10131b;
  --panel-raised: #171b25;
  --line: #2a303e;
  --text: #f6f7f9;
  --muted: #929bab;
  --acid: #b7ff5a;
  --acid-ink: #132000;
  --blue: #7397ff;
  --danger: #ff7676;
  --warning: #ffce73;
  --radius: 18px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

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

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -15%, rgba(115, 151, 255, 0.15), transparent 35rem),
    var(--bg);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(183, 255, 90, 0.5);
  outline-offset: 3px;
}

.shell {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 80px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  text-decoration: none;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 10px;
  background: var(--acid);
  color: var(--acid-ink);
}

.brand-mark svg {
  width: 17px;
  height: 17px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.retention-badge {
  color: var(--muted);
  font-size: 0.875rem;
}

.logout-form {
  margin: 0;
}

.link-button {
  padding: 0;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

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

.workspace {
  padding: 68px 0 80px;
}

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 56px;
  align-items: end;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
  color: var(--acid);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.eyebrow::before {
  width: 24px;
  height: 2px;
  background: currentColor;
  content: "";
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 760px;
  margin-bottom: 0;
  font-size: clamp(2.5rem, 7vw, 5.8rem);
  line-height: 0.94;
  letter-spacing: -0.065em;
}

.intro-copy {
  max-width: 390px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.download-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-top: 44px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(16, 19, 27, 0.84);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
}

.download-form input {
  width: 100%;
  min-width: 0;
  height: 58px;
  padding: 0 18px;
  border: 0;
  color: var(--text);
  background: transparent;
  font-size: 1rem;
}

.download-form input::placeholder {
  color: #687181;
}

.download-form input:focus-visible {
  outline-offset: -2px;
}

.primary-button,
.secondary-button,
.ghost-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border-radius: 12px;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.primary-button {
  min-width: 190px;
  padding: 0 22px;
  border: 1px solid var(--acid);
  color: var(--acid-ink);
  background: var(--acid);
  font-weight: 760;
}

.primary-button:hover {
  transform: translateY(-1px);
  background: #c7ff80;
}

.primary-button:disabled {
  opacity: 0.55;
  cursor: wait;
  transform: none;
}

.queue-section {
  margin-top: 76px;
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
  letter-spacing: -0.025em;
}

.section-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.jobs {
  display: grid;
  gap: 14px;
}

.empty-state {
  display: grid;
  min-height: 220px;
  place-items: center;
  padding: 40px;
  border: 1px dashed #343b4a;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1rem;
}

.job-card {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  min-height: 104px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.job-icon {
  position: relative;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  overflow: hidden;
  border-radius: 15px;
  color: var(--blue);
  background: #1b2130;
}

.job-icon::after {
  position: absolute;
  right: -14px;
  bottom: -14px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: currentColor;
  content: "";
  opacity: 0.35;
}

.job-icon svg {
  width: 22px;
  height: 22px;
}

.job-title {
  margin: 0 0 7px;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 680;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px 14px;
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.status-ready {
  color: var(--acid);
}

.status-downloading,
.status-queued {
  color: var(--blue);
}

.status-failed {
  color: var(--danger);
}

.progress-track {
  display: block;
  width: min(360px, 100%);
  height: 4px;
  margin-top: 12px;
  appearance: none;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: #272d38;
}

.progress-track::-webkit-progress-bar {
  border-radius: inherit;
  background: #272d38;
}

.progress-track::-webkit-progress-value,
.progress-track::-moz-progress-bar {
  background: var(--blue);
  border-radius: inherit;
}

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

.secondary-button,
.ghost-button {
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-raised);
  font-size: 0.875rem;
  font-weight: 660;
}

.secondary-button:hover,
.ghost-button:hover {
  border-color: #4a5365;
  background: #202632;
}

.secondary-button.accent {
  border-color: rgba(183, 255, 90, 0.24);
  color: var(--acid);
  background: rgba(183, 255, 90, 0.08);
}

.icon-button {
  width: 42px;
  padding: 0;
}

.icon-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
}

.error-text {
  color: #ff9a9a;
}

dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 22px;
  color: var(--text);
  background: var(--panel-raised);
  box-shadow: 0 36px 120px rgba(0, 0, 0, 0.6);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(7px);
}

.dialog-body {
  padding: 28px;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}

.dialog-header h2 {
  margin-bottom: 6px;
  font-size: 1.25rem;
}

.dialog-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.close-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.ttl-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ttl-option {
  position: relative;
}

.ttl-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ttl-option label {
  display: grid;
  min-height: 58px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  cursor: pointer;
}

.ttl-option input:checked + label {
  border-color: var(--acid);
  color: var(--acid-ink);
  background: var(--acid);
  font-weight: 760;
}

.ttl-option input:focus-visible + label {
  outline: 3px solid rgba(183, 255, 90, 0.45);
  outline-offset: 2px;
}

.custom-ttl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.custom-ttl input {
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #0d1017;
}

.custom-ttl span {
  color: var(--muted);
  font-size: 0.875rem;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 10;
  max-width: min(380px, calc(100% - 48px));
  padding: 14px 18px;
  border: 1px solid #3d4657;
  border-radius: 12px;
  color: var(--text);
  background: #202633;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  padding: 36px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(16, 19, 27, 0.94);
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.45);
}

.login-card .brand {
  margin-bottom: 44px;
}

.login-card h1 {
  margin-bottom: 12px;
  font-size: 2rem;
  line-height: 1.1;
  letter-spacing: -0.04em;
}

.login-card > p {
  margin-bottom: 30px;
  color: var(--muted);
  line-height: 1.6;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field label {
  color: #c9cfda;
  font-size: 0.875rem;
  font-weight: 650;
}

.field input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #0b0e14;
}

.login-card .primary-button {
  width: 100%;
  margin-top: 8px;
}

.login-error {
  display: none;
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 118, 118, 0.3);
  border-radius: 10px;
  color: #ffaaaa;
  background: rgba(255, 118, 118, 0.08);
  font-size: 0.875rem;
}

.login-error.visible {
  display: block;
}

.watch-workspace {
  padding: 46px 0 80px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 26px;
  color: var(--muted);
  text-decoration: none;
}

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

.watch-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 26px;
  align-items: start;
}

.player-frame {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #000;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.34);
}

.player-frame video {
  display: block;
  width: 100%;
  max-height: 72vh;
  aspect-ratio: 16 / 9;
  background: #000;
}

.watch-info {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
}

.watch-info h1 {
  margin-bottom: 14px;
  font-size: 1.35rem;
  line-height: 1.3;
  letter-spacing: -0.035em;
}

.watch-timer {
  margin-bottom: 22px;
  color: var(--acid);
  font-size: 0.9375rem;
}

.watch-actions {
  display: grid;
  gap: 10px;
}

.watch-actions .primary-button,
.watch-actions .secondary-button {
  width: 100%;
}

@media (max-width: 820px) {
  .intro,
  .watch-layout {
    grid-template-columns: 1fr;
    gap: 28px;
  }

  .intro-copy {
    max-width: 650px;
  }

  .watch-info {
    order: -1;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 24px, 1120px);
  }

  .topbar {
    min-height: 68px;
  }

  .retention-badge {
    display: none;
  }

  .workspace {
    padding-top: 42px;
  }

  .download-form {
    grid-template-columns: 1fr;
  }

  .download-form .primary-button {
    min-height: 54px;
  }

  .queue-section {
    margin-top: 54px;
  }

  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 8px;
  }

  .job-card {
    grid-template-columns: 48px minmax(0, 1fr);
    gap: 14px;
  }

  .job-icon {
    width: 48px;
    height: 48px;
  }

  .job-actions {
    grid-column: 1 / -1;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .job-actions .secondary-button:not(.icon-button) {
    flex: 1;
  }

  .job-actions .ttl-button {
    flex-basis: 100%;
  }

  .ttl-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dialog-body,
  .login-card {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
