:root {
  color-scheme: dark;
  --bg: #070812;
  --panel: rgba(18, 21, 36, 0.88);
  --panel-2: rgba(27, 31, 52, 0.92);
  --text: #f7f7fb;
  --muted: #a8adc2;
  --line: rgba(255, 255, 255, 0.12);
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --danger: #fb7185;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 5%, rgba(139, 92, 246, 0.3), transparent 28rem),
    radial-gradient(circle at 85% 15%, rgba(34, 211, 238, 0.24), transparent 24rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

main {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 50px;
}

header {
  max-width: 820px;
  margin-bottom: 24px;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.1rem, 5vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.06em;
}

h2 {
  margin-bottom: 16px;
  font-size: 1.2rem;
}

header p:not(.eyebrow),
#job-state,
.notice {
  color: var(--muted);
}

.eyebrow {
  color: var(--accent-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 26px;
  background: linear-gradient(145deg, var(--panel), rgba(12, 14, 24, 0.88));
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34);
  padding: 22px;
  backdrop-filter: blur(16px);
}

.grid,
.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.style-grid {
  margin: 16px 0 22px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

input,
select,
button,
.file-button,
.download {
  border: 1px solid var(--line);
  border-radius: 13px;
  font: inherit;
}

input,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 10px 12px;
  outline: none;
}

input[type="color"] {
  padding: 3px;
  height: 42px;
}

button,
.file-button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 15px;
  background: linear-gradient(135deg, var(--accent), #6d5dfc);
  color: #fff;
  font-weight: 760;
  cursor: pointer;
  text-decoration: none;
}

button.secondary,
.file-button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.oauth-button {
  display: inline-flex;
  gap: 12px;
  min-width: 236px;
  border-radius: 999px;
  background: #fff;
  color: #1f1f1f;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}

.oauth-button:hover {
  filter: brightness(0.96);
}

.oauth-button.apple {
  background: #050505;
  color: #fff;
}

.oauth-icon {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  font-weight: 900;
}

.oauth-button.google .oauth-icon {
  color: #4285f4;
  font-family: Arial, sans-serif;
}

.oauth-button.apple .oauth-icon {
  color: #fff;
  font-size: 1.25rem;
}

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

.file-button input {
  display: none;
}

.actions,
.toolbar,
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.actions {
  margin-top: 16px;
}

.actions.small {
  justify-content: space-between;
  margin: 0 0 12px;
}

.topbar {
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  margin: -2px 0 16px;
  padding-bottom: 14px;
}

.topbar h2,
.topbar p {
  margin-bottom: 0;
}

.toolbar {
  margin-bottom: 12px;
}

.error {
  color: var(--danger);
  margin: 12px 0 0;
}

.notice {
  margin: 8px 0 0;
  font-size: 0.9rem;
}

.workbench {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(420px, 1fr);
  gap: 18px;
}

.lyrics,
.video-side {
  min-width: 0;
}

.cues {
  display: grid;
  gap: 8px;
  max-height: min(68vh, 820px);
  overflow: auto;
  padding-right: 4px;
}

.cue {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 76px 34px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.cue.active {
  border-color: rgba(34, 211, 238, 0.8);
  background: rgba(34, 211, 238, 0.1);
}

.cue input {
  border-color: transparent;
}

.cue .time {
  padding: 8px 6px;
  font-size: 0.75rem;
  text-align: center;
  color: var(--muted);
}

.cue .text {
  font-size: 0.95rem;
}

.cue .trash {
  min-height: 34px;
  padding: 0;
  border-radius: 10px;
  background: rgba(251, 113, 133, 0.16);
  color: #fecdd3;
}

.video-frame {
  position: sticky;
  top: 16px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #000;
  aspect-ratio: 16 / 9;
}

video {
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
}

.subtitle-preview {
  pointer-events: none;
  position: absolute;
  inset: auto 8% 9% 8%;
  display: grid;
  justify-items: center;
  gap: 0.25em;
  text-align: center;
  font-weight: 800;
  line-height: 1.15;
}

.subtitle-preview .context {
  opacity: 0.46;
  font-size: 0.72em;
}

.subtitle-preview span {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 160ms ease-out, transform 160ms ease-out;
  white-space: pre-wrap;
}

.timeline {
  display: flex;
  gap: 3px;
  align-items: stretch;
  min-height: 54px;
  margin-top: 12px;
  overflow-x: auto;
  padding: 6px 0 2px;
}

.segment {
  min-width: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.68rem;
  overflow: hidden;
  padding: 6px;
  text-align: left;
  text-overflow: ellipsis;
}

.segment.active {
  background: rgba(139, 92, 246, 0.42);
  border-color: rgba(139, 92, 246, 0.9);
  color: #fff;
}

#result-video {
  height: auto;
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.download {
  margin-top: 10px;
}

@media (max-width: 980px) {
  .workbench {
    grid-template-columns: 1fr;
  }

  .video-frame {
    position: relative;
    top: auto;
  }
}

@media (max-width: 640px) {
  main {
    width: min(100vw - 18px, 1480px);
    padding-top: 18px;
  }

  .panel {
    padding: 14px;
    border-radius: 18px;
  }

  .cue {
    grid-template-columns: 68px minmax(0, 1fr) 68px 32px;
    gap: 5px;
  }
}
