:root {
  --bg: #f6f4ec;
  --surface: #ffffff;
  --surface-sunken: #eef0e6;
  --text: #1f2a20;
  --text-muted: #61705f;
  --border: #dde2d2;
  --accent: #3c7a52;
  --accent-strong: #2a5a3c;
  --accent-contrast: #f5fbf3;
  --readout-bg: #1c231b;
  --readout-fg: #d8f5df;
  --readout-fg-dim: #7fa98a;
  --warn: #a35a1c;
  --warn-bg: #f7ead9;
  --danger: #b3261e;
  --danger-bg: #fbe4e1;
  --shadow: 0 1px 2px rgba(30, 40, 25, 0.06), 0 8px 24px -12px rgba(30, 40, 25, 0.18);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10140f;
    --surface: #171d15;
    --surface-sunken: #1e2519;
    --text: #e8ede3;
    --text-muted: #93a390;
    --border: #2b3427;
    --accent: #6cbf85;
    --accent-strong: #8fd6a2;
    --accent-contrast: #0d1a10;
    --readout-bg: #0b100a;
    --readout-fg: #b9f3c6;
    --readout-fg-dim: #5c8468;
    --warn: #e0a05a;
    --warn-bg: #2c2013;
    --danger: #ff8a80;
    --danger-bg: #3a1512;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: #10140f;
  --surface: #171d15;
  --surface-sunken: #1e2519;
  --text: #e8ede3;
  --text-muted: #93a390;
  --border: #2b3427;
  --accent: #6cbf85;
  --accent-strong: #8fd6a2;
  --accent-contrast: #0d1a10;
  --readout-bg: #0b100a;
  --readout-fg: #b9f3c6;
  --readout-fg-dim: #5c8468;
  --warn: #e0a05a;
  --warn-bg: #2c2013;
  --danger: #ff8a80;
  --danger-bg: #3a1512;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 28px -14px rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  padding-inline: 20px;
  padding-block: 40px;
  display: flex;
  justify-content: center;
  margin: 0;
}

.page {
  position: relative;
  width: 100%;
  max-width: 460px;
}

header {
  margin-bottom: 24px;
}

.eyebrow {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent-strong);
  margin: 0 0 6px;
}

h1 {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 600;
  font-size: 1.9rem;
  line-height: 1.15;
  margin: 0 0 8px;
  text-wrap: balance;
  color: var(--text);
}

.sub {
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.5;
  margin: 0;
  max-width: 42ch;
}

.sub code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.85em;
  background: var(--surface-sunken);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.01em;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

input[type="number"], select {
  width: 100%;
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background: var(--surface-sunken);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s ease;
}

select {
  font-family: "Inter", sans-serif;
  font-weight: 500;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

input[type="number"]:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.unit {
  position: absolute;
  right: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
  pointer-events: none;
}

input[type="number"] {
  padding-right: 38px;
}

.adv {
  border: none;
  padding: 0;
  margin: 0;
}

.adv summary {
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
}

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

.adv summary::before {
  content: "▸";
  font-size: 0.7em;
  transition: transform 0.15s ease;
}

.adv[open] summary::before {
  transform: rotate(90deg);
}

.adv .field {
  margin-top: 12px;
}

.readout {
  background: var(--readout-bg);
  border-radius: 12px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.readout-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}

.readout-label {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--readout-fg-dim);
}

.readout-value {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  color: var(--readout-fg-dim);
  white-space: nowrap;
}

.readout-row.main .readout-value {
  font-size: 1.9rem;
  color: var(--readout-fg);
  font-weight: 600;
}

.readout-row.main .readout-label {
  color: var(--readout-fg);
}

.divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.note {
  font-size: 0.82rem;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 9px;
  background: var(--warn-bg);
  color: var(--warn);
  display: none;
}

.req {
  color: var(--warn);
  font-weight: 600;
}

.note.info {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.note.critical {
  background: var(--danger-bg);
  color: var(--danger);
}

.note.show { display: block; }

.note.show:not(.info) {
  animation: note-blink 1.1s ease-in-out infinite;
}

@keyframes note-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

@media (prefers-reduced-motion: reduce) {
  .note.show:not(.info) { animation: none; }
}

footer {
  margin-top: 20px;
  font-size: 0.76rem;
  color: var(--text-muted);
  line-height: 1.6;
  text-align: center;
}

footer code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
}

.footer-divider {
  height: 1px;
  background: var(--border);
  margin: 14px auto;
  max-width: 220px;
}

.footer-contact {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  margin-bottom: 6px;
  font-size: 0.8rem;
}

.footer-contact a {
  color: var(--accent-strong);
  text-decoration: none;
  font-weight: 500;
}

.footer-contact a:hover {
  text-decoration: underline;
}

.footer-copy {
  margin: 0;
  font-size: 0.72rem;
}

@media (max-width: 420px) {
  .field-row { grid-template-columns: 1fr; }
  h1 { font-size: 1.6rem; }
}
