:root {
  color-scheme: light;
  --bg: #fff8f2;
  --panel: #ffffff;
  --panel-soft: #fff3e8;
  --text: #251b16;
  --muted: #7b6a60;
  --line: #ecd7c7;
  --accent: #d95f3d;
  --accent-dark: #ad3f25;
  --accent-soft: #fff0e8;
  --danger: #b42318;
  --ok: #087443;
  --warn: #a15c07;
  --shadow: 0 12px 32px rgba(86, 46, 27, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #fff3e8 0, var(--bg) 260px),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: var(--accent);
}

.shell {
  width: min(900px, calc(100vw - 32px));
  margin: 32px auto;
}

.shell.wide {
  width: min(1180px, calc(100vw - 32px));
}

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

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: #2b1710;
}

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

h3 {
  margin: 14px 0 8px;
  font-size: 15px;
}

p {
  margin: 4px 0;
}

.topbar p,
.muted {
  color: var(--muted);
}

.warn-text {
  color: var(--warn);
  font-weight: 600;
}

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

.hidden {
  display: none !important;
}

.home-panel {
  display: grid;
  gap: 18px;
}

.intro {
  margin: -6px -6px 0;
  padding: 16px;
  border-bottom: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
}

.intro p {
  max-width: 760px;
}

textarea {
  width: 100%;
  min-height: 320px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  font: inherit;
  background: #fffdfb;
  color: var(--text);
}

input {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
  background: #fffdfb;
  color: var(--text);
}

textarea:focus,
input:focus {
  outline: 3px solid rgba(217, 95, 61, .18);
  border-color: var(--accent);
}

.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-weight: 600;
}

.form-section {
  margin-bottom: 16px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.form-section.compact {
  max-width: 520px;
  margin-bottom: 0;
  border-bottom: 0;
}

.actions,
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

.actions {
  margin-top: 12px;
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0 14px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.button.secondary {
  background: #fffdfb;
  color: var(--accent);
}

button.secondary {
  background: #fffdfb;
  color: var(--accent);
}

.button.secondary:hover,
button.secondary:hover {
  background: var(--accent-soft);
}

button.danger,
.button.danger {
  border-color: var(--danger);
  background: #fff0ed;
  color: var(--danger);
}

button.danger:hover,
.button.danger:hover {
  background: #ffe0da;
}

.button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #fff8f2;
}

tr.selected-job td {
  background: #fff3dc;
  box-shadow: inset 0 1px 0 #f4c36d, inset 0 -1px 0 #f4c36d;
}

tr.selected-job td:first-child {
  box-shadow: inset 4px 0 0 var(--accent), inset 0 1px 0 #f4c36d, inset 0 -1px 0 #f4c36d;
}

.badge {
  display: inline-block;
  min-width: 78px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #f4ebe4;
  color: #5a453b;
  text-align: center;
}

.badge.finished {
  background: #eaf8ef;
  color: var(--ok);
}

.badge.failed {
  background: #fff0ed;
  color: var(--danger);
}

.badge.skipped {
  background: #fff5df;
  color: var(--warn);
}

.badge.cancelled {
  background: #eeeeee;
  color: #555;
}

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

.result-grid {
  margin-top: 16px;
}

.result-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(380px, .94fr);
  gap: 16px;
  align-items: start;
}

.hero-grid {
  align-items: stretch;
}

.hero-grid > .panel {
  min-height: 420px;
}

.basic-panel {
  overflow: hidden;
}

.video-summary-panel {
  min-width: 0;
}

.subsection-title {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.support-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.support-section {
  min-width: 0;
}

.source-comments-list {
  display: grid;
  gap: 10px;
}

.source-comment {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fffdfb;
}

.source-comment p {
  margin: 6px 0 0;
}

.source-comment-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.comments-panel {
  position: sticky;
  top: 16px;
  display: flex;
  max-height: calc(100vh - 32px);
  min-height: 420px;
  flex-direction: column;
  overflow: hidden;
}

.comments-head {
  flex: 0 0 auto;
}

.comments-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  padding-bottom: min(42vh, 320px);
}

dl {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 0;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
}

pre {
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  background: #fff8f2;
  border-radius: 6px;
}

.comment {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.problem-comment-action {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.inline-copy-row {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 8px;
}

.inline-copy-row a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.copy-button {
  min-height: 26px;
  flex: 0 0 auto;
  padding: 0 8px;
  font-size: 12px;
}

.copy-line {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  margin: 8px 0;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: #fffdfb;
  cursor: copy;
  overflow-wrap: anywhere;
}

.copy-line:hover,
.copy-line.copied {
  border-color: var(--line);
  background: var(--accent-soft);
}

.copy-line strong {
  color: var(--muted);
}

.video-frame {
  aspect-ratio: 16 / 9;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #211612;
}

.video-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

video {
  max-height: 520px;
  border-radius: 6px;
  background: #211612;
}

.fallback {
  margin-top: 12px;
}

.fallback summary {
  cursor: pointer;
  color: var(--accent);
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-card h2 {
  margin-bottom: 4px;
}

.history-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.preview-jobs {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.preview-jobs li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}

.order {
  color: var(--muted);
}

.long-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.long-text.collapsed {
  display: -webkit-box;
  max-height: 3em;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.compact-text {
  line-height: 1.5;
}

.link-button {
  min-height: auto;
  border: 0;
  padding: 4px 0;
  background: transparent;
  color: var(--accent);
}

.link-button:hover {
  background: transparent;
  color: var(--accent-dark);
}

.link-button.inline {
  display: inline;
  margin-left: 6px;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.4);
}

.modal {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  background: var(--panel);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

.modal h2 {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.duplicate-list {
  margin: 12px 0;
  max-height: 320px;
  overflow-y: auto;
}

.duplicate-item {
  padding: 10px 12px;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdfb;
}

.dup-url {
  font-weight: 600;
  font-size: 13px;
  word-break: break-all;
  color: var(--text);
}

.dup-meta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.dup-meta a {
  color: var(--accent);
}

@media (max-width: 760px) {
  .topbar,
  .actions,
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .result-layout {
    grid-template-columns: 1fr;
  }

  .comments-panel {
    position: static;
    max-height: none;
  }

  .comments-scroll {
    max-height: none;
    overflow: visible;
    padding-right: 0;
    padding-bottom: 0;
  }

  .history-head {
    flex-direction: column;
  }

  dl {
    grid-template-columns: 1fr;
  }
}
