:root {
  color-scheme: light;
  --bg: #f6f4ee;
  --ink: #111827;
  --muted: #5f655e;
  --soft: #eef0e6;
  --card: rgba(255, 255, 255, 0.78);
  --card-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(17, 24, 39, 0.12);
  --line-strong: rgba(17, 24, 39, 0.2);
  --accent: #ddf299;
  --accent-ink: #1e2b0a;
  --danger: #b42318;
  --warning: #9a5b00;
  --success: #177245;
  --shadow: 0 24px 80px rgba(17, 24, 39, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(221, 242, 153, 0.88), transparent 34rem),
    radial-gradient(circle at bottom right, rgba(214, 220, 255, 0.7), transparent 28rem),
    var(--bg);
}

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

button {
  cursor: pointer;
}

.page-shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero,
.stats-grid,
.toolbar,
.cases-card,
.detail-card {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.login-card {
  width: min(760px, 100%);
  margin: 9vh auto 0;
  padding: clamp(28px, 5vw, 56px);
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--card-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.login-form {
  display: grid;
  gap: 14px;
  max-width: 420px;
  margin-top: 30px;
}

.login-form label {
  display: grid;
  gap: 8px;
}

.login-form label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-form button,
.auth-bar button {
  min-height: 44px;
  border: 1px solid rgba(30, 43, 10, 0.18);
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 24px;
  align-items: center;
  min-height: 300px;
  padding: clamp(24px, 4vw, 48px);
  border-radius: 30px;
}

.top-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.auth-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.64);
}

.auth-bar span {
  padding-left: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-bar button {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid rgba(30, 43, 10, 0.16);
  border-radius: 999px;
  background: rgba(221, 242, 153, 0.64);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

h1 {
  max-width: 860px;
  margin: 24px 0 16px;
  font-size: clamp(40px, 6vw, 74px);
  line-height: 0.94;
  letter-spacing: -0.07em;
}

.lede {
  max-width: 850px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(16px, 2vw, 20px);
  line-height: 1.48;
}

.hero-widget {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.62);
}

.hero-widget strong,
.hero-widget span {
  display: block;
}

.hero-widget span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
  padding: 12px;
  border-radius: 24px;
}

.stat-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  letter-spacing: -0.05em;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 190px 160px 220px;
  gap: 12px;
  margin-top: 18px;
  padding: 14px;
  border-radius: 24px;
}

.toolbar label,
.search-box {
  display: grid;
  gap: 7px;
}

.toolbar span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.84);
  color: var(--ink);
  outline: none;
}

input,
select {
  min-height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 92px;
  padding: 12px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(30, 43, 10, 0.44);
  box-shadow: 0 0 0 4px rgba(221, 242, 153, 0.55);
}

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(380px, 520px);
  gap: 18px;
  margin-top: 18px;
  align-items: start;
}

.cases-card,
.detail-card {
  border-radius: 26px;
  overflow: hidden;
}

.table-scroll {
  max-height: 72vh;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(250, 250, 246, 0.96);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.case-row {
  cursor: pointer;
  transition: background 150ms ease;
}

.case-row:hover,
.case-row.selected {
  background: rgba(221, 242, 153, 0.2);
}

.case-button {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.case-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.case-title {
  display: block;
  min-width: 0;
  overflow: hidden;
  font-weight: 760;
  letter-spacing: -0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.index-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 2px 7px;
  border: 1px solid rgba(17, 24, 39, 0.14);
  border-radius: 999px;
  background: rgba(17, 24, 39, 0.06);
  color: var(--ink);
  font-size: 11px;
  font-weight: 820;
  flex-shrink: 0;
}

.case-subtitle,
.feedback-snippet,
.empty-cell {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.case-subtitle {
  display: block;
  margin-top: 5px;
}

.pill-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.status-pill,
.review-pill,
.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.status-pill.success,
.review-pill.looks_good {
  border-color: rgba(23, 114, 69, 0.22);
  background: rgba(23, 114, 69, 0.1);
  color: var(--success);
}

.status-pill.failure,
.review-pill.needs_adjustment {
  border-color: rgba(180, 35, 24, 0.22);
  background: rgba(180, 35, 24, 0.1);
  color: var(--danger);
}

.status-pill.unknown {
  border-color: rgba(154, 91, 0, 0.22);
  background: rgba(154, 91, 0, 0.1);
  color: var(--warning);
}

.review-pill.unreviewed {
  color: var(--muted);
}

.difficulty-pill.easy {
  border-color: rgba(23, 114, 69, 0.2);
  background: rgba(23, 114, 69, 0.08);
  color: var(--success);
}

.difficulty-pill.medium {
  border-color: rgba(154, 91, 0, 0.2);
  background: rgba(154, 91, 0, 0.08);
  color: var(--warning);
}

.difficulty-pill.hard,
.priority-pill.p0 {
  border-color: rgba(180, 35, 24, 0.2);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.priority-pill.p1 {
  border-color: rgba(154, 91, 0, 0.2);
  background: rgba(154, 91, 0, 0.08);
  color: var(--warning);
}

.priority-pill.p2 {
  border-color: rgba(23, 114, 69, 0.2);
  background: rgba(23, 114, 69, 0.08);
  color: var(--success);
}

.detail-card {
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--card-strong);
}

.detail-empty,
.detail-content {
  padding: 22px;
}

.detail-empty h2,
.detail-head h2,
.panel-title h3,
.scenario-box h3 {
  margin: 0;
  letter-spacing: -0.04em;
}

.detail-empty p {
  color: var(--muted);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.detail-content {
  overflow: auto;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.detail-meta {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 740;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.scenario-box,
.conversation-panel,
.review-panel {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.58);
}

.scenario-box h3 + p {
  margin-top: 6px;
}

.scenario-box p {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.48;
}

.panel-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title span {
  color: var(--muted);
  font-size: 12px;
}

.conversation-list {
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}

.turn {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.76);
}

.turn.user {
  background: rgba(221, 242, 153, 0.22);
}

.turn.tool {
  background: rgba(17, 24, 39, 0.04);
}

.turn-role {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.turn p {
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.tool-block {
  margin-top: 8px;
  padding: 10px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.06);
  font-size: 12px;
  line-height: 1.45;
}

.tool-block code {
  display: block;
  margin-top: 6px;
  overflow: auto;
  color: #28320d;
  white-space: pre-wrap;
}

.reviewer-grid {
  display: grid;
  gap: 12px;
}

.reviewer-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.66);
}

.reviewer-card.locked {
  opacity: 0.58;
}

.permission-note {
  display: none;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.06);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.reviewer-card.locked .permission-note {
  display: block;
}

.reviewer-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.reviewer-title span {
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.6);
  font-size: 13px;
  font-weight: 680;
}

.reviewer-card button {
  min-height: 42px;
  border: 1px solid rgba(30, 43, 10, 0.18);
  border-radius: 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 780;
}

.save-message {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.save-message.error {
  color: var(--danger);
}

@media (max-width: 1180px) {
  .review-layout,
  .hero {
    grid-template-columns: 1fr;
  }

  .detail-card {
    position: static;
    max-height: none;
  }
}

@media (max-width: 780px) {
  .page-shell {
    width: min(100% - 20px, 1480px);
    padding-top: 16px;
  }

  .stats-grid,
  .toolbar {
    grid-template-columns: 1fr;
  }

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4),
  th:nth-child(5),
  td:nth-child(5) {
    display: none;
  }

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

/* Compact review workspace overrides */
@media (min-width: 781px) {
  body {
    overflow: hidden;
  }

  .page-shell {
    width: calc(100vw - 12px);
    max-width: none;
    padding: 6px 0;
  }

  #appContent {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 12px);
    min-height: 0;
  }

  .hero {
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 0;
    padding: 8px 10px;
    border-radius: 16px;
    gap: 10px;
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.08);
  }

  .top-line {
    gap: 8px;
  }

  .eyebrow {
    padding: 4px 8px;
    font-size: 10px;
  }

  .auth-bar {
    gap: 6px;
    padding: 3px;
  }

  .auth-bar span {
    padding-left: 8px;
    font-size: 12px;
  }

  .auth-bar button {
    min-height: 28px;
    padding: 0 10px;
    font-size: 12px;
  }

  h1 {
    margin: 8px 0 3px;
    max-width: none;
    font-size: 24px;
    line-height: 1;
    letter-spacing: -0.045em;
  }

  .lede {
    max-width: none;
    font-size: 12px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero-widget {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px;
    border-radius: 14px;
  }

  .hero-widget strong {
    font-size: 12px;
    white-space: nowrap;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
    margin-top: 6px;
    padding: 6px;
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.07);
  }

  .stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 12px;
  }

  .stat-card span {
    font-size: 10px;
  }

  .stat-card strong {
    margin-top: 0;
    font-size: 18px;
  }

  .toolbar {
    grid-template-columns: minmax(280px, 1fr) 190px 140px 190px;
    gap: 7px;
    margin-top: 6px;
    padding: 7px;
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.07);
  }

  .toolbar label,
  .search-box {
    gap: 3px;
  }

  .toolbar span {
    font-size: 9px;
  }

  input,
  select {
    min-height: 32px;
    padding: 0 9px;
    border-radius: 10px;
    font-size: 12px;
  }

  .review-layout {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1.22fr) minmax(540px, 0.78fr);
    gap: 8px;
    margin-top: 6px;
    align-items: stretch;
  }

  .cases-card,
  .detail-card {
    min-height: 0;
    height: 100%;
    border-radius: 16px;
    box-shadow: 0 8px 28px rgba(17, 24, 39, 0.08);
  }

  .detail-card {
    position: static;
    max-height: none;
  }

  .table-scroll {
    height: 100%;
    max-height: none;
  }

  th,
  td {
    padding: 7px 8px;
  }

  th {
    font-size: 9px;
  }

  .case-title {
    font-size: 13px;
  }

  .case-subtitle,
  .feedback-snippet,
  .empty-cell {
    font-size: 11px;
    line-height: 1.28;
  }

  .case-button .case-subtitle:last-child,
  .feedback-snippet {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .pill-line {
    gap: 4px;
    margin-top: 4px;
  }

  .status-pill,
  .review-pill,
  .meta-pill {
    min-height: 20px;
    padding: 2px 7px;
    font-size: 10px;
  }

  .detail-empty,
  .detail-content {
    padding: 10px;
  }

  .detail-content {
    min-height: 0;
  }

  .detail-head {
    position: sticky;
    top: 0;
    z-index: 2;
    align-items: center;
    gap: 8px;
    margin: -10px -10px 8px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
  }

  .detail-head h2 {
    font-size: 18px;
  }

  .detail-meta {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .detail-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .detail-actions button {
    min-height: 30px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.8);
    color: var(--ink);
    font-size: 12px;
    font-weight: 760;
  }

  .detail-actions button:not(:disabled):hover {
    background: var(--accent);
    color: var(--accent-ink);
  }

  .detail-actions button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
  }

  .scenario-box,
  .conversation-panel,
  .review-panel {
    margin-top: 8px;
    padding: 10px;
    border-radius: 14px;
  }

  .scenario-box p {
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.35;
  }

  .panel-title {
    margin-bottom: 8px;
  }

  .panel-title h3,
  .scenario-box h3 {
    font-size: 14px;
  }

  .conversation-list {
    max-height: 42vh;
    gap: 6px;
  }

  .turn {
    padding: 8px;
    border-radius: 12px;
  }

  .turn-role {
    margin-bottom: 4px;
    font-size: 9px;
  }

  .turn p {
    font-size: 12px;
    line-height: 1.34;
  }

  .tool-block {
    margin-top: 6px;
    padding: 7px;
    font-size: 11px;
  }

  .reviewer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .reviewer-card {
    gap: 7px;
    padding: 8px;
    border-radius: 12px;
  }

  .reviewer-title span,
  .permission-note,
  .save-message {
    font-size: 11px;
  }

  .segmented {
    gap: 5px;
  }

  .segmented label {
    min-height: 30px;
    padding: 5px 7px;
    border-radius: 9px;
    font-size: 11px;
  }

  textarea {
    min-height: 58px;
    padding: 8px;
    border-radius: 10px;
    font-size: 12px;
  }

  .reviewer-card button {
    min-height: 32px;
    border-radius: 10px;
    font-size: 12px;
  }
}

/* Keep ElevenLabs widget out of the review workflow */
.voice-dock {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100vw - 28px));
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 16px 48px rgba(17, 24, 39, 0.16);
  backdrop-filter: blur(18px);
}

.voice-dock > span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.voice-dock elevenlabs-convai {
  display: block;
  width: 260px;
  max-width: 260px;
  min-height: 44px;
}

@media (min-width: 781px) {
  .voice-dock {
    transform: scale(0.82);
    transform-origin: bottom right;
  }

  .page-shell {
    width: calc(100vw - 6px);
  }

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

  .case-title-line {
    gap: 6px;
  }

  .index-pill {
    min-width: 38px;
    padding: 1px 6px;
    font-size: 10px;
  }

  .compact-pills .meta-pill {
    max-width: 155px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .tools-line {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
  }

  th:nth-child(1),
  td:nth-child(1) {
    width: 45%;
  }

  th:nth-child(2),
  td:nth-child(2) {
    width: 16%;
  }

  th:nth-child(3),
  td:nth-child(3),
  th:nth-child(4),
  td:nth-child(4) {
    width: 12%;
  }

  th:nth-child(5),
  td:nth-child(5) {
    width: 15%;
  }
}

@media (max-width: 780px) {
  .voice-dock {
    right: 10px;
    bottom: 10px;
    max-width: calc(100vw - 20px);
  }

  .voice-dock > span {
    display: none;
  }

  .voice-dock elevenlabs-convai {
    width: min(300px, calc(100vw - 40px));
    max-width: min(300px, calc(100vw - 40px));
  }
}
