:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --panel: #ffffff;
  --panel-soft: #fbfbf8;
  --ink: #18181b;
  --muted: #6b7280;
  --line: #deded7;
  --line-strong: #c9c9c0;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e7f5f1;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --shadow: 0 16px 50px rgba(24, 24, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0)) 0 0 / 100% 220px no-repeat,
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overflow: hidden;
}

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

button {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: #9ca3af;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  outline-offset: 2px;
}

.shell {
  display: grid;
  grid-template-columns: minmax(360px, 460px) minmax(0, 1fr);
  height: 100vh;
  min-height: 0;
}

.queue {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100vh;
  background: rgba(255, 255, 255, 0.92);
  border-right: 1px solid var(--line);
  overflow: hidden;
}

.queue-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  margin-bottom: 6px;
  color: #dc143c;
  font-weight: 800;
  text-decoration: none;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 26px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.queue-head p,
.eyebrow,
.sample-meta,
.metric span,
.label small,
.label-stats {
  color: var(--muted);
  font-size: 13px;
}

.button,
.status {
  min-height: 38px;
  border-radius: 8px;
  padding: 0 12px;
  font-weight: 650;
}

.primary,
.status.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.progress-wrap {
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.progress-bar {
  height: 20px;
  overflow: hidden;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: #ecece6;
}

.progress-bar span {
  display: flex;
  width: 0;
  height: 100%;
  min-width: 0;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  transition: width 160ms ease;
}

.label-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
  margin-top: 8px;
}

.stat-chip,
.pill {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 8px;
  font-weight: 650;
}

.stat-chip {
  border: 1px solid var(--line);
  background: #fff;
}

.setup {
  display: grid;
  gap: 10px;
  padding: 14px 18px 16px;
  border-bottom: 1px solid var(--line);
}

.setup.collapsed {
  display: none;
}

.setup label {
  display: grid;
  gap: 5px;
  color: #3f3f46;
  font-size: 13px;
  font-weight: 650;
}

.setup input,
select,
textarea {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
}

.setup input {
  height: 40px;
  padding: 0 11px;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.sample-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 10px;
}

.sample {
  width: 100%;
  display: grid;
  gap: 7px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px;
}

.sample:hover {
  background: #f4f4ef;
}

.sample.active {
  background: var(--accent-soft);
  border-color: #8fc8bf;
  box-shadow: inset 3px 0 0 var(--accent);
}

.sample-title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.sample-text {
  color: #374151;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sample-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.pill {
  background: #e5e7eb;
  color: #374151;
}

.pill.done,
.stat-chip.keep,
.stat-chip.minor {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.pill.bad,
.stat-chip.text_bad,
.stat-chip.audio_bad,
.stat-chip.background_audio {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #fecaca;
}

.stat-chip.unsure {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #fde68a;
}

.review {
  display: grid;
  grid-template-rows: auto auto auto auto auto 1fr;
  gap: 16px;
  align-content: start;
  height: 100vh;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  padding: 24px;
}

.topbar,
.audio-row,
.label-panel {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 60px;
}

.nav,
.labels {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.audio-row,
.metrics,
.text-panel article,
.label-panel {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.audio-row {
  padding: 12px;
}

audio {
  width: min(780px, 100%);
}

.speed {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #3f3f46;
  font-weight: 650;
}

select {
  height: 38px;
  padding: 0 8px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 0;
  overflow: hidden;
}

.metric {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric strong {
  font-size: 15px;
  overflow-wrap: anywhere;
}

.text-panel {
  max-height: 42vh;
  min-height: 0;
  overflow-y: auto;
  display: grid;
  align-content: start;
}

.text-panel article {
  height: 100%;
  min-height: 100%;
  border-left: 5px solid var(--accent);
  padding: 18px;
}

.text-panel header {
  font-weight: 800;
  color: #374151;
  margin-bottom: 10px;
}

.text-panel p {
  font-size: 23px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.label-panel {
  align-items: stretch;
  padding: 12px;
}

.labels {
  flex: 1;
}

.label {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 0 8px;
  min-width: 124px;
  min-height: 58px;
  align-items: center;
  border-radius: 8px;
  padding: 8px 10px;
}

.label span {
  grid-row: 1 / 3;
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #f4f4ef;
  font-weight: 800;
}

.label strong,
.label small {
  overflow-wrap: anywhere;
}

.label.keep.active,
.label.minor.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.label.background_audio.active,
.label.text_bad.active,
.label.audio_bad.active {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.label.unsure.active {
  background: var(--warn);
  border-color: var(--warn);
  color: #fff;
}

.label.active small,
.label.active span {
  color: inherit;
}

.server-reviewed {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid #99d5c9;
  border-radius: 8px;
  background: #ecfdf5;
  color: var(--accent);
  padding: 10px 12px;
  font-weight: 750;
}

textarea {
  width: min(420px, 36vw);
  min-height: 74px;
  resize: vertical;
  padding: 10px;
}

.save-status {
  align-self: start;
  color: var(--muted);
  min-height: 1.2em;
  font-size: 14px;
  font-weight: 650;
}

.save-status.ok {
  color: var(--accent);
}

.save-status.err {
  color: var(--danger);
}

@media (max-width: 1180px) {
  .label-panel {
    display: grid;
    gap: 12px;
  }

  .label {
    min-width: calc(33.333% - 8px);
  }

  textarea {
    width: 100%;
  }
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric:nth-child(2) {
    border-right: 0;
  }

  .metric:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .shell {
    grid-template-columns: 1fr;
    height: auto;
  }

  .queue {
    height: 46vh;
    min-height: 46vh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .review {
    height: auto;
    min-height: 54vh;
    overflow: visible;
    padding: 16px;
  }

  .topbar,
  .audio-row,
  .label-panel {
    display: grid;
    gap: 12px;
  }

  .nav,
  .speed,
  .labels {
    margin-top: 0;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .label {
    min-width: calc(50% - 6px);
  }

  textarea {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .queue-head {
    grid-template-columns: 1fr;
  }

  .filters,
  .setup,
  .progress-wrap,
  .queue-head {
    padding-left: 12px;
    padding-right: 12px;
  }

  h2 {
    font-size: 22px;
  }

  .text-panel p {
    font-size: 20px;
  }

  .label {
    min-width: 100%;
  }
}
