:root {
  --bg: #0b0d12; --bg2: #11151d; --card: rgba(22, 27, 37, .78); --line: rgba(255,255,255,.08);
  --text: #eef1f6; --muted: #8b95a7; --accent: #c8102e; --accent2: #ff4d5e; --gold: #f2c14e; --ok: #3ddc97;
  --paint: #c8102e; --paint-light: #ff5a6a; --paint-dark: #6e0816;
  --radius: 20px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(1200px 600px at 80% -10%, rgba(200,16,46,.25), transparent 60%),
              radial-gradient(900px 500px at -10% 30%, rgba(40,90,200,.18), transparent 60%), var(--bg);
  color: var(--text); min-height: 100vh; line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent2); }
.bg-road { position: fixed; inset: auto 0 0 0; height: 30vh; pointer-events: none; z-index: -1;
  background: repeating-linear-gradient(90deg, transparent 0 60px, rgba(255,255,255,.03) 60px 120px);
  mask-image: linear-gradient(to top, #000, transparent); }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

.topbar { display: flex; align-items: center; justify-content: space-between; max-width: 1180px; margin: 0 auto; padding: 18px 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .02em; }
.brand b { color: var(--accent2); }
.badge { min-width: 34px; height: 34px; padding: 0 10px; font-size: .85rem; letter-spacing: .04em; display: grid; place-items: center; border-radius: 999px; font-weight: 800;
  background: linear-gradient(145deg, #e0213e, #7a0718); box-shadow: 0 0 0 2px rgba(255,255,255,.15) inset, 0 6px 18px rgba(200,16,46,.4); }

main { max-width: 1180px; margin: 0 auto; padding: 0 20px 40px; display: grid; gap: 20px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  backdrop-filter: blur(10px); box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.card h2 { font-size: 1.05rem; margin: 0; letter-spacing: .01em; }
.muted { color: var(--muted); } .small { font-size: .82rem; }
.pill { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: rgba(200,16,46,.18); color: #ffb3bb; border: 1px solid rgba(200,16,46,.35); }

.btn { font: inherit; color: var(--text); background: rgba(255,255,255,.07); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 16px; cursor: pointer; transition: transform .15s, background .2s; }
.btn:hover { background: rgba(255,255,255,.12); } .btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--accent), #8f0b21); border-color: transparent; font-weight: 600; box-shadow: 0 8px 22px rgba(200,16,46,.35); }
.btn.ghost { background: transparent; }

/* hero */
.hero { text-align: center; padding: 28px 22px 30px; overflow: hidden; position: relative; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: .18em; font-size: .78rem; color: var(--muted); }
.car-name { margin: 6px 0 0; font-size: clamp(1.6rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.01em;
  background: linear-gradient(90deg, #fff, #ffb3bb); -webkit-background-clip: text; background-clip: text; color: transparent; }
.car-stage { position: relative; max-width: 620px; margin: 6px auto 4px; }
.paint-picker { display: flex; justify-content: center; gap: 8px; margin-top: 4px; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255,255,255,.25); cursor: pointer; padding: 0; transition: transform .15s; }
.swatch:hover { transform: scale(1.15); } .swatch[aria-pressed="true"] { border-color: #fff; box-shadow: 0 0 0 3px rgba(255,255,255,.18); }

.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(8px, 2vw, 18px); max-width: 760px; margin: 18px auto 10px; }
.unit { background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02)); border: 1px solid var(--line);
  border-radius: 18px; padding: clamp(12px, 2.4vw, 22px) 6px; position: relative; overflow: hidden; }
.unit::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0,0,0,.35); }
.num { display: block; font-size: clamp(2.2rem, 8vw, 5rem); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1;
  letter-spacing: -.03em; text-shadow: 0 6px 30px rgba(200,16,46,.45); }
.num.tick { animation: tick .35s ease-out; }
@keyframes tick { from { transform: translateY(-6px); opacity: .5; } }
.lbl { display: block; margin-top: 8px; text-transform: uppercase; letter-spacing: .16em; font-size: clamp(.6rem, 1.5vw, .78rem); color: var(--muted); }
.arrival-line { margin: 10px 0 0; color: var(--muted); }
.arrival-line strong { color: var(--text); }
.empty-cta { margin-top: 14px; }
.celebrate h2 { font-size: clamp(1.8rem, 5vw, 3rem); margin: 10px 0 4px; }
.hero.arrived .countdown { opacity: .35; }

/* progress */
.track { position: relative; height: 14px; border-radius: 999px; background: rgba(255,255,255,.07); margin: 30px 6px 8px; }
.track-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #7a0718, var(--accent), var(--accent2)); transition: width 1s; box-shadow: 0 0 18px rgba(200,16,46,.6); }
.track-car { position: absolute; top: -28px; left: 0; transform: translateX(-50%) scaleX(-1); font-size: 26px; transition: left 1s; }
.milestones { list-style: none; padding: 0; margin: 14px 0 6px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.milestones li { font-size: .8rem; color: var(--muted); }
.milestones li .dot { display: block; width: 14px; height: 14px; border-radius: 50%; margin: 0 auto 6px; border: 2px solid rgba(255,255,255,.25); }
.milestones li.done { color: var(--text); } .milestones li.done .dot { background: var(--accent); border-color: var(--accent2); box-shadow: 0 0 10px var(--accent); }
.milestones .ms-date { display: block; font-size: .72rem; color: var(--muted); }

/* grid */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { background: rgba(255,255,255,.04); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.stat .v { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat .k { font-size: .8rem; color: var(--muted); }

.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 340px; overflow: auto; }
.checklist li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 12px; background: rgba(255,255,255,.03); }
.checklist li.done span { color: var(--muted); text-decoration: line-through; }
.checklist input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.checklist span { flex: 1; font-size: .92rem; }
.checklist .del { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 1rem; opacity: 0; transition: opacity .2s; }
.checklist li:hover .del, .checklist .del:focus { opacity: 1; }
@media (hover: none) { .checklist .del { opacity: .6; } }
.add-item { display: flex; gap: 8px; margin-top: 12px; }

input[type=text], input[type=number], input[type=date], input[type=datetime-local] {
  font: inherit; color: var(--text); background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px; width: 100%; min-width: 0; }
input:focus { outline: 2px solid rgba(200,16,46,.6); outline-offset: 1px; }

.facts { display: grid; grid-template-columns: 1fr auto; gap: 8px 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: .9rem; } .facts dd { margin: 0; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.sources { margin-top: 14px; }

.fuel-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fuel-form label { font-size: .8rem; color: var(--muted); display: grid; gap: 4px; }
.fuel-result { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.fuel-result .stat .v { color: var(--ok); }

.trips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.trips li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.03); }
.trips .emoji { font-size: 1.4rem; } .trips .name { font-weight: 600; } .trips .desc { font-size: .8rem; color: var(--muted); }
.trips .meta { text-align: right; font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.trips .meta b { color: var(--text); display: block; }

.hype-card { text-align: center; }
.flappy-card { display: flex; flex-direction: column; }
.flappy-stage { position: relative; border-radius: 14px; overflow: hidden; background: #0b0d12; border: 1px solid var(--line);
  aspect-ratio: 16 / 10; min-height: 220px; touch-action: none; user-select: none; -webkit-user-select: none; }
.flappy-stage canvas { width: 100%; height: 100%; display: block; cursor: pointer; touch-action: none; }
.flappy-stage canvas:focus { outline: 2px solid rgba(200,16,46,.55); outline-offset: -2px; }
.flappy-overlay { position: absolute; inset: 0; z-index: 2; display: grid; place-content: center; justify-items: center; gap: 8px; text-align: center;
  padding: 16px; background: linear-gradient(180deg, rgba(11,13,18,.5), rgba(11,13,18,.82)); pointer-events: auto; }
.flappy-overlay[hidden] { display: none; }
.flappy-overlay h3 { margin: 0; font-size: 1.35rem; font-weight: 800; }
.flappy-scoreline { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.flappy-overlay .btn { pointer-events: auto; }
.flappy-flag { margin: 0; min-height: 1.2em; color: var(--gold); font-weight: 700; font-size: .88rem; }
.flappy-flag[hidden] { display: none; }
.flappy-board-title { margin: 14px 0 6px; font-size: .92rem; letter-spacing: .01em; }
.flappy-board { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.flappy-board li { display: grid; grid-template-columns: 1.4rem 1fr auto auto; gap: 8px; align-items: center;
  padding: 6px 10px; border-radius: 10px; background: rgba(255,255,255,.03); font-size: .86rem; font-variant-numeric: tabular-nums; }
.flappy-board li.mine { box-shadow: inset 0 0 0 1px rgba(200,16,46,.45); }
.flappy-board li.fresh { background: rgba(242,193,78,.14); }
.flappy-board .rank { color: var(--muted); font-weight: 700; }
.flappy-board .who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flappy-board .pts { font-weight: 800; }
.flappy-board .when { color: var(--muted); font-size: .75rem; }
.flappy-board .empty { grid-column: 1 / -1; color: var(--muted); font-size: .85rem; padding: 8px 4px; }
.horn { font: inherit; font-size: 1.2rem; font-weight: 700; color: #fff; border: none; border-radius: 999px; padding: 16px 28px; cursor: pointer;
  background: radial-gradient(circle at 30% 30%, #ff5a6a, #8f0b21); box-shadow: 0 10px 30px rgba(200,16,46,.45); transition: transform .1s; }
.horn:active { transform: scale(.94); }
.hype-quote { min-height: 2.8em; margin: 14px 0 10px; font-style: italic; }
.hype-bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,.07); overflow: hidden; }
.hype-bar div { height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--accent2)); transition: width .3s; }

.foot { text-align: center; padding: 10px 20px 30px; }

.dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg2); color: var(--text); padding: 0; width: min(460px, 92vw); }
.dialog::backdrop { background: rgba(0,0,0,.6); backdrop-filter: blur(4px); }
.settings-form { padding: 22px; display: grid; gap: 14px; }
.settings-form h2 { margin: 0 0 4px; }
.settings-form label { display: grid; gap: 6px; font-size: .9rem; }
.req { color: var(--accent2); }
.form-error { color: #ff8a95; min-height: 1.2em; margin: 0; font-size: .85rem; }
.dialog-actions { display: flex; gap: 8px; flex-wrap: wrap; } .spacer { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); opacity: 0; transition: .3s; background: #1d2330;
  border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; z-index: 60; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .card { padding: 16px; }
  .milestones { grid-template-columns: repeat(5, 1fr); } .milestones li { font-size: .68rem; } .milestones .ms-date { display: none; }
  .fuel-result { grid-template-columns: 1fr 1fr 1fr; } .fuel-result .stat .v { font-size: 1.1rem; }
  .grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---- Luxury trim / Hampstead Grey ---- */
:root { --paint: #5d6167; --paint-light: #9a9ea4; --paint-dark: #2f3134; }
.trim-tag { display: inline-flex; align-items: center; gap: 8px; margin: 10px 0 0; font-size: .85rem; color: var(--muted);
  background: rgba(255,255,255,.05); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; }
.trim-badge { font-weight: 800; letter-spacing: .22em; font-size: .7rem; color: #1a1b1e; padding: 4px 10px; border-radius: 999px;
  background: linear-gradient(135deg, #f4f5f7, #aeb4bb 55%, #e6e8eb); box-shadow: 0 1px 0 rgba(255,255,255,.6) inset, 0 4px 12px rgba(0,0,0,.35); }
.trim-sep { opacity: .5; }
.paint-dot { width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(255,255,255,.35); }
.trim-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.trim-list li { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 8px 12px; border-radius: 12px; background: rgba(255,255,255,.03); }
.trim-list .emoji { font-size: 1.2rem; } .trim-list .name { font-weight: 600; font-size: .92rem; } .trim-list .desc { font-size: .78rem; color: var(--muted); }

/* ---- real photo hero ---- */
.car-stage { max-width: 560px; width: 100%; }
.car-photo { position: relative; margin: 6px auto 0; padding: 0; overflow: visible; }
.car-photo img { position: relative; z-index: 1; display: block; width: auto; height: auto; max-width: 100%; max-height: 30vh; margin: 0 auto; object-fit: contain;
  filter: drop-shadow(0 18px 22px rgba(0,0,0,.55)); transition: opacity .35s ease, transform .35s ease;
  animation: float 6s ease-in-out infinite; }
.car-photo img.swapping { opacity: 0; transform: translateY(4px) scale(.99); }
.car-glow { position: absolute; inset: 8% 6% 18%; border-radius: 50%; z-index: 0;
  background: radial-gradient(closest-side, rgba(180,190,205,.22), rgba(200,16,46,.10) 60%, transparent 100%); filter: blur(18px); }
.car-floor { position: absolute; left: 8%; right: 8%; bottom: -2%; height: 12%; z-index: 0; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(0,0,0,.7), transparent); }
@keyframes float { 50% { transform: translateY(-3px); } }
.photo-credit { margin: 8px 0 0; font-size: .68rem; color: #6b7486; }
.photo-credit a { color: #8b95a7; }

/* ---- compact hero layout (v4) ---- */
img { max-width: 100%; }
.hero { display: grid; grid-template-areas: "head" "media" "count"; gap: 6px; padding: 18px 18px 18px; }
.hero-head { grid-area: head; } .car-stage { grid-area: media; margin: 0 auto; } .hero-count { grid-area: count; min-width: 0; }
.car-photo img { max-height: min(30vh, 250px); }
.countdown { margin: 10px auto 6px; }
.photo-credit { margin: 4px 0 0; font-size: .62rem; }
.paint-picker { margin-top: 2px; } .swatch { width: 20px; height: 20px; }
.topbar { padding-top: 12px; padding-bottom: 12px; }
@media (min-width: 900px) {
  .hero { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); grid-template-areas: "media head" "media count";
    align-items: center; column-gap: clamp(16px, 3vw, 40px); padding: 22px clamp(18px, 3vw, 36px); text-align: center; }
  .hero-head { align-self: end; } .hero-count { align-self: start; }
  .car-stage { max-width: 600px; }
  .car-photo img { max-height: min(36vh, 320px); }
  .countdown { gap: 10px; margin: 14px 0 6px; max-width: none; }
  .num { font-size: clamp(2.2rem, 4.4vw, 4.2rem); }
  .unit { padding: 14px 4px; }
}
@media (max-width: 560px) {
  .hero { padding: 14px 12px; }
  .car-name { font-size: 1.5rem; }
  .eyebrow { font-size: .68rem; letter-spacing: .14em; }
  .trim-tag { margin-top: 6px; font-size: .78rem; }
  .car-photo img { max-height: 24vh; }
  .num { font-size: 2.3rem; } .unit { padding: 10px 4px; border-radius: 14px; } .lbl { margin-top: 5px; }
  .countdown { margin-top: 8px; }
}

/* ---- auth gate (v6) ---- */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
body.locked > .topbar, body.locked > .layout, body.locked > .foot, body.locked > .chat-fab { visibility: hidden; }
.top-actions { display: flex; gap: 6px; }
.gate { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 20px; overflow: hidden;
  background: #07080b; transition: transform 1.1s cubic-bezier(.7,0,.25,1); will-change: transform; }
.gate.opening, .gate.open { transform: translateY(-102%); }
.gate.closing { transition-duration: .8s; }
.gate-bg { position: absolute; inset: -40px; display: grid; place-items: center; }
.gate-bg img { width: min(1400px, 130vw); max-width: none; filter: blur(5px) brightness(.5) saturate(.85); transform: scale(1.02); }
.gate-bg::after { content: ""; position: absolute; inset: 0;
  background: radial-gradient(800px 500px at 50% 45%, transparent, rgba(5,6,9,.85) 70%), linear-gradient(180deg, rgba(200,16,46,.10), transparent 40%); }
.gate-slats { position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(180deg, rgba(255,255,255,.045) 0 1px, rgba(0,0,0,.18) 1px 3px, transparent 3px 52px); }
.gate::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 14px;
  background: linear-gradient(180deg, #2a2f39, #111419); border-top: 1px solid rgba(255,255,255,.12); box-shadow: 0 -8px 24px rgba(0,0,0,.6); }
.gate-card { position: relative; z-index: 1; width: min(380px, 100%); text-align: center; display: grid; gap: 12px; justify-items: center;
  background: rgba(17,21,29,.72); border: 1px solid rgba(255,255,255,.1); border-radius: 24px; padding: 28px 24px 22px;
  backdrop-filter: blur(16px); box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.03) inset; transition: opacity .4s, transform .4s; }
.gate.opening .gate-card { opacity: 0; transform: translateY(-20px) scale(.98); }
.gate-title { margin: 0; font-size: 1.7rem; font-weight: 800; background: linear-gradient(90deg, #fff, #ffb3bb);
  -webkit-background-clip: text; background-clip: text; color: transparent; }
.gate-sub { margin: -4px 0 4px; font-size: .9rem; }
.gate-field { width: 100%; }
.gate-field input { width: 100%; font: inherit; font-size: 1rem; color: var(--text); background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.14);
  border-radius: 14px; padding: 12px 14px; text-align: center; letter-spacing: .08em; }
.gate-field input:focus { outline: 2px solid rgba(200,16,46,.65); outline-offset: 1px; }
.gate-btn { width: 100%; padding: 12px; font-size: 1rem; }
.gate-btn:disabled { opacity: .55; cursor: not-allowed; }
.remember { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--muted); cursor: pointer; justify-self: start; }
.remember input { width: 16px; height: 16px; accent-color: var(--accent); }
.gate .form-error { min-height: 1.2em; margin: 0; font-size: .85rem; }
.gate-foot { margin: 2px 0 0; letter-spacing: .06em; }
.strength { width: 100%; height: 5px; border-radius: 99px; background: rgba(255,255,255,.08); overflow: hidden; }
.strength span { display: block; height: 100%; width: 0; border-radius: inherit; transition: width .3s, background .3s; background: #e5484d; }
.strength[data-level="1"] span { width: 25%; } .strength[data-level="2"] span { width: 50%; background: #f2a33a; }
.strength[data-level="3"] span { width: 75%; background: #b7d34a; } .strength[data-level="4"] span { width: 100%; background: var(--ok); }
.shake { animation: shake .45s cubic-bezier(.36,.07,.19,.97); }
@keyframes shake { 15%, 85% { transform: translateX(-3px); } 30%, 70% { transform: translateX(7px); } 45%, 55% { transform: translateX(-10px); } }

/* key fob */
.fob { position: relative; width: 64px; height: 104px; border-radius: 32px 32px 26px 26px; margin-bottom: 4px;
  background: linear-gradient(160deg, #2b303a, #0e1014 70%); border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 14px 30px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.12); display: grid; justify-items: center; align-content: start; gap: 8px; padding-top: 12px;
  animation: fobIdle 3.2s ease-in-out infinite; }
.fob::before { content: ""; position: absolute; top: -12px; width: 18px; height: 16px; border: 3px solid #6b7486; border-bottom: 0; border-radius: 10px 10px 0 0; }
.fob-led { width: 6px; height: 6px; border-radius: 50%; background: #3a2a12; }
.fob-badge { font-weight: 800; font-size: .7rem; letter-spacing: .04em; color: #1a1b1e; background: linear-gradient(135deg, #f4f5f7, #aeb4bb); border-radius: 50%; width: 26px; height: 26px; display: grid; place-items: center; }
.fob-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: .95rem;
  background: radial-gradient(circle at 40% 35%, #2f3540, #15181e); border: 1px solid rgba(255,255,255,.1); }
@keyframes fobIdle { 50% { box-shadow: 0 14px 30px rgba(0,0,0,.55), 0 0 26px rgba(200,16,46,.25), inset 0 1px 0 rgba(255,255,255,.12); } }
.gate.unlocking .fob { animation: fobPress .3s ease-out; }
.gate.unlocking .fob-btn { box-shadow: 0 0 0 3px rgba(61,220,151,.35), 0 0 22px rgba(61,220,151,.5); }
.gate.unlocking .fob-led { animation: blink .3s steps(1) 2; background: #f2a33a; box-shadow: 0 0 10px #f2a33a; }
.gate.unlocking .gate-card { box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 60px rgba(242,163,58,.18); }
@keyframes fobPress { 50% { transform: scale(.94); } }
@keyframes blink { 50% { background: #3a2a12; box-shadow: none; } }

/* change password */
.pw-change { border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; background: rgba(255,255,255,.02); }
.pw-change summary { cursor: pointer; font-weight: 600; font-size: .92rem; }
.pw-change[open] { display: grid; gap: 10px; } .pw-change[open] summary { margin-bottom: 4px; }
.pw-change label { display: grid; gap: 6px; font-size: .88rem; }
.pw-change input { font: inherit; color: var(--text); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; }
.pw-change .btn { justify-self: start; } .pw-change p { margin: 0; }
.form-error.ok { color: var(--ok); }
@media (max-width: 560px) { .top-actions .btn { padding: 8px 10px; } .gate-card { padding: 22px 18px 18px; } }
.gate[hidden] { display: none; }
.top-actions .btn { white-space: nowrap; }
@media (max-width: 420px) { .top-actions .btn-label { display: none; } .brand { white-space: nowrap; } }

/* ======================= v7: users, chat, sub-tasks ======================= */
/* avatars */
.avatar { display: inline-grid; place-items: center; flex: none; border-radius: 50%; color: #fff; font-weight: 700; width: 36px; height: 36px; font-size: .95rem;
  background: #444; box-shadow: inset 0 0 0 2px rgba(255,255,255,.18); text-transform: uppercase; user-select: none; }
.avatar.xs { width: 18px; height: 18px; font-size: .6rem; }
.avatar.sm { width: 28px; height: 28px; font-size: .78rem; }
.avatar.lg { width: 56px; height: 56px; font-size: 1.4rem; }
.avatar.xl { width: 72px; height: 72px; font-size: 1.9rem; box-shadow: inset 0 0 0 3px rgba(255,255,255,.2), 0 10px 26px rgba(0,0,0,.45); }

/* login user picker */
.gate-step[hidden], #gateForm[hidden] { display: none !important; }
.pick-title { margin: 4px 0 14px; font-size: 1.25rem; }
.user-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); gap: 12px; margin: 6px 0 8px; }
.user-tile { font: inherit; color: var(--text); cursor: pointer; display: grid; justify-items: center; gap: 8px; padding: 18px 10px 14px; border-radius: 18px;
  background: rgba(255,255,255,.05); border: 1px solid var(--line); transition: transform .15s, border-color .2s, background .2s; }
.user-tile:hover, .user-tile:focus-visible { transform: translateY(-3px); border-color: rgba(255,255,255,.28); background: rgba(255,255,255,.09); outline: none; }
.user-tile .tile-name { font-weight: 700; font-size: 1.05rem; }
.user-tile .tile-state { font-size: .76rem; color: var(--muted); }
.user-tile .tile-state.unclaimed { color: var(--gold); }
.back-link { font: inherit; background: none; border: none; color: var(--muted); cursor: pointer; padding: 0; margin-bottom: 8px; font-size: .85rem; }
.back-link:hover { color: var(--text); }
#gateAvatar { margin: 0 auto 6px; }
.who { display: inline-flex; align-items: center; gap: 8px; padding: 3px 12px 3px 3px; border-radius: 999px; background: rgba(255,255,255,.06); border: 1px solid var(--line); font-size: .88rem; }
.who[hidden] { display: none; }
@media (max-width: 420px) { .who .who-name { display: none; } .who { padding: 3px; } }

/* layout: dashboard + chat column */
.layout { max-width: 1180px; margin: 0 auto; }
.layout > main { max-width: none; }
@media (min-width: 1200px) {
  .topbar { max-width: 1580px; }
  .layout { max-width: 1580px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 0 20px; padding-right: 20px; align-items: start; }
  .layout > main { padding-right: 0; }
  .chat { position: sticky; top: 12px; height: calc(100vh - 86px); min-height: 460px; max-height: 980px; }
  .chat-close, .chat-fab { display: none !important; }
  .chat-expand-btn { display: none !important; }
}
@media (min-width: 1500px) { .layout { grid-template-columns: minmax(0, 1fr) 380px; } }

/* chat collapsed state (desktop only) */
@media (min-width: 1200px) {
  body.chat-collapsed .layout { grid-template-columns: minmax(0, 1fr) 0; padding-right: 20px; }
  body.chat-collapsed .chat { width: 0; min-width: 0; opacity: 0; pointer-events: none; overflow: hidden; }
  body.chat-collapsed .chat-expand-btn { display: inline-flex !important; position: relative; }
  .chat-expand-btn .unread { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--gold); color: #1d1405; font-size: .7rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 2px var(--bg); }
  .chat-expand-btn .unread[hidden] { display: none; }
  .chat-expand-btn.has-unread { animation: pulse 2s ease-in-out infinite; }
  @keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }
}

/* chat header actions */
.chat-head-actions { display: flex; gap: 4px; }
.chat-collapse { padding: 6px 10px; font-size: 1.2rem; line-height: 1; }
@media (max-width: 1199.98px) {
  .chat-collapse { display: none !important; }
  .chat-expand-btn { display: none !important; }
}

/* chat panel */
.chat { display: flex; flex-direction: column; min-height: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); overflow: hidden; position: relative; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.chat-head h2 { margin: 0; font-size: 1.05rem; }
.chat-presence { margin: 2px 0 0; }
.chat-close { padding: 6px 10px; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 12px 4px; display: flex; flex-direction: column; gap: 2px; scroll-behavior: smooth; overscroll-behavior: contain; }
.chat-empty { margin: auto; text-align: center; max-width: 220px; }
.chat-day { align-self: center; margin: 10px 0 6px; font-size: .72rem; color: var(--muted); background: rgba(255,255,255,.05); border-radius: 999px; padding: 2px 10px; }
.msg { display: flex; align-items: flex-end; gap: 8px; margin-top: 8px; max-width: 100%; }
.msg.grouped { margin-top: 2px; }
.msg.grouped .msg-avatar { visibility: hidden; }
.msg.mine { flex-direction: row-reverse; }
.bubble { max-width: min(78%, 260px); padding: 7px 11px 5px; border-radius: 16px; background: rgba(255,255,255,.08); border: 1px solid var(--line); overflow-wrap: anywhere; }
@media (min-width: 1500px) { .bubble { max-width: min(78%, 300px); } }
.msg.theirs .bubble { border-bottom-left-radius: 5px; }
.msg.mine .bubble { background: linear-gradient(135deg, rgba(200,16,46,.85), rgba(122,7,24,.9)); border-color: transparent; border-bottom-right-radius: 5px; }
.msg-who { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); margin-bottom: 1px; }
.msg.mine .msg-who { display: none; }
.msg-text { margin: 0; white-space: pre-wrap; font-size: .92rem; line-height: 1.38; }
.msg-text.big-emoji { font-size: 2rem; line-height: 1.15; }
.msg-time { display: block; text-align: right; font-size: .66rem; color: rgba(255,255,255,.55); margin-top: 2px; font-variant-numeric: tabular-nums; }
.msg.beep .bubble { background: linear-gradient(135deg, var(--gold), #e08a1e); color: #1d1405; border-color: transparent; font-weight: 700; animation: honk .5s ease 2; }
.msg.beep .msg-time, .msg.beep .msg-who { color: rgba(29,20,5,.65); }
@keyframes honk { 0%,100% { transform: none; } 25% { transform: translateX(-3px) rotate(-2deg); } 75% { transform: translateX(3px) rotate(2deg); } }
.chat-jump { position: absolute; left: 50%; transform: translateX(-50%); bottom: 132px; font: inherit; font-size: .8rem; cursor: pointer; color: #fff;
  background: var(--accent); border: none; border-radius: 999px; padding: 5px 12px; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.chat-jump[hidden] { display: none; }
.chat-typing { min-height: 22px; padding: 2px 16px; }
.dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); animation: blinkdot 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .2s; } .dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blinkdot { 0%,80%,100% { opacity: .25; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }
.chat-form { padding: 8px 12px 12px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.chat-form textarea { font: inherit; font-size: .92rem; color: var(--text); background: rgba(0,0,0,.35); border: 1px solid var(--line); border-radius: 12px;
  padding: 9px 11px; resize: none; width: 100%; min-height: 40px; max-height: 140px; line-height: 1.35; }
.chat-form textarea:focus { outline: none; border-color: rgba(255,255,255,.3); }
.chat-actions { display: flex; align-items: center; gap: 8px; }
.chat-actions .chat-count { margin-left: auto; }
.chat-actions .primary { margin-left: auto; }
.chat-count:not(:empty) + .primary { margin-left: 0; }
.beep-btn { padding: 7px 12px; }

/* floating chat button + drawer (narrow screens) */
.chat-fab { position: fixed; right: 18px; bottom: 18px; z-index: 35; width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer; font-size: 1.6rem;
  background: linear-gradient(135deg, var(--accent), #7a0718); color: #fff; box-shadow: 0 12px 30px rgba(200,16,46,.45); }
.chat-fab .unread { position: absolute; top: -4px; right: -4px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--gold); color: #1d1405;
  font-size: .75rem; font-weight: 800; display: grid; place-items: center; box-shadow: 0 0 0 3px var(--bg); }
.chat-fab .unread[hidden] { display: none; }
.chat-fab.honk { animation: honk .45s ease 2; }
@media (max-width: 1199.98px) {
  .chat { position: fixed; top: 0; right: 0; bottom: 0; z-index: 38; width: min(400px, 100vw); height: 100vh; height: 100dvh; border-radius: 0; border-width: 0 0 0 1px;
    background: rgba(17,21,29,.97); transform: translateX(105%); transition: transform .28s ease; visibility: hidden; }
  .chat.open { transform: none; visibility: visible; box-shadow: -20px 0 60px rgba(0,0,0,.55); }
  .chat-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .chat-form { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .chat.open ~ .chat-fab { display: none; }
}
@media (max-width: 1199.98px) { body:has(.chat.open) { overflow: hidden; } }

/* checklist v7: sub-tasks + notes */
.checklist { max-height: 420px; }
.checklist li.item { display: block; padding: 0; }
.checklist .item-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; }
.checklist li.item.open { background: rgba(255,255,255,.055); box-shadow: inset 0 0 0 1px var(--line); }
.checklist .item-text { flex: 1; font-size: .92rem; cursor: pointer; }
.checklist li.done > .item-row .item-text { color: var(--muted); text-decoration: line-through; }
.checklist li span { text-decoration: none; }
.checklist .item-badges { flex: none; display: inline-flex; align-items: center; gap: 6px; }
.sub-pill { font-size: .72rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--muted); font-variant-numeric: tabular-nums; }
.sub-pill.complete { background: rgba(61,220,151,.16); color: var(--ok); }
.note-flag { font-size: .8rem; }
.checklist .expand { background: none; border: none; color: var(--muted); cursor: pointer; font-size: .95rem; padding: 2px 4px; transition: transform .2s; }
.checklist li.open .expand { transform: rotate(180deg); color: var(--text); }
.item-detail { padding: 0 12px 12px 38px; display: grid; gap: 8px; }
.subtasks { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.subtasks li { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-radius: 8px; }
.subtasks li:hover { background: rgba(255,255,255,.04); }
.checklist .subtasks input[type=checkbox] { width: 15px; height: 15px; }
.subtasks .sub-text { flex: 1; font-size: .86rem; cursor: pointer; }
.subtasks li.done .sub-text { color: var(--muted); text-decoration: line-through; }
.subtasks li:hover .del { opacity: 1; }
.add-sub { display: flex; gap: 6px; }
.add-sub input { font: inherit; font-size: .85rem; color: var(--text); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 9px; padding: 6px 9px; flex: 1; min-width: 0; }
.small-btn { padding: 4px 12px; }
.item-detail .notes { font: inherit; font-size: .86rem; color: var(--text); background: rgba(0,0,0,.3); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px;
  width: 100%; resize: vertical; min-height: 64px; line-height: 1.4; }
.notes-status:empty { display: none; }
.item-meta { margin: 0; }

@media (max-width: 400px) { .brand-word { display: none; } }
#pickStep, #gateForm { width: 100%; }
.user-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.checklist li.done .item-badges span, .checklist li.done .item-detail span:not(.sub-text) { text-decoration: none; }
