:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #18201c;
  --muted: #5b665f;
  --line: #cfd8d1;
  --accent: #176b57;
  --accent-2: #b04835;
  --accent-3: #2f5f8f;
  --soft: #e8f1ed;
  --warn: #fff2d6;
  --shadow: 0 10px 30px rgba(20, 33, 27, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

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

a {
  color: var(--accent);
}

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

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0.45rem 0.75rem;
  text-decoration: none;
  cursor: pointer;
  font-weight: 650;
}

button.secondary,
.button.secondary {
  background: #fff;
  color: var(--accent);
}

button.ghost {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.site-header,
.site-footer {
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.site-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  padding: 1rem 1.25rem;
}

.site-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.8rem 1.25rem;
}

.site-brand a {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: flex-end;
}

.top-nav a {
  border-radius: 6px;
  color: var(--muted);
  padding: 0.35rem 0.5rem;
  text-decoration: none;
}

.top-nav a[aria-current="page"],
.top-nav a:hover {
  background: var(--soft);
  color: var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  gap: 1rem;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.content {
  min-width: 0;
}

.panel,
.sidebar-card,
.biomorph-card,
.summary-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel,
.sidebar-card,
.summary-card {
  padding: 1rem;
}

.panel {
  overflow-x: auto;
}

.hero {
  padding: 1.25rem 0 1rem;
}

.hero h1,
.content h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(2rem, 4vw, 4rem);
  line-height: 1;
  letter-spacing: 0;
}

.hero p,
.lede {
  max-width: 72ch;
  color: var(--muted);
  font-size: 1.05rem;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 1rem;
}

.stage {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0.75rem;
}

.stage-header,
.panel-header,
.card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}

.stage-title h2,
.panel-header h2,
.card-header h3,
.sidebar-card h3 {
  margin: 0;
}

.stage-title p,
.panel-header p,
.card-header p {
  margin: 0.25rem 0 0;
  color: var(--muted);
}

.canvas-wrap {
  position: relative;
  min-height: 0;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(24, 32, 28, 0.045) 1px, transparent 1px),
    linear-gradient(rgba(24, 32, 28, 0.045) 1px, transparent 1px),
    #fbfcfa;
  background-size: 34px 34px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.canvas-overlay {
  position: absolute;
  left: 0.75rem;
  bottom: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  max-width: calc(100% - 1.5rem);
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--muted);
  padding: 0.2rem 0.55rem;
  font-size: 0.82rem;
  font-weight: 650;
}

.button-row,
.icon-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.grid-variants {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  max-width: 920px;
  margin: 0 auto;
}

.biomorph-card {
  display: grid;
  grid-template-rows: auto auto auto;
  min-width: 0;
  overflow: hidden;
}

.biomorph-card button {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 0;
  border-radius: 0;
  background: #fbfcfa;
  color: inherit;
  padding: 0;
}

.biomorph-card canvas {
  min-height: 0;
}

.variant-meta {
  border-top: 1px solid var(--line);
  padding: 0.65rem;
}

.variant-meta strong {
  display: block;
}

.variant-meta span {
  color: var(--muted);
  font-size: 0.9rem;
}

.chosen {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.control-group {
  display: grid;
  gap: 0.35rem;
  margin-bottom: 0.8rem;
}

.control-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 4.5rem;
  gap: 0.5rem;
  align-items: center;
}

.control-line output,
.value-readout {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.evaluator-panel {
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.evaluator-panel summary {
  margin-bottom: 0.65rem;
}

.evaluator-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7rem;
  gap: 0.75rem;
}

.status-line {
  color: var(--muted);
  margin: 0.55rem 0;
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.score-table th,
.score-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem;
  text-align: left;
}

.score-table th {
  background: var(--soft);
}

.score-table .best-score td {
  background: #fff2d6;
  font-weight: 750;
}

label {
  font-weight: 700;
}

input[type="range"] {
  width: 100%;
}

input[type="number"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0.45rem 0.55rem;
}

textarea {
  min-height: 9rem;
  resize: vertical;
}

details {
  border-top: 1px solid var(--line);
  padding: 0.7rem 0;
}

details:first-of-type {
  border-top: 0;
}

summary {
  cursor: pointer;
  font-weight: 800;
}

.gene-list {
  display: grid;
  gap: 0.65rem;
}

.gene-row {
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.6rem;
  align-items: start;
}

.gene-badge {
  border-radius: 6px;
  background: var(--soft);
  color: var(--accent);
  padding: 0.25rem 0.4rem;
  text-align: center;
  font-weight: 800;
}

.legend-table,
.standards-table,
.history-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.legend-table {
  min-width: 0;
  font-size: 0.9rem;
}

.legend-table th,
.legend-table td,
.standards-table th,
.standards-table td,
.history-table th,
.history-table td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  text-align: left;
  vertical-align: top;
}

.legend-table th,
.standards-table th,
.history-table th {
  background: var(--soft);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.75rem;
}

.summary-card strong {
  display: block;
  font-size: 1.6rem;
  line-height: 1.1;
}

.summary-card span {
  color: var(--muted);
}

.notice {
  border: 1px solid #ead39a;
  border-radius: 8px;
  background: var(--warn);
  padding: 0.75rem;
}

.hidden-file {
  display: none;
}

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

  .sidebar {
    order: 2;
  }
}

@media (max-width: 680px) {
  .site-title-row,
  .stage-header,
  .panel-header,
  .card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .layout {
    padding: 0.75rem;
  }

  .grid-variants {
    gap: 0.45rem;
  }

  .variant-meta {
    padding: 0.45rem;
  }

  .variant-meta strong {
    font-size: 0.82rem;
  }

  .variant-meta span {
    font-size: 0.72rem;
  }

  .evaluator-controls {
    grid-template-columns: 1fr;
  }
}
