/* ---- Tokens ---- */
:root {
    --bg: #1c1712;
    --surface: #262019;
    --surface-raised: #302921;
    --border: #4a4033;
    --text: #ede6da;
    --text-muted: #a89c8a;

    --sage: #86ac8a;
    --sage-dim: #4f6b53;
    --amber: #d9a056;
    --amber-dim: #7a5c33;
    --slate: #7699b8;
    --slate-dim: #445a6c;
    --terracotta: #d17a54;

    --font-display: "Fraunces", Georgia, serif;
    --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;

    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    margin: 0;
    padding: 32px 16px 64px;
    line-height: 1.5;
}

.page {
    max-width: 640px;
    margin: 0 auto;
}

/* ---- Header ---- */
.page-header {
    text-align: center;
    margin-bottom: 28px;
}

h1 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: clamp(28px, 5vw, 38px);
    margin: 0 0 8px;
    letter-spacing: -0.01em;
}

.tagline {
    color: var(--text-muted);
    font-size: 16px;
    margin: 0;
    max-width: 46ch;
    margin-inline: auto;
}

h2 {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 22px;
    margin: 0 0 10px;
}

.tool-divider {
    text-align: center;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.tool-divider h2 {
    margin-bottom: 6px;
}

/* ---- Layout sections ---- */
.container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.calculator,
.result,
.explainer,
.references {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
}

.explainer,
.references {
    text-align: left;
}

.explainer p {
    color: var(--text-muted);
}

.explainer p + h2 {
    margin-top: 20px;
}

/* ---- Calculator inputs ---- */
.input-group {
    margin-bottom: 16px;
}

.input-group:last-of-type {
    margin-bottom: 0;
}

.input-group > label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: var(--text-muted);
    text-align: left;
}

.input-group--split {
    display: flex;
    gap: 16px;
}

.input-group--split > div {
    flex: 1;
}

.input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

input[type="number"],
select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--surface-raised);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 16px;
    font-variant-numeric: tabular-nums;
}

.input-row input[type="number"] {
    max-width: 110px;
}

input[type="number"]:focus-visible,
select:focus-visible,
button:focus-visible,
.temp-toggle label:has(input:focus-visible) {
    outline: 2px solid var(--sage);
    outline-offset: 2px;
}

.temp-toggle {
    display: flex;
    gap: 8px;
}

.temp-toggle input[type="radio"] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.temp-toggle label {
    cursor: pointer;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background-color: var(--surface-raised);
    color: var(--text);
    font-family: var(--font-mono);
    font-size: 14px;
}

.temp-toggle input[type="radio"]:checked + label {
    background-color: var(--sage-dim);
    border-color: var(--sage);
}

.field-hint {
    font-size: 13px;
    color: var(--text-muted);
    margin: 8px 0 0;
    text-align: left;
}

.field-hint a {
    color: var(--sage);
}

.advanced-settings {
    margin-bottom: 16px;
}

.advanced-settings summary {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    list-style: none;
    font-size: 14px;
    color: var(--text-muted);
    user-select: none;
}

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

.advanced-settings summary::before {
    content: "\25B8";
    display: inline-block;
    color: var(--text-muted);
    transition: transform 0.15s ease;
}

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

.advanced-settings summary:hover {
    color: var(--text);
}

.advanced-settings summary:focus-visible {
    outline: 2px solid var(--sage);
    outline-offset: 2px;
}

.advanced-settings .input-group--split {
    margin-top: 14px;
}

.advanced-settings .field-hint {
    margin-top: 10px;
}

.input-error {
    background-color: rgba(209, 122, 84, 0.15);
    border: 1px solid var(--terracotta);
    color: var(--text);
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 14px;
    margin: 16px 0 0;
    text-align: left;
}

button {
    width: 100%;
    padding: 12px 20px;
    border: none;
    border-radius: 6px;
    background-color: var(--sage-dim);
    color: var(--text);
    cursor: pointer;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 15px;
    margin-top: 18px;
    transition: background-color 0.15s ease;
}

button:hover {
    background-color: var(--sage);
    color: #14100c;
}

/* ---- Result / gauge ---- */
.result {
    text-align: center;
}

.gauge-wrap {
    margin-bottom: 20px;
}

.gauge {
    position: relative;
    height: 14px;
    border-radius: 999px;
    overflow: visible;
    background-color: var(--surface-raised);
}

.gauge-zone {
    position: absolute;
    top: 0;
    height: 100%;
}

/* Zone bounds derived from GAUGE_MIN=0.4, GAUGE_MAX=2.2, split at 0.7 and 1.2 kPa.
   Keep in sync with the JS constants of the same name. */
.gauge-zone--slow {
    left: 0;
    width: 16.67%;
    background-color: var(--slate-dim);
    border-radius: 999px 0 0 999px;
}

.gauge-zone--transition {
    left: 16.67%;
    width: 27.77%;
    background-color: var(--surface-raised);
}

.gauge-zone--fast {
    left: 44.44%;
    width: 55.56%;
    background-color: var(--amber-dim);
    border-radius: 0 999px 999px 0;
}

.gauge-ideal {
    position: absolute;
    top: -3px;
    height: 20px;
    background-color: rgba(134, 172, 138, 0.45);
    border: 1px solid var(--sage);
    border-radius: 999px;
    transition: left 0.3s ease, width 0.3s ease;
}

.gauge-needle {
    position: absolute;
    top: -6px;
    width: 4px;
    height: 26px;
    background-color: var(--text);
    border-radius: 2px;
    transform: translateX(-2px);
    transition: left 0.3s ease;
}

.gauge-scale {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.gauge-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

.vpd-readout {
    font-family: var(--font-display);
    font-size: 40px;
    font-weight: 600;
    margin: 4px 0 2px;
    font-variant-numeric: tabular-nums;
}

.vpd-readout .unit {
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 500;
    color: var(--text-muted);
}

.result p {
    margin: 6px 0;
}

.muted-line {
    color: var(--text-muted);
    font-size: 14px;
}

.result .disclaimer {
    color: var(--text-muted);
    font-size: 12px;
    max-width: 48ch;
    margin: 16px auto 0;
}

.warning-message {
    color: var(--amber);
    font-size: 14px;
}

.status-good {
    color: var(--sage);
    font-weight: 600;
}

.status-okay {
    color: var(--amber);
    font-weight: 600;
}

.status-bad {
    color: var(--terracotta);
    font-weight: 600;
}

/* ---- Explainer / chart figure ---- */
.chart-figure {
    margin: 20px 0 0;
}

.chart-figure img {
    width: 100%;
    height: auto;
    border-radius: 6px;
    border: 1px solid var(--border);
    display: block;
}

.chart-figure figcaption {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}

.chart-figure figcaption a {
    color: var(--sage);
}

/* ---- References ---- */
.references ol {
    list-style-type: decimal;
    padding-left: 20px;
    margin: 0;
    color: var(--text-muted);
}

.references ol li {
    margin-bottom: 6px;
}

.references ol li a {
    color: var(--sage);
}

.references ol li a:hover {
    text-decoration: underline;
}

/* ---- Responsive ---- */
@media (max-width: 420px) {
    .input-group--split {
        flex-direction: column;
        gap: 16px;
    }

    .vpd-readout {
        font-size: 34px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gauge-ideal,
    .gauge-needle,
    button {
        transition: none;
    }
}
