:root {
  color-scheme: light;
  --paper: #f5f7fc;
  --white: #fff;
  --ink: #14213a;
  --muted: #4b5870;
  --line: #dbe2ef;
  --blue: #2548d1;
  --blue-dark: #1b36a5;
  --blue-pale: #e9efff;
  --navy: #172642;
  font: 16px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); }
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: var(--blue-dark); text-underline-offset: .18em; }
a:hover { color: var(--blue); }
:focus-visible { outline: 3px solid #315cf3; outline-offset: 3px; }
.shell { width: min(70rem, 100% - 3rem); margin-inline: auto; }
.skip-link { position: absolute; z-index: 2; left: .75rem; top: .75rem; transform: translateY(-150%); background: white; padding: .6rem; }
.skip-link:focus { transform: translateY(0); }

.site-header { background: var(--white); border-bottom: 1px solid var(--line); }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: .5rem; min-height: 4.25rem; }
.wordmark { display: inline-flex; align-items: center; gap: .55rem; color: var(--ink); font-weight: 790; letter-spacing: -.025em; text-decoration: none; white-space: nowrap; }
.mark { display: flex; align-items: end; gap: .13rem; width: 1.72rem; height: 1.72rem; padding: .32rem; background: var(--blue); border-radius: .43rem; }
.mark i { display: block; flex: 1; height: 100%; background: white; border-radius: .05rem; }
.mark i:nth-child(2) { height: 73%; }
.mark i:nth-child(3) { height: 45%; }
nav { display: flex; gap: .2rem; align-items: center; }
nav a { display: block; color: var(--muted); font-size: .91rem; font-weight: 650; padding: .55rem .8rem; border-radius: .5rem; text-decoration: none; white-space: nowrap; }
nav a:hover, nav a[aria-current] { background: var(--blue-pale); color: var(--blue-dark); }

.intro { padding-block: clamp(1.9rem, 4.4vw, 3.55rem) 1.85rem; }
.intro h1 { font-size: clamp(2rem, 5.3vw, 3.48rem); line-height: 1.04; max-width: 18ch; letter-spacing: -.063em; font-weight: 790; }
.intro p { color: var(--muted); max-width: 43rem; margin-top: .85rem; font-size: clamp(1rem, 1.6vw, 1.11rem); }
.tool-grid { display: grid; grid-template-columns: minmax(0, 1.47fr) minmax(0, 1fr); align-items: start; gap: 1.1rem; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 1rem; min-width: 0; }
.calculator { padding: clamp(1rem, 3vw, 1.65rem); }
.panel-heading { margin-bottom: 1.05rem; }
h2 { font-size: 1.28rem; line-height: 1.23; letter-spacing: -.025em; }
.panel-heading p { margin-top: .35rem; }
.hint { color: var(--muted); font-size: .9rem; font-weight: 450; line-height: 1.45; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .83rem 1rem; }
label { display: block; min-width: 0; color: var(--ink); font-size: .92rem; font-weight: 690; }
.fields > label { display: grid; grid-template-rows: 1fr auto; align-items: end; }
.unit { display: inline-block; color: var(--muted); font-weight: 500; font-size: .82rem; }
input { display: block; width: 100%; min-width: 0; height: 2.75rem; margin-top: .32rem; padding: .48rem .65rem; border: 1px solid #b5c0d4; border-radius: .51rem; background: var(--white); color: var(--ink); font: inherit; font-size: 1rem; font-variant-numeric: tabular-nums; }
input:hover { border-color: #7183a6; }
input:focus { border-color: var(--blue); }
input:user-invalid { border-color: #ad362f; }
.field-note { margin-top: .64rem; }
.stock { min-width: 0; padding: .62rem .8rem .73rem; margin: 1rem 0 .7rem; border: 1px solid #cbd7ed; border-radius: .69rem; background: #f5f8ff; }
.stock legend { font-weight: 730; padding-inline: .28rem; }
.stock > p { margin-top: .6rem; }
.tile-fields > label { grid-template-rows: auto auto 1fr; align-items: start; }
.tile-fields .hint { margin-top: .33rem; }
.adjustment { padding-block: .13rem .62rem; }
summary { cursor: pointer; color: var(--blue-dark); font-weight: 660; font-size: .92rem; }
.adjustment label { margin-top: .62rem; max-width: 23rem; }
.adjustment > p { margin-top: .45rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: .62rem; margin-top: .9rem; }
button { cursor: pointer; font: inherit; font-size: .94rem; font-weight: 730; min-height: 2.72rem; border: 1px solid transparent; border-radius: .54rem; padding: .48rem .86rem; }
.primary { color: white; background: var(--blue); }
.primary:hover { background: var(--blue-dark); }
.secondary { color: var(--blue-dark); background: var(--white); border-color: #bfd0fb; }
.secondary:hover { background: var(--blue-pale); }
.form-note { margin-top: .75rem; }

.result { overflow: hidden; }
.result-top { color: white; background: var(--navy); padding: 1.35rem 1.5rem 1.24rem; border-bottom: .23rem solid #5776fa; }
.result-top h2 { color: #e1eaff; font-size: 1rem; letter-spacing: 0; }
.result-value { margin-block: .15rem .07rem; font-size: clamp(2.6rem, 5.6vw, 4rem); line-height: 1.13; font-weight: 790; letter-spacing: -.062em; overflow-wrap: anywhere; }
.result-copy { color: #e1eaff; font-size: .96rem; }
.result-body { padding: .38rem 1.5rem 1.2rem; }
.metrics > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: .8rem; padding: .69rem 0; border-bottom: 1px solid var(--line); }
.metrics dt { color: var(--muted); font-size: .92rem; }
.metrics dd { font-weight: 760; font-variant-numeric: tabular-nums; }
.result-note { color: var(--muted); font-size: .9rem; margin-top: .8rem; }

.guide { margin-block: clamp(2rem, 4vw, 3.3rem); }
.guide-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.2rem; margin-top: .95rem; }
.guide-grid > div { padding-top: .65rem; border-top: 2px solid #ccd7f5; }
.guide h3 { font-size: 1rem; margin-bottom: .28rem; }
.guide p { color: var(--muted); }
.guide-source { margin-top: 1rem; font-size: .94rem; }
.site-footer { border-top: 1px solid var(--line); }
.footer-inner { display: flex; justify-content: space-between; align-items: center; gap: .6rem; min-height: 3.9rem; color: var(--muted); font-size: .92rem; }

@media (max-width: 47rem) {
  .shell { width: min(70rem, 100% - 2rem); }
  .tool-grid { grid-template-columns: 1fr; }
  .intro h1 { max-width: 20ch; }
  .guide-grid { grid-template-columns: 1fr; gap: .8rem; }
}

@media (max-width: 26rem) {
  .shell { width: calc(100% - 1.5rem); }
  nav a { font-size: .85rem; padding-inline: .43rem; }
  .wordmark { gap: .35rem; font-size: .95rem; }
  .mark { width: 1.52rem; height: 1.52rem; }
  .fields { gap: .7rem; }
  .stock { padding-inline: .58rem; }
  .result-top, .result-body { padding-inline: 1rem; }
}

@media (max-width: 22rem) {
  .header-inner { flex-wrap: wrap; padding-block: .58rem; }
}
