/* Kelvin Temperature: "absolute cold" theme.
   Dark, deep-blue field with an icy accent. No external fonts, no frameworks. */

:root {
    --bg: #04070f;
    --bg-2: #081120;
    --surface: rgba(140, 200, 255, 0.055);
    --surface-strong: rgba(140, 200, 255, 0.10);
    --border: rgba(140, 200, 255, 0.16);
    --border-strong: rgba(140, 200, 255, 0.35);
    --text: #e7f1ff;
    --text-muted: #93a7c4;
    --text-faint: #5f7190;
    --ice: #8fe9ff;
    --ice-deep: #38bdf8;
    --ice-glow: rgba(143, 233, 255, 0.45);
    --warm: #ffb36b;
    --danger: #ff7a90;
    --danger-bg: rgba(255, 122, 144, 0.10);
    --radius: 18px;
    --radius-sm: 10px;
    --max: 1100px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
    font-family: var(--font);
    font-size: 17px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1100px 600px at 50% -10%, rgba(56, 189, 248, 0.22), transparent 70%),
        radial-gradient(800px 500px at 100% 110%, rgba(99, 102, 241, 0.12), transparent 70%),
        linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%);
    background-attachment: fixed;
}

/* Soft "frost" grain so large flat areas don't band. Pure CSS, no image request. */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    background-image:
        repeating-linear-gradient(0deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px),
        repeating-linear-gradient(90deg, rgba(255,255,255,0.012) 0 1px, transparent 1px 3px);
    mix-blend-mode: screen;
}

body > * { position: relative; z-index: 1; }

a { color: var(--ice); text-decoration-color: rgba(143, 233, 255, 0.4); text-underline-offset: 3px; }
a:hover { color: #fff; text-decoration-color: #fff; }
:focus-visible { outline: 2px solid var(--ice); outline-offset: 3px; border-radius: 4px; }

.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
    white-space: nowrap;
}

.skip-link {
    position: absolute; left: 1rem; top: -3rem;
    background: var(--ice); color: #04070f; padding: .5rem .9rem; border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: 1rem; z-index: 50; }

/* ---------- Header ---------- */
.site-header {
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(10px);
    background: rgba(4, 7, 15, 0.55);
    position: sticky; top: 0; z-index: 20;
}
.site-header .inner {
    max-width: var(--max); margin: 0 auto; padding: .8rem 1.25rem;
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: .65rem; text-decoration: none; color: var(--text); font-weight: 650; letter-spacing: .01em; }
.brand:hover { color: #fff; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 9px; flex: none;
    display: grid; place-items: center;
    background: linear-gradient(145deg, #0b1b33, #0a2a4a);
    border: 1px solid var(--border-strong);
    box-shadow: 0 0 18px rgba(56, 189, 248, 0.25), inset 0 0 12px rgba(143, 233, 255, 0.15);
    color: var(--ice); font-weight: 800; font-size: 1.1rem; font-family: var(--mono);
}
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: .25rem; }
.site-nav a {
    display: inline-block; padding: .45rem .8rem; border-radius: 999px;
    color: var(--text-muted); text-decoration: none; font-weight: 500; font-size: .95rem;
}
.site-nav a:hover { color: #fff; background: var(--surface); }
.site-nav a[aria-current="page"] { color: var(--ice); background: var(--surface-strong); }
.site-nav a.nav-donate {
    color: #04111e; font-weight: 650; margin-left: .35rem;
    background: linear-gradient(135deg, #38bdf8, #8fe9ff);
    box-shadow: 0 6px 18px -8px var(--ice-glow);
}
.site-nav a.nav-donate:hover { color: #04111e; background: linear-gradient(135deg, #5fd0ff, #b9f1ff); }

/* ---------- Layout ---------- */
main { max-width: var(--max); margin: 0 auto; padding: 2.5rem 1.25rem 4rem; }
.hero { text-align: center; margin: 0 auto 2rem; max-width: 760px; }
.eyebrow {
    display: inline-block; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
    color: var(--ice); font-weight: 600; margin-bottom: .9rem;
    padding: .3rem .7rem; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
}
h1 {
    font-size: clamp(2rem, 5.2vw, 3.4rem); line-height: 1.08; letter-spacing: -.02em; margin: 0 0 .8rem;
    background: linear-gradient(180deg, #ffffff 0%, #bfe9ff 100%);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { color: var(--text-muted); font-size: 1.1rem; margin: 0; }

/* ---------- Converter card ---------- */
.converter {
    display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 1.25rem;
    grid-template-areas: "form result" "presets presets";
    align-items: stretch;
}
.converter > form { grid-area: form; }
.converter > .result { grid-area: result; }
.converter > .presets { grid-area: presets; }
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(6px);
    box-shadow: 0 20px 60px -30px rgba(0, 0, 0, .8), inset 0 1px 0 rgba(255,255,255,.04);
}
.field { display: flex; flex-direction: column; gap: .4rem; margin-bottom: 1.1rem; }
.field label { font-size: .85rem; color: var(--text-muted); font-weight: 600; letter-spacing: .02em; }
.control {
    width: 100%; font: inherit; color: var(--text);
    background: rgba(4, 7, 15, 0.6); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    padding: .75rem .9rem; transition: border-color .15s, box-shadow .15s;
}
.control:hover { border-color: rgba(143, 233, 255, 0.55); }
.control:focus { outline: none; border-color: var(--ice); box-shadow: 0 0 0 3px rgba(143, 233, 255, 0.18), 0 0 24px rgba(56,189,248,.25); }
select.control {
    appearance: none; -webkit-appearance: none; padding-right: 2.6rem; cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none' stroke='%238fe9ff' stroke-width='1.8'><path d='M4 6l4 4 4-4'/></svg>");
    background-repeat: no-repeat; background-position: right .9rem center;
}
.value-wrap { position: relative; }
.value-wrap input { font-size: 1.6rem; font-variant-numeric: tabular-nums; padding-right: 3.6rem; font-weight: 600; }
.value-wrap input::-webkit-outer-spin-button, .value-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.value-wrap input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.unit-badge {
    position: absolute; right: .9rem; top: 50%; transform: translateY(-50%);
    color: var(--ice); font-weight: 700; font-size: 1.05rem; pointer-events: none; font-variant-numeric: tabular-nums;
}
.control.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(255,122,144,.15); }
.scale-hint { color: var(--text-faint); font-size: .85rem; margin: -.4rem 0 1rem; min-height: 1.3em; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; }
.btn {
    font: inherit; font-weight: 600; cursor: pointer; border-radius: 999px; padding: .65rem 1.2rem;
    border: 1px solid var(--border-strong); background: var(--surface-strong); color: var(--text);
    transition: transform .08s ease, background .15s, box-shadow .15s;
}
.btn:hover { background: rgba(140, 200, 255, 0.18); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(135deg, #38bdf8, #8fe9ff); color: #04111e; border-color: transparent; box-shadow: 0 8px 24px -8px var(--ice-glow); }
.btn-primary:hover { background: linear-gradient(135deg, #5fd0ff, #b9f1ff); }
.btn-ghost { background: transparent; }
.btn-sm { padding: .4rem .85rem; font-size: .88rem; }

.presets { display: flex; align-items: center; gap: .6rem 1.25rem; flex-wrap: wrap; padding: 1rem 1.5rem; }
.presets p { margin: 0; font-size: .8rem; color: var(--text-faint); text-transform: uppercase; letter-spacing: .12em; font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: .45rem; }
.chip {
    font: inherit; font-size: .85rem; cursor: pointer; color: var(--text-muted);
    background: transparent; border: 1px solid var(--border); border-radius: 999px; padding: .35rem .75rem;
    transition: color .15s, border-color .15s, background .15s;
}
.chip:hover { color: var(--ice); border-color: var(--border-strong); background: var(--surface); }

/* ---------- Result card ---------- */
.result { display: flex; flex-direction: column; justify-content: space-between; gap: 1rem; position: relative; overflow: hidden; }
.result::after {
    content: ""; position: absolute; inset: auto -30% -60% -30%; height: 70%;
    background: radial-gradient(closest-side, rgba(56,189,248,.18), transparent); pointer-events: none;
}
.result-label { font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--text-faint); font-weight: 600; margin: 0; }
.result-echo { color: var(--text-muted); margin: .25rem 0 0; font-size: 1.05rem; min-height: 1.5em; font-variant-numeric: tabular-nums; }
.result-value {
    margin: .2rem 0 0; font-weight: 750; letter-spacing: -.03em; line-height: 1;
    font-size: clamp(2.6rem, 7vw, 4.6rem); font-variant-numeric: tabular-nums;
    color: #fff; text-shadow: 0 0 28px var(--ice-glow), 0 0 2px rgba(255,255,255,.6);
    transition: opacity .15s;
    overflow-wrap: anywhere;
}
.result-value .unit { color: var(--ice); font-weight: 600; font-size: .5em; margin-left: .18em; vertical-align: .38em; letter-spacing: 0; }
.result.is-empty .result-value { color: var(--text-faint); text-shadow: none; }
.result-note { margin: .4rem 0 0; color: var(--text-muted); min-height: 1.5em; }
.result.is-error .result-value { color: var(--danger); text-shadow: 0 0 20px rgba(255,122,144,.35); }
.result.is-error .result-note { color: var(--danger); }
.result-tools { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.result-tools .copied { color: var(--ice); font-size: .85rem; opacity: 0; transition: opacity .2s; }
.result-tools .copied.show { opacity: 1; }

.equivalents { list-style: none; margin: 0; padding: .9rem 0 0; border-top: 1px solid var(--border);
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1rem; }
.equivalents li { display: flex; justify-content: space-between; gap: .75rem; font-size: .95rem; }
.equivalents .k { color: var(--text-faint); }
.equivalents .v { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Absolute scale ---------- */
.scale-card { margin-top: 1.25rem; }
.scale-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }
.scale-head h2 { margin: 0; font-size: 1.05rem; letter-spacing: .01em; }
.scale-head p { margin: 0; color: var(--text-faint); font-size: .88rem; }
.scale { position: relative; height: 150px; margin: 0 1.25rem; }
.scale-bar {
    position: absolute; left: 0; right: 0; top: 64px; height: 12px; border-radius: 999px;
    background: linear-gradient(90deg, #0a1a3a 0%, #1746a2 20%, #38bdf8 46%, #c8f3ff 62%, #ffe9b8 80%, #ffb36b 100%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.08), 0 0 24px rgba(56,189,248,.18);
}
.scale-tick { position: absolute; top: 60px; width: 1px; height: 20px; background: rgba(255,255,255,.35); transform: translateX(-50%); }
.scale-tick .lbl {
    position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap;
    font-size: .72rem; color: var(--text-faint); line-height: 1.2; text-align: center;
}
.scale-tick .lbl b { display: block; color: var(--text-muted); font-weight: 600; font-variant-numeric: tabular-nums; }
.scale-tick.row1 .lbl { top: 26px; }
.scale-tick.row2 .lbl { top: 56px; }
.scale-tick.row2 { height: 50px; background: linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,.08)); }
.scale-tick.edge .lbl { transform: none; left: auto; right: 0; text-align: right; }
.scale-tick.minor { height: 12px; top: 64px; background: rgba(255,255,255,.22); }
.scale-marker {
    position: absolute; top: 8px; transform: translateX(-50%); transition: left .35s cubic-bezier(.2,.8,.2,1), opacity .2s;
    display: flex; flex-direction: column-reverse; align-items: center; pointer-events: none; opacity: 0;
}
.scale-marker.show { opacity: 1; }
.scale-marker .tag {
    font-size: .78rem; font-weight: 700; color: #04111e; background: #fff; padding: .15rem .5rem; border-radius: 6px;
    white-space: nowrap; font-variant-numeric: tabular-nums; box-shadow: 0 4px 16px rgba(0,0,0,.5);
}
.scale-marker .pin { width: 4px; height: 50px; margin-top: 4px; border-radius: 2px; background: #fff; box-shadow: 0 0 14px #fff, 0 0 30px var(--ice-glow); }
.scale-marker.pinned .tag::after { content: " \2192"; }
.scale-foot { margin: .4rem 0 0; color: var(--text-muted); font-size: .92rem; min-height: 1.4em; }

/* ---------- Prose ---------- */
.prose { max-width: 760px; margin: 3.5rem auto 0; }
.prose h2 { font-size: 1.55rem; letter-spacing: -.01em; margin: 2.4rem 0 .7rem; color: #fff; }
.prose h3 { font-size: 1.15rem; margin: 1.8rem 0 .5rem; color: #fff; }
.prose p, .prose li { color: #c4d2e6; }
.prose li { margin-bottom: .5rem; }
.prose li b, .prose p b { color: var(--text); }
.prose code { font-family: var(--mono); font-size: .92em; color: var(--ice); background: var(--surface); padding: .1em .4em; border-radius: 6px; }
.prose .note { border-left: 3px solid var(--ice-deep); padding: .6rem 1rem; background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--text-muted); }

table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.5rem; font-size: .95rem; }
th, td { text-align: left; padding: .6rem .75rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--text-muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; }
td { color: #c4d2e6; font-variant-numeric: tabular-nums; }
td code { white-space: nowrap; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .2rem 1rem; margin-bottom: .6rem; background: var(--surface); }
details summary { cursor: pointer; font-weight: 600; padding: .6rem 0; color: var(--text); list-style: none; display: flex; justify-content: space-between; gap: 1rem; }
details summary::-webkit-details-marker { display: none; }
details summary::after { content: "+"; color: var(--ice); font-weight: 700; }
details[open] summary::after { content: "−"; }
details p { margin: 0 0 .9rem; }

.breadcrumb { font-size: .85rem; color: var(--text-faint); margin: 0 0 1rem; }
.breadcrumb ol { list-style: none; padding: 0; margin: 0; display: flex; gap: .4rem; flex-wrap: wrap; }
.breadcrumb li + li::before { content: "/"; margin-right: .4rem; color: var(--text-faint); }
.breadcrumb a { color: var(--text-muted); }

.cta-card { margin-top: 2.5rem; text-align: center; }
.cta-card p { margin: 0 0 1rem; color: var(--text-muted); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); margin-top: 2rem; }
.site-footer .inner { max-width: var(--max); margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--text-faint); font-size: .88rem; }
.site-footer a { color: var(--text-muted); }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 1rem; flex-wrap: wrap; }

/* ---------- 404 ---------- */
.lost { text-align: center; padding: 4rem 0; }
.lost .big { font-size: clamp(4rem, 15vw, 9rem); font-weight: 800; line-height: 1; letter-spacing: -.04em; color: #fff; text-shadow: 0 0 40px var(--ice-glow); margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
    .converter { grid-template-columns: 1fr; grid-template-areas: "form" "result" "presets"; }
    .scale-tick.mobile-hide .lbl { display: none; }
    .scale-tick.mobile-hide.row2 { height: 20px; }
    .scale-tick .lbl { font-size: .68rem; }
}
@media (max-width: 560px) {
    html { font-size: 16px; }
    .nav-long { display: none; }
    .brand span:last-child { white-space: nowrap; }
    .site-header .inner { padding: .7rem 1rem; gap: .5rem; }
    .site-nav ul { gap: .1rem; }
    .site-nav a { font-size: .9rem; }
    .site-nav a.nav-donate { margin-left: .2rem; }
    main { padding: 1.75rem 1rem 3rem; }
    .card { padding: 1.15rem; }
    .site-nav a { padding: .4rem .6rem; }
    .equivalents { grid-template-columns: 1fr; }
}
@media (max-width: 430px) {
    .brand span:last-child { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
