:root {
  color-scheme: light dark;
  --border: #ccc;
  --muted: #666;
  --bg-alt: #f4f4f4;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.topbar .brand {
  font-weight: 600;
  text-decoration: none;
}

.topbar nav {
  flex: 1;
}

.topbar nav a {
  margin-right: 1rem;
}

.logout-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
}

.logout-form button {
  padding: 0.3rem 0.8rem;
  font-size: 0.85rem;
}

main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem;
}

footer {
  max-width: 860px;
  margin: 2rem auto;
  padding: 0 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

fieldset {
  margin-bottom: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem;
}

.upload-widget {
  margin-top: 1rem;
}

.upload-widget progress {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 0.5rem;
  height: 0.9rem;
}

.upload-cancel {
  margin-top: 0.5rem;
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
}

label {
  display: block;
  margin-top: 0.75rem;
  font-weight: 600;
}

select, input[type="number"], input[type="text"], input[type="password"] {
  display: block;
  margin-top: 0.25rem;
  padding: 0.4rem;
  width: 100%;
  max-width: 420px;
}

button {
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  cursor: pointer;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  color: #b00020;
  font-weight: 600;
}

table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.5rem;
}

table.kv th {
  text-align: left;
  width: 180px;
  color: var(--muted);
  font-weight: 600;
  vertical-align: top;
}

th, td {
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.status {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-alt);
}

.status-completed { background: #d4f7dc; color: #14532d; }
.status-failed { background: #fbd5d5; color: #7f1d1d; }
.status-running { background: #fef3c7; color: #78350f; }
.status-queued { background: #e5e7eb; color: #374151; }
.status-interrupted { background: #fbd5d5; color: #7f1d1d; }

/* v0.16.0 review & regenerate */
.result-video {
  display: block;
  width: 100%;
  max-width: 720px;
  background: #000;
  border-radius: 6px;
  margin-bottom: 0.75rem;
}

.notice {
  background: var(--bg-alt);
  border-left: 4px solid #b45309;
  padding: 0.6rem 0.8rem;
  border-radius: 4px;
}

a.button-link {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  font-size: 1rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-alt);
}

a.cancel-link {
  margin-left: 1rem;
}

details.log-details summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* v0.16.1 source exclusions */
.exclusion-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

ul.exclusion-list,
ul.exclusion-summary {
  list-style: none;
  padding-left: 0;
}

ul.exclusion-list li {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.25rem 0;
}

button.exclusion-remove {
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

/* v0.17.0 review player & timeline */
.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 860px) {
  .review-layout {
    grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    align-items: start;
  }
  .clip-list-wrap {
    max-height: 460px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
  }
}

.review-timeline h3 {
  margin-top: 0;
}

.playback-meta {
  margin: 0.25rem 0 0.5rem;
  min-height: 1.2em;
}

.clip-controls {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.clip-controls button {
  padding: 0.35rem 0.8rem;
  font-size: 0.9rem;
}

ol.clip-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.clip-item {
  border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
}

.clip-item:last-child {
  border-bottom: none;
}

.clip-item .clip-seek,
.clip-item .clip-static {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  padding: 0.5rem 0.6rem;
  font: inherit;
  color: inherit;
}

.clip-item .clip-seek {
  cursor: pointer;
}

.clip-item .clip-seek:hover,
.clip-item .clip-seek:focus-visible {
  background: var(--bg-alt);
}

.clip-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: baseline;
}

.clip-index {
  font-weight: 600;
}

.clip-duration {
  color: var(--muted);
  font-size: 0.85rem;
}

.clip-source,
.clip-summary {
  display: block;
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.clip-labels {
  display: block;
  margin-top: 0.15rem;
}

.clip-label {
  display: inline-block;
  padding: 0 0.5rem;
  margin-right: 0.35rem;
  border-radius: 999px;
  background: var(--bg-alt);
  font-size: 0.78rem;
}

.clip-transition {
  display: block;
  padding: 0 0.6rem 0.4rem;
  font-size: 0.78rem;
}

/* Active state: border + bold marker, never color alone (also mirrored by
   aria-current="true" for assistive tech). */
.clip-item.clip-active {
  border-left-color: #2563eb;
  background: var(--bg-alt);
}

.clip-item.clip-active .clip-index::after {
  content: " \25B6";
  font-size: 0.75em;
}

.clip-item.clip-chapter .clip-head::before {
  content: "\00A7";
  color: var(--muted);
}

pre.log {
  background: var(--bg-alt);
  padding: 1rem;
  border-radius: 6px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.85rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --border: #444;
    --bg-alt: #1e1e1e;
  }
  body { background: #121212; color: #e6e6e6; }
  .status-completed { background: #14351f; color: #a7f3c9; }
  .status-failed { background: #3a1616; color: #fca5a5; }
  .status-running { background: #3a2f0e; color: #fde68a; }
  .status-queued { background: #2a2a2a; color: #d1d5db; }
  .status-interrupted { background: #3a1616; color: #fca5a5; }
}
