:root {
    --bg: #f4f4f5;
    --surface: #fafafa;
    --surface-strong: #ffffff;
    --text: #18181b;
    --muted: #71717a;
    --border: #e4e4e7;
    --border-strong: #d4d4d8;
    --accent: #3f3f46;
    --accent-strong: #18181b;
    --accent-soft: #f4f4f5;
    --success: #3f3f46;
    --shadow: 0 20px 50px rgba(24, 24, 27, 0.06);
    --shadow-soft: 0 8px 24px rgba(24, 24, 27, 0.05);
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;
    --container: 1180px;
    --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
    --ease-spring: cubic-bezier(0.34, 1.2, 0.64, 1);
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(14px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes header-line {
    0%,
    100% {
        opacity: 0.35;
    }
    50% {
        opacity: 0.85;
    }
}

@keyframes brand-soft {
    0%,
    100% {
        box-shadow: var(--shadow-soft);
    }
    50% {
        box-shadow: 0 12px 32px rgba(24, 24, 27, 0.09);
    }
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    color: var(--text);
    background-color: #fafafa;
    background-image:
        radial-gradient(ellipse 120% 80% at 50% -20%, rgba(228, 228, 231, 0.65), transparent 55%),
        radial-gradient(ellipse 90% 50% at 100% 0%, rgba(244, 244, 245, 0.9), transparent 45%),
        linear-gradient(180deg, #ffffff 0%, var(--bg) 55%, #f4f4f5 100%);
}

a {
    color: inherit;
}

img {
    max-width: 100%;
    display: block;
}

.container {
    width: min(var(--container), calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--border);
    transition:
        background 0.35s var(--ease-out),
        box-shadow 0.35s var(--ease-out),
        border-color 0.35s var(--ease-out);
}

.site-header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(161, 161, 170, 0.45) 50%,
        transparent 100%
    );
    pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
    html.motion-on .site-header::after {
        animation: header-line 4s ease-in-out infinite;
    }
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    transition: opacity 0.2s var(--ease-out);
}

.brand:hover {
    opacity: 0.92;
}

.brand:active {
    opacity: 0.85;
}

.brand__mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(145deg, #ffffff, #e4e4e7);
    border: 1px solid var(--border-strong);
    color: var(--accent-strong);
    font-weight: 700;
    box-shadow: var(--shadow-soft);
    transition:
        transform 0.28s var(--ease-spring),
        box-shadow 0.28s var(--ease-out),
        border-color 0.28s var(--ease-out);
}

@media (prefers-reduced-motion: no-preference) {
    html.motion-on .brand__mark {
        animation: brand-soft 5s ease-in-out infinite;
    }
}

.brand:hover .brand__mark {
    transform: scale(1.04) rotate(-1deg);
    box-shadow: 0 14px 36px rgba(24, 24, 27, 0.1);
}

.brand__text strong,
.brand__text span {
    display: block;
}

.brand__text span {
    font-size: 13px;
    color: var(--muted);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* Dropdown „Moje konto” w nagłówku (kompakt zamiast wielu przycisków) */
.nav-user {
    position: relative;
    z-index: 40;
}

.nav-user__summary {
    list-style: none;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 14rem;
}

.nav-user__summary::-webkit-details-marker {
    display: none;
}

.nav-user__summary::marker {
    content: none;
}

.nav-user__summary-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-user__summary-chev {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
    margin-top: 2px;
    opacity: 0.5;
    transition: transform 0.2s var(--ease-out);
}

.nav-user[open] .nav-user__summary-chev {
    transform: rotate(180deg);
}

.nav-user__panel {
    position: absolute;
    z-index: 50;
    top: calc(100% + 8px);
    right: 0;
    min-width: 260px;
    max-width: min(100vw - 32px, 320px);
    padding: 6px 0;
    background: var(--surface-strong);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
}

.nav-user__link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 11px 16px;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s ease;
}

.nav-user__link:hover {
    background: var(--accent-soft);
}

.nav-user__sep {
    height: 1px;
    margin: 6px 10px;
    background: var(--border);
}

.nav-user__logout {
    display: block;
    margin: 0;
    padding: 0 8px 6px;
}

.nav-user__logout-btn {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 0 10px 0 8px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #b91c1c;
    font: inherit;
    font-weight: 600;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    transform: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-user__logout-btn:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #991b1b;
    box-shadow: none;
    transform: none;
}

.nav-user__logout-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 2px rgba(63, 63, 70, 0.35);
}

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

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 999px;
    background: linear-gradient(145deg, #3f3f46, #27272a);
    color: #fafafa;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition:
        transform 0.22s var(--ease-spring),
        box-shadow 0.22s var(--ease-out),
        opacity 0.2s ease,
        background 0.22s ease;
    box-shadow: 0 12px 28px rgba(24, 24, 27, 0.18);
}

.button:hover,
button:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 36px rgba(24, 24, 27, 0.22);
}

.button:active,
button:active {
    transform: translateY(0) scale(0.98);
    box-shadow: 0 8px 20px rgba(24, 24, 27, 0.15);
}

.button:focus-visible,
button:focus-visible {
    outline: none;
    box-shadow:
        0 12px 28px rgba(24, 24, 27, 0.18),
        0 0 0 3px rgba(63, 63, 70, 0.35);
}

.button--ghost {
    background: rgba(255, 255, 255, 0.98);
    color: var(--text);
    border: 1px solid var(--border-strong);
    box-shadow: 0 1px 2px rgba(24, 24, 27, 0.04);
}

.button--ghost:hover {
    background: #ffffff;
    border-color: #a1a1aa;
}

.panel {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    transition:
        box-shadow 0.35s var(--ease-out),
        border-color 0.28s ease,
        transform 0.35s var(--ease-out),
        opacity 0.45s var(--ease-out);
}

/* Wejście w widok: wszystkie karty/panele w main (start, panel, konto, checkout, admin, ogłoszenie) */
html.motion-on main .panel:not(.panel--inview) {
    opacity: 0;
    transform: translateY(16px);
}

html.reduce-motion main .panel {
    opacity: 1 !important;
    transform: none !important;
}

html.motion-on main .panel.panel--inview {
    opacity: 1;
    transform: translateY(0);
    transition:
        opacity 0.58s var(--ease-out),
        transform 0.58s var(--ease-out),
        box-shadow 0.35s var(--ease-out),
        border-color 0.28s ease;
}

@media (prefers-reduced-motion: no-preference) {
    html.motion-on main .panel.panel--inview:hover {
        transform: translateY(-3px);
        box-shadow: 0 22px 48px rgba(24, 24, 27, 0.09);
        border-color: var(--border-strong);
    }
}

/* --- Widoki wewnętrzne: logowanie, rejestracja, panele, konto, admin, szczegół ogłoszenia --- */
.page-shell,
.detail-page {
    position: relative;
    isolation: isolate;
}

.page-shell {
    padding: 42px 0 60px;
}

.detail-page {
    padding: 44px 0 68px;
}

.page-shell::before,
.detail-page::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background:
        radial-gradient(ellipse 100% 60% at 50% -15%, rgba(228, 228, 231, 0.55), transparent 52%),
        radial-gradient(ellipse 70% 45% at 100% 30%, rgba(244, 244, 245, 0.9), transparent 50%),
        radial-gradient(ellipse 55% 40% at 0% 80%, rgba(250, 250, 250, 0.95), transparent 45%);
}

@media (prefers-reduced-motion: no-preference) {
    html.motion-on .page-shell .section-head .chip {
        animation: fade-up 0.5s var(--ease-out) both;
    }

    html.motion-on .page-shell .section-head .section-title {
        animation: fade-up 0.55s var(--ease-out) 0.05s both;
    }

    html.motion-on .page-shell .section-head .section-copy {
        animation: fade-up 0.52s var(--ease-out) 0.1s both;
    }

    html.motion-on .page-shell .section-head .button,
    html.motion-on .page-shell .section-head a.button {
        animation: fade-up 0.48s var(--ease-out) 0.14s both;
    }
}

.section-title {
    margin: 0 0 8px;
    font-size: clamp(1.7rem, 3vw, 2.6rem);
    line-height: 1.05;
}

.section-copy {
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 14px;
    transition:
        border-color 0.2s ease,
        background 0.2s ease;
}

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

.card-link {
    text-decoration: none;
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--muted);
}

.field,
textarea,
select,
input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"] {
    width: 100%;
    min-height: 52px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
    transition:
        border-color 0.2s ease,
        box-shadow 0.2s ease;
}

textarea {
    min-height: 160px;
    resize: vertical;
}

.field:focus,
textarea:focus,
select:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="password"]:focus,
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(63, 63, 70, 0.12);
}

.message {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.message--error {
    background: #f4f4f5;
    color: #52525b;
    border: 1px solid var(--border-strong);
}

.message--success {
    background: #fafafa;
    color: #3f3f46;
    border: 1px solid var(--border-strong);
}

.site-footer {
    padding: 32px 0 48px;
    color: var(--muted);
}

.site-footer__inner {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.stat {
    padding: 16px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    transition:
        border-color 0.2s ease,
        box-shadow 0.25s var(--ease-out);
}

.stat:hover {
    box-shadow: var(--shadow-soft);
}

.stat strong {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.stat span {
    color: var(--muted);
    font-size: 14px;
}

.premium-note {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
}

@media (max-width: 900px) {
    .site-header__inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .section-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .nav-user {
        width: 100%;
    }

    .nav-user__summary {
        width: 100%;
        max-width: none;
        justify-content: space-between;
    }

    .nav-user__summary-text {
        flex: 1;
    }

    .nav-user__panel {
        left: 0;
        right: 0;
        width: 100%;
        max-width: none;
    }
}

@media (max-width: 640px) {
    .container {
        width: min(var(--container), calc(100% - 20px));
    }
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.nav-chat {
    position: relative;
    gap: 6px;
}

.nav-chat__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    margin-left: 4px;
    border-radius: 999px;
    background: #dc2626;
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
}

.nav-chat__badge[hidden] {
    display: none;
}
