:root {
    --ink: #0d0d0f;
    --ink-soft: #86868c;
    --bg: #ffffff;
    --panel: #ffffff;
    --panel-alt: #f2f2f4;
    --line: #ececee;
    --accent: #f56201;
    --accent-ink: #a84400;
    --pos: #34a35a;
    --neg: #d64545;
    --radius: 18px;
    --radius-lg: 26px;
    --radius-pill: 999px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --font-head: 'Manrope', 'Segoe UI', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-body);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}

a { color: inherit; text-decoration: none; }
.ic { width: 20px; height: 20px; flex-shrink: 0; stroke-width: 1.6px; }
.ic-lg { width: 28px; height: 28px; }
.ic-xl { width: 40px; height: 40px; }
.ic-knob { fill: currentColor; stroke: none; }

/* ---------- App shell: header + footer pinned, only the middle scrolls ---------- */
.app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    max-width: 480px;
    margin: 0 auto;
    background: var(--bg);
    overflow: hidden;
}

/* ---------- Topbar ---------- */
.topbar {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 9px 16px;
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(10px);
    view-transition-name: app-topbar;
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 34px; width: auto; display: block; }
.topbar-link {
    display: flex; align-items: center; gap: 6px;
    font-weight: 700;
    font-size: 13px;
    padding: 10px 16px;
    border-radius: var(--radius-pill);
    background: var(--panel-alt);
    color: var(--ink);
}
.topbar-link .ic { width: 16px; height: 16px; }

.app-main {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    padding: 8px 16px 16px;
    view-transition-name: app-main;
}

/* ---------- Buttons ---------- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    width: 100%;
    padding: 14px 20px;
    font-family: var(--font-head);
    font-size: 15.5px;
    font-weight: 700;
    letter-spacing: -.01em;
    border-radius: var(--radius-pill);
    border: none;
    cursor: pointer;
    min-height: 50px;
    text-align: center;
    transition: transform .08s ease, opacity .15s ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { opacity: .85; }
.btn-secondary { background: var(--panel-alt); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); font-weight: 700; }
.btn-block { margin-top: 10px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

/* ---------- Cards ---------- */
.card {
    background: var(--panel);
    border-radius: var(--radius-lg);
    padding: 16px 16px;
    border: 1px solid var(--line);
    box-shadow: 0 10px 30px -18px rgba(13,13,15,.25);
    margin-bottom: 12px;
}

/* Large "album art" style visual block, echoing the reference mock */
.hero-art {
    width: 92px;
    height: 92px;
    margin: 0 auto 12px;
    border-radius: 24px;
    background: radial-gradient(120% 120% at 20% 15%, #2b2b30 0%, #0d0d0f 70%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 14px 26px -14px rgba(13,13,15,.45);
}
.hero-art .ic { width: 38px; height: 38px; color: #fff; stroke-width: 1.3px; }

.hero { text-align: center; padding: 4px 4px 2px; }
.hero h1 { font-family: var(--font-head); font-size: 21px; font-weight: 800; margin: 0 0 5px; line-height: 1.22; letter-spacing: -.02em; }
.hero p { color: var(--ink-soft); font-size: 13.5px; line-height: 1.4; }

.field { margin-bottom: 12px; }
.field label { display: block; font-family: var(--font-head); font-weight: 700; font-size: 12.5px; margin-bottom: 6px; color: var(--ink-soft); }
.field input[type=email],
.field input[type=password],
.field input[type=text],
.field input[type=number] {
    width: 100%;
    padding: 13px 15px;
    font-size: 16px;
    font-family: var(--font-body);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-alt);
    color: var(--ink);
}
.field input:focus { outline: none; border-color: var(--ink); background: #fff; }
.field-hint { font-size: 12px; color: var(--ink-soft); margin-top: 5px; }
.field-checkbox { display: flex; align-items: flex-start; gap: 10px; font-size: 12.5px; line-height: 1.5; color: var(--ink-soft); cursor: pointer; }
.field-checkbox input { margin-top: 2px; width: 17px; height: 17px; flex-shrink: 0; accent-color: var(--accent); }
.field-checkbox a { color: var(--ink); font-weight: 600; text-decoration: underline; }
.field-error { font-size: 13px; color: var(--neg); margin-top: 5px; font-weight: 600; }

.alert { display: flex; align-items: flex-start; gap: 9px; padding: 11px 14px; border-radius: var(--radius); font-size: 13.5px; font-weight: 600; margin-bottom: 12px; }
.alert .ic { margin-top: 1px; width: 17px; height: 17px; }
.alert-error { background: #fdeeee; color: #a83a3a; }
.alert-success { background: #eaf7ee; color: #2c7a45; }
.alert-info { background: var(--panel-alt); color: var(--ink); }

/* ---------- Progress / motivator ---------- */
.progress-wrap {
    position: sticky;
    top: 0;
    z-index: 15;
    background: var(--bg);
    padding: 6px 0 10px;
}
.progress-track { display: flex; gap: 4px; }
.progress-seg { flex: 1; height: 5px; border-radius: 3px; background: var(--panel-alt); }
.progress-seg.filled { background: var(--accent); }
.progress-motivator {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: var(--font-head);
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink-soft);
    margin-top: 8px;
}
.progress-motivator .ic { color: var(--accent); width: 16px; height: 16px; }

/* ---------- Wizard question ---------- */
.q-breadcrumb { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin-bottom: 6px; }
.q-breadcrumb .ic { width: 14px; height: 14px; }
.q-title { font-family: var(--font-head); font-size: 20px; font-weight: 800; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.02em; }
.q-help { color: var(--ink-soft); font-size: 13.5px; margin-bottom: 12px; }

.option-grid { display: flex; flex-direction: column; gap: 8px; }
.option-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 18px;
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--panel-alt);
    cursor: pointer;
    min-height: 54px;
}
.option-btn.selected { border-color: var(--accent); background: #fff8f2; box-shadow: 0 8px 20px -14px rgba(245,98,1,.35); }
.option-btn .check { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid #d6d6da; flex-shrink: 0; background: #fff; }
.option-btn.selected .check { border-color: var(--accent); background: var(--accent); position: relative; }
.option-btn.selected .check::after { content: ""; position: absolute; left: 6px; top: 3px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(40deg); }

/* ---------- Number entry (clean, no LCD) ---------- */
.number-screen { background: var(--panel-alt); border-radius: var(--radius-lg); padding: 16px 10px; text-align: center; }
.number-screen input {
    background: transparent;
    border: none;
    color: var(--ink);
    font-family: var(--font-head);
    font-size: 34px;
    font-weight: 800;
    width: 100%;
    text-align: center;
    letter-spacing: -.02em;
}
.number-screen input:focus { outline: none; }
.number-unit { font-family: var(--font-body); color: var(--ink-soft); font-size: 13px; font-weight: 600; margin-top: 1px; }
.number-input-wrap { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.stepper-btn {
    width: 46px; height: 46px; flex-shrink: 0;
    border-radius: 50%;
    border: 1.5px solid var(--line);
    background: #fff;
    font-family: var(--font-head);
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
}
.stepper-btn:active { background: var(--panel-alt); }
.range-hint { flex: 1; text-align: center; font-family: var(--font-body); font-size: 12px; font-weight: 600; color: var(--ink-soft); }

/* ---------- Rating gauge (monochrome bars) ---------- */
.rating-wrap { text-align: center; padding: 2px 0 2px; }
.rating-name { font-family: var(--font-head); font-size: 19px; font-weight: 800; margin: 8px 0 16px; }
.gauge-track { display: flex; gap: 6px; align-items: flex-end; height: 48px; padding: 0 4px; }
.gauge-seg { flex: 1; border-radius: 6px 6px 3px 3px; background: var(--panel-alt); cursor: pointer; transition: background .12s; }
.gauge-seg:nth-child(1) { height: 32%; } .gauge-seg:nth-child(2) { height: 52%; } .gauge-seg:nth-child(3) { height: 68%; } .gauge-seg:nth-child(4) { height: 84%; } .gauge-seg:nth-child(5) { height: 100%; }
.gauge-seg.on { background: var(--accent); }
.rating-scale-labels { display: flex; justify-content: space-between; font-family: var(--font-body); font-size: 10.5px; font-weight: 600; color: var(--ink-soft); margin-top: 10px; text-transform: uppercase; letter-spacing: .03em; }

.r-meter { display: inline-flex; align-items: flex-end; gap: 2px; height: 15px; vertical-align: middle; }
.r-bar { display: block; width: 4px; border-radius: 1px; background: #dfdfe3; }
.r-bar-1 { height: 30%; } .r-bar-2 { height: 50%; } .r-bar-3 { height: 66%; } .r-bar-4 { height: 82%; } .r-bar-5 { height: 100%; }
.r-bar.is-active { background: var(--accent); }
.r-meter.lg { height: 24px; gap: 3px; }
.r-meter.lg .r-bar { width: 6px; }

/* ---------- Filters / lists ---------- */
.filter-bar { display: flex; gap: 7px; overflow-x: auto; padding: 2px 0 8px; -webkit-overflow-scrolling: touch; }
.filter-label { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 6px 0 4px; }
.filter-label .ic { width: 14px; height: 14px; }
.filter-chip {
    flex-shrink: 0;
    display: flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    border: none;
    background: var(--panel-alt);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}
.filter-chip.active { background: var(--accent); color: #fff; }

.setting-card { display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; margin-bottom: 10px; box-shadow: 0 10px 26px -20px rgba(13,13,15,.3); }
.setting-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.setting-badge { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-head); font-weight: 700; font-size: 12.5px; padding: 7px 12px; border-radius: var(--radius-pill); background: var(--panel-alt); color: var(--ink); }
.setting-meta { font-family: var(--font-body); font-size: 11.5px; font-weight: 600; color: var(--ink-soft); }
.setting-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; background: var(--panel-alt); color: var(--ink); padding: 5px 10px; border-radius: var(--radius-pill); }
.tag .ic { width: 13px; height: 13px; }

/* ---------- Locked "teaser" screen: real (but blurred) cards behind an overlay ---------- */
.locked-wrap { position: relative; min-height: min(66vh, 520px); margin: 4px -16px -16px; overflow: hidden; }
.locked-preview {
    padding: 16px 16px 0;
    filter: blur(3.5px);
    opacity: .85;
    -webkit-mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 96%);
    mask-image: linear-gradient(180deg, #000 0%, #000 60%, transparent 96%);
    user-select: none;
    pointer-events: none;
}

.locked-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 28px;
    background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.97) 0%, rgba(255,255,255,.97) 34%, rgba(255,255,255,.6) 58%, rgba(255,255,255,0) 92%);
}
.lock-badge {
    width: 72px; height: 72px;
    border-radius: 24px;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
    box-shadow: 0 16px 30px -12px rgba(245,98,1,.55);
}
.lock-badge .ic { width: 32px; height: 32px; color: #fff; stroke-width: 1.6px; }

/* Compact variant: an inline teaser card rather than a full-bleed screen */
.locked-wrap.compact { min-height: 200px; margin: 0 0 14px; border-radius: var(--radius-lg); border: 1px solid var(--line); }
.locked-wrap.compact .locked-preview { padding: 12px 12px 0; }
.locked-wrap.compact .locked-overlay { padding: 14px 20px; background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.97) 0%, rgba(255,255,255,.97) 30%, rgba(255,255,255,.55) 54%, rgba(255,255,255,0) 90%); }
.locked-wrap.compact .lock-badge { width: 48px; height: 48px; border-radius: 16px; margin-bottom: 8px; box-shadow: 0 12px 22px -10px rgba(245,98,1,.55); }
.locked-wrap.compact .lock-badge .ic { width: 20px; height: 20px; }
.locked-wrap.compact .q-help { font-size: 13px; line-height: 1.4; }

/* ---------- Marquee: looping "how it works" ticker, scrolls to the right ---------- */
.marquee {
    overflow: hidden;
    width: 100%;
    margin: 12px 0;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
    mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.marquee-track {
    display: flex;
    align-items: center;
    gap: 10px;
    width: max-content;
    animation: marquee-right 20s linear infinite;
}
.marquee-track.reverse { animation-name: marquee-left; animation-duration: 24s; }
.marquee-track .ic { width: 14px; height: 14px; color: var(--ink-soft); flex-shrink: 0; stroke-width: 2.2px; }
.marquee-item {
    display: inline-flex; align-items: center; gap: 7px;
    font-family: var(--font-head); font-size: 14.5px; font-weight: 700;
    color: var(--ink-soft); white-space: nowrap;
    background: var(--panel-alt);
    padding: 7px 13px;
    border-radius: var(--radius-pill);
}
.marquee-n {
    display: flex; align-items: center; justify-content: center;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    flex-shrink: 0;
}
.marquee-n .ic { width: 10px; height: 10px; color: #fff; }
@keyframes marquee-right {
    from { transform: translateX(-50%); }
    to { transform: translateX(0%); }
}
@keyframes marquee-left {
    from { transform: translateX(0%); }
    to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
    .marquee-track { animation: none; }
}

/* ---------- Answer table ---------- */
.answer-group { margin-bottom: 14px; }
.answer-group h3 { display: flex; align-items: center; gap: 6px; font-family: var(--font-head); font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-soft); margin: 0 0 6px; }
.answer-group h3 .ic { width: 14px; height: 14px; }
.answer-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; gap: 10px; }
.answer-row:last-child { border-bottom: none; }
.answer-row .a-label { color: var(--ink-soft); }
.answer-row .a-value { font-family: var(--font-head); font-weight: 700; }

.history-item { display: flex; justify-content: space-between; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: none; }

/* ---------- Bottom nav (pinned via flex, not position:fixed) ---------- */
.bottom-nav {
    flex: 0 0 auto;
    display: flex;
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    padding: 7px 10px calc(7px + var(--safe-bottom));
    view-transition-name: app-bottomnav;
}
.bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    font-family: var(--font-head);
    font-size: 10.5px;
    font-weight: 700;
    color: var(--ink-soft);
    padding: 3px 0;
}
.bottom-nav a .ic-wrap { width: 30px; height: 30px; border-radius: 11px; display: flex; align-items: center; justify-content: center; transition: background .18s ease; }
.bottom-nav a .ic { width: 19px; height: 19px; }
.bottom-nav a.active { color: var(--accent); }
.bottom-nav a.active .ic-wrap { background: var(--accent); }
.bottom-nav a.active .ic { color: #fff; }
.bottom-nav a.locked { opacity: .45; }

/* Bottom action bar for the wizard - fixed to the viewport so it stays pinned
   even though it lives inside the scrollable .app-main (position:fixed escapes
   the scroll container regardless of DOM nesting). */
.wizard-footer {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    background: var(--bg);
    border-top: 1px solid var(--line);
    padding: 12px 16px calc(12px + var(--safe-bottom));
    z-index: 25;
    view-transition-name: app-bottomnav;
}
.wizard-footer-inner { max-width: 480px; margin: 0 auto; display: flex; gap: 10px; }
.wizard-footer-inner:not(.stack) .btn-secondary { flex: 0 0 50px; padding: 0; }
.wizard-footer-inner.stack { flex-direction: column; gap: 8px; }

body.wizard-body .app-main { padding-bottom: 78px; }
body.has-footer .app-main { padding-bottom: 150px; }
body.has-footer-legal .app-main { padding-bottom: 178px; }

.hero-logo { height: 44px; width: auto; display: block; margin: 0 auto 14px; }

/* ---------- Legal pages (regulamin / polityka prywatności) ---------- */
.legal { padding-bottom: 20px; }
.legal h1 { font-family: var(--font-head); font-size: 21px; font-weight: 800; margin: 4px 0 4px; letter-spacing: -.02em; }
.legal .legal-updated { color: var(--ink-soft); font-size: 12.5px; margin-bottom: 18px; }
.legal h2 { font-family: var(--font-head); font-size: 15px; font-weight: 800; margin: 22px 0 8px; letter-spacing: -.01em; }
.legal h2:first-of-type { margin-top: 4px; }
.legal p { font-size: 14px; line-height: 1.6; color: var(--ink); margin: 0 0 10px; }
.legal ul, .legal ol { margin: 0 0 10px; padding-left: 20px; }
.legal li { font-size: 14px; line-height: 1.6; color: var(--ink); margin-bottom: 6px; }
.legal strong { font-weight: 700; }
.legal a { color: var(--accent-ink); text-decoration: underline; }

.legal-links { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; font-size: 12.5px; color: var(--ink-soft); }
.legal-links a { color: var(--ink-soft); text-decoration: underline; }

@media (min-width: 540px) {
    /* On wide screens the app shell reads as a framed phone screen */
    body { background: #e7e7ea; }
    .app-shell { box-shadow: 0 30px 70px -30px rgba(13,13,15,.35); }
}

/* =================================================================
   Screen transitions: header and bottom nav stay put, only the
   middle area animates - powered by the View Transitions API.
   Browsers without support just get the plain instant navigation
   plus the CSS fallback fade-in below.
   ================================================================= */
@view-transition {
    navigation: auto;
}

/* Header/footer keep the same view-transition-name across pages, so the
   browser treats them as the *same* persistent element instead of
   cross-fading them - they simply do not move. */
::view-transition-old(app-topbar),
::view-transition-new(app-topbar),
::view-transition-old(app-bottomnav),
::view-transition-new(app-bottomnav) {
    animation: none;
    mix-blend-mode: normal;
}

::view-transition-old(app-main),
::view-transition-new(app-main) {
    animation-duration: .32s;
    animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}
::view-transition-old(app-main) { animation-name: screen-out; }
::view-transition-new(app-main) { animation-name: screen-in; }

@keyframes screen-out {
    to { opacity: 0; transform: translateY(-8px) scale(.98); }
}
@keyframes screen-in {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
}

/* The active bottom-nav indicator glides to its new tab instead of popping */
::view-transition-group(nav-indicator) {
    animation-duration: .28s;
    animation-timing-function: cubic-bezier(.4, 0, .2, 1);
}

/* Fallback entrance animation for browsers without View Transitions support */
@supports not (selector(::view-transition)) {
    .app-main { animation: content-enter .35s cubic-bezier(.4, 0, .2, 1) both; }
    @keyframes content-enter {
        from { opacity: 0; transform: translateY(10px); }
        to { opacity: 1; transform: translateY(0); }
    }
}
