:root {
  color-scheme: light;
  --wall: #e4eaf2;
  --sheet: #f7f9fb;
  --ink: #182230;
  --ink-soft: #3d4d60;
  --line: #d0d8e4;
  --forest: #0f5c46;
  --manila: #efe2c6;
  --lamp: #b42318;
  --focus: #1d4e89;
  --sans: "Segoe UI Variable", "Segoe UI", sans-serif;
  --script: "Palatino Linotype", Palatino, Georgia, serif;
  --devanagari: "Nirmala UI", Mangal, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; min-height: 100vh; }

body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}

button, input, select { font: inherit; color: inherit; }

button, a, summary { -webkit-tap-highlight-color: transparent; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

::selection { background: #d7ebe3; }

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.desk {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

header { grid-row: 1; }
#banner { grid-row: 2; }
.layout { grid-row: 3; }

header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  flex-wrap: wrap;
  padding: 18px 28px 16px;
  background: var(--sheet);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; gap: 12px; align-items: flex-start; }

.tally {
  width: 10px;
  height: 10px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--forest);
  flex: none;
}

.tally.working {
  background: var(--lamp);
  animation: tally 1.4s ease-in-out infinite alternate;
}

.name {
  font-family: var(--script);
  font-size: 1.7rem;
  line-height: 1;
  margin: 0;
}

.purpose, .limits, .help, .meta { margin: 0; }

.purpose { color: var(--ink-soft); margin-top: 4px; }

.limits { color: var(--ink-soft); padding-bottom: 2px; }

.banner {
  background: #f8e8e6;
  color: #6f1d16;
  padding: 10px 28px;
  border-bottom: 1px solid #e4c4c0;
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  min-height: 0;
}

aside, main { min-height: 0; overflow: auto; }

aside { padding: 8px 22px 36px; }

main {
  background: var(--sheet);
  border-left: 1px solid var(--line);
  padding: 28px 36px 72px;
}

aside h2 {
  font-family: var(--script);
  font-size: 1.25rem;
  font-weight: 500;
  margin: 28px 0 8px;
}

aside label { display: block; margin: 16px 0 6px; }

aside label.check {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 16px;
}

aside select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
}

.help { color: var(--ink-soft); margin-top: 8px; max-width: 40rem; }

aside .help { margin-top: 8px; }

details { margin-top: 28px; }

summary { cursor: pointer; }

#gate-list { padding-left: 1.1rem; }

#gate-list li { margin: 8px 0; }

.past-job {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  cursor: pointer;
}

.past-job .status { color: var(--ink-soft); flex: none; }

h1 {
  font-family: var(--script);
  font-weight: 500;
  font-size: 2.05rem;
  line-height: 1.15;
  margin: 0 0 8px;
}

h2 {
  font-family: var(--script);
  font-weight: 500;
  font-size: 1.35rem;
  margin: 0;
}

.meta { color: var(--ink-soft); margin-top: 4px; }

.link-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  max-width: 44rem;
  margin-top: 18px;
}

.link-form input,
.names input {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  padding: 12px 14px;
}

.file-row { margin-top: 22px; max-width: 44rem; }

.file-row input { margin-top: 8px; }

.form-error { color: var(--lamp); min-height: 1.2em; margin-top: 8px; }

.mat {
  background: var(--manila);
  padding: 10px;
  display: inline-block;
  margin: 16px 0;
  max-width: 100%;
}

.mat img { display: block; width: min(480px, 100%); height: auto; background: #d5dbe3; }

.mat.small img { width: min(240px, 100%); }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  padding: 10px 14px;
  border: 1px solid transparent;
  background: transparent;
  text-decoration: none;
  cursor: pointer;
}

.button.primary { background: var(--forest); color: white; }

.button.primary:hover { background: #0c4d3b; }

.button.secondary { border-color: var(--line); background: white; color: var(--ink); }

.button.danger { border-color: #e4c4c0; color: var(--lamp); background: white; }

.button:disabled { opacity: 0.45; cursor: not-allowed; }

.text-button {
  border: 0;
  background: none;
  color: var(--forest);
  padding: 0;
  cursor: pointer;
}

.file-button input { display: none; }

.rights {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  max-width: 40rem;
}

.rights input { margin-top: 4px; }

.video-row {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.video-row img {
  width: 120px;
  height: 68px;
  object-fit: cover;
  background: #d5dbe3;
}

.video-title { margin: 0; }

.queue {
  list-style: none;
  padding: 0;
  margin: 18px 0 0;
  max-width: 42rem;
}

.queue li {
  display: grid;
  grid-template-columns: 16px 8.5rem minmax(0, 1fr) auto;
  gap: 12px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.mark {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid var(--ink-soft);
  align-self: center;
}

.mark.done { background: var(--forest); border-color: var(--forest); }

.mark.active { background: var(--lamp); border-color: var(--lamp); }

.mark.failed {
  background: var(--lamp);
  border-color: var(--lamp);
  border-radius: 1px;
}

.step-detail { color: var(--ink-soft); }

.step-flag { color: var(--ink-soft); }

.job-error:empty { display: none; }

.job-error {
  border-left: 3px solid var(--lamp);
  padding: 2px 0 2px 12px;
  color: #6f1d16;
  max-width: 40rem;
  margin-top: 16px;
}

.warning {
  border-left: 3px solid #8a5a12;
  padding: 2px 0 2px 12px;
  color: #5c3d0c;
  max-width: 42rem;
  margin: 8px 0;
}

.listen {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 18px;
}

.listen audio { flex: 1 1 240px; width: 100%; }

.names {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin: 14px 0;
}

.names label {
  display: grid;
  gap: 4px;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

.names input { width: 12rem; padding: 8px 10px; }

.script-block { margin-top: 28px; max-width: 48rem; }

.script-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}

.script-head .actions { margin-top: 0; }

.file-url {
  display: inline-block;
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.turn {
  display: grid;
  grid-template-columns: 7rem minmax(0, 62ch);
  gap: 8px 16px;
  margin: 0 0 1.15rem;
}

.script { margin-top: 16px; }

.speaker {
  color: var(--forest);
  padding-top: 0.28rem;
}

.utterance {
  font-family: var(--script);
  font-size: 1.2rem;
  line-height: 1.55;
  margin: 0;
}

.utterance.devanagari {
  font-family: var(--devanagari);
  font-size: 1.28rem;
  line-height: 1.7;
}

@media (max-width: 800px) {
  html, body, .desk { height: auto; }
  .layout { grid-template-columns: 1fr; }
  aside, main { overflow: visible; }
  main { border-left: 0; border-top: 1px solid var(--line); padding: 22px 16px 48px; }
  header, .banner, aside { padding-left: 16px; padding-right: 16px; }
}

@media (max-width: 700px) {
  .link-form, .video-row { grid-template-columns: 1fr; }
  .video-row img { width: 100%; height: auto; aspect-ratio: 16 / 9; }
  .queue li { grid-template-columns: 16px minmax(0, 1fr) auto; }
  .step-detail { grid-column: 2 / -1; }
  .turn { grid-template-columns: 1fr; gap: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  .tally.working { animation: none; }
}

@keyframes tally {
  from { opacity: 1; }
  to { opacity: 0.35; }
}
