:root {
  color-scheme: light;
  --bg: #f5f7f6;
  --panel: #ffffff;
  --ink: #1d2024;
  --muted: #66707a;
  --line: #d8dedc;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --blue: #4f46e5;
  --orange: #b45309;
  --warn: #b45309;
  --danger: #b42318;
  --good: #15803d;
  --shadow: 0 18px 48px rgba(31, 41, 55, 0.08);
  --top-pane-height: 760px;
}

* {
  box-sizing: border-box;
}

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

button,
textarea {
  font: inherit;
}

h1,
h2,
p {
  margin: 0;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  width: min(1800px, calc(100% - 88px));
  margin: 8px auto 0;
  padding: 28px 26px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.title-block {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.project-subtitle {
  max-width: 1220px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.58;
}

.project-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.project-badges span {
  padding: 6px 9px;
  border: 1px solid rgba(15, 118, 110, 0.18);
  border-radius: 8px;
  background: #edf7f5;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  max-width: 1380px;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 16px;
  line-height: 1.2;
  letter-spacing: 0;
}

.header-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 118px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--warn);
}

.status.ready .status-dot {
  background: var(--good);
}

.status.error .status-dot {
  background: var(--danger);
}

.workspace {
  display: grid;
  gap: 18px;
  width: min(1800px, calc(100% - 88px));
  margin: 26px auto;
}

.workspace.compare-mode {
  grid-template-columns:
    minmax(280px, 0.72fr) repeat(3, minmax(310px, 1.18fr));
}

.compare-mode .comparison-pane,
.compare-mode .risk-note-pane,
.compare-mode .benchmark-pane {
  grid-column: 1 / -1;
}

.compare-mode .base-json-pane {
  grid-column: 2;
  grid-row: 1;
}

.compare-mode .result-pane {
  grid-column: 3;
  grid-row: 1;
}

.compare-mode .teacher-pane {
  grid-column: 4;
  grid-row: 1;
}

.compare-mode .input-pane {
  display: flex;
  flex-direction: column;
  grid-column: 1;
  grid-row: 1;
  height: var(--top-pane-height);
  min-height: var(--top-pane-height);
}

.compare-mode .input-pane textarea {
  height: 350px;
  min-height: 350px;
  max-height: 350px;
  resize: none;
}

.compare-mode .model-pane {
  display: flex;
  flex-direction: column;
  height: var(--top-pane-height);
  min-height: var(--top-pane-height);
}

.compare-mode .model-pane .empty-state {
  flex: 1;
  min-height: 0;
}

.input-pane,
.model-pane,
.comparison-pane,
.risk-note-pane,
.benchmark-pane,
.debug-pane {
  min-width: 0;
  min-height: 620px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.comparison-pane,
.risk-note-pane,
.benchmark-pane,
.debug-pane {
  min-height: auto;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  margin-bottom: 16px;
}

.icon-button,
.primary-button,
.sample-button,
.small-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  place-items: center;
  padding: 0;
}

svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

textarea {
  display: block;
  width: 100%;
  min-height: 430px;
  resize: vertical;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: #fbfcfa;
  line-height: 1.55;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.input-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
}

.compare-mode .input-footer {
  align-items: stretch;
  flex-direction: column;
  flex: 1;
  justify-content: space-between;
  margin-top: 14px;
  padding: 0 0 26px;
}

.sample-group {
  display: grid;
  gap: 8px;
}

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

.sample-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sample-hint {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.samples {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.compare-mode .samples {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.sample-button {
  min-height: 36px;
  padding: 0 12px;
  color: var(--accent-dark);
  font-weight: 800;
}

.compare-mode .sample-button {
  width: 100%;
  padding: 0 10px;
  font-size: 14px;
  white-space: nowrap;
}

.sample-button:hover,
.icon-button:hover,
.small-button:hover {
  border-color: var(--accent);
  background: #f3fbf9;
  color: var(--accent-dark);
}

.sample-button.active {
  border-color: var(--accent);
  background: #e8f4f2;
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.2);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  height: 40px;
  padding: 0 16px;
  border-color: var(--accent);
  background: var(--accent);
  color: white;
  font-weight: 800;
}

.compare-mode .primary-button {
  align-self: stretch;
  width: 100%;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.small-button {
  height: 32px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.language-toggle {
  min-width: 72px;
  color: var(--accent-dark);
  font-weight: 800;
}

.model-state {
  padding: 6px 10px;
  border-radius: 8px;
  background: #f2f5f1;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.empty-state {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  min-height: 520px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.compact-empty {
  min-height: 96px;
}

.empty-state svg {
  width: 34px;
  height: 34px;
}

.hidden {
  display: none !important;
}

.result-content {
  display: grid;
  gap: 18px;
}

.compare-mode .result-content {
  flex: 1;
  gap: 12px;
  min-height: 0;
  overflow: auto;
}

.model-output {
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.compare-mode .model-output {
  gap: 10px;
  padding: 14px;
  min-height: min-content;
}

.fine-tuned-output {
  border-color: rgba(15, 118, 110, 0.36);
  background: #fbfefd;
}

.prompted-output {
  border-color: rgba(79, 70, 229, 0.24);
  background: #fbfbff;
}

.teacher-output {
  border-color: rgba(180, 83, 9, 0.28);
  background: #fffdf8;
}

.model-output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.small-eyebrow {
  margin-bottom: 3px;
  font-size: 11px;
}

.model-badge {
  padding: 6px 9px;
  border-radius: 8px;
  background: #e8f4f2;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.model-note {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.prompted-badge {
  background: #eef2ff;
  color: #3730a3;
}

.teacher-badge {
  background: #fff7ed;
  color: #9a3412;
}

.score-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.compare-mode .score-row {
  padding: 14px;
}

.field-label {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.sentiment {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 10px;
}

.sentiment-label {
  font-size: 30px;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
}

.compare-mode .sentiment-label {
  font-size: 24px;
}

.score-value {
  color: var(--muted);
}

.risk-flag {
  padding: 8px 10px;
  border-radius: 8px;
  background: #eef8f0;
  color: var(--good);
  font-size: 14px;
  font-weight: 800;
  white-space: nowrap;
}

.risk-flag.risky {
  background: #fff3e6;
  color: var(--warn);
}

.score-meter {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7df;
}

.score-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 160ms ease;
}

.prompted-score-fill {
  background: var(--blue);
}

.teacher-score-fill {
  background: var(--orange);
}

.field-block {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.compare-mode .field-block {
  padding: 12px;
}

.compare-mode .reasoning {
  max-height: 180px;
  overflow: auto;
}

.ticker-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.ticker {
  padding: 5px 9px;
  border-radius: 8px;
  background: #e8f4f2;
  color: var(--accent-dark);
  font-size: 14px;
  font-weight: 800;
}

.reasoning {
  color: #303437;
  line-height: 1.65;
  word-break: break-word;
}

.raw-block {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
}

.raw-block summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 800;
}

pre {
  margin: 12px 0 0;
  overflow: auto;
  max-height: 240px;
  padding: 12px;
  border-radius: 8px;
  background: #161a1d;
  color: #f4f6f8;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.comparison-content {
  display: grid;
  gap: 12px;
}

.comparison-content > p {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
  line-height: 1.6;
}

.comparison-intro {
  color: #3d464d;
}

.risk-note-pane {
  padding: 12px 16px;
  box-shadow: none;
  background: #fffaf3;
}

.risk-note-pane p {
  color: #5f6368;
  font-size: 13px;
  line-height: 1.55;
}

.risk-note-pane strong {
  color: #3d464d;
}

.lesson-card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.lesson-card h3 {
  margin-top: 4px;
  font-size: 19px;
  line-height: 1.25;
}

.lesson-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.lesson-note,
.teacher-reference {
  margin-top: 8px;
  color: #3d464d;
  line-height: 1.58;
}

.teacher-reference {
  font-weight: 750;
}

.lesson-takeaway {
  border-color: rgba(15, 118, 110, 0.28);
  background: #f3fbf9;
}

.positive-takeaway h3 {
  color: var(--accent-dark);
}

.insight-list {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.insight-list li {
  color: #303437;
  line-height: 1.58;
}

.hidden-insight-card {
  border-color: rgba(15, 118, 110, 0.28);
  box-shadow: inset 3px 0 0 var(--accent);
}

.compact-reasoning-card {
  display: grid;
  gap: 16px;
  padding: 18px;
}

.compact-reasoning-card .signal-chips {
  margin-top: 0;
}

.reasoning-card-head {
  display: grid;
  gap: 8px;
  max-width: 980px;
}

.reasoning-card-head h3 {
  margin: 0;
  font-size: 21px;
  line-height: 1.32;
}

.reasoning-panel-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
}

.reasoning-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.reasoning-panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.reasoning-panel-text {
  margin-top: 8px;
  color: #303437;
  font-size: 14px;
  line-height: 1.58;
}

.before-panel {
  border-color: rgba(79, 70, 229, 0.18);
  background: #fbfbff;
}

.after-panel {
  border-color: rgba(15, 118, 110, 0.24);
  background: #f8fffd;
}

.why-panel {
  border-color: rgba(180, 83, 9, 0.18);
  background: #fffdf8;
}

.compact-insight-list {
  gap: 8px;
  margin-top: 8px;
}

.compact-insight-list li {
  font-size: 14px;
  line-height: 1.5;
}

.signal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.signal-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e8f4f2;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 850;
}

.muted-chip {
  background: #eef1ef;
  color: var(--muted);
}

.comparison-footer {
  font-weight: 780;
}

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

.benchmark-grid > div {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.benchmark-grid p + p {
  margin-top: 6px;
}

.metric-table {
  width: 100%;
  margin-top: 12px;
  border-collapse: collapse;
  font-size: 13px;
}

.metric-table th,
.metric-table td {
  padding: 9px 8px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.metric-table th {
  color: var(--muted);
  font-weight: 850;
  line-height: 1.3;
}

.metric-table td {
  color: #303437;
}

.metric-table td:last-child {
  color: var(--accent-dark);
}

.benchmark-note {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.55;
}

.benchmark-baseline {
  margin-top: 12px;
  color: #3d464d;
  line-height: 1.55;
}

.debug-panel {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

.debug-card {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.debug-card span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.debug-card strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.debug-error {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid #f3c8c4;
  border-radius: 8px;
  background: #fff7f6;
  color: var(--danger);
  line-height: 1.45;
  word-break: break-word;
}

.debug-timeline {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.debug-timeline li {
  position: relative;
  padding: 10px 10px 10px 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.debug-timeline li::before {
  content: "";
  position: absolute;
  top: 15px;
  left: 11px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.debug-timeline strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.debug-timeline span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.debug-timeline code {
  display: block;
  overflow: auto;
  margin-top: 6px;
  padding: 7px;
  border-radius: 6px;
  background: #f2f5f1;
  color: #303437;
  font-size: 12px;
  line-height: 1.4;
  white-space: pre-wrap;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(420px, calc(100vw - 48px));
  padding: 12px 14px;
  border: 1px solid #f3c8c4;
  border-radius: 8px;
  background: #fff7f6;
  color: var(--danger);
  box-shadow: var(--shadow);
}

@media (max-width: 1100px) {
  .workspace.compare-mode {
    grid-template-columns: 1fr;
    width: min(100% - 28px, 760px);
  }

  .compare-mode .input-pane,
  .compare-mode .model-pane {
    height: auto;
    min-height: auto;
  }

  .compare-mode .result-content {
    overflow: visible;
  }

  .compare-mode .teacher-pane,
  .compare-mode .comparison-pane,
  .compare-mode .risk-note-pane,
  .compare-mode .benchmark-pane {
    grid-column: auto;
    grid-row: auto;
  }

  .compare-mode .input-pane {
    grid-column: auto;
  }

  .compare-mode .base-json-pane,
  .compare-mode .result-pane {
    grid-column: auto;
    grid-row: auto;
  }

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

@media (max-width: 760px) {
  .topbar,
  .input-footer,
  .score-row,
  .debug-head,
  .model-output-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    padding-inline: 16px;
  }

  .header-actions {
    justify-content: stretch;
    align-items: stretch;
    width: 100%;
    padding-top: 0;
  }

  .input-pane,
  .model-pane,
  .comparison-pane,
  .risk-note-pane,
  .benchmark-pane,
  .debug-pane {
    min-height: auto;
    padding: 18px;
  }

  textarea {
    min-height: 260px;
  }

  .primary-button {
    width: 100%;
  }

  .benchmark-grid,
  .debug-grid {
    grid-template-columns: 1fr;
  }
}
