:root {
  color-scheme: dark;
  --ink: #edf1ff;
  --muted: #a6aec7;
  --faint: #939db8;
  --canvas: #10131b;
  --surface: #171b26;
  --surface-raised: #1d2331;
  --line: #2c3448;
  --accent: #8be5c1;
  --accent-strong: #39c695;
  --accent-ink: #081e17;
  --warn: #ffb6a8;
  --focus: #f1d77d;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 84% -12%, rgba(57, 198, 149, 0.14), transparent 31rem),
    var(--canvas);
  line-height: 1.5;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 5;
  padding: 0.65rem 0.9rem;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 0.5rem;
  font-weight: 750;
}

.skip-link:focus {
  top: 1rem;
}

.section-shell,
.header-inner {
  width: min(1120px, calc(100% - 3rem));
  margin-inline: auto;
}

.site-header {
  border-bottom: 1px solid rgba(44, 52, 72, 0.7);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 5.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 0.6rem;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

.header-note,
.result-subtitle,
.section-note,
.muted-note,
.local-note,
.footer-boundary {
  color: var(--muted);
  font-size: 0.86rem;
}

.intro {
  padding-block: clamp(4.8rem, 11vw, 8.4rem) 3.8rem;
}

.eyebrow {
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

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

h1,
h2,
h3 {
  letter-spacing: -0.04em;
  line-height: 1.08;
}

h1 {
  max-width: 760px;
  margin: 0.9rem 0 1.25rem;
  font-size: clamp(2.8rem, 7vw, 5.8rem);
  font-weight: 760;
}

.lede {
  max-width: 650px;
  margin-bottom: 1.8rem;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.2rem);
}

.scope-line {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 700;
}

.scope-dot {
  width: 0.6rem;
  height: 0.6rem;
  background: var(--accent-strong);
  border-radius: 999px;
  box-shadow: 0 0 0 0.3rem rgba(57, 198, 149, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.75fr);
  gap: 1rem;
}

.panel {
  background: linear-gradient(145deg, rgba(29, 35, 49, 0.96), rgba(23, 27, 38, 0.96));
  border: 1px solid var(--line);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}

.input-panel {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.boundary-panel {
  padding: clamp(1.25rem, 3vw, 2rem);
}

.panel-heading,
.results-heading,
.section-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel h2,
.results h2 {
  margin: 0.4rem 0 1.4rem;
  font-size: 1.65rem;
}

.boundary-panel h2 {
  max-width: 16rem;
  margin: 0.65rem 0 1rem;
  font-size: 1.65rem;
}

.boundary-panel p {
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--ink);
  font-size: 0.86rem;
  font-weight: 750;
}

textarea {
  display: block;
  width: 100%;
  min-height: 20rem;
  padding: 1rem;
  color: #d9f7eb;
  background: #0d1119;
  border: 1px solid #39445d;
  border-radius: 0.7rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.88rem;
  line-height: 1.65;
  resize: vertical;
}

textarea:focus {
  border-color: var(--accent-strong);
  outline: 3px solid rgba(139, 229, 193, 0.16);
  outline-offset: 0;
}

.input-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.65rem 0 1.15rem;
}

.field-help,
.byte-count {
  margin: 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.field-help {
  max-width: 32rem;
}

.byte-count {
  flex: none;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.byte-count.over-limit {
  color: var(--warn);
  font-weight: 700;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 0.55rem;
  font-size: 0.86rem;
  font-weight: 800;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button-primary {
  min-width: 9.6rem;
  color: var(--accent-ink);
  background: var(--accent);
}

.button-primary:hover {
  background: #a7f2d4;
}

.button-quiet {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.button-quiet:hover {
  background: rgba(139, 229, 193, 0.08);
  border-color: #52627f;
}

.button-arrow {
  font-size: 1.1rem;
  line-height: 1;
}

.status {
  min-height: 1.4rem;
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.status-success {
  color: var(--accent);
}

.status-error {
  color: var(--warn);
}

.boundary-list {
  display: grid;
  gap: 0.85rem;
  margin: 1.4rem 0;
  padding: 0;
  list-style: none;
}

.boundary-list li {
  position: relative;
  padding-left: 1.35rem;
  color: var(--ink);
  font-size: 0.9rem;
}

.boundary-list li::before {
  position: absolute;
  left: 0;
  color: var(--accent);
  content: "＋";
  font-weight: 800;
}

.muted-note {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
}

.local-note {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 1.8rem 0 0;
  color: var(--accent);
  font-weight: 700;
}

.results {
  padding-block: 6.5rem 3rem;
}

.results-heading {
  align-items: end;
  margin-bottom: 1.5rem;
}

.results-heading h2 {
  margin-bottom: 0;
}

.result-subtitle {
  margin: 0;
  font-variant-numeric: tabular-nums;
}

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

.check-card {
  padding: 1.2rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.8rem;
}

.check-card-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
}

.check-name {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 1.1rem;
}

.check-dice {
  flex: none;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.73rem;
  white-space: nowrap;
}

.metrics {
  display: grid;
  grid-template-columns: 1.25fr 1fr 1fr;
  gap: 0.8rem;
  margin: 1rem 0 0;
}

.metric-label,
.metric-value,
.metric-note {
  margin: 0;
}

.metric-label {
  color: var(--faint);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 0.28rem;
  color: var(--ink);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.metric:first-child .metric-value {
  color: var(--accent);
}

.metric-note {
  margin-top: 0.18rem;
  color: var(--faint);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.7rem;
  overflow-wrap: anywhere;
}

.comparison-section,
.distributions-section {
  margin-top: 3.5rem;
}

.section-heading-row {
  align-items: end;
  margin-bottom: 1rem;
}

.section-heading-row h3 {
  margin: 0.35rem 0 0;
  font-size: 1.35rem;
}

.section-note {
  margin: 0;
  text-align: right;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th,
td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

tr:last-child th,
tr:last-child td {
  border-bottom: 0;
}

thead th {
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody th {
  color: var(--ink);
  font-weight: 750;
}

tbody td {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.comparison-percent,
.comparison-fraction {
  display: block;
}

.comparison-fraction {
  margin-top: 0.15rem;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.68rem;
  font-weight: 500;
}

.comparison-name:first-child,
.comparison-section thead th:first-child {
  text-align: left;
}

.comparison-name:last-child,
.comparison-section thead th:last-child {
  text-align: left;
}

.comparison-tie {
  color: var(--muted);
}

.distribution-card {
  margin-top: 0.65rem;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.distribution-card[open] {
  background: var(--surface-raised);
}

.distribution-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem;
  cursor: pointer;
  list-style: none;
}

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

.distribution-summary::before {
  width: 1.2rem;
  color: var(--accent);
  content: "＋";
  font-weight: 800;
}

.distribution-card[open] .distribution-summary::before {
  content: "−";
}

.distribution-title {
  flex: 1;
  font-weight: 800;
}

.distribution-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.distribution-table-wrap {
  margin: 0 1rem 1rem;
  max-height: 28rem;
  overflow: auto;
}

.distribution-table-wrap table {
  font-size: 0.8rem;
}

.distribution-table-wrap th,
.distribution-table-wrap td {
  padding-block: 0.62rem;
}

.distribution-table-wrap tbody th {
  text-align: right;
}

.distribution-ways {
  color: var(--ink);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-weight: 500;
}

.distribution-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  margin: 0 1rem 1rem;
}

.distribution-page-button {
  min-height: 2.25rem;
  padding: 0.4rem 0.7rem;
}

.distribution-page-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.distribution-page-range {
  min-width: 10rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 2rem 3rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.site-footer p {
  margin: 0;
}

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

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ink: #192235;
    --muted: #56627b;
    --faint: #58667f;
    --canvas: #f5f7fb;
    --surface: #ffffff;
    --surface-raised: #f0f4fa;
    --line: #d9e0ed;
    --accent: #147a58;
    --accent-strong: #17966a;
    --accent-ink: #ffffff;
    --warn: #b13f36;
    --focus: #8b6500;
    --shadow: 0 18px 60px rgba(33, 50, 83, 0.08);
  }

  body {
    background:
      radial-gradient(circle at 84% -12%, rgba(23, 150, 106, 0.1), transparent 31rem),
      var(--canvas);
  }

  textarea {
    color: #18392d;
    background: #f8fbff;
    border-color: #bfcbe0;
  }
}

@media (max-width: 720px) {
  .section-shell,
  .header-inner {
    width: min(100% - 2rem, 1120px);
  }

  .header-inner,
  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0.55rem;
  }

  .header-inner {
    padding-block: 1.2rem;
  }

  .header-note {
    margin: 0;
  }

  .intro {
    padding-block: 3.8rem 2.8rem;
  }

  h1 {
    font-size: clamp(2.6rem, 14vw, 4.6rem);
  }

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

  .input-meta,
  .results-heading,
  .section-heading-row,
  .distribution-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .byte-count,
  .section-note {
    text-align: left;
  }

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

  .metrics {
    grid-template-columns: repeat(3, 1fr);
  }

  .distribution-meta {
    margin-left: 1.8rem;
    text-align: left;
  }
}

@media (max-width: 430px) {
  .metrics {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .metric {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: baseline;
    column-gap: 0.8rem;
  }

  .metric-note {
    grid-column: 2;
    grid-row: 1 / span 2;
    text-align: right;
  }
}

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