/* ==================== Tokens ==================== */
:root {
    --bg: #f3f6f7;
    --bg-glow: rgba(15, 118, 110, 0.10);
    --surface: #ffffff;
    --surface-2: #f6f9f9;
    --border: #dde5e7;
    --border-strong: #c3d0d3;
    --ink: #0f1f24;
    --ink-2: #4a5b61;
    --ink-3: #5a6a70;
    --primary: #0f766e;
    --primary-hover: #0b5f58;
    --primary-soft: #e3f3f1;
    --on-primary: #ffffff;
    --focus: rgba(15, 118, 110, 0.28);

    --ok: #15803d;
    --ok-soft: #e4f5ea;
    --low: #b45309;
    --low-soft: #fdf0e1;
    --high: #be123c;
    --high-soft: #fde7ec;
    --band: #bfe5d0;

    --shadow-sm: 0 1px 2px rgba(15, 31, 36, 0.06);
    --shadow-md: 0 1px 3px rgba(15, 31, 36, 0.06), 0 8px 24px rgba(15, 31, 36, 0.07);
    --shadow-lg: 0 12px 40px rgba(15, 31, 36, 0.14);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --font: "Inter", "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "Cascadia Mono", "SF Mono", ui-monospace, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0b1416;
        --bg-glow: rgba(45, 212, 191, 0.08);
        --surface: #121e21;
        --surface-2: #17262a;
        --border: #24363b;
        --border-strong: #345056;
        --ink: #e6f0f1;
        --ink-2: #a7b8bc;
        --ink-3: #8ea1a6;
        --primary: #2dd4bf;
        --primary-hover: #5eead4;
        --primary-soft: #133a37;
        --on-primary: #04201d;
        --focus: rgba(45, 212, 191, 0.32);

        --ok: #4ade80;
        --ok-soft: #12301d;
        --low: #fbbf24;
        --low-soft: #3a2a0c;
        --high: #fb7185;
        --high-soft: #3d1520;
        --band: #1f5a43;

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
        --shadow-md: 0 1px 3px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
        --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
    }
}

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

* {
    margin: 0;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background:
        radial-gradient(1200px 500px at 50% -120px, var(--bg-glow), transparent 70%),
        var(--bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
    color: inherit;
}

[hidden] {
    display: none !important;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

/* ==================== Top bar ==================== */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: saturate(160%) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: 920px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
}

.brand-mark {
    width: 30px;
    height: 30px;
}

.brand-mark rect {
    fill: var(--primary);
}

.brand-mark path {
    fill: none;
    stroke: var(--on-primary);
    stroke-width: 2.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-tagline {
    color: var(--ink-3);
    font-size: 0.875rem;
}

.segmented.segmented-sm button {
    padding: 3px 10px;
    font-size: 0.8rem;
}

/* ==================== Page ==================== */
.page {
    flex: 1;
    width: 100%;
    max-width: 920px;
    margin: 0 auto;
    padding: 48px 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* ==================== Hero & search ==================== */
.hero h1 {
    font-size: clamp(1.75rem, 4vw, 2.5rem);
    line-height: 1.15;
    letter-spacing: -0.025em;
    font-weight: 750;
    text-wrap: balance;
}

.hero-sub {
    margin-top: 10px;
    max-width: 60ch;
    color: var(--ink-2);
    font-size: 1.05rem;
    text-wrap: pretty;
}

.search {
    position: relative;
    margin-top: 24px;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    width: 22px;
    height: 22px;
    transform: translateY(-50%);
    fill: none;
    stroke: var(--ink-3);
    stroke-width: 2;
    stroke-linecap: round;
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 60px;
    padding: 0 56px 0 52px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    background: var(--surface);
    font-size: 1.1rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input::placeholder {
    color: var(--ink-3);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus);
}

.search-kbd {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    min-width: 26px;
    padding: 2px 8px;
    border: 1px solid var(--border-strong);
    border-bottom-width: 2px;
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-family: var(--mono);
    font-size: 0.8rem;
    text-align: center;
    pointer-events: none;
}

.search-input:focus ~ .search-kbd {
    display: none;
}

/* Listbox */
.listbox {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 30;
    max-height: min(440px, 60vh);
    overflow-y: auto;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overscroll-behavior: contain;
}

.listbox-group {
    position: sticky;
    top: -6px;
    z-index: 1;
    padding: 10px 12px 6px;
    background: var(--surface);
    color: var(--ink-3);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.option {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.option-name {
    font-weight: 600;
    white-space: nowrap;
}

.option-desc {
    color: var(--ink-3);
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.option-alias {
    color: var(--primary);
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.option-cat {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--ink-3);
    font-size: 0.75rem;
}

.option mark {
    background: transparent;
    color: var(--primary);
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.option.is-active {
    background: var(--primary-soft);
}

.listbox-empty {
    padding: 18px 12px;
    color: var(--ink-2);
}

/* Category chips */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 16px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font-size: 0.875rem;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background-color 0.15s;
}

.chip:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.chip[aria-pressed="true"] {
    background: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.chip-count {
    font-size: 0.75rem;
    color: var(--ink-3);
    font-variant-numeric: tabular-nums;
}

.chip[aria-pressed="true"] .chip-count {
    color: inherit;
    opacity: 0.92;
}

/* Recent */
.recent {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
    font-size: 0.875rem;
}

.recent-label {
    color: var(--ink-3);
}

.recent-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.recent-item {
    padding: 2px 10px;
    border: none;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.recent-item:hover {
    text-decoration: underline;
}

/* ==================== Empty state ==================== */
.steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.step {
    padding: 20px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-md);
}

.step-num {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
}

.step h3 {
    margin-top: 12px;
    font-size: 1rem;
}

.step p {
    margin-top: 4px;
    color: var(--ink-2);
    font-size: 0.925rem;
}

/* ==================== Test card ==================== */
.card {
    padding: 28px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    animation: rise 0.25s ease-out;
}

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.pill {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.test-name {
    margin-top: 8px;
    font-size: clamp(1.5rem, 3vw, 1.9rem);
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.test-description {
    margin-top: 4px;
    color: var(--ink-2);
}

.test-example {
    margin-top: 6px;
    font-weight: 600;
    color: var(--ink);
}

.test-example-factor,
.test-source {
    margin-top: 2px;
    font-size: 0.9rem;
    color: var(--ink-2);
}

.test-source a {
    color: inherit;
    text-decoration: underline;
}

.btn-ghost {
    flex-shrink: 0;
    padding: 8px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink-2);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* Men / women switch */
.range-switch {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    margin-top: 20px;
}

.range-switch-label {
    color: var(--ink-2);
    font-size: 0.9rem;
}

.segmented {
    display: inline-flex;
    padding: 3px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.segmented button {
    padding: 5px 14px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--ink-2);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.segmented button:hover {
    color: var(--primary);
}

.segmented button[aria-checked="true"] {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Status + range bar */
.status {
    margin-top: 22px;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.status-top {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.875rem;
}

.badge.ok {
    background: var(--ok-soft);
    color: var(--ok);
}

.badge.low {
    background: var(--low-soft);
    color: var(--low);
}

.badge.high {
    background: var(--high-soft);
    color: var(--high);
}

.status-text {
    color: var(--ink-2);
    font-size: 0.925rem;
    font-variant-numeric: tabular-nums;
}

.rangebar {
    margin-top: 16px;
}

.rangebar-track {
    position: relative;
    height: 10px;
    border-radius: 999px;
    background: var(--border);
}

.rangebar-band {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 999px;
    background: var(--band);
}

.rangebar-marker {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid var(--surface);
    background: var(--ink);
    box-shadow: var(--shadow-sm);
    transform: translate(-50%, -50%);
    transition: left 0.25s ease-out, background-color 0.2s;
}

.status[data-state="ok"] .rangebar-marker { background: var(--ok); }
.status[data-state="low"] .rangebar-marker { background: var(--low); }
.status[data-state="high"] .rangebar-marker { background: var(--high); }

.rangebar-labels {
    position: relative;
    height: 18px;
    margin-top: 6px;
    color: var(--ink-3);
    font-size: 0.75rem;
    font-variant-numeric: tabular-nums;
}

.rangebar-labels span {
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
}

/* Unit fields */
.units {
    margin-top: 22px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
    gap: 12px;
}

.unit {
    position: relative;
    min-width: 0;
    padding: 12px 14px 12px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}

.unit:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--focus);
}

.unit.is-source {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.unit.is-invalid {
    border-color: var(--high);
}

.unit-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.unit-input {
    flex: 1;
    width: 100%;
    min-width: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.5rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    font-variant-numeric: tabular-nums;
}

.unit-input:focus {
    outline: none;
}

.unit-input::placeholder {
    color: var(--ink-3);
    font-weight: 400;
    opacity: 0.6;
}

.unit-symbol {
    flex-shrink: 0;
    color: var(--ink-2);
    font-weight: 600;
    font-size: 0.95rem;
}

.unit-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
    min-height: 24px;
}

.unit-ref {
    color: var(--ink-3);
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.unit-error {
    color: var(--high);
    font-size: 0.8rem;
}

.copy-btn {
    padding: 2px 8px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--ink-3);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background-color 0.15s;
}

.unit:hover .copy-btn,
.copy-btn:focus-visible,
.copy-btn.is-done {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--surface-2);
    color: var(--primary);
}

.copy-btn.is-done {
    color: var(--ok);
}

.unit-same {
    margin-top: 2px;
    color: var(--ink-3);
    font-size: 0.78rem;
}

.more-units {
    margin-top: 14px;
}

.more-btn {
    padding: 6px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
}

.more-btn:hover {
    border-style: solid;
    border-color: var(--primary);
}

.more-units .units {
    margin-top: 12px;
}

.pill-research {
    margin-left: 6px;
    background: var(--low-soft);
    color: var(--low);
}

.research-note {
    margin-top: 18px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--low-soft);
    color: var(--ink-2);
    font-size: 0.875rem;
}

.card-note {
    margin-top: 20px;
    color: var(--ink-3);
    font-size: 0.825rem;
    max-width: 75ch;
}

/* ==================== Footer ==================== */
.footer {
    padding: 24px 20px 32px;
    text-align: center;
    color: var(--ink-3);
    font-size: 0.85rem;
}

.footer-meta {
    margin-top: 4px;
    font-size: 0.8rem;
}

.footer-legal {
    margin-top: 10px;
    font-size: 0.8rem;
}

.footer-legal a {
    color: var(--ink-3);
    text-decoration: none;
}

.footer-legal a:hover,
.footer-legal a:focus-visible {
    color: var(--primary);
    text-decoration: underline;
}

.footer-legal span {
    margin: 0 8px;
    color: var(--border-strong);
}

/* ==================== Legal pages ==================== */
.legal {
    max-width: 720px;
    margin: 0 auto;
    padding: 40px 20px 60px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.legal h1 {
    font-size: 1.6rem;
    margin-bottom: 4px;
}

.legal h2 {
    font-size: 1.15rem;
    margin-top: 28px;
    color: var(--ink);
}

.legal h3 {
    font-size: 1rem;
    margin-top: 16px;
    color: var(--ink-2);
}

.legal p,
.legal li {
    color: var(--ink-2);
    font-size: 0.95rem;
}

.legal ul {
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legal a {
    color: var(--primary);
}

.legal .legal-meta {
    color: var(--ink-3);
    font-size: 0.85rem;
}

.legal .legal-lang-divider {
    margin: 36px 0 8px;
    border: none;
    border-top: 1px solid var(--border);
}

.legal .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    margin-bottom: 8px;
}

.source-dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    margin: 0 4px 1px 8px;
    border-radius: 50%;
    background: var(--ok);
}

.source-dot.offline {
    background: var(--low);
}

/* ==================== Responsive ==================== */
@media (max-width: 720px) {
    .page {
        padding: 28px 16px 32px;
        gap: 22px;
    }

    .topbar-inner {
        padding: 10px 16px;
    }

    .steps {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px 16px;
    }

    .card-head {
        flex-direction: column;
    }

    .units {
        grid-template-columns: 1fr;
    }

    .option-cat,
    .search-kbd {
        display: none;
    }

    .copy-btn {
        opacity: 1;
    }
}

@media (max-width: 420px) {
    .brand-tagline {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation: none !important;
        transition: none !important;
    }
}

/* ==================== Contact form (legal/kontakt.html) ==================== */
.contact-form {
    max-width: 560px;
    margin-top: 20px;
}

.contact-form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 0.9rem;
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
}

.contact-form input:focus-visible,
.contact-form textarea:focus-visible {
    outline: 3px solid var(--focus);
    border-color: var(--primary);
}

.contact-form .cf-consent {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.contact-form .cf-consent label {
    font-weight: 400;
    margin: 0;
}

.contact-form .cf-consent input {
    margin-top: 4px;
}

.contact-form .cf-hp {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.contact-form .cf-submit {
    padding: 10px 22px;
    font: inherit;
    font-weight: 600;
    color: var(--on-primary);
    background: var(--primary);
    border: 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.contact-form .cf-submit:hover {
    background: var(--primary-hover);
}

.contact-form .cf-submit:disabled {
    opacity: 0.6;
    cursor: wait;
}

.contact-form .cf-ok {
    color: var(--ok);
}

.contact-form .cf-err {
    color: var(--high);
}
