/* Loadout — HIG-flavored, dark-aware, one-hand-friendly. */

:root {
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #000000;
  --text-2: #6D6D72;
  --sep: rgba(60, 60, 67, 0.16);
  --accent: #0A84FF;
  --destructive: #FF3B30;
  --fill: rgba(120, 120, 128, 0.14);
  --fill-2: rgba(120, 120, 128, 0.22);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1C1C1E;
    --text: #FFFFFF;
    --text-2: #98989E;
    --sep: rgba(84, 84, 88, 0.5);
    --fill: rgba(120, 120, 128, 0.22);
    --fill-2: rgba(120, 120, 128, 0.32);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
h1 { font-size: 30px; font-weight: 800; letter-spacing: 0.2px; margin: 0 0 6px; }
h2 { font-size: 20px; font-weight: 700; margin: 0; }
.sub { font-size: 16px; line-height: 1.4; color: var(--text-2); margin: 0; }

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.page-head { padding: max(28px, env(safe-area-inset-top)) 24px 8px; }
.nav-bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: max(10px, env(safe-area-inset-top)) 16px 6px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
}
.nav-btn { font-size: 17px; color: var(--accent); padding: 8px 4px; min-height: 44px; }
.nav-btn.destructive { color: var(--destructive); }
.chip {
  font-size: 13px; font-weight: 600; color: var(--text-2);
  background: var(--fill); padding: 6px 12px; border-radius: 999px;
}

/* ── Van select ──────────────────────────────────────────── */
#screen-van { justify-content: center; gap: 8px; }
#screen-van .page-head { text-align: center; padding-bottom: 20px; }
.van-choices { display: flex; flex-direction: column; gap: 14px; padding: 0 24px max(24px, env(safe-area-inset-bottom)); }
.van-card {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--card); border-radius: 20px; padding: 26px 16px 22px;
  box-shadow: 0 1px 0 var(--sep);
}
.van-card:active { background: var(--fill); }
.van-card svg { width: 74px; height: 48px; color: var(--accent); margin-bottom: 6px; }
.van-name { font-size: 20px; font-weight: 700; }
.van-hint { font-size: 14px; color: var(--text-2); }

/* ── Upload ──────────────────────────────────────────────── */
.upload-body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 0 28px; text-align: center; align-items: center; }
.upload-foot { padding: 12px 0 max(20px, env(safe-area-inset-bottom)); text-align: center; }
.link-btn { color: var(--accent); font-size: 15px; padding: 10px 16px; }

.btn-primary {
  display: block; width: 100%; max-width: 420px;
  background: var(--accent); color: #fff;
  font-size: 17px; font-weight: 600; text-align: center;
  padding: 15px 20px; border-radius: 14px; min-height: 50px;
}
.btn-primary:active { opacity: 0.75; }
.btn-primary[disabled] { opacity: 0.4; }
.big-cta { margin-top: 14px; }
.btn-secondary {
  display: block; width: 100%; max-width: 420px;
  background: var(--fill); color: var(--accent);
  font-size: 17px; font-weight: 600; text-align: center;
  padding: 15px 20px; border-radius: 14px; min-height: 50px;
}
.btn-secondary:active { background: var(--fill-2); }
.btn-secondary.destructive { color: var(--destructive); }

/* ── Review ──────────────────────────────────────────────── */
.review-body { padding: 4px 16px 0; }
.review-body h1 { padding: 0 8px; }
.review-body .sub { padding: 0 8px 6px; }
.group-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 8px 8px; }
.add-btn {
  width: 32px; height: 32px; border-radius: 999px; background: var(--fill);
  color: var(--accent); font-size: 20px; line-height: 32px; text-align: center; font-weight: 600;
}
.item-list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 14px; overflow: hidden; }
.item-list:empty::after {
  content: "Nothing yet"; display: block; padding: 16px; color: var(--text-2); font-size: 15px;
}
.item-row { display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 12px; min-height: 56px; position: relative; }
.item-row + .item-row::before {
  content: ""; position: absolute; top: 0; left: 60px; right: 0; height: 0.5px; background: var(--sep);
}
.item-row:active { background: var(--fill); }
.item-swatch {
  width: 38px; height: 38px; border-radius: 9px; flex: none;
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800;
  border: 1px solid rgba(120,120,128,0.25);
}
.item-title { font-size: 17px; font-weight: 600; flex: 1; }
.item-title small { display: block; font-size: 13px; font-weight: 400; color: var(--text-2); }
.row-del { width: 44px; height: 44px; color: var(--text-2); font-size: 17px; flex: none; }
.review-spacer { height: 110px; }
.cta-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 12px 16px max(16px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  display: flex; justify-content: center;
}

/* ── Loading deck ────────────────────────────────────────── */
.load-screen { background: #000; color: #fff; overflow: hidden; padding: 0; }
.load-head {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) 16px 0;
}
.round-btn {
  width: 44px; height: 44px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.16); color: #fff;
  display: grid; place-items: center;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.round-btn svg { width: 20px; height: 20px; }
.round-btn:active { background: rgba(255, 255, 255, 0.3); }
.voice-btn.on { background: var(--accent); }
.voice-btn:not(.on) .wave { opacity: 0.35; }
.load-counter {
  font-size: 15px; font-weight: 700; letter-spacing: 0.4px;
  background: rgba(255, 255, 255, 0.16); border-radius: 999px; padding: 9px 16px;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  font-variant-numeric: tabular-nums;
}

.deck {
  position: absolute; inset: 0;
  display: flex; align-items: stretch;
  gap: 10px;
  scrollbar-width: none;
}
.deck::-webkit-scrollbar { display: none; }

/* Landscape: horizontal swipe with side peeks. */
@media (orientation: landscape) {
  .deck {
    flex-direction: row;
    overflow-x: auto; overflow-y: hidden;
    scroll-snap-type: x mandatory;
    padding: calc(max(14px, env(safe-area-inset-top)) + 56px) 8vw
             calc(max(14px, env(safe-area-inset-bottom)) + 30px);
    touch-action: pan-x;
  }
  .card { width: 84vw; }
}

/* Portrait: vertical swipe (up = next) with prev/next chips top and bottom. */
@media (orientation: portrait) {
  .deck {
    flex-direction: column;
    overflow-y: auto; overflow-x: hidden;
    scroll-snap-type: y mandatory;
    padding: calc(max(14px, env(safe-area-inset-top)) + 92px) 12px
             calc(max(14px, env(safe-area-inset-bottom)) + 78px);
    touch-action: pan-y;
  }
  .card {
    width: 100%;
    height: calc(100dvh - max(14px, env(safe-area-inset-top)) - 92px - max(14px, env(safe-area-inset-bottom)) - 78px);
  }
}

.chip {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(max(14px, env(safe-area-inset-top)) + 54px);
  z-index: 5;
  font-size: 14px; font-weight: 800; letter-spacing: 0.3px;
  padding: 8px 16px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-variant-numeric: tabular-nums;
}
.chip.chip-next {
  top: auto; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 30px);
}
@media (orientation: landscape) { .chip { display: none; } }

.card {
  flex: none;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 0;
  background: var(--cbg, #2C2C2E); color: var(--cfg, #fff);
  overflow: hidden;
  position: relative;
}
.card .badge {
  position: absolute; top: 18px; left: 0; right: 0;
  text-align: center; font-size: 15px; font-weight: 700; letter-spacing: 1.5px;
  opacity: 0.72; text-transform: uppercase; font-variant-numeric: tabular-nums;
}
.card .num {
  font-size: min(44vh, 48vw);
  font-weight: 800; line-height: 0.95;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.card .num.d3 { font-size: min(38vh, 29vw); }
.card .num.d4 { font-size: min(30vh, 22vw); }
.card .name {
  font-size: min(8.5vh, 13vw);
  font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
  margin-top: -0.1em;
}
.card .sub-name {
  font-size: min(2.6vh, 4.2vw);
  font-weight: 700; letter-spacing: 0.34em; text-transform: uppercase;
  opacity: 0.6; margin-top: 1.4vh;
}
.card.box { --cbg: #C29A61; --cfg: #2B1D0C; border-color: rgba(0, 0, 0, 0.2); }
.card.done { background: #248A3D; color: #fff; text-align: center; gap: 10px; }
.card.done svg { width: min(20vh, 30vw); height: min(20vh, 30vw); }
.card.done .name { font-size: min(6vh, 9vw); letter-spacing: 0.04em; text-transform: none; }
.card.done .sub { color: rgba(255, 255, 255, 0.8); font-size: 17px; }
.card.done .btn-secondary { width: auto; margin-top: 18px; background: rgba(255,255,255,0.2); color: #fff; padding: 13px 34px; }

.swipe-hint {
  position: absolute; bottom: max(14px, env(safe-area-inset-bottom)); left: 0; right: 0;
  text-align: center; font-size: 14px; color: rgba(255, 255, 255, 0.55);
  margin: 0; transition: opacity 0.5s;
  pointer-events: none;
}
.swipe-hint.gone { opacity: 0; }

/* ── Busy overlay ────────────────────────────────────────── */
.busy {
  position: fixed; inset: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
}
.busy p { font-size: 16px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.spinner {
  width: 34px; height: 34px; border-radius: 999px;
  border: 3.5px solid var(--fill-2); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sheet ───────────────────────────────────────────────── */
dialog#edit-sheet {
  border: 0; padding: 18px 20px calc(18px + env(safe-area-inset-bottom));
  width: 100%; max-width: 480px;
  margin: auto auto 0;
  background: var(--card); color: var(--text);
  border-radius: 22px 22px 0 0;
}
dialog#edit-sheet::backdrop { background: rgba(0, 0, 0, 0.45); }
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--fill-2); margin: 0 auto 14px; }
#sheet-title { margin-bottom: 14px; }
.seg { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; margin-bottom: 16px; }
.seg button { flex: 1; padding: 9px; border-radius: 8px; font-size: 15px; font-weight: 600; color: var(--text-2); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.swatch-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.swatch {
  border-radius: 12px; padding: 10px 4px; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border: 2.5px solid transparent; background: var(--fill);
  font-size: 12px; font-weight: 700;
}
.swatch .dot { width: 24px; height: 24px; border-radius: 7px; border: 1px solid rgba(120,120,128,0.35); }
.swatch.on { border-color: var(--accent); }
.num-label { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); margin-bottom: 18px; }
.num-label input {
  display: block; width: 100%; margin-top: 6px;
  font-size: 34px; font-weight: 800; text-align: center;
  padding: 10px; border: 0; border-radius: 12px;
  background: var(--fill); color: var(--text);
  font-variant-numeric: tabular-nums;
}
.num-label input:focus { outline: 2px solid var(--accent); }
.sheet-actions { display: flex; flex-direction: column; gap: 10px; }
.sheet-actions .btn-primary, .sheet-actions .btn-secondary { max-width: none; }

/* ── Toast ───────────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 8px);
  transform: translateX(-50%);
  z-index: 60;
  background: rgba(28, 28, 30, 0.92); color: #fff;
  font-size: 15px; font-weight: 600;
  padding: 12px 20px; border-radius: 999px;
  max-width: 86vw; text-align: center;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ── Review extras: stack plan row + overflow order ──────── */
.plan-row {
  display: flex; align-items: center; gap: 12px;
  width: 100%; text-align: left;
  background: var(--card); border-radius: 14px;
  padding: 12px 14px; margin-top: 12px;
  min-height: 56px;
}
.plan-row:active { background: var(--fill); }
.plan-icon { font-size: 22px; color: var(--accent); width: 32px; text-align: center; }
.plan-text { flex: 1; display: flex; flex-direction: column; gap: 1px; }
.plan-text strong { font-size: 17px; font-weight: 600; }
.plan-text small { font-size: 13px; color: var(--text-2); }
.plan-chevron { color: var(--text-2); font-size: 20px; }
.item-title .stops { display: block; font-size: 12px; font-weight: 400; color: var(--text-2); }
.swatch-box { background: #C29A61; color: #2B1D0C; }
.of-seg { margin-top: 12px; }
.of-seg button.on { background: var(--card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.18); }
.of-hint { font-size: 13px; color: var(--text-2); padding: 6px 10px 0; margin: 0; }

/* ── Rental stack plan overlay ───────────────────────────── */
.stack-overlay {
  position: fixed; inset: 0; z-index: 50;
  background: var(--bg);
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.stack-overlay h2 { font-size: 17px; }
.stack-help {
  font-size: 13px; line-height: 1.45; color: var(--text-2);
  margin: 0; padding: 4px 20px 12px;
}
.stack-scroll {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  padding: 8px 20px calc(20px + env(safe-area-inset-bottom));
  -webkit-overflow-scrolling: touch;
}
.stack-top { display: flex; gap: 8px; padding-left: 34px; min-height: 70px; margin-bottom: 8px; }
.stack-cols { display: flex; gap: 8px; align-items: flex-end; }
.stack-col { display: flex; flex-direction: column; gap: 8px; }
.stack-gap { width: 64px; height: 64px; }
.stack-cell {
  width: 64px; height: 64px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid rgba(120, 120, 128, 0.3);
  touch-action: none;
  user-select: none; -webkit-user-select: none;
}
.stack-cell b { font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stack-cell span { font-size: 8.5px; font-weight: 700; text-transform: uppercase; }
.stack-cell em { font-size: 8.5px; font-style: normal; opacity: 0.8; }
.stack-cell.stack-dragging { opacity: 0.35; }
.stack-cell.stack-over { outline: 3px solid var(--accent); outline-offset: 1px; }
.stack-ghost {
  position: fixed; z-index: 60; pointer-events: none;
  transform: translate(-50%, -50%) scale(1.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
.stack-legend {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text-2);
  padding-top: 12px; min-width: 100%;
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
