:root {
  color-scheme: light;
  font-family: system-ui, sans-serif;
  color: #173043;
  background: #f3f6f7;
  font-synthesis: none;
  --muted: #526778;
  --line: #dce5e8;
  --accent: #17645f;
  --dark: #102b3b;
  --paper: #fff;
  --error: #952f33;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
body, input, select, button { line-height: 1.45; }
button, input, select { font: inherit; }
button, .button { cursor: pointer; }
button:disabled, .button[aria-disabled="true"] { cursor: default; opacity: .55; }
button, .button, input, select, summary {
  -webkit-tap-highlight-color: transparent;
}
:focus-visible { outline: 3px solid #298b83; outline-offset: 3px; }
h1, h2, h3, p, ul, dl, dd { margin: 0; }
h1 { font-size: clamp(2rem, 4.5vw, 3rem); line-height: 1.1; letter-spacing: -.05em; }
h2 { font-size: 1.25rem; letter-spacing: -.025em; }
h3 { font-size: 1rem; }
a { color: var(--accent); }

.wrap { width: min(1150px, calc(100% - 48px)); margin: 0 auto; }
.topbar { color: #eaf0f2; background: var(--dark); }
.topbar-inner { display: flex; align-items: center; min-height: 70px; gap: 35px; }
.brand { display: flex; align-items: center; gap: 11px; font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.brand-mark { position: relative; width: 29px; height: 22px; display: inline-grid; place-items: center; border: 2px solid #8ed9cd; border-radius: 5px; }
.brand-mark i { width: 16px; height: 7px; border-block: 2px solid #8ed9cd; }
.topbar nav { display: flex; gap: 6px; }
.topbar nav button, .topbar .sign-out {
  border: 1px solid transparent;
  border-radius: 7px;
  background: none;
  color: #d8e5e9;
  padding: 8px 12px;
  font-size: .9rem;
}
.topbar nav button:hover, .topbar .sign-out:hover { background: #264757; }
.topbar nav button[aria-current="page"] { background: #315464; color: white; }
.topbar .sign-out { margin-left: auto; border-color: #416170; }

.screen { padding: 48px 0 70px; }
.screen-head { margin-bottom: 27px; }
.screen-head p { margin-top: 10px; color: var(--muted); }
.jobs-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.panel { min-width: 0; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: 0 1px 2px #102b3b09; }
.panel h2 + p, .panel h2 + label, .panel h2 + div:not(.source) { margin-top: 12px; }
.panel .source { margin-top: 15px; }
.login { width: min(450px, 100%); margin: 9vh auto; padding: 30px; }
.login h1 { font-size: 2.2rem; }
.login p { margin: 10px 0 14px; }
.login .notice { margin: 0; }
.stack { display: grid; gap: 14px; min-width: 0; }
.actions { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.actions .notice { width: 100%; }
.muted { color: var(--muted); font-size: .9rem; }
.options { margin-top: 15px; }
.source { padding: 13px 14px; border: 1px solid var(--line); border-radius: 8px; background: #f9fbfb; }
.source-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.source-header h3 { min-width: 7rem; }
.source-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.source-note { margin-top: 8px; }
.source-list, .media-list, .pair-list, .issue-list, .engine-notes { margin-top: 8px; padding-left: 0; list-style: none; }
.source-list li, .media-list li, .pair-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: space-between;
  border-top: 1px solid var(--line);
  padding: 8px 0 0;
  margin-top: 8px;
  overflow-wrap: anywhere;
}
.source-list li span:first-child { min-width: 0; }
.source-list li span:first-child small { color: var(--muted); white-space: nowrap; }
progress { width: 100%; height: 8px; margin-top: 10px; accent-color: var(--accent); }
.issue-list { padding-left: 17px; list-style: disc; font-size: .9rem; color: #7c3818; }
.issue-list li + li { margin-top: 5px; }
.pair-list li { align-items: baseline; }
.episode { color: var(--accent); font-size: .85rem; font-weight: 700; }
.pair-name { text-align: right; }

button, .button {
  display: inline-block;
  padding: 8px 12px;
  text-align: center;
  border: 1px solid transparent;
  border-radius: 7px;
  text-decoration: none;
  font-weight: 600;
}
.primary { color: white; background: var(--accent); }
.primary:not(:disabled):hover { background: #104f4a; }
.secondary { color: var(--accent); border-color: #aac9c6; background: white; }
.secondary:not(:disabled):hover { background: #e7f5f2; }
.quiet { background: transparent; color: var(--accent); }
.quiet:not(:disabled):hover { background: #e8f1f0; }
.source-actions button, .source-list button, .media-list button { font-size: .85rem; }
.warning-action { color: var(--error); }
label { display: grid; gap: 5px; min-width: 0; font-weight: 600; font-size: .92rem; }
input:not([type="checkbox"]), select {
  min-width: 0;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #bacbd0;
  border-radius: 6px;
  background: white;
  color: inherit;
  font-weight: 400;
}
input[type="checkbox"] { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent); }
.check { display: flex; align-items: center; font-weight: 400; }
.advanced summary { cursor: pointer; color: var(--accent); font-size: .9rem; font-weight: 600; }
.advanced label { margin-top: 10px; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.anchor-label { font-weight: 700; }
.notice { padding: 10px 12px; border-radius: 7px; background: #eaf2f4; color: #284b5c; font-size: .9rem; overflow-wrap: anywhere; }
.notice.error { background: #fbecef; color: var(--error); }

.job-list, .batch-downloads { display: grid; gap: 10px; }
.batch-downloads:not(:empty), #jobs-note { margin-bottom: 15px; }
.job-row {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(130px, .65fr) minmax(0, auto);
  gap: 14px;
  align-items: center;
}
.job-name { overflow-wrap: anywhere; }
.job-name p { margin-top: 4px; }
.job-status { display: grid; justify-items: start; gap: 5px; }
.status {
  display: inline-block;
  padding: 3px 7px;
  border-radius: 20px;
  color: #324c5a;
  background: #e9eff1;
  font-size: .77rem;
  font-weight: 700;
}
.status.completed { color: #155743; background: #e1f4e9; }
.status.running { color: #23567d; background: #e5f1fa; }
.status.failed, .status.interrupted { color: var(--error); background: #f9e9eb; }
.job-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.job-actions .button, .job-actions button { font-size: .85rem; }
.batch-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

dialog {
  position: fixed;
  width: min(680px, calc(100% - 28px));
  max-height: calc(100dvh - 50px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: inherit;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: #102b3b96; }
.dialog-head, .dialog-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; }
.dialog-head { border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.dialog-foot { border-top: 1px solid var(--line); justify-content: flex-end; }
.dialog-body { overflow: auto; padding: 16px 18px; }
.media-list li { justify-content: flex-start; }
.media-list label { place-items: center start; grid-template-columns: auto 1fr; }
.detail-stat { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); gap: 8px; }
.detail-stat div { padding: 8px; border-radius: 6px; background: #edf3f4; }
.detail-stat dt { font-size: .82rem; color: var(--muted); }
.detail-stat dd { font-weight: 700; }
.samples { margin-top: 8px; width: 100%; border-collapse: collapse; text-align: left; font-variant-numeric: tabular-nums; }
.samples th, .samples td { padding: 7px; border-bottom: 1px solid var(--line); }
.engine-notes { padding: 9px; border-radius: 7px; font-family: ui-monospace, monospace; font-size: .82rem; background: #edf3f4; overflow-wrap: anywhere; }

@media (max-width: 710px) {
  .wrap { width: calc(100% - 26px); }
  .topbar-inner { gap: 10px; padding-block: 11px; flex-wrap: wrap; }
  .topbar nav { order: 3; flex-basis: 100%; }
  .topbar nav button { padding-inline: 10px; }
  .screen { padding-top: 31px; }
  .layout { grid-template-columns: 1fr; gap: 14px; }
  .panel { padding: 16px; }
  .job-row { grid-template-columns: minmax(0, 1fr) auto; }
  .job-actions { grid-column: 1 / -1; justify-content: flex-start; }
}

@media (max-width: 385px) {
  .field-row { grid-template-columns: 1fr; }
  .job-row { grid-template-columns: 1fr; }
}
