:root {
  color-scheme: light;
  --ink: #1d2528;
  --muted: #6a7376;
  --line: #d9dfdc;
  --paper: #fafafa;
  --panel: #ffffff;
  --teal: #087f7a;
  --teal-dark: #05605c;
  --rose: #b8325f;
  --amber: #a96500;
  --green: #237445;
  --shadow: 0 10px 30px rgba(29, 37, 40, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
}

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

button[type="button"] {
  background: #fff;
  color: var(--teal);
}

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0 22px;
}

.top-actions {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.account-panel {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(120px, 170px) auto auto auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-runtime-status {
  grid-column: 1 / -1;
  text-align: right;
  white-space: normal;
}

.compact-check {
  min-height: 36px;
  align-self: end;
  white-space: nowrap;
}

.scheduler-panel {
  display: grid;
  grid-template-columns: 92px 92px auto;
  gap: 8px;
  align-items: end;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.scheduler-panel input {
  width: 100%;
}

.scheduler-panel .muted {
  grid-column: 1 / -1;
}

.execution-settings {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.field.compact {
  gap: 4px;
}

.field.compact input,
.field.compact select {
  min-height: 36px;
  padding: 7px 9px;
}

.account-panel button {
  min-height: 36px;
  padding: 7px 12px;
}

.studio-settings {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf9;
}

.studio-settings button {
  min-height: 36px;
  padding: 7px 12px;
}

.tabs {
  display: inline-flex;
  gap: 6px;
  margin: 0 0 16px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.tab {
  min-width: 96px;
  background: transparent;
  color: var(--teal-dark);
  border-color: transparent;
}

.tab:hover,
.tab.is-active {
  background: var(--teal);
  color: #fff;
  border-color: var(--teal);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

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

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  gap: 18px;
  align-items: start;
}

.compose,
.status-pane,
.history {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.compose {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px;
}

.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  margin: 0;
}

.mode-toggle legend {
  padding: 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.mode-toggle label {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.mode-toggle input {
  position: absolute;
  inset: 0;
  opacity: 0;
  min-height: 0;
  cursor: pointer;
}

.mode-toggle span {
  display: inline-flex;
  min-width: 76px;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--teal-dark);
}

.mode-toggle input:checked + span {
  background: var(--teal);
  color: #fff;
}

.mode-meta {
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
}

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

.span-2 {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: 10px 11px;
  min-height: 42px;
}

textarea {
  min-height: 170px;
  resize: vertical;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  outline: 3px solid rgba(8, 127, 122, 0.14);
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding-top: 20px;
}

.check input {
  width: 18px;
  height: 18px;
  min-height: 0;
}

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

.status-pane {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.status-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
}

.progress {
  height: 10px;
  margin: 14px 0 16px;
  background: #eef1ef;
  border-radius: 999px;
  overflow: hidden;
}

.progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--teal), var(--green));
  transition: width 180ms ease;
}

.notice {
  border: 1px solid rgba(169, 101, 0, 0.35);
  background: #fff7e8;
  color: #5f3b00;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 13px;
}

.error-box {
  display: grid;
  gap: 10px;
  border: 1px solid rgba(184, 50, 95, 0.35);
  background: #fff0f4;
  color: #791735;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.hidden {
  display: none;
}

.streams,
.files {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.stream-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.stream-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.stream-heading {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.stream-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stream-cover {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(8, 127, 122, 0.16), rgba(35, 116, 69, 0.1)),
    #eef1ef;
  border: 1px solid var(--line);
}

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

.stream-cover.is-empty::after {
  content: "";
  display: block;
  width: 18px;
  height: 18px;
  margin: 13px auto;
  border-radius: 999px;
  border: 2px solid rgba(8, 127, 122, 0.45);
}

.stream-item audio {
  display: none;
}

.player {
  display: grid;
  grid-template-columns: 36px auto minmax(90px, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 42px;
  background: #f1f3f2;
  border-radius: 999px;
  padding: 5px 10px 5px 5px;
}

.player-play {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 999px;
  padding: 0;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.player-play:hover {
  background: #e3e8e5;
}

.player-time {
  min-width: 36px;
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.player-timeline {
  position: relative;
  height: 24px;
  display: grid;
  align-items: center;
}

.player-timeline::before,
.player-buffer,
.player-progress {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 5px;
  border-radius: 999px;
}

.player-timeline::before {
  background: #c8cecb;
}

.player-buffer {
  width: 0;
  right: auto;
  background: #aeb7b2;
}

.player-progress {
  width: 0;
  right: auto;
  background: var(--ink);
}

.player-seek {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  appearance: none;
  cursor: pointer;
}

.player-seek:focus {
  outline: 3px solid rgba(8, 127, 122, 0.16);
}

.player-seek::-webkit-slider-runnable-track {
  height: 5px;
  background: transparent;
}

.player-seek::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -4.5px;
  border-radius: 999px;
  background: var(--teal);
  border: 2px solid #fff;
  appearance: none;
}

.player-seek::-moz-range-track {
  height: 5px;
  background: transparent;
}

.player-seek::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--teal);
  border: 2px solid #fff;
}

.player-seek:disabled {
  cursor: wait;
  opacity: 0.6;
}

.files a,
.files .file-card {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--teal-dark);
  text-decoration: none;
}

.timing-summary {
  display: grid;
  gap: 8px;
}

.timing-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.timing-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timing-chip {
  border-radius: 999px;
  background: #eef3f1;
  color: var(--teal-dark);
  font-size: 12px;
  padding: 4px 8px;
}

.timing-clip-list {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.event-log {
  display: grid;
  gap: 6px;
  max-height: 300px;
  overflow: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.event {
  display: grid;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
}

.event strong {
  color: var(--ink);
}

.studio-segments {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.studio-segment {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  overflow-wrap: anywhere;
}

.studio-segment.has-error {
  border-color: rgba(184, 50, 95, 0.35);
  background: rgba(184, 50, 95, 0.04);
}

.studio-segment strong {
  font-size: 13px;
}

.studio-segment-error {
  color: var(--rose);
  font-size: 12px;
  font-weight: 700;
}

.history {
  margin-top: 18px;
  padding: 18px;
}

.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto auto minmax(140px, 0.7fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  border-radius: 0;
  padding: 12px 0;
  text-align: left;
}

.job-row:first-child {
  border-top: 0;
}

.job-row:hover {
  background: #f4f7f5;
}

.job-row:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.studio-job-row {
  grid-template-columns: minmax(0, 1fr) auto auto auto auto minmax(180px, 0.9fr);
}

.inline-cancel {
  padding: 5px 10px;
  min-height: 30px;
  border-radius: 6px;
  font-size: 12px;
}

.failure-summary,
.studio-failure-summary {
  min-width: 0;
  max-width: 100%;
  color: var(--rose);
  font-size: 12px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  border-radius: 999px;
  padding: 4px 9px;
  color: #fff;
  background: var(--muted);
  font-size: 12px;
}

.badge.completed {
  background: var(--green);
}

.badge.failed,
.badge.cancelled {
  background: var(--rose);
}

.badge.challenge_required,
.badge.challenge_manual_wait {
  background: var(--amber);
}

@media (max-width: 840px) {
  .shell {
    padding: 16px;
  }

  .workspace,
  .compose {
    grid-template-columns: 1fr;
  }

  .status-pane {
    position: static;
  }

  .topbar,
  .top-actions,
  .account-panel {
    align-items: stretch;
  }

  .topbar,
  .top-actions {
    flex-direction: column;
  }

  .account-panel {
    grid-template-columns: 1fr;
  }

  .studio-settings {
    grid-template-columns: 1fr;
  }

  .scheduler-panel,
  .execution-settings {
    grid-template-columns: 1fr;
  }

  .job-row {
    grid-template-columns: 1fr;
  }

  .stream-title {
    align-items: start;
  }

  .stream-heading {
    grid-template-columns: 40px minmax(0, 1fr);
  }

  .stream-cover {
    width: 40px;
    height: 40px;
  }
}
