@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@400;500;600;700&family=Newsreader:opsz,wght@6..72,500;6..72,650&display=swap");

:root {
  --ink: #f7f3ec;
  --ink-soft: #c9c4ba;
  --muted: #908b82;
  --canvas: #11100f;
  --line: rgba(247, 243, 236, 0.12);
  --line-strong: rgba(247, 243, 236, 0.22);
  --blue: #5eb7c4;
  --poppy: #d76442;
  --gold: #d7b46a;
  --danger: #ff815f;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  background:
    linear-gradient(135deg, rgba(94, 183, 196, 0.12), transparent 34%),
    linear-gradient(315deg, rgba(215, 180, 106, 0.10), transparent 38%),
    var(--canvas);
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(247, 243, 236, 0.035) 0,
      rgba(247, 243, 236, 0.035) 1px,
      transparent 1px,
      transparent 96px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(247, 243, 236, 0.025) 0,
      rgba(247, 243, 236, 0.025) 1px,
      transparent 1px,
      transparent 96px
    );
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1280px, calc(100% - 40px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px 0 40px;
}

.masthead {
  display: flex;
  align-items: center;
  min-height: 56px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background:
    linear-gradient(135deg, transparent 0 46%, var(--blue) 46% 54%, transparent 54%),
    linear-gradient(45deg, var(--poppy), var(--gold));
  box-shadow: 0 0 0 4px rgba(94, 183, 196, 0.06);
}

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

.controls,
.result {
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(247, 243, 236, 0.045), transparent 28%),
    rgba(25, 24, 23, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.controls {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 22px;
  padding: 22px;
}

.panel-heading {
  display: grid;
  gap: 12px;
  padding-bottom: 6px;
}

.eyebrow,
.group span,
.group legend,
.metric-label,
details summary {
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-family: "Newsreader", Georgia, serif;
  font-weight: 650;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
  line-height: 1;
}

h2 {
  max-width: 16ch;
  font-size: 54px;
  line-height: 0.94;
}

.group {
  display: grid;
  gap: 9px;
}

.group fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

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

.group-source .choice-row {
  grid-template-columns: 1fr;
}

.choice {
  position: relative;
  min-width: 0;
}

.choice input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.choice span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(17, 16, 15, 0.72);
  color: var(--ink-soft);
  font-weight: 600;
  transition:
    transform 150ms var(--ease),
    border-color 150ms var(--ease),
    background-color 150ms var(--ease),
    color 150ms var(--ease);
}

.choice:hover span {
  border-color: var(--line-strong);
  transform: translateY(-1px);
}

.choice input:checked + span {
  border-color: rgba(94, 183, 196, 0.72);
  background: rgba(94, 183, 196, 0.16);
  color: var(--ink);
}

input[type="text"] {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: rgba(17, 16, 15, 0.72);
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-size: 14px;
  letter-spacing: 0;
  outline: none;
  transition:
    border-color 150ms var(--ease),
    background-color 150ms var(--ease);
}

input[type="text"]::placeholder {
  color: rgba(201, 196, 186, 0.42);
}

input[type="text"]:hover,
input[type="text"]:focus {
  border-color: rgba(94, 183, 196, 0.72);
  background: rgba(17, 16, 15, 0.92);
}

input[type="text"]:focus-visible,
button:focus-visible,
.choice input:focus-visible + span {
  outline: 2px solid var(--blue);
  outline-offset: 3px;
}

.source-note {
  margin: -6px 0 0;
  padding: 12px 12px 12px 14px;
  border-left: 3px solid var(--blue);
  border-radius: 0 7px 7px 0;
  background: rgba(94, 183, 196, 0.08);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.run-strip {
  display: grid;
  gap: 10px;
  padding-top: 4px;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 7px;
  padding: 0 18px;
  background: var(--ink);
  color: var(--canvas);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    transform 150ms var(--ease),
    background-color 150ms var(--ease),
    opacity 150ms var(--ease);
}

button::after {
  content: " >";
}

button:hover {
  background: var(--gold);
  transform: translateY(-1px);
}

button[disabled] {
  cursor: wait;
  opacity: 0.58;
  transform: none;
}

.result {
  display: grid;
  gap: 24px;
  min-height: calc(100vh - 100px);
  padding: 24px;
}

.headline {
  display: grid;
  gap: 16px;
}

.result-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.summary {
  max-width: 64ch;
  margin: 0;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.55;
}

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

.metric {
  min-width: 0;
  min-height: 112px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(247, 243, 236, 0.04), transparent),
    rgba(17, 16, 15, 0.54);
}

.metric-value {
  margin-top: 16px;
  color: var(--ink);
  font-family: "IBM Plex Mono", monospace;
  font-feature-settings: "tnum" on;
  font-size: 24px;
  font-weight: 600;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.chart {
  min-height: 360px;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(94, 183, 196, 0.08), transparent 28%),
    rgba(17, 16, 15, 0.62);
}

.chart-figure,
.chart-figure > svg {
  display: block;
  width: 100%;
  height: auto;
}

.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.notes li {
  min-height: 58px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--poppy);
  border-radius: 7px;
  background: rgba(17, 16, 15, 0.42);
  color: var(--ink-soft);
  font-size: 14px;
}

.alert {
  padding: 14px 16px;
  border: 1px solid rgba(255, 129, 95, 0.44);
  border-radius: 7px;
  background: rgba(215, 100, 66, 0.12);
  color: var(--danger);
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 16, 15, 0.36);
}

details summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--ink-soft);
  list-style: none;
  user-select: none;
}

details summary::-webkit-details-marker {
  display: none;
}

pre {
  max-height: 420px;
  margin: 0;
  padding: 0 16px 16px;
  overflow: auto;
  color: var(--ink-soft);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.signature {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.signature a {
  color: var(--ink-soft);
  text-decoration: none;
}

.signature a:hover {
  color: var(--blue);
}

.masthead,
.controls,
.result,
.signature {
  animation: rise 520ms var(--ease) both;
}

.result {
  animation-delay: 60ms;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

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

  .controls {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-heading,
  .source-note,
  .group-source,
  .group-path,
  .run-strip {
    grid-column: 1 / -1;
  }

  h1 {
    max-width: 18ch;
  }

  .result {
    min-height: auto;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 24px, 100%);
    padding-top: 14px;
  }

  .controls,
  .result {
    padding: 16px;
  }

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

  .panel-heading,
  .source-note,
  .group-source,
  .group-path,
  .run-strip {
    grid-column: auto;
  }

  .choice-row,
  .group-source .choice-row {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    max-width: 12ch;
    font-size: 42px;
  }

  .chart {
    min-height: 240px;
    padding: 10px;
  }

  .signature {
    flex-direction: column;
  }
}
