:root {
    --bg: #10203a; --bg2: #070f1d; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #eef4ff; --muted: #b6c7e6; --accent: #7aa7ff; --accent-ink: #061636; --field: rgba(255,255,255,.08);
    --soft: rgba(122,167,255,.15); --good: #8ce99a; --warn: #ffc94d; --warn-bg: rgba(255,201,77,.13); --bad: #ff8f8f; --bad-bg: rgba(255,107,107,.16);
    color-scheme: dark;
}
@media (prefers-color-scheme: light) {
    :root { --bg: #f2f6fd; --bg2: #dbe6f8; --card: #fff; --line: #bfcfea; --ink: #0b1a33; --muted: #3d5378;
            --accent: #1f5bc8; --accent-ink: #fff; --field: #f8fbff; --soft: #e4edfc; --good: #2b8a3e; --warn: #9a5b00; --warn-bg: #fff3d6; --bad: #c92a2a; --bad-bg: #ffe8e8; color-scheme: light; }
}
:root[data-theme="light"] { --bg: #f2f6fd; --bg2: #dbe6f8; --card: #fff; --line: #bfcfea; --ink: #0b1a33; --muted: #3d5378;
            --accent: #1f5bc8; --accent-ink: #fff; --field: #f8fbff; --soft: #e4edfc; --good: #2b8a3e; --warn: #9a5b00; --warn-bg: #fff3d6; --bad: #c92a2a; --bad-bg: #ffe8e8; color-scheme: light; }
:root[data-theme="dark"] {
    --bg: #10203a; --bg2: #070f1d; --card: rgba(255,255,255,.06); --line: rgba(255,255,255,.17);
    --ink: #eef4ff; --muted: #b6c7e6; --accent: #7aa7ff; --accent-ink: #061636; --field: rgba(255,255,255,.08);
    --soft: rgba(122,167,255,.15); --good: #8ce99a; --warn: #ffc94d; --warn-bg: rgba(255,201,77,.13); --bad: #ff8f8f; --bad-bg: rgba(255,107,107,.16);
    color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; padding: clamp(1rem,4vw,2.5rem) 1rem 4rem; display: flex; justify-content: center;
       font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink);
       background: var(--bg2) linear-gradient(180deg, var(--bg), var(--bg2) 900px) no-repeat; touch-action: manipulation; }
.app { width: min(560px, 100%); min-width: 0; display: flex; flex-direction: column; }
.col-cars, .col-add { display: contents; }
.app.empty .cars { display: none; }
header { text-align: center; margin-bottom: 1.1rem; }
h1 { margin: 0; font-size: 1.7rem; line-height: 1.2; letter-spacing: -.02em; }
.sub { margin: .4rem 0 0; color: var(--muted); font-size: 1rem; }
h2 { margin: 0 0 .7rem; font-size: 1.15rem; overflow-wrap: anywhere; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 1.1rem; margin-bottom: .9rem; min-width: 0; }
label, .label-like { display: block; margin: 1rem 0 .35rem; font-size: .9rem; font-weight: 600; color: var(--muted); padding: 0; }
form > label:first-child { margin-top: 0; }
.opt { font-weight: 400; }
input[type=text], input[type=time], select, textarea { display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 48px; padding: .6rem .8rem; font: inherit; font-size: 1.05rem; color: var(--ink);
       background: var(--field); border: 1px solid var(--line); border-radius: 12px; -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; line-height: 1.4; }
select { -webkit-appearance: auto; appearance: auto; }
input[type=time] { -webkit-appearance: auto; appearance: auto; max-width: 14rem; }
select option { color: #111; background: #fff; }
input:focus-visible, textarea:focus-visible, button:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
::placeholder { color: var(--muted); opacity: .75; }
.hint { margin: .5rem 0 0; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }
.paid-text { font-weight: 600; color: var(--ink); }
.paid-text:empty { display: none; }
[hidden] { display: none !important; }
.warn-box { margin: 0 0 .9rem; padding: .7rem .9rem; border-radius: 12px; background: var(--warn-bg); border-left: 5px solid var(--warn); font-weight: 600; }
.err { margin: .5rem 0 0; color: var(--bad); font-weight: 600; font-size: .92rem; }
.err:empty { display: none; }
.msg { margin-top: .6rem; font-size: .95rem; display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .7rem; overflow-wrap: anywhere; }
.msg:empty { display: none; }
.msg .link { margin: 0; min-height: 36px; }
.copy-box { font-size: .92rem; }

/* buttons */
.primary, .secondary { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 48px; padding: .5rem .7rem; border-radius: 12px;
       font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer; line-height: 1.2; overflow-wrap: anywhere; }
.primary { border: 0; background: var(--accent); color: var(--accent-ink); margin-top: .8rem; }
.primary.big { min-height: 56px; font-size: 1.15rem; border-radius: 14px; margin-top: 1.1rem; }
.secondary { border: 1px solid var(--line); background: var(--soft); color: var(--ink); }
.secondary:hover { border-color: var(--accent); }
.secondary.small { min-height: 44px; font-size: .92rem; font-weight: 600; }
.secondary:disabled { opacity: .6; cursor: wait; }
#cancel-edit { margin-top: .6rem; }
.link { background: none; border: 0; padding: .3rem 0; min-height: 44px; color: var(--accent); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; text-align: left; }
.add-opt { display: block; margin-top: .6rem; text-decoration: none; }
.add-opt:hover { text-decoration: underline; }
.opt-block { margin-top: .4rem; }
.row-btns { display: grid; gap: .5rem; margin-top: .55rem; }
.row-btns.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row-btns.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-btns.three .secondary { padding: .4rem .2rem; white-space: nowrap; font-size: .97rem; }
.loc-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.loc-row:has(#loc-clear:not([hidden])) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.photo-prev { margin-top: .6rem; }
.photo-prev img { display: block; max-width: 100%; max-height: 220px; border-radius: 12px; border: 1px solid var(--line); }

/* paid time choices */
.presets { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.preset { min-height: 46px; padding: .4rem .5rem; border-radius: 12px; border: 1px solid var(--line); background: var(--field); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; line-height: 1.2; }
.preset[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dhm { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .5rem; margin-top: .3rem; }
.dhm label { margin-top: .5rem; }

.checks { display: grid; gap: .25rem; margin-bottom: .6rem; }
.check { display: flex; align-items: flex-start; gap: .6rem; margin: 0; padding: .45rem 0; font-weight: 500; color: var(--ink); font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; margin: 0; flex: none; accent-color: var(--accent); }
.alerts .secondary.small { width: auto; padding: 0 1rem; }

/* parked cars: each in its own box */
.box-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.spot { border: 2px solid var(--line); border-left: 6px solid var(--accent); border-radius: 14px; padding: .95rem 1rem 1rem; background: var(--field); min-width: 0; }
.spot.st-free { border-left-color: var(--muted); }
.spot.st-soon { border-color: var(--warn); background: var(--warn-bg); }
.spot.st-over { border-color: var(--bad); background: var(--bad-bg); }
.spot-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .4rem .7rem; }
.car-name { margin: 0; font-size: 1.1rem; overflow-wrap: anywhere; min-width: 0; }
.badge { padding: .15rem .65rem; border-radius: 999px; font-size: .82rem; font-weight: 700; background: var(--soft); color: var(--accent); white-space: nowrap; }
.st-free .badge { color: var(--muted); }
.st-soon .badge { background: var(--warn); color: #241600; }
.st-over .badge { background: var(--bad); color: #fff; }
.big { margin: .45rem 0 .2rem; font-size: 2.2rem; font-weight: 800; line-height: 1.1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.st-soon .big { color: var(--warn); }
.st-over .big { color: var(--bad); font-size: 1.9rem; }
.st-free .big { font-size: 1.6rem; }
.bar { height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; margin: .4rem 0 .5rem; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .5s linear; }
.st-soon .bar i { background: var(--warn); }
.st-over .bar i { background: var(--bad); }
.line { margin: 0; font-weight: 700; font-size: 1.02rem; overflow-wrap: anywhere; }
.parked { margin: .1rem 0 0; color: var(--muted); font-size: .92rem; }
.note { margin: .65rem 0 0; padding: .55rem .75rem; border-radius: 10px; background: var(--card); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.02rem; }
.note-k { font-weight: 700; color: var(--muted); }
.photo-btn { display: block; margin: .65rem 0 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: none; cursor: zoom-in; overflow: hidden; max-width: 100%; }
.photo-btn img { display: block; max-width: 100%; max-height: 140px; }
.photo-btn.big { cursor: zoom-out; }
.photo-btn.big img { max-height: none; }
.locline { margin: .55rem 0 0; color: var(--muted); font-size: .9rem; }
.acts { margin-top: .3rem; }
.acts > .secondary { margin-top: .55rem; }
.acts .walk { margin-top: .7rem; }
.far-out { margin: .5rem 0 0; font-weight: 600; overflow-wrap: anywhere; }
.far-out:empty { display: none; }
.secondary.clear { background: transparent; }

.faq { margin-top: .6rem; }
.faq details { border-top: 1px solid var(--line); padding: .7rem 0; }
.faq summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.faq p { color: var(--muted); margin: .5rem 0 0; }
footer { text-align: center; margin-top: 1.4rem; font-size: .9rem; }
footer a { color: var(--muted); }

.back { display: inline-flex; align-items: center; gap: .4rem; min-height: 44px; margin: 0 0 .5rem; padding: 0 1rem 0 .8rem; border: 1px solid var(--line, rgba(127,127,127,.4)); border-radius: 999px; color: var(--muted, var(--mut, inherit)); font-size: .92rem; font-weight: 600; text-decoration: none; background: transparent; }
.back:hover { color: var(--ink, inherit); border-color: currentColor; }
.back:focus-visible { outline: 3px solid var(--accent, var(--acc, #fff)); outline-offset: 2px; }
@media print { .back { display: none; } }

@media (max-width: 380px) {
    .card { padding: .95rem .8rem; }
    .spot { padding: .85rem .75rem; }
    .big { font-size: 1.9rem; }
    .row-btns.two, .loc-row:has(#loc-clear:not([hidden])) { grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
    .topbar .theme-toggle { padding: 0; width: 44px; justify-content: center; }
    .topbar .theme-toggle span { display: none; }
}
@media (min-width: 600px) {
    .presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 900px) {
    .app { width: min(1140px, 100%); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); column-gap: 1.5rem; align-items: start; }
    .app > * { grid-column: 1 / -1; }
    .app.empty .cars { display: block; }
    .col-cars, .col-add { display: block; min-width: 0; }
    .app > .back { justify-self: start; }
    .app > .col-add { grid-column: 1; grid-row: 4; }
    .app > .col-cars { grid-column: 2; grid-row: 4; }
    .app > .faq { grid-row: 5; width: min(760px, 100%); justify-self: center; }
    .app > footer { grid-row: 6; width: min(760px, 100%); justify-self: center; }
    header h1 { font-size: 2.3rem; }
    .cars { padding: 1.3rem 1.4rem; min-height: 320px; }
    .big { font-size: 2.8rem; }
    .presets { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .photo-btn img { max-height: 180px; }
}
