:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #151820;
  --muted: #5d6472;
  --line: #d9dee8;
  --chemical: #0b51d6;
  --chemical-soft: #eaf1ff;
  --transcript: #13803d;
  --transcript-soft: #eaf7ee;
  --operator: #6a2eb8;
  --operator-soft: #f1e9ff;
  --warn: #d72c22;
  --up: #13803d;
  --down: #0b51d6;
  --neutral: #7a808c;
  --shadow: 0 18px 48px rgba(32, 39, 57, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100% - 40px));
  margin: 0 auto;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  padding: 28px 0 18px;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--operator);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.08;
}

h2 {
  margin-bottom: 4px;
  font-size: 22px;
}

h3 {
  margin-bottom: 0;
  font-size: 16px;
}

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

.language-button {
  min-height: 40px;
  border: 1px solid var(--operator);
  border-radius: 8px;
  color: var(--operator);
  background: #fff;
  padding: 0 14px;
  font-weight: 900;
  cursor: pointer;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--up);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 430px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  padding-bottom: 40px;
}

.input-panel,
.results-panel,
.evidence-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.results-panel {
  padding: 18px;
}

.section-title {
  display: flex;
  gap: 12px;
  align-items: start;
  margin-bottom: 16px;
}

.section-title p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.4;
}

.step-index {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--operator-soft);
  color: var(--operator);
  font-weight: 800;
  flex: 0 0 auto;
}

.predict-form {
  display: grid;
  gap: 10px;
}

.cell-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 6px;
  padding: 0;
  border: 0;
}

.cell-picker legend {
  grid-column: 1 / -1;
  margin-bottom: 2px;
  color: var(--ink);
  font-weight: 700;
}

.cell-picker label {
  cursor: pointer;
}

.cell-picker input {
  position: absolute;
  opacity: 0;
}

.cell-picker span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  transition: 160ms ease;
}

.cell-picker input:checked + span {
  border-color: var(--operator);
  background: var(--operator-soft);
  color: var(--operator);
}

.field-label {
  color: var(--ink);
  font-weight: 700;
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  color: var(--ink);
  padding: 10px 11px;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
}

input:focus,
textarea:focus {
  border-color: var(--operator);
  box-shadow: 0 0 0 3px rgba(106, 46, 184, 0.13);
}

.gene-status {
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 700;
}

.gene-status.supported {
  color: #0f6b32;
  background: var(--transcript-soft);
  border: 1px solid #b7dfc2;
}

.gene-status.unsupported {
  color: #9b2a20;
  background: #fff0ef;
  border: 1px solid #f0b7b1;
}

.gene-status.pending {
  color: var(--muted);
  background: #f4f6fa;
  border: 1px solid var(--line);
}

.button-row {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--operator);
  padding: 0 14px;
  cursor: pointer;
  font-weight: 800;
}

.primary-button {
  flex: 1;
  color: #fff;
  background: var(--operator);
}

.ghost-button {
  color: var(--operator);
  background: #fff;
}

.scope-note {
  margin-top: 16px;
  border-left: 4px solid var(--operator);
  background: #fbfaff;
  padding: 12px;
  color: var(--muted);
  line-height: 1.5;
  border-radius: 4px;
}

.scope-note.muted {
  border-left-color: #b9bfca;
  background: #fafbfc;
}

.result-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.direction-card,
.score-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-height: 132px;
  background: #fbfcff;
}

.card-label {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.direction-word {
  font-size: clamp(38px, 5vw, 58px);
  line-height: 0.95;
  font-weight: 900;
}

.direction-word.up {
  color: var(--up);
}

.direction-word.down {
  color: var(--down);
}

.direction-word.abstain {
  color: var(--neutral);
  font-size: clamp(30px, 4vw, 42px);
}

.confidence-chip {
  display: inline-flex;
  margin-top: 12px;
  padding: 6px 9px;
  border-radius: 999px;
  background: #eceff4;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-meter {
  position: relative;
  height: 20px;
  overflow: hidden;
  border-radius: 999px;
  background: linear-gradient(90deg, #dce8ff 0%, #eceff4 50%, #dcf3e4 100%);
  border: 1px solid var(--line);
}

.score-fill {
  height: 100%;
  width: 0%;
  background: rgba(106, 46, 184, 0.85);
  transition: width 220ms ease;
}

.score-midline {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  opacity: 0.9;
}

.score-value {
  margin-top: 14px;
  font-size: 36px;
  line-height: 1;
  font-weight: 900;
}

.cell-badge {
  display: inline-flex;
  min-width: 76px;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--operator);
  background: var(--operator-soft);
  font-weight: 900;
  font-size: 26px;
}

.small-copy {
  margin-top: 10px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.35;
  font-size: 13px;
}

.evidence-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}

.evidence-box {
  padding: 14px;
}

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

.box-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.heading-with-help {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.help-button,
.modal-close,
.copy-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--operator);
  cursor: pointer;
  font-weight: 900;
}

.help-button {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.structure-tabs {
  display: inline-flex;
  gap: 6px;
  margin-bottom: 10px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f6fa;
}

.structure-tab {
  min-width: 48px;
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
}

.structure-tab.active {
  background: #fff;
  color: var(--operator);
  box-shadow: 0 1px 4px rgba(32, 39, 57, 0.12);
}

.structure-view {
  width: 100%;
  height: 260px;
  display: none;
  background: #fbfcff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}

.structure-view.active {
  display: grid;
  place-items: center;
}

.structure-view svg {
  width: 100%;
  height: 100%;
}

#structure-3d {
  min-height: 260px;
}

.structure-placeholder {
  color: var(--muted);
  font-weight: 700;
  text-align: center;
  padding: 20px;
}

.transcript-track {
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 14px;
}

.selected-sequences {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.sequence-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 10px;
}

.sequence-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.sequence-card strong {
  color: var(--ink);
}

.sequence-text {
  margin: 0;
  max-height: 96px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  color: #263142;
}

.copy-button {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}

.track-axis {
  position: relative;
  height: 22px;
  border-radius: 999px;
  background: repeating-linear-gradient(90deg, #dceedd 0 12px, #c7e2ca 12px 18px);
  border: 1px solid #b7d8bc;
}

.window-block {
  position: absolute;
  top: -8px;
  height: 36px;
  border: 2px solid var(--operator);
  border-radius: 8px;
  background: rgba(106, 46, 184, 0.18);
}

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

.window-meta div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
}

.window-meta strong {
  display: block;
  color: var(--ink);
  font-size: 13px;
}

.path-strip {
  display: grid;
  grid-template-columns: auto 28px auto 28px auto 28px auto 28px auto;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  padding-bottom: 6px;
}

.path-node {
  display: grid;
  place-items: center;
  min-height: 48px;
  min-width: 120px;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 8px 10px;
  font-weight: 800;
  text-align: center;
  font-size: 13px;
}

.path-node.chemical {
  color: var(--chemical);
  background: var(--chemical-soft);
  border-color: #aac5ff;
}

.path-node.transcript {
  color: var(--transcript);
  background: var(--transcript-soft);
  border-color: #add9bb;
}

.path-node.operator {
  color: var(--operator);
  background: var(--operator-soft);
  border-color: #d4bdf8;
}

.path-node.output {
  color: var(--ink);
  background: #f2f4f8;
}

.path-arrow {
  height: 2px;
  background: var(--line);
  position: relative;
}

.path-arrow::after {
  content: "";
  position: absolute;
  right: 0;
  top: -4px;
  width: 0;
  height: 0;
  border-left: 7px solid var(--line);
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.evidence-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  overflow: hidden;
  border-radius: 8px;
  font-size: 13px;
}

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

.evidence-table th {
  color: var(--muted);
  background: #f4f6fa;
  font-size: 12px;
}

.evidence-table tr:last-child td {
  border-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 24, 32, 0.42);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.modal-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-heading h2 {
  margin: 0;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  font-size: 24px;
  line-height: 1;
}

.modal-body {
  padding: 18px 20px 20px;
  color: var(--muted);
  line-height: 1.6;
}

.modal-body h3 {
  margin: 18px 0 6px;
  color: var(--ink);
}

.modal-body ul {
  padding-left: 20px;
}

.modal-body li {
  margin-bottom: 8px;
}

@media (max-width: 1100px) {
  .workspace,
  .evidence-layout,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 620px) {
  .app-shell {
    width: min(100% - 24px, 1480px);
  }

  .cell-picker {
    grid-template-columns: repeat(2, 1fr);
  }

  .button-row {
    flex-direction: column;
  }

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

  .path-arrow {
    display: none;
  }

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