@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Fraunces:opsz,wght@9..144,500;700&family=Silkscreen:wght@400;700&display=swap");

:root {
  --bg: #f6f1ea;
  --bg-deep: #f0e3d4;
  --ink: #1a1a1a;
  --muted: #6a5b4b;
  --accent: #e85d25;
  --accent-2: #2c7a7b;
  --card: #fff7ef;
  --stroke: #d8c7b6;
  --shadow: 0 20px 40px rgba(26, 26, 26, 0.12);
  --container: 1100px;
  --gutter: 1.5rem;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Space Grotesk", system-ui, sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at top, #fff6ec 0%, var(--bg) 45%, var(--bg-deep) 100%);
  min-height: 100vh;
  line-height: 1.45;
}

.hero {
  padding: 4rem 0 2.5rem;
  background: linear-gradient(135deg, rgba(232,93,37,0.18), rgba(44,122,123,0.12));
  border-bottom: 1px solid var(--stroke);
}

.hero-inner {
  max-width: var(--container);
  margin: 0 auto;
}

.hero-title-row {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 0.6rem;
}

.hero-logo-inline {
  width: 68px;
  height: 68px;
  flex: 0 0 68px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(26, 26, 26, 0.15);
}

.eyebrow {
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 1rem;
}

h1 {
  font-family: "Fraunces", serif;
  font-size: clamp(2.5rem, 4vw, 4rem);
  margin: 0 0 0.8rem;
}

.sub {
  font-size: 1.1rem;
  max-width: 1040px;
  color: var(--muted);
}

.citation {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.85rem;
  color: #7a6a5b;
  font-style: italic;
}

.page {
  padding: 2rem 0 4rem;
  display: grid;
  gap: 1.5rem;
}

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.hero .container {
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-left: 0;
  overflow: hidden;
}

.nav-strip {
  background: #fff7ef;
  border-bottom: 1px solid var(--stroke);
  padding: 0.75rem 0;
}

.nav-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hidden {
  display: none;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.2rem;
}

.panel-title h2 {
  margin: 0;
  font-size: 1.3rem;
}

.panel-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.btn {
  border: 1px solid var(--stroke);
  background: white;
  color: var(--ink);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.btn.ghost {
  background: transparent;
}

.btn.is-active {
  background: var(--accent-2);
  border-color: var(--accent-2);
  color: #fff;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(26, 26, 26, 0.12);
}

.btn:focus-visible {
  outline: 3px solid rgba(44, 122, 123, 0.35);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn.loading {
  position: relative;
}

.grid {
  display: grid;
  grid-auto-flow: row;
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.grid-row {
  display: grid;
  gap: 0.75rem;
  grid-auto-flow: column;
  grid-auto-columns: minmax(220px, 260px);
  grid-template-columns: 120px;
  align-items: stretch;
}

.grid-header {
  font-size: 0.9rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.layer-label {
  display: flex;
  align-items: center;
  font-weight: 700;
}

.cell {
  border: 1px solid var(--stroke);
  background: #fffaf4;
  border-radius: 16px;
  padding: 0.75rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cell:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px rgba(26, 26, 26, 0.1);
}

.cell h4 {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
}

.cell p {
  margin: 0;
  font-size: 0.7rem;
  color: var(--muted);
}

.cell-input {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.6rem;
  font-size: 0.7rem;
  color: var(--muted);
}

.cell-input input {
  width: 100%;
}

.cell-input select {
  width: 100%;
}

.cell-inputs {
  display: grid;
  gap: 0.4rem;
}


.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 15, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 20;
}

.modal.open {
  display: flex;
}

.modal-card {
  background: #fffaf4;
  border-radius: 20px;
  padding: 1.5rem;
  width: min(980px, 96vw);
  max-height: min(86vh, 900px);
  overflow: auto;
  box-shadow: var(--shadow);
  border: 1px solid var(--stroke);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-header h3 {
  margin: 0;
}

.agent-box {
  border: 1px dashed var(--stroke);
  border-radius: 14px;
  padding: 0.9rem;
  margin: 0.6rem 0 1rem;
  background: #fff6ea;
}

.agent-box legend {
  font-weight: 600;
  padding: 0 0.4rem;
}

.agent-toggle {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.agent-hint {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.icon {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
}

.modal-body {
  display: grid;
  gap: 0.9rem;
}

.param-grid {
  display: grid;
  gap: 0.7rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  align-items: start;
}

.param-grid > label {
  display: grid;
  gap: 0.4rem;
  min-width: 0;
}

.param-row {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: minmax(120px, 1.2fr) minmax(110px, 0.9fr) minmax(110px, 0.9fr) minmax(120px, 1fr) minmax(170px, 1.3fr) minmax(170px, 1.3fr);
  grid-column: 1 / -1;
  width: 100%;
  padding: 0.65rem;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  background: #fffdf9;
  align-items: center;
}

.param-options {
  min-width: 0;
}

.param-values {
  min-width: 0;
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.hint {
  margin: 0.5rem 0 0;
  color: var(--muted);
}


.controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  align-items: end;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 600;
}

input, select {
  padding: 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  font-size: 0.95rem;
  background: #fff;
}

input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(44, 122, 123, 0.22);
  outline-offset: 1px;
  border-color: #2c7a7b;
}

.status {
  margin-top: 1rem;
  color: var(--muted);
  min-height: 1.2rem;
}

.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.2rem;
}

.paper-notes {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 14px;
  border: 1px dashed var(--stroke);
  background: #fffdf9;
}

.paper-notes h4 {
  margin: 0 0 0.6rem;
}

.paper-notes ul {
  margin: 0 0 0.8rem 1.2rem;
  color: var(--muted);
}

.output {
  background: #101010;
  color: #f6f3ef;
  padding: 1rem;
  border-radius: 14px;
  min-height: 160px;
  overflow: auto;
  font-size: 0.85rem;
}

.interpretation-card {
  background: #fff7ef;
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 1.2rem;
  box-shadow: var(--shadow);
}

.interpretation-card h3 {
  margin: 0 0 0.6rem;
}

.output.interpretation {
  background: #fffdf9;
  color: var(--ink);
  min-height: 140px;
  border: 1px dashed var(--stroke);
}

.output.text-panel {
  background: #fffdf9;
  color: var(--ink);
  border: 1px dashed var(--stroke);
}

#validationErrors,
#runtimeErrors {
  margin-top: 0.8rem;
  border-style: solid;
}

#validationErrors {
  border-color: #cc7a00;
  background: #fff8ef;
}

#runtimeErrors {
  border-color: #c53f3f;
  background: #fff1f1;
}

.output.small {
  min-height: 120px;
  margin-top: 0.8rem;
}

.run-facts-card {
  margin-top: 0.8rem;
  border: 1px dashed var(--stroke);
  border-radius: 14px;
  padding: 0.8rem;
  background: #fffdf9;
}

.run-facts-card .panel-title {
  margin-bottom: 0.6rem;
}

.footer-links {
  display: flex;
  gap: 1rem;
  padding-bottom: 2rem;
  font-size: 0.9rem;
}

.chart-wrap {
  background: #fffaf4;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 0.75rem;
}

.chart-wrap canvas {
  width: 100%;
  display: block;
}

.scenario-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 0.8rem;
}

.scenario-card {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 0.6rem;
  background: #fffdf9;
}

.scenario-title {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.scenario-card canvas {
  width: 100%;
  max-width: 100%;
  display: block;
}

.workflow-strip {
  background: #fff;
  border-bottom: 1px solid var(--stroke);
}

.workflow-steps {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.75rem 0;
}

.step-chip {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.82rem;
  background: #fffaf4;
}

.preset-cards {
  display: grid;
  gap: 0.8rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.preset-card {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: #fffaf4;
  padding: 0.9rem;
}

.status-meta {
  margin-top: 0.35rem;
  font-size: 0.84rem;
  color: var(--muted);
}

.status-meta.dirty {
  color: #8d3b1f;
  font-weight: 700;
}

.results-tabs {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.results-pane {
  border-top: 1px solid var(--stroke);
  padding-top: 0.9rem;
}

.pixel-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.8rem;
  padding: 0.6rem;
  border: 1px solid rgba(216, 199, 182, 0.8);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 251, 244, 0.96), rgba(249, 239, 228, 0.85));
}

.pixel-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

.pixel-scrub {
  grid-column: 1 / -1;
}

.pixel-scrub span {
  font-size: 0.85rem;
  color: var(--muted);
}

.pixel-wrap {
  background:
    linear-gradient(140deg, rgba(42, 72, 87, 0.22), rgba(232, 93, 37, 0.12)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.14), rgba(255,255,255,0.14) 3px, rgba(255,255,255,0.04) 3px, rgba(255,255,255,0.04) 6px),
    #f9efe4;
  border: 1px solid #bda184;
  border-radius: 16px;
  padding: 0.7rem;
  box-shadow: inset 0 0 0 2px rgba(255, 247, 239, 0.9), 0 12px 24px rgba(26, 26, 26, 0.14);
  animation: pixelStageGlow 2.8s ease-in-out infinite alternate;
}

.pixel-wrap canvas {
  width: 100%;
  max-width: 100%;
  display: block;
  image-rendering: pixelated;
  border-radius: 10px;
  border: 2px solid rgba(46, 62, 72, 0.3);
  background: linear-gradient(180deg, #fffaf4, #f2e5d6);
}

.pixel-legend-title {
  margin: 0.85rem 0 0.45rem;
  font-family: "Silkscreen", "Space Grotesk", sans-serif;
  font-size: 0.82rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #74563f;
}

.pixel-legend {
  margin-top: 0.2rem;
  display: grid;
  gap: 0.55rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.pixel-legend-item {
  border: 1px solid #ceb59b;
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(255, 251, 245, 0.98), rgba(248, 237, 224, 0.96));
  padding: 0.52rem 0.62rem;
  display: grid;
  gap: 0.24rem;
  box-shadow: 0 4px 12px rgba(26, 26, 26, 0.08);
}

.pixel-legend-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.4rem;
  font-size: 0.78rem;
}

.pixel-legend-box {
  display: inline-block;
  border-radius: 8px;
  border: 1px solid #be9f82;
  background:
    repeating-linear-gradient(90deg, #f7d8a9, #f7d8a9 3px, #efc693 3px, #efc693 6px);
  padding: 0.14rem 0.46rem;
  font-family: "Silkscreen", "Space Grotesk", sans-serif;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  font-weight: 700;
}

.pixel-legend-stream {
  font-size: 0.83rem;
  font-weight: 600;
  color: #2d2a27;
}

.pixel-legend-meta {
  font-size: 0.74rem;
  color: var(--muted);
}

.pixel-legend-key {
  font-size: 0.73rem;
  font-family: "Silkscreen", "Space Grotesk", monospace;
  letter-spacing: 0.03em;
  background: #f9f2e8;
  border: 1px dashed #cab19a;
  border-radius: 8px;
  padding: 0.22rem 0.35rem;
  overflow-x: auto;
  white-space: nowrap;
  color: #54402d;
}

.pixel-legend-params {
  font-size: 0.75rem;
  color: #4f4338;
  border-top: 1px dotted rgba(202, 177, 154, 0.9);
  padding-top: 0.22rem;
}

.pixel-legend-value {
  margin-left: auto;
  border: 1px solid #93b7b8;
  border-radius: 8px;
  padding: 0.08rem 0.38rem;
  font-size: 0.68rem;
  font-family: "Silkscreen", "Space Grotesk", monospace;
  background: #e8f4f4;
  color: #1e5355;
}

.pixel-legend-swatch {
  width: 14px;
  height: 14px;
  border: 1px solid rgba(51, 42, 35, 0.35);
  border-radius: 3px;
  image-rendering: pixelated;
  background:
    repeating-linear-gradient(0deg, var(--legend-color, #c88a32), var(--legend-color, #c88a32) 2px, rgba(255,255,255,0.34) 2px, rgba(255,255,255,0.34) 4px);
  box-shadow: 0 0 0 1px rgba(255, 250, 244, 0.65) inset;
}

@keyframes pixelStageGlow {
  from {
    box-shadow: inset 0 0 0 2px rgba(255, 247, 239, 0.9), 0 12px 24px rgba(26, 26, 26, 0.14);
  }
  to {
    box-shadow: inset 0 0 0 2px rgba(255, 247, 239, 0.95), 0 16px 28px rgba(26, 26, 26, 0.2);
  }
}

.table-actions {
  display: flex;
  gap: 0.5rem;
  margin: 0.6rem 0;
}

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

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.summary-table th,
.summary-table td {
  border: 1px solid var(--stroke);
  padding: 0.5rem 0.6rem;
  text-align: left;
  white-space: nowrap;
}

.summary-table th {
  background: #f9efe4;
  position: sticky;
  top: 0;
  z-index: 1;
  font-weight: 700;
}

.summary-table th.is-metric,
.summary-table td.is-metric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-table .table-empty {
  text-align: center;
  color: var(--muted);
  font-style: italic;
}

.tour-card {
  width: min(680px, 94vw);
}

.tour-progress {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.6rem;
}

.tour-body h4 {
  margin: 0 0 0.45rem;
}

.tour-body p {
  margin: 0;
}

.cookie-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 2000;
  background: #fff7ef;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.7rem;
  pointer-events: auto;
  touch-action: manipulation;
}

.cookie-banner:not(.hidden) {
  animation: cookieSlideUp 180ms ease-out;
}

.cookie-banner p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.cookie-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#cookieAcknowledgeBtn {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  position: relative;
  z-index: 2100;
  min-height: 42px;
}

.cookie-launcher {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1990;
  border-radius: 999px;
  background: #fff7ef;
  border: 1px solid var(--stroke);
  box-shadow: var(--shadow);
  padding: 0.45rem 0.85rem;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

@keyframes cookieSlideUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .panel {
    padding: 1.2rem;
  }

  .param-row {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .container {
    padding: 0 1rem;
  }

  .hero {
    padding: 3rem 0 1.8rem;
  }

  h1 {
    font-size: clamp(2rem, 10vw, 2.8rem);
  }

  .hero-title-row {
    align-items: center;
    gap: 0.55rem;
  }

  .hero-logo-inline {
    width: 52px;
    height: 52px;
    flex-basis: 52px;
  }

  .sub {
    font-size: 1rem;
  }

  .grid-row {
    grid-template-columns: 1fr;
    grid-auto-columns: minmax(200px, 1fr);
  }

  .layer-label {
    padding: 0.4rem 0;
  }

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

  .modal-card {
    padding: 1rem;
  }

  .param-row {
    grid-template-columns: 1fr;
  }

  .modal-actions {
    justify-content: flex-start;
  }

  .cookie-actions {
    justify-content: flex-start;
  }
}
