:root {
  color-scheme: light;
  --ink: #132027;
  --muted: #5b666c;
  --paper: #f7f7f3;
  --surface: #ffffff;
  --line: #cfd3d1;
  --line-strong: #aeb5b1;
  --accent: #a85227;
  --max-width: 1120px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
}

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

.skip-link {
  position: fixed;
  z-index: 30;
  top: 0.5rem;
  left: 0.5rem;
  padding: 0.45rem 0.65rem;
  transform: translateY(-160%);
  background: var(--paper);
  border: 1px solid var(--accent);
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header,
main,
footer {
  width: min(calc(100% - 1.5rem), var(--max-width));
  margin-inline: auto;
}

.site-header {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 750;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 1.85rem;
  height: 1.85rem;
  place-items: center;
  background: var(--ink);
  color: #fff;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
}

nav {
  display: flex;
  gap: 0.8rem;
}

nav a,
.text-link,
.link-button {
  font-size: 0.78rem;
  font-weight: 750;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.25rem;
}

.link-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(280px, 0.6fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  align-items: end;
  padding: clamp(2.5rem, 5.5vw, 4.5rem) 0 clamp(2rem, 4.5vw, 3.5rem);
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

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

h1,
h2 {
  margin-bottom: 0;
  letter-spacing: -0.045em;
}

h1 {
  max-width: 770px;
  font-size: clamp(2.45rem, 5.8vw, 4.9rem);
  font-weight: 680;
  line-height: 0.98;
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.8rem);
  font-weight: 650;
  line-height: 1.05;
}

h3 {
  margin-bottom: 0.8rem;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hero-summary {
  padding-bottom: 0.2rem;
}

.hero-summary > p,
.section-intro > p:not(.eyebrow),
.source-note,
.terms-note,
#results-status {
  color: var(--muted);
}

.hero-summary > p {
  margin-bottom: 0;
  font-size: 1.02rem;
}

.share-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
}

.form-section,
.results {
  display: grid;
  grid-template-columns: minmax(220px, 0.28fr) minmax(0, 0.72fr);
  gap: clamp(1.5rem, 4vw, 4rem);
  padding: clamp(1.7rem, 3.5vw, 2.75rem) 0;
  border-top: 1px solid var(--line);
  scroll-margin-top: 1rem;
}

.setup-section,
.input-section,
.results {
  grid-template-columns: 1fr;
  gap: 1rem;
}

.form-section > .matrix-scroll,
.form-section > .source-note {
  grid-column: 2;
}

.setup-section > .matrix-scroll,
.setup-section > .source-note,
.input-section > *,
.results > * {
  grid-column: 1;
}

.setup-section .section-intro > p:not(.eyebrow),
.input-section .section-intro > p:not(.eyebrow),
.results .section-intro > p:not(.eyebrow) {
  max-width: 820px;
}

.section-intro > p:not(.eyebrow) {
  max-width: 460px;
  margin: 0.7rem 0 0;
  font-size: 0.9rem;
}

.matrix-scroll,
.table-scroll {
  width: 100%;
  overflow-x: auto;
  scrollbar-color: var(--accent) #e2e4e1;
  scrollbar-width: thin;
}

.matrix-scroll:focus-visible,
.table-scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.matrix {
  display: grid;
  grid-template-columns: 108px repeat(6, minmax(0, 1fr));
  min-width: 0;
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line);
}

.matrix > * {
  min-width: 0;
  padding: 0.65rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.matrix-label {
  background: var(--ink);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.matrix label {
  display: grid;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.35);
}

.matrix label > span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
}

input[type="text"],
select,
textarea {
  width: 100%;
  min-height: 38px;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line-strong);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.82rem;
}

input:disabled {
  background: #eceeeb;
  color: var(--muted);
}

input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
}

.check-cell {
  align-content: center;
  grid-template-columns: auto 1fr !important;
  align-items: center;
}

.source-note {
  margin: 0;
  font-size: 0.72rem;
}

.source-note.is-warning {
  color: #8a5b00;
}

.status-dot {
  display: inline-block;
  width: 0.45rem;
  height: 0.45rem;
  margin-right: 0.35rem;
  background: var(--accent);
  border-radius: 50%;
}

.toggle-panel,
.input-panel,
.input-example,
.results-content {
  min-width: 0;
}

.toggle-row {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 0.65rem;
  padding: 0.65rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
  font-weight: 750;
}

.dilution-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1rem;
}

.dilution-fields[hidden] {
  display: none;
}

.dilution-fields label,
.input-panel > label {
  display: grid;
  gap: 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.example-heading {
  margin: 0 0 0.55rem;
  font-size: 0.82rem;
  font-weight: 750;
}

table {
  width: 100%;
  min-width: 660px;
  border-collapse: collapse;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

th,
td {
  padding: 0.55rem;
  border: 1px solid var(--line);
  text-align: right;
}

th {
  background: var(--ink);
  color: #fff;
  font-size: 0.66rem;
  letter-spacing: 0.04em;
}

.example-table {
  min-width: 720px;
}

.example-table th,
.example-table td {
  padding: 0.34rem 0.5rem;
  line-height: 1.15;
}

.example-table th:first-child,
.example-table td:first-child {
  text-align: left;
}

.example-table .void-row td {
  color: var(--accent);
  font-weight: 750;
}

textarea {
  min-height: 135px;
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.55;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.8rem;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.8rem;
  border: 1px solid var(--ink);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 750;
}

.button-primary {
  background: var(--ink);
  color: #fff;
}

.button-secondary {
  background: transparent;
  color: var(--ink);
}

.button:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.terms-note {
  margin: 0.7rem 0 0;
  font-size: 0.7rem;
}

.results {
  border-bottom: 1px solid var(--line);
}

.results-content {
  width: 100%;
}

.results-content[hidden] {
  display: none;
}

.result-block {
  padding: 1rem 0;
  border-top: 1px solid var(--line);
}

.result-block:first-child {
  padding-top: 0;
  border-top: 0;
}

.result-block[hidden] {
  display: none;
}

.result-block pre {
  min-height: 48px;
  margin: 0;
  overflow-x: auto;
  color: var(--ink);
  font: 0.76rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.batch-summary {
  margin-bottom: 1rem;
  padding: 0.8rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  font-size: 0.82rem;
  font-weight: 750;
}

.batch-summary[hidden],
.batch-results[hidden],
#single-results[hidden] {
  display: none;
}

.batch-results {
  display: grid;
  gap: 1rem;
}

.hole-result {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-top: 3px solid var(--ink);
  background: var(--paper);
}

.hole-result.blocked {
  border-top-color: #a33a2b;
}

.hole-result.review_required {
  border-top-color: #b7791f;
}

.hole-result-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.hole-result-heading h3 {
  margin: 0;
}

.hole-status {
  padding: 0.24rem 0.45rem;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hole-status.calculated {
  border-color: #53745b;
  color: #31583c;
}

.hole-status.blocked {
  border-color: #a33a2b;
  color: #8b2d20;
}

.hole-status.review_required {
  border-color: #b7791f;
  color: #80540f;
}

.batch-result-section {
  padding: 0.8rem 0;
  border-top: 1px solid var(--line);
}

.batch-result-section h4 {
  margin: 0 0 0.5rem;
}

.batch-result-section pre,
.hole-error {
  margin: 0;
  overflow-x: auto;
  color: var(--ink);
  font: 0.76rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre;
}

.hole-error,
.hole-warning {
  padding: 0.7rem;
  background: #fff6ed;
  color: #7a321f;
}

.hole-warning {
  font-size: 0.76rem;
}

footer {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.modal[hidden] {
  display: none;
}

.modal {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  overflow-y: auto;
  place-items: start center;
  padding: 5vh 0.75rem;
  background: rgba(19, 32, 39, 0.68);
}

.modal-panel {
  position: relative;
  width: min(100%, 760px);
  max-height: 90vh;
  overflow-y: auto;
  padding: clamp(1.2rem, 3vw, 2.2rem);
  background: var(--paper);
  border-top: 3px solid var(--accent);
}

.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.8rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.8rem;
  line-height: 1;
}

.terms-content {
  margin-top: 1.2rem;
  color: var(--muted);
  font-size: 0.86rem;
}

.terms-content h3 {
  margin: 1.2rem 0 0.35rem;
  color: var(--ink);
  font-size: 0.76rem;
}

.terms-content p {
  margin-bottom: 0.75rem;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 820px) {
  .hero,
  .form-section,
  .results {
    grid-template-columns: 1fr;
  }

  .form-section > .matrix-scroll,
  .form-section > .source-note {
    grid-column: 1;
  }
}

@media (max-width: 640px) {
  .matrix-scroll {
    overflow-x: visible;
  }

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

  .matrix-label {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  nav a:not(:first-child) {
    display: none;
  }

  .hero {
    padding-block: 2.2rem 1.8rem;
  }

  h1 {
    font-size: clamp(2.25rem, 12vw, 3.5rem);
  }

  .dilution-fields {
    grid-template-columns: 1fr;
  }

  footer {
    align-items: flex-start;
    flex-direction: column;
    justify-content: center;
    padding-block: 0.8rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
