:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #68727d;
  --line: #d9dee5;
  --teal: #087e8b;
  --teal-strong: #045f68;
  --coral: #ff5a5f;
  --amber: #d9981e;
  --green: #2f8f55;
  --shadow: 0 18px 45px rgba(31, 35, 40, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.login-screen {
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(340px, 440px);
  gap: 48px;
  align-items: center;
  min-height: 100vh;
  padding: 48px;
  background:
    linear-gradient(135deg, rgba(8, 126, 139, 0.11), transparent 38%),
    linear-gradient(315deg, rgba(255, 90, 95, 0.1), transparent 38%),
    var(--bg);
}

.login-visual {
  position: relative;
  overflow: hidden;
  min-height: 560px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    #171b20;
  box-shadow: var(--shadow);
}

.login-visual::before {
  content: "";
  position: absolute;
  inset: 28px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
}

.login-visual::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 46%;
  background: linear-gradient(0deg, rgba(8, 126, 139, 0.34), transparent);
}

.login-mark {
  position: absolute;
  left: 42px;
  top: 42px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 22px;
  font-weight: 900;
}

.login-frames {
  position: absolute;
  inset: 138px 44px 54px;
  z-index: 2;
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  grid-template-rows: 1fr 1fr;
  gap: 14px;
}

.login-frames span {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.02)),
    rgba(255, 255, 255, 0.04);
}

.login-frames span:nth-child(2) {
  grid-row: span 2;
  background:
    linear-gradient(180deg, rgba(8, 126, 139, 0.42), rgba(255, 90, 95, 0.2)),
    rgba(255, 255, 255, 0.06);
}

.login-card {
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 8px;
}

.login-heading h1 {
  margin: 0;
  font-size: 25px;
  line-height: 1.12;
}

.wide-button {
  width: 100%;
}

.login-status {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.login-status.error {
  color: #b3261e;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 22px;
  padding: 24px;
  border-right: 1px solid var(--line);
  background: #ffffff;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.job-detail h3,
.job-detail p {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  line-height: 1.1;
}

.brand p,
.eyebrow,
.field span,
.provider-option small,
.dropzone small,
.job-card small,
.job-detail p {
  color: var(--muted);
}

.provider-stack {
  display: grid;
  gap: 10px;
}

.single-provider {
  grid-template-columns: 1fr;
}

.provider-option {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 64px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
  color: inherit;
  text-align: left;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.provider-option.active {
  border-color: var(--teal);
  background: #edf9fa;
  box-shadow: 0 10px 22px rgba(8, 126, 139, 0.12);
}

.provider-option:hover {
  transform: translateY(-1px);
  border-color: #9fb0ba;
}

.provider-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--amber);
  flex: none;
}

.provider-option.configured .provider-dot {
  background: var(--green);
}

.provider-option.missing .provider-dot {
  background: var(--coral);
}

.provider-option span:last-child {
  display: grid;
  gap: 2px;
}

.history-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  color: #343941;
}

.job-list {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.job-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-align: left;
  color: inherit;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.job-card.active {
  border-color: var(--teal);
  box-shadow: 0 10px 24px rgba(8, 126, 139, 0.11);
}

.job-card:hover {
  transform: translateY(-1px);
  border-color: #b8c4cd;
}

.job-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-progress {
  overflow: hidden;
  display: block;
  height: 4px;
  border-radius: 999px;
  background: #e9eef3;
}

.job-progress span {
  display: block;
  width: var(--job-progress, 0%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  transition: width 220ms ease;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 800;
  letter-spacing: 0;
}

.topbar h2 {
  max-width: 720px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.08;
  font-weight: 850;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex: none;
}

.primary-button,
.secondary-button,
.icon-button,
.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  text-decoration: none;
  font-weight: 800;
}

.primary-button {
  padding: 0 18px;
  background: var(--teal);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--teal-strong);
}

.primary-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.secondary-button,
.download-link {
  padding: 0 14px;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button {
  width: 38px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line);
  color: var(--ink);
}

.primary-button svg,
.secondary-button svg,
.icon-button svg,
.download-link svg {
  width: 18px;
  height: 18px;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 22px;
  align-items: start;
}

.tool-panel,
.preview-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-panel {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.field-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field-row > .field:first-child:not(.compact) {
  grid-column: 1 / -1;
}

.advanced-panel > .field-row {
  grid-template-columns: 120px minmax(0, 1fr);
}

.advanced-panel > .field-row.voice-clone-row {
  grid-template-columns: minmax(0, 1fr) minmax(120px, 0.55fr) minmax(170px, 0.7fr);
}

.advanced-panel > .field-row > .field:first-child:not(.compact) {
  grid-column: auto;
}

.field {
  display: grid;
  gap: 7px;
}

.field span {
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  outline: none;
}

.field input,
.field select {
  min-height: 44px;
  padding: 0 12px;
}

.field textarea {
  resize: vertical;
  min-height: 132px;
  padding: 12px;
  line-height: 1.45;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(8, 126, 139, 0.14);
}

.upload-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.dropzone {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 164px;
  padding: 18px;
  border: 1px dashed #b8c1ca;
  border-radius: 8px;
  background: #fbfcfd;
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease;
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.dropzone.dragover,
.dropzone.has-file {
  border-color: var(--teal);
  background: #eefafa;
}

.dropzone:hover {
  border-color: var(--teal);
}

.dropzone-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.32;
  filter: saturate(1.08);
}

.dropzone > :not(input):not(.dropzone-preview) {
  position: relative;
  z-index: 1;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: #e9eef3;
  color: var(--teal);
  box-shadow: 0 8px 20px rgba(8, 126, 139, 0.14);
}

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

.references-dropzone {
  grid-column: 1 / -1;
  min-height: 118px;
}

.audio-dropzone {
  grid-column: 1 / -1;
  min-height: 118px;
}

.reference-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

.reference-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  min-height: 34px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafb;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.reference-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reference-chip small {
  color: var(--muted);
  font-weight: 700;
}

.reference-chip button {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  padding: 0;
}

.reference-chip button:hover {
  background: #e9eef3;
  color: var(--ink);
}

.reference-chip svg {
  width: 15px;
  height: 15px;
}

.advanced-panel {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.advanced-panel summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 42px;
  font-weight: 800;
  cursor: pointer;
}

.advanced-panel summary::marker {
  content: "";
}

.advanced-panel[open] summary svg {
  transform: rotate(180deg);
}

.advanced-panel > .field-row,
.advanced-panel > .field {
  margin-top: 12px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  font-weight: 800;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
}

.checkbox-field span {
  font-size: 13px;
}

.form-status {
  min-height: 24px;
  color: var(--muted);
  font-weight: 700;
}

.form-status.error {
  color: #b3261e;
}

.preview-panel {
  overflow: hidden;
}

.preview-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 360px;
  height: min(58vh, 560px);
  background: #181c20;
}

.preview-stage img,
.preview-stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.preview-stage img[hidden],
.preview-stage video[hidden],
.empty-preview[hidden],
.preview-alert[hidden],
.download-link[hidden] {
  display: none !important;
}

.empty-preview {
  display: grid;
  place-items: center;
  gap: 12px;
  color: #d8e1e8;
  text-align: center;
}

.empty-preview svg {
  width: 44px;
  height: 44px;
}

.empty-preview p {
  margin: 0;
  color: #d8e1e8;
  font-weight: 800;
}

.preview-alert {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  z-index: 3;
  max-height: 42%;
  overflow: auto;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(20, 25, 31, 0.92);
  color: #ffffff;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.28);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.45;
}

.preview-alert.failed {
  border-color: rgba(255, 90, 95, 0.55);
  background: rgba(84, 18, 22, 0.95);
}

.preview-alert.running {
  border-color: rgba(217, 152, 30, 0.58);
  background: rgba(76, 50, 9, 0.94);
}

.preview-alert.running::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: #ffd166;
  animation: pulseDot 1.2s ease-in-out infinite;
}

@keyframes pulseDot {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.82);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.job-detail {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.job-detail-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
}

.job-detail h3 {
  margin-top: 8px;
  font-size: 19px;
  line-height: 1.2;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  background: #eef1f4;
  color: #404852;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-badge.running {
  background: #fff4d8;
  color: #805200;
}

.status-badge.succeeded {
  background: #e5f5ea;
  color: #1c6b3a;
}

.status-badge.failed {
  background: #ffe7e8;
  color: #9b1c22;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  border-radius: 999px;
  background: #e8edf1;
}

.progress-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--coral));
  transition: width 220ms ease;
}

@media (max-width: 1100px) {
  .login-screen {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .login-visual {
    min-height: 260px;
  }

  .login-frames {
    inset: 96px 32px 32px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    grid-template-rows: auto auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .history-panel {
    display: none;
  }

  .provider-stack {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .provider-stack.single-provider {
    grid-template-columns: 1fr;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .login-screen {
    padding: 18px;
  }

  .login-visual {
    min-height: 180px;
  }

  .login-mark {
    left: 24px;
    top: 24px;
    width: 50px;
    height: 50px;
    font-size: 18px;
  }

  .login-frames {
    inset: 90px 22px 22px;
    gap: 8px;
  }

  .login-card {
    padding: 20px;
  }

  .workspace,
  .rail {
    padding: 18px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .topbar-actions > * {
    flex: 1;
  }

  .provider-stack,
  .field-row,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .advanced-panel > .field-row.voice-clone-row {
    grid-template-columns: 1fr;
  }

  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .preview-stage {
    min-height: 0;
    height: 300px;
  }
}
