:root {
  --bg: #f4f6f4;
  --ink: #151b1d;
  --muted: #66706f;
  --line: #d8dfdc;
  --panel: #ffffff;
  --panel-soft: #eef4f1;
  --target: #b74336;
  --distractor: #2f6f8e;
  --green: #2f7d57;
  --gold: #bc842a;
  --shadow: 0 18px 45px rgba(28, 38, 36, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border-radius: 7px;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 28px;
}

.topbar {
  align-items: end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 0 auto 20px;
  max-width: 1480px;
}

.eyebrow {
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3.4vw, 46px);
  line-height: 1.04;
  max-width: 860px;
}

h2 {
  font-size: 18px;
}

.main-tabs {
  background: #e4eae7;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 4px;
  padding: 4px;
}

.main-tabs button {
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  min-width: 150px;
  padding: 11px 14px;
}

.main-tabs button.active {
  background: var(--ink);
  color: #fff;
}

.tab-panel {
  display: none;
  margin: 0 auto;
  max-width: 1480px;
}

.tab-panel.active {
  display: block;
}

.summary-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  margin-bottom: 18px;
}

.metric,
.side-panel,
.browser-panel,
.cost-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 16px;
}

.metric span,
.cost-card span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 7px;
  text-transform: uppercase;
}

.metric strong,
.cost-card strong {
  display: block;
  font-size: 24px;
}

.metric small,
.cost-card small {
  color: var(--muted);
  display: block;
  margin-top: 6px;
}

.workspace {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
}

.cost-stack {
  display: grid;
  gap: 18px;
}

.side-panel {
  align-self: start;
  max-height: calc(100vh - 150px);
  overflow: auto;
  padding: 18px;
  position: sticky;
  top: 20px;
}

.browser-panel,
.transcript-panel {
  min-height: 600px;
  padding: 18px;
}

.panel-block + .panel-block {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 18px;
}

.field {
  display: grid;
  gap: 7px;
  margin-top: 14px;
}

.field span,
.card-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input[type="number"],
input[type="range"] {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  min-height: 40px;
  padding: 8px 10px;
  width: 100%;
}

.checkbox-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.mini-stats {
  display: grid;
  gap: 9px;
  margin-top: 14px;
}

.mini-stats div,
.smoke-result,
.result-grid {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px;
}

.mini-stats strong {
  display: block;
  font-size: 18px;
}

.mini-stats span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.result-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr auto;
  margin-top: 10px;
}

.result-grid span {
  color: var(--muted);
}

.panel-heading,
.case-topline,
.panel-title-row,
.transcript-toolbar,
.toolbar-actions {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.toolbar-actions {
  align-items: center;
}

.toolbar-actions input {
  background: #fff;
  border: 1px solid var(--line);
  min-height: 40px;
  min-width: 260px;
  padding: 8px 10px;
}

.legend {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 12px;
}

.dot {
  border-radius: 50%;
  display: inline-block;
  height: 9px;
  margin-right: 5px;
  width: 9px;
}

.dot.target {
  background: var(--target);
}

.dot.distractor {
  background: var(--distractor);
}

.case-list {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.target-card {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 12px;
  padding: 13px;
}

.target-card.soft-blue {
  background: #eef4f8;
}

.target-card p {
  font-size: 13px;
  line-height: 1.45;
  margin: 7px 0 12px;
}

.target-card button,
.ghost-button {
  background: var(--ink);
  border: 0;
  color: white;
  font-size: 13px;
  font-weight: 800;
  padding: 9px 11px;
}

.ghost-button {
  background: #e8eeeb;
  color: var(--ink);
}

.persona-strip {
  background: #f7f9f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #303b39;
  font-size: 13px;
  line-height: 1.45;
  margin: 14px 0;
  padding: 12px;
}

.context-rail {
  background: #d8dfdc;
  border-radius: 999px;
  height: 18px;
  margin: 12px 0 10px;
  position: relative;
}

.rail-marker {
  border-radius: 999px;
  bottom: 0;
  min-width: 8px;
  position: absolute;
  top: 0;
  width: 8px;
}

.rail-marker.target {
  background: var(--target);
  box-shadow: 0 0 0 3px rgba(183, 67, 54, 0.18);
}

.rail-marker.distractor {
  background: var(--distractor);
  box-shadow: 0 0 0 3px rgba(47, 111, 142, 0.18);
}

.rail-legend {
  margin-bottom: 12px;
}

.transcript {
  border-top: 1px solid var(--line);
  max-height: calc(100vh - 310px);
  overflow: auto;
  padding-top: 12px;
}

.turn {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 120px minmax(0, 1fr);
  margin-bottom: 10px;
  padding: 12px;
}

.turn.target {
  border-color: rgba(183, 67, 54, 0.55);
  box-shadow: inset 3px 0 0 var(--target);
}

.turn.distractor {
  border-color: rgba(47, 111, 142, 0.55);
  box-shadow: inset 3px 0 0 var(--distractor);
}

.turn-meta {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 800;
  gap: 5px;
  text-transform: uppercase;
}

.turn-text {
  font-size: 14px;
  line-height: 1.55;
}

.badge {
  border-radius: 999px;
  color: white;
  display: inline-block;
  font-size: 11px;
  padding: 4px 7px;
  width: fit-content;
}

.badge.target {
  background: var(--target);
}

.badge.distractor {
  background: var(--distractor);
}

mark {
  background: #ffe08c;
  border-radius: 3px;
  padding: 0 2px;
}

.case-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.case-topline strong {
  display: block;
  font-size: 15px;
}

.case-topline span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  margin-top: 3px;
}

.pill {
  background: #e7edf2;
  border-radius: 999px;
  color: #28556f !important;
  font-weight: 800;
  padding: 6px 9px;
  white-space: nowrap;
}

.question {
  color: #25302f;
  font-size: 15px;
  line-height: 1.45;
  margin: 14px 0;
}

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

.evidence-grid div {
  background: #f7f9f8;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.evidence-grid p {
  font-size: 13px;
  line-height: 1.45;
  margin: 7px 0 0;
}

.target-text {
  border-left: 3px solid var(--target);
  padding-left: 9px;
}

.distractor-text {
  border-left: 3px solid var(--distractor);
  padding-left: 9px;
}

.cost-cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  margin: 18px 0;
}

.usage-panel {
  min-height: 0;
}

.usage-controls {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 2fr 1fr 1fr;
  margin-top: 16px;
}

.mini-stats.inline {
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  margin-top: 0;
  min-width: 470px;
}

.cost-card {
  padding: 18px;
}

.cost-card strong {
  font-size: 34px;
}

.note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  margin: 0;
  max-width: 420px;
}

.poisson-chart {
  align-items: end;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 2px;
  height: 160px;
  margin-top: 14px;
  padding: 12px 10px 26px;
}

.bar {
  background: var(--green);
  border-radius: 4px 4px 0 0;
  flex: 1;
  min-width: 5px;
  opacity: 0.86;
  position: relative;
}

.bar span {
  bottom: -20px;
  color: var(--muted);
  font-size: 9px;
  left: 50%;
  position: absolute;
  transform: translateX(-50%) rotate(-45deg);
  transform-origin: center;
}

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

.cost-table {
  border-collapse: collapse;
  min-width: 760px;
  width: 100%;
}

.cost-table th,
.cost-table td {
  border-bottom: 1px solid var(--line);
  padding: 12px 10px;
  text-align: right;
}

.cost-table th:first-child,
.cost-table td:first-child {
  text-align: left;
}

.cost-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

@media (max-width: 960px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .panel-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .main-tabs {
    width: 100%;
  }

  .main-tabs button {
    min-width: 0;
    width: 50%;
  }

  .workspace,
  .cost-stack,
  .evidence-grid,
  .cost-cards,
  .usage-controls,
  .mini-stats.inline {
    grid-template-columns: 1fr;
  }

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

  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions input {
    min-width: 0;
    width: 100%;
  }

  .transcript {
    max-height: none;
  }

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