/* p2pcars — plain, readable, mobile-first. No inline styles anywhere (CSP style-src 'self'). */
:root {
    --ink: #1d232a; --muted: #5d6873; --line: #dde2e7; --bg: #f6f7f9; --card: #fff;
    --brand: #0b5fff; --ok: #137a3d; --warn: #9a5b00; --bad: #b42318;
    --radius: 8px; --gap: 1rem; --width: 1056px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-up: 0 4px 14px rgba(0, 0, 0, .08);
    --ease: 120ms ease;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column;
    font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); background: var(--bg); }
main { width: 100%; max-width: var(--width); margin: 0 auto; padding: 1.5rem 1rem 2rem; flex: 1; }
main > :first-child { margin-top: 0; }
/* The column itself is narrow, so inline children like a lone button line up with the text too. */
main.narrow { max-width: 38rem; }
h1 { font-size: 1.6rem; line-height: 1.25; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; line-height: 1.3; margin: 1.75rem 0 .5rem; }
h3 { font-size: 1.05rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- Header / footer ---------- */
header.site { position: sticky; top: 0; z-index: 20; background: var(--card); border-bottom: 1px solid var(--line); }
/* Brand centred on its own line, nav centred under it. */
header.site .bar { max-width: var(--width); margin: 0 auto; padding: .6rem 1rem .4rem;
    display: flex; flex-direction: column; align-items: center; gap: .3rem; }
.brand { font-weight: 800; font-size: 1.75rem; line-height: 1.1; text-decoration: none; color: var(--ink); letter-spacing: -.02em; }
header.site nav { flex-wrap: wrap; justify-content: center; }
/* Signed out there's only "Sign in": it sits at the right of the brand line, not under it. */
header.site .bar { position: relative; }
header.site nav.guest { position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); }
header.site nav { display: flex; gap: .4rem; align-items: center; }
header.site nav form { margin: 0; }
/* Pills, like the wallet chip at the end. */
.nav-link { display: inline-flex; align-items: center; height: 2.25rem; padding: 0 .9rem; border-radius: 999px;
    border: 1px solid var(--line); background: var(--card); font: inherit; font-size: .95rem; color: var(--ink); text-decoration: none;
    cursor: pointer; margin: 0; min-height: 0; font-weight: 400; box-shadow: none; white-space: nowrap; transition: background var(--ease); }
.nav-link:hover { background: var(--bg); border-color: #c4cbd2; text-decoration: none; }
.nav-link:active { transform: none; }
.nav-link.active { background: var(--bg); border-color: #c4cbd2; font-weight: 600; }
.nav-link.quiet { color: var(--muted); }

footer.site { width: 100%; max-width: var(--width); margin: 0 auto; padding: 1.25rem 1rem 2rem;
    border-top: 1px solid var(--line); color: var(--muted); font-size: .875rem;
    display: flex; flex-wrap: wrap; gap: .25rem 1rem; align-items: center; }
footer.site a { color: var(--muted); text-decoration: none; }
footer.site a:hover { color: var(--ink); text-decoration: underline; }
footer.site span { margin-left: auto; }

/* ---------- Buttons ---------- */
button, .button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 2.5rem; padding: 0 1rem; margin: 0; border-radius: 6px; border: 1px solid var(--line);
    background: var(--card); color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem; line-height: 1.2;
    text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; user-select: none;
    box-shadow: var(--shadow); transition: background var(--ease), border-color var(--ease), box-shadow var(--ease), transform var(--ease), filter var(--ease); }
button:hover, .button:hover { border-color: #c4cbd2; background: var(--bg); text-decoration: none; }
button:active, .button:active { transform: translateY(1px); box-shadow: none; }
button.primary, .button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover, .button.primary:hover { filter: brightness(.92); background: var(--brand); }
button.block, .button.block { display: flex; width: 100%; }
button.small, .button.small { min-height: 2rem; padding: 0 .75rem; font-size: .875rem; }
/* "← Back" links: a button without the box until hovered */
.back { display: inline-flex; align-items: center; gap: .35rem; min-height: 2rem; padding: 0 .6rem; margin: 0 0 1rem -.6rem;
    border-radius: 6px; color: var(--muted); font-size: .9rem; font-weight: 600; text-decoration: none; transition: background var(--ease), color var(--ease); }
.back:hover { background: var(--line); color: var(--ink); text-decoration: none; }
/* While htmx waits on the server: feedback, and no double submits */
.htmx-request, .htmx-request button { opacity: .65; pointer-events: none; cursor: progress; }

form.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: 1rem; }
.actions form { margin: 0; }
.actions.split { justify-content: space-between; }
form.card > button[type=submit], form.card > .actions { margin-top: 1.25rem; }

/* ---------- Cards, alerts, badges ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; margin: 0 0 1rem; box-shadow: var(--shadow); }
.card > :last-child { margin-bottom: 0; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.card.muted { background: #fbfbfc; box-shadow: none; }
.card.next { border-left: 4px solid var(--brand); }
.card.next.done { border-left-color: var(--ok); }
.card.next .button { margin-top: .25rem; }
.eyebrow + h2 { margin-top: .25rem; }
.eyebrow { text-transform: uppercase; font-size: .75rem; letter-spacing: .05em; color: var(--muted); margin: 0 0 .25rem; font-weight: 600; }
.hint { color: var(--muted); font-size: .9rem; }

.alert { padding: .75rem 1rem; margin: 0 0 1rem; border-radius: 6px; background: #fff7e6; border: 1px solid #f3d9a4; }
.alert.ok { background: #ecf8f0; border-color: #b6e2c4; }
.alert.error { background: #fdecea; border-color: #f5c2bd; color: var(--bad); }

.badge { display: inline-flex; align-items: center; font-size: .8rem; font-weight: 600; padding: .15rem .6rem; border-radius: 999px;
    background: #eef1f4; color: var(--muted); white-space: nowrap; }
.badge.state-DONE { background: #ecf8f0; color: var(--ok); }
.badge.state-TODO, .badge.state-EXPIRED { background: #fff7e6; color: var(--warn); }
.badge.state-PENDING_REVIEW { background: #eaf1ff; color: var(--brand); }

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .95rem; margin: 1rem 0 .35rem; }
form > label:first-of-type { margin-top: 0; }
h1 + .hint { margin-top: -.5rem; }
input + .hint, select + .hint, .row + .hint { margin: .35rem 0 0; }
label.check { font-weight: 400; display: flex; gap: .6rem; align-items: flex-start; margin: .75rem 0; cursor: pointer; }
input, select, textarea { font: inherit; min-height: 2.5rem; padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 6px;
    width: 100%; background: #fff; color: var(--ink); transition: border-color var(--ease), box-shadow var(--ease); }
/* Own chevron, inset from the edge like the text; the native one sits against the border. */
select:not([multiple]) { appearance: none; padding-right: 2.25rem; background: #fff no-repeat right .8rem center / .7rem
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235b6573' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
select:disabled { opacity: .55; cursor: not-allowed; }
input:hover, select:hover, textarea:hover { border-color: #c4cbd2; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(11, 95, 255, .15); }
input[type=checkbox], input[type=radio] { width: 1.05rem; height: 1.05rem; min-height: 0; margin: .2rem 0 0; flex: none; accent-color: var(--brand); }
fieldset { border: 0; padding: 0; margin: 1rem 0 0; }
legend { font-weight: 600; font-size: .95rem; padding: 0; margin-bottom: .35rem; }
fieldset label.check { margin: .4rem 0; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row input, .row select { flex: 1; min-width: 6rem; }
.row > label { margin: 0; }
.prefix { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0 .7rem; border: 1px solid var(--line);
    border-radius: 6px; background: var(--bg); color: var(--muted); }

progress { width: 100%; height: .6rem; border: 0; border-radius: 999px; overflow: hidden; background: var(--line); appearance: none; }
progress::-webkit-progress-bar { background: var(--line); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--brand); border-radius: 999px; transition: width 300ms ease; }
progress::-moz-progress-bar { background: var(--brand); border-radius: 999px; }

/* ---------- Profile ---------- */
/* "To finish your profile": one compact row per step left, the next one marked. */
.todo-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.todo-head h2 { margin: 0; font-size: 1.15rem; }
.todo progress { margin: .6rem 0 .25rem; }
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-item { display: flex; align-items: center; gap: .5rem 1rem; padding: .8rem 0; border-bottom: 1px solid var(--line); }
.todo-item:last-child { border-bottom: 0; }
.todo-item.next { border-left: 3px solid var(--brand); padding-left: .75rem; margin-left: -.75rem; }
.todo-main { flex: 1; min-width: 0; }
.todo-title { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .6rem; }
.todo-main p { margin: .2rem 0 0; }
.todo-item .button { flex: none; }
.needed-for { font-size: .85rem; color: var(--muted); }
.can-now { margin: .75rem 0 0; padding-top: .75rem; border-top: 1px solid var(--line); font-size: .9rem; color: var(--muted); }
@media (max-width: 40rem) {
    .todo-item { flex-direction: column; align-items: stretch; }
    .todo-item .button { align-self: flex-start; }
}
.each-time summary { cursor: pointer; font-weight: 600; }
.each-time ul { margin: .6rem 0 0; padding-left: 1.2rem; }
.each-time li { margin: .3rem 0; color: var(--muted); }
.each-time li strong { color: var(--ink); }
.ticks { padding-left: 1.2rem; margin: 0 0 1.25rem; }
.ticks li { margin: .25rem 0; }
/* Home: centred under the brand; the three points side by side, one under another on phones. */
main.home { text-align: center; padding-top: 3rem; }
main.home h1 { font-size: 2.25rem; letter-spacing: -.02em; text-wrap: balance; }
main.home .lead { max-width: 40rem; margin: 0 auto 2rem; color: var(--muted); font-size: 1.1rem; text-wrap: balance; }
.points { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--gap); max-width: 48rem; margin: 0 auto; }
.points .card { margin: 0; }
.points h3 { margin: 0 0 .35rem; font-size: 1rem; }
.points p { margin: 0; color: var(--muted); font-size: .95rem; }
main.home .actions { justify-content: center; margin-top: 2rem; }
@media (max-width: 560px) { .points { grid-template-columns: 1fr; } main.home h1 { font-size: 1.75rem; } }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .75rem; border-bottom: 1px solid var(--line); vertical-align: top; }

/* ---------- Top-right panel ("profile not complete", quota notices) ---------- */
.corner { position: fixed; top: 6.75rem; right: 1rem; z-index: 30; width: min(360px, calc(100vw - 2rem)); }
.corner:empty { display: none; }
.corner-card { position: relative; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--warn);
    border-radius: var(--radius); padding: 1rem 2.75rem 1rem 1.1rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .14);
    animation: corner-in 160ms ease-out; }
.corner-card strong { display: block; font-size: 1rem; margin-bottom: .35rem; }
.corner-card p { margin: 0 0 .5rem; color: var(--muted); font-size: .925rem; }
.corner-card p:last-child { margin: 0; color: var(--ink); }
.corner-card ul { list-style: none; margin: 0 0 1rem; padding: 0; }
.corner-card li { display: flex; align-items: center; gap: .55rem; padding: .4rem 0; border-top: 1px solid var(--line); font-weight: 600; font-size: .95rem; }
.corner-card li:first-child { border-top: 0; }
.corner-card li::before { content: ""; width: .55rem; height: .55rem; flex: none; border: 2px solid var(--warn); border-radius: 50%; }
.corner-card .button { width: 100%; }
.corner-card .close { position: absolute; top: .5rem; right: .5rem; width: 2rem; height: 2rem; display: inline-flex;
    align-items: center; justify-content: center; border-radius: 50%; color: var(--muted); font-size: 1.25rem; line-height: 1;
    text-decoration: none; transition: background var(--ease), color var(--ease); }
.corner-card .close:hover { background: var(--bg); color: var(--ink); }
@keyframes corner-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .corner-card { animation: none; } * { transition: none !important; } }

/* ---------- Car listings ---------- */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: .5rem 1rem; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
/* "Cars in Pune ▾": the city reads as part of the heading, underlined to show it can change. */
.city-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 .3em; }
.city-pick { position: relative; display: inline-block; max-width: 100%; border-bottom: 2px solid var(--line); }
.city-pick:hover { border-bottom-color: var(--ink); }
.city-pick:focus-within { border-bottom-color: var(--brand); }
/* As wide as the chosen city (not the longest option), with a chevron sized to the heading. */
.city-pick select { font: inherit; field-sizing: content; width: auto; max-width: 100%; min-height: 0;
    padding: 0 .85em 0 0; border: 0; border-radius: 0; background: transparent; appearance: none; cursor: pointer; }
.city-pick select:focus { box-shadow: none; }
/* The list itself at body size, not the heading's. Chrome 135+ styles its picker from these; others keep the native one. */
.city-pick select, .city-pick select::picker(select) { appearance: base-select; }
.city-pick select::picker-icon { display: none; }
.city-pick select::picker(select) { margin-top: .35rem; padding: .25rem; border: 1px solid var(--line); border-radius: 8px;
    background: var(--card); box-shadow: 0 8px 24px rgba(0, 0, 0, .12); }
.city-pick option { font-size: 1rem; font-weight: 500; padding: .45rem .75rem; border-radius: 6px; }
.city-pick option:hover, .city-pick option:focus-visible { background: var(--bg); }
.city-pick option::checkmark { display: none; }
.city-pick option:checked { font-weight: 700; }
.city-pick::after { content: ""; position: absolute; right: .1em; top: 50%; width: .32em; height: .32em;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: translateY(-70%) rotate(45deg);
    pointer-events: none; }
.page-head p { margin: .25rem 0 0; }
.cards { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.car-card { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 1.1rem 1.1rem 1rem; box-shadow: var(--shadow); transition: box-shadow var(--ease), border-color var(--ease); }
.car-card:hover { box-shadow: var(--shadow-up); border-color: #c4cbd2; }
/* The whole card opens the details: "View details" stretches an overlay over it; buttons sit above. */
.car-card { position: relative; }
.car-card .stretch::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.car-card .stretch:active { transform: none; }
.car-card .shortlist-toggle, .car-card .actions form { z-index: 1; }
.car-card .actions form { position: relative; }
.car-card h2 { margin: 0 0 .15rem; font-size: 1.05rem; }
.car-card .where { margin: 0; color: var(--muted); font-size: .875rem; }
.car-card .price { margin: .6rem 0 .1rem; }
.car-card .facts { margin: 0 0 1rem; color: var(--muted); font-size: .9rem; }
.car-card .actions { margin-top: auto; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: .5rem; }
.car-card .actions button, .car-card .actions .button { padding: 0 .5rem; }
.car-card .actions form, .car-card .actions button, .car-card .actions .button { width: 100%; }
.price { font-size: 1.25rem; font-weight: 700; letter-spacing: -.01em; margin: 0 0 .75rem; }

/* Detail page */
.detail-head { margin-bottom: 1rem; }
.detail-head h1 { margin-bottom: .25rem; }
.detail-head .price { margin: 0; }
.facts-table { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); border-collapse: separate;
    border-spacing: 0; overflow: hidden; box-shadow: var(--shadow); margin: 0 0 1rem; font-size: .95rem; }
.facts-table th, .facts-table td { padding: .65rem 1rem; }
.facts-table tr:last-child th, .facts-table tr:last-child td { border-bottom: 0; }
.facts-table th { width: 42%; color: var(--muted); font-weight: 500; }
.contact-card { margin: .25rem 0 1.5rem; }
.contact-card:not(.card) { text-align: center; }
.notes-card h2 { margin: 0 0 .5rem; font-size: 1.05rem; }
.notes-card .notes { margin: 0; }
.contact-card p { margin: 0 0 1rem; }

@media (max-width: 560px) {
    h1 { font-size: 1.4rem; }
    header.site .bar { padding: 0 .75rem; }
    .nav-link { padding: 0 .5rem; font-size: .9rem; }
    header.site nav { gap: 0; }
    .page-head { align-items: flex-start; }
    footer.site span { margin-left: 0; }
}

/* ---------- Photos ---------- */
.cover, .thumb { position: relative; aspect-ratio: 4 / 3; background: var(--bg); border-radius: 6px; overflow: hidden;
    display: flex; align-items: center; justify-content: center; }
.cover img, .thumb img, .photo-grid img, .photo-strip img, .gallery img { display: block; width: 100%; height: 100%; object-fit: cover; }
.no-photo { color: var(--muted); font-size: .85rem; }
.car-card .cover { margin: -.35rem -.35rem .85rem; }
.gallery { margin: 0 0 1rem; }
.gallery .stage { position: relative; border-radius: 6px; overflow: hidden; background: var(--bg); }
/* A fixed frame, so swiping between wide and tall photos doesn't move the page; each photo fits inside it. */
.gallery .main { display: block; aspect-ratio: 4 / 3; max-height: 70vh; margin: 0 auto; cursor: zoom-in; }
.gallery .main img { object-fit: contain; }
.gallery .thumbs { display: flex; gap: .5rem; margin-top: .5rem; overflow-x: auto; padding: 2px; }
.gallery .thumbs a { flex: 0 0 96px; aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--bg);
    opacity: .7; outline: 2px solid transparent; outline-offset: 0; }
.gallery .thumbs a:hover { opacity: 1; }
.gallery .thumbs a[aria-current] { opacity: 1; outline-color: var(--brand); }
.gallery .count { position: absolute; left: .5rem; bottom: .5rem; padding: .1rem .45rem; border-radius: 4px;
    background: rgba(0, 0, 0, .55); color: #fff; font-size: .8rem; }
.gallery .zoom { position: absolute; right: .5rem; bottom: .5rem; box-shadow: var(--shadow); }
.gallery .nav, .lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 2.5rem; height: 2.5rem;
    padding: 0; border-radius: 50%; font-size: 1.6rem; line-height: 1; box-shadow: var(--shadow); }
.gallery .nav:active, .lightbox .nav:active { transform: translateY(-50%); }
.gallery .nav.prev, .lightbox .nav.prev { left: .5rem; }
.gallery .nav.next, .lightbox .nav.next { right: .5rem; }
.lightbox { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
    background: rgba(0, 0, 0, .92); }
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: rgba(0, 0, 0, .6); }
.lightbox img { max-width: calc(100vw - 7rem); max-height: calc(100vh - 4rem); object-fit: contain; }
.lightbox .close { position: absolute; top: .75rem; right: .75rem; width: 2.5rem; height: 2.5rem; padding: 0;
    border-radius: 50%; font-size: 1.5rem; line-height: 1; }
.lightbox .count { position: absolute; left: 50%; bottom: .9rem; transform: translateX(-50%); color: #fff; font-size: .9rem; }
.photo-count { margin: 0 0 .75rem; color: var(--muted); }
.photo-count strong { color: var(--ink); }
.photo-grid { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.photo-grid li { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.photo-grid img { aspect-ratio: 4 / 3; height: auto; }
.cover-badge { position: absolute; top: .4rem; left: .4rem; background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.photo-actions { display: flex; gap: .35rem; padding: .4rem; }
.photo-actions form { margin: 0; flex: 1; }
.photo-actions button { width: 100%; padding: 0 .4rem; }
.photo-strip { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.photo-strip li { aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--bg); }
.photo-strip a { display: block; height: 100%; }
.upload input[type=file] { padding: .5rem; min-height: 0; cursor: pointer; }
.upload button { margin-top: 1rem; }
.rc h2 { margin: 0 0 .25rem; font-size: 1.05rem; }
.rc .hint { margin-top: 0; }
.rc-done { display: flex; align-items: center; gap: .6rem; margin-bottom: .75rem; }
.rc-done .hint { margin: 0; }
.rc-done form { margin: 0 0 0 auto; }

/* ---------- Selling ---------- */
.stepper { list-style: none; padding: 0; margin: 0 0 1.25rem; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .35rem; counter-reset: none; }
.stepper li { border-bottom: 3px solid var(--line); padding: 0 0 .4rem; font-size: .875rem; font-weight: 600; color: var(--muted); }
.stepper li.done { border-bottom-color: var(--ok); }
.stepper li.current { border-bottom-color: var(--brand); color: var(--ink); }
.stepper a { color: inherit; text-decoration: none; }
.stepper a:hover { color: var(--ink); text-decoration: underline; }
.listing-form fieldset { margin: 0 0 1.5rem; padding: 0 0 1.25rem; border-bottom: 1px solid var(--line); }
.listing-form fieldset:last-of-type { border-bottom: 0; padding-bottom: 0; }
.listing-form legend { font-size: 1.05rem; margin-bottom: .25rem; }
.listing-form legend + label, .listing-form legend + .grid-2 > div:nth-child(-n+2) > label, .listing-form legend + textarea { margin-top: .5rem; }
.grid-2 { display: grid; gap: 0 1rem; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.optional { font-weight: 400; color: var(--muted); font-size: .85rem; margin-left: .25rem; }
.field-error { color: var(--bad); font-size: .875rem; margin: .3rem 0 0; }
input.invalid, select.invalid, textarea.invalid { border-color: var(--bad); }
input.upper { text-transform: uppercase; letter-spacing: .03em; }
.row.nowrap { flex-wrap: nowrap; }
textarea { resize: vertical; min-height: 6rem; }
.notes { white-space: pre-line; }
.checklist { list-style: none; padding: 0; margin: 0 0 1rem; }
.checklist li { display: flex; flex-direction: column; padding: .55rem 0 .55rem 1.4rem; border-top: 1px solid var(--line); position: relative; }
.checklist li:first-child { border-top: 0; }
.checklist li::before { content: ""; position: absolute; left: 0; top: .95rem; width: .55rem; height: .55rem; border: 2px solid var(--warn); border-radius: 50%; }
.empty .button { margin-top: .5rem; }

.my-cars { list-style: none; padding: 0; margin: 0; display: grid; gap: .75rem; }
.my-car { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 1rem; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.live-toggle { margin: 0; flex: none; }
button.switch, button.switch:hover { min-height: 0; padding: .2rem 0; border: 0; background: none; box-shadow: none;
    gap: .5rem; font-size: .875rem; color: var(--muted); }
.switch .track { position: relative; flex: none; width: 2.25rem; height: 1.25rem; border-radius: 999px; background: #c4cbd2;
    transition: background var(--ease); }
.switch .knob { position: absolute; top: 2px; left: 2px; width: calc(1.25rem - 4px); height: calc(1.25rem - 4px);
    border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform var(--ease); }
.switch.on { color: var(--ok); }
.switch.on .track { background: var(--ok); }
.switch.on .knob { transform: translateX(1rem); }
/* Slides as soon as it's clicked, before the server answers. */
.live-toggle.htmx-request, .live-toggle.htmx-request button { opacity: 1; }
.live-toggle.htmx-request .switch.on { color: var(--muted); }
.live-toggle.htmx-request .switch.on .track { background: #c4cbd2; }
.live-toggle.htmx-request .switch.on .knob { transform: none; }
.live-toggle.htmx-request .switch:not(.on) { color: var(--ok); }
.live-toggle.htmx-request .switch:not(.on) .track { background: var(--ok); }
.live-toggle.htmx-request .switch:not(.on) .knob { transform: translateX(1rem); }
.switch-label { min-width: 3.4rem; text-align: left; }
.switch, .switch .track, .switch .knob { transition: color .2s ease, background .2s ease, transform .2s ease; }
.switch:focus-visible { outline: none; }
.switch:focus-visible .track { outline: 2px solid var(--brand); outline-offset: 2px; }
.my-car .title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.my-car h2 { margin: 0; font-size: 1.05rem; }
.my-car .hint { margin: .25rem 0 .5rem; }
.my-car .alert { margin: .5rem 0; }
.my-car .actions { margin-top: .75rem; }
.push-right { margin-left: auto; }
.badge.listing-ACTIVE { background: #ecf8f0; color: var(--ok); }
.badge.listing-IN_REVIEW { background: #eaf1ff; color: var(--brand); }
.badge.listing-REJECTED, .badge.listing-EXPIRED { background: #fff7e6; color: var(--warn); }
button.quiet, .button.quiet { color: var(--muted); box-shadow: none; }
button.danger { color: var(--bad); }

/* A <details> used as "are you sure?" — no JavaScript needed */
details.confirm, details.reject { position: relative; }
details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details.confirm[open] > summary { display: none; }
details.confirm form { display: flex; align-items: center; gap: .5rem; margin: 0; }
details.confirm form .hint { margin: 0; }

/* ---------- Admin ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin: 0 0 1.25rem; }
.tabs a { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; margin-bottom: -1px; color: var(--muted);
    font-weight: 600; font-size: .95rem; text-decoration: none; border-bottom: 2px solid transparent; transition: color var(--ease), border-color var(--ease); }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.review { padding: 1.25rem 1.25rem 1rem; }
.review-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; margin-bottom: 1rem; }
.review-head h2 { margin: 0; }
.review-head .hint { margin: .2rem 0 0; }
.review-head .price { margin: 0; }
.match { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; margin: 0 0 1rem; }
.match > div { background: #fbfbfc; padding: .75rem 1rem; display: flex; flex-direction: column; gap: .1rem; }
.match .eyebrow { margin: 0; }
.match .hint { margin: 0; }
.evidence { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 1rem; margin: 0 0 1rem; }
.evidence figure { margin: 0; }
.evidence .eyebrow { margin: 0 0 .4rem; }
.rc-view a { display: block; }
.rc-view img { display: block; width: 100%; height: auto; max-height: 380px; object-fit: contain; background: var(--bg);
    border: 1px solid var(--line); border-radius: 6px; }
.rc-missing { margin: 0; padding: 2.5rem 1rem; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 6px; }
.review-photos { list-style: none; padding: 0; margin: 0; display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.review-photos li { aspect-ratio: 4 / 3; border-radius: 6px; overflow: hidden; background: var(--bg); }
.review-photos a { display: block; height: 100%; }
.review-photos img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .03em; }
.review-actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-start; }
.review-actions form { margin: 0; }
details.reject[open] { flex-basis: 100%; }
details.reject[open] > summary { margin-bottom: .75rem; }
details.reject form label { margin-top: 0; }
details.reject form button { margin-top: .75rem; }

@media (max-width: 560px) {
    .grid-2, .match, .evidence { grid-template-columns: minmax(0, 1fr); }
    .match { grid-auto-flow: row; }
    .my-car { grid-template-columns: 96px minmax(0, 1fr); gap: .75rem; padding: .75rem; }
    .gallery .thumbs a { flex-basis: 72px; }
    .lightbox img { max-width: 100vw; }
    .review-head { flex-direction: column; gap: .25rem; }
    .push-right { margin-left: 0; }
}
@media (max-width: 420px) {
    .nav-link { padding: 0 .4rem; font-size: .85rem; }
    .brand { font-size: 1.5rem; }
}

/* Filters above the cards: one row, wrapping to two on phones */
.filters { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: .75rem; align-items: end; margin: 0 0 1rem; }
.filters label { margin: 0; font-size: .8rem; font-weight: 600; color: var(--muted); }
.filters select { margin-top: .25rem; width: 100%; }
.results-line { margin: 0 0 .75rem; color: var(--muted); font-size: .9rem; }
@media (max-width: 560px) {
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
}

/* Shortlist */
.shortlist-toggle { position: absolute; top: .45rem; right: .45rem; }
.detail-head .shortlist-toggle { position: static; margin-top: .6rem; }
button.star { background: var(--card); box-shadow: var(--shadow); color: var(--ink); }
button.star.on { color: var(--brand); border-color: var(--brand); }
button.star.on:hover { background: var(--card); }
.contacted-number { display: flex; flex-direction: column; gap: .1rem; margin: .5rem 0 .25rem; padding: .6rem .75rem;
    background: var(--bg); border-radius: 6px; }
.contacted-number .phone { font-weight: 700; font-size: 1.05rem; }
.contacted-number .hint { margin: 0; }
.contacted-when { margin: 0 0 .5rem; font-size: .8rem; }
.car-card.gone { box-shadow: none; }
.car-card.gone h2, .car-card.gone .price, .car-card.gone .facts, .car-card.gone .where { color: var(--muted); }
.car-card.gone .actions .hint { align-self: center; margin: 0; }
.empty-state { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem 1rem; }
.empty-state p { margin: 0; }
.clear-gone { margin-top: 1rem; }

/* Contact allowance ring */
.meter { display: flex; align-items: center; gap: .65rem; max-width: 22rem; }
.ring { position: relative; flex: none; width: 2.75rem; height: 2.75rem; }
.ring svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3.5; }
.ring .track { stroke: var(--line); }
.ring .fill { stroke: var(--brand); stroke-linecap: round; }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; font-size: .85rem; font-weight: 700; }
.meter-text { display: flex; flex-direction: column; line-height: 1.3; }
.meter-text strong { font-size: .9rem; }
.faint { color: var(--muted); font-size: .75rem; opacity: .85; }
.meter-text .faint { margin-top: .1rem; }
.contact-panel .limit-head { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.contact-panel .limit-head p { margin: .15rem 0 0; }
.contact-panel .faint { margin: .6rem 0 0; padding-top: .5rem; border-top: 1px solid var(--line); }
.panel-actions { display: flex; align-items: stretch; gap: .5rem; flex-wrap: wrap; margin-top: .5rem; }
.panel-actions > * { margin: 0; }
.em { font-weight: 600; }
.phone { display: block; margin: .2rem 0; font-size: 1.5rem; font-weight: 700; letter-spacing: .01em; color: var(--ink); text-decoration: none; }
.phone:hover { text-decoration: underline; }
.eyebrow { margin: 0; color: var(--muted); font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

/* Registration series, drawn like a number plate */
.plate { position: absolute; left: .45rem; bottom: .45rem; padding: .05rem .4rem; border: 1px solid var(--ink); border-radius: 4px;
    background: var(--card); color: var(--ink); font: 600 .75rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .08em; }
.plate.inline { position: static; margin-right: .4rem; }
.facts-table td.reg { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .04em; }
.updated { margin: .35rem 0 0; color: var(--muted); font-size: .85rem; display: flex; align-items: center; flex-wrap: wrap; gap: .25rem; }
.corner-card .panel-actions > * { flex: 1 1 0; }
.corner-card .panel-actions .button { width: auto; }
.corner-card p.faint { color: var(--muted); font-size: .75rem; margin: .85rem 0 0; padding-top: .6rem; }
.corner-card .phone { margin: .1rem 0 .4rem; }
.detail-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 1rem; }
.contact-card .eyebrow, .contact-card .phone { margin-bottom: .2rem; }
.contact-card p:last-child { margin-bottom: 0; }
.page-head > div:first-child, .detail-head > div:first-child { flex: 1 1 20rem; min-width: 0; }
.page-head > .meter, .detail-head > .meter { flex: 0 1 18rem; }
.detail-head > div:first-child { flex-basis: 16rem; }
.detail-head > .meter { flex-basis: 15rem; }

/* Sign-in panel over the current page (auth/panel.html). */
.drawer-wrap { position: fixed; inset: 0; z-index: 50; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(29, 35, 42, .35); }
.drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(420px, 100%); overflow-y: auto;
    background: var(--card); box-shadow: var(--shadow-up); padding: 1.5rem 1.25rem; }
/* Title and × on one line, centred on each other. */
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin: 0 0 .25rem; }
.drawer-head h2 { margin: 0; }
.drawer-close { flex: none; width: 2.25rem; min-height: 2.25rem; padding: 0; font-size: 1.4rem; line-height: 1;
    border-color: transparent; box-shadow: none; color: var(--muted); }
.drawer-close:hover { color: var(--ink); }
.drawer-head + .hint { margin: 0 0 1.25rem; }
.drawer-foot { margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--line); }
.drawer .actions { margin-top: 1rem; }

/* ---------- Sign-in and sign-up ---------- */
/* Fields stacked with their labels; the submit button set apart from the last field. */
form.stack > button[type=submit].block { margin-top: 1.25rem; }
.center { text-align: center; }
.row.nowrap > button { flex: none; }
.password-field { position: relative; }
.password-field input { padding-right: 4.5rem; }
.password-field .reveal { position: absolute; top: 50%; right: .3rem; transform: translateY(-50%); min-height: 1.9rem;
    border-color: transparent; box-shadow: none; color: var(--muted); font-weight: 600; }
.password-field .reveal:hover { color: var(--ink); }
.password-field .reveal:active { transform: translateY(-50%); }
input.invalid { border-color: var(--bad); }
input.invalid:focus { box-shadow: 0 0 0 3px rgba(180, 35, 24, .15); }
.field-error { color: var(--bad); font-size: .9rem; margin: .35rem 0 0; }
.field-status { font-size: .9rem; margin: .35rem 0 0; min-height: 0; }
.field-status:empty { display: none; }
.field-status.ok { color: var(--ok); }
.field-status.bad { color: var(--bad); }
.field-status .suggestion { min-height: 1.75rem; padding: 0 .55rem; margin: .15rem .1rem 0; font-size: .85rem; font-weight: 600;
    color: var(--ink); }
.password-field + .hint, .field-error + .hint, .field-status + .hint { margin: .35rem 0 0; }
button:disabled, button:disabled:hover { opacity: .55; cursor: not-allowed; background: var(--card); border-color: var(--line);
    transform: none; filter: none; }
button.primary:disabled { background: var(--brand); border-color: var(--brand); }
form.resend { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin: .75rem 0 0; }
form.resend .hint { margin: 0; }

/* ---------- Wallet ---------- */
/* Balance at the end of the nav. */
.wallet-chip { display: inline-flex; align-items: center; gap: .3rem; height: 2rem; margin-left: .25rem;
    padding: 0 .65rem; border: 1px solid var(--line); border-radius: 999px; color: var(--ink); text-decoration: none;
    font-size: .8rem; background: var(--card); white-space: nowrap; }
.wallet-chip:hover { background: var(--bg); text-decoration: none; }
.wallet-chip .faint { color: var(--muted); font-size: .75rem; }
.corner-card p.refund-note { color: var(--ink); background: var(--bg); border-radius: 6px; padding: .5rem .65rem; font-size: .875rem; }
.wallet .balance { font-size: 2rem; font-weight: 800; letter-spacing: -.01em; margin: 0; line-height: 1.2; }
.wallet .amounts { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0 0; }
.wallet .amounts button { flex: 1 1 6rem; }
.wallet .custom { margin-top: .75rem; }
.wallet .custom input { max-width: 12rem; }
.ledger { width: 100%; border-collapse: collapse; font-size: .9rem; }
.ledger th, .ledger td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.ledger th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.ledger td.num, .ledger th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ledger td.credit { color: var(--ok); }
.ledger details { margin-top: .35rem; }
.ledger summary { cursor: pointer; color: var(--brand); font-weight: 600; }
.ledger details form { margin-top: .5rem; }
.ledger details label { margin-top: .5rem; }
.ledger details button { margin-top: .6rem; }

/* ---------- Admin tables ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); overflow: hidden; }
.data-table th, .data-table td { padding: .55rem .7rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table th { background: var(--bg); color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
.data-table th a { color: inherit; text-decoration: none; }
.data-table th a.sorted { color: var(--ink); }
.data-table td.num, .data-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; margin: 0 0 1.25rem; }
.flag { display: inline-block; font-size: .75rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px;
    background: #fdecea; color: var(--bad); margin: .1rem .2rem 0 0; white-space: nowrap; }
.search { display: flex; gap: .5rem; margin: 0 0 1rem; max-width: 28rem; }
.refund-case .actions form { flex: 1 1 14rem; }
.refund-case textarea { min-height: 3.5rem; }

/* Admin review queue: a decided card folds away (review.js). */
.review:focus { outline: none; }
.review:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.review.leaving { overflow: hidden; pointer-events: none; }
.badge[hidden], .card[hidden], .field-error[hidden] { display: none; }

/* Profile: "Your details". Label, value with its state, then the link; stacks on phones. */
.details h2 { margin: 0 0 .5rem; font-size: 1.15rem; }
.details-list { margin: 0; }
.detail-row { display: grid; grid-template-columns: 11rem 1fr auto; gap: .25rem 1rem; align-items: baseline;
    padding: .7rem 0; border-bottom: 1px solid var(--line); }
.detail-row:last-child { border-bottom: 0; padding-bottom: 0; }
.detail-row dt { color: var(--muted); }
.detail-row dd { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .6rem; min-width: 0; }
.detail-row .value { font-weight: 600; overflow-wrap: anywhere; }
.detail-row .value.muted { font-weight: 400; color: var(--muted); }
.detail-row .hint { flex-basis: 100%; margin: 0; }
.detail-row .detail-action { justify-self: end; white-space: nowrap; }
@media (max-width: 40rem) {
    .detail-row { grid-template-columns: 1fr auto; }
    .detail-row dt { grid-column: 1 / -1; font-size: .875rem; }
}
