/* Same look as the Android app: neutral surfaces, one blue accent, green for done. Light only, like it. */
:root {
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --soft: #E9EDF2;
  --accent: #2563EB;
  --accent-soft: #DBEAFE;
  --done: #16A34A;
  --text: #0F172A;
  --muted: #64748B;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --skipped: #B45309;
  --skipped-soft: #FEF3C7;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input { font: inherit; color: var(--text); }

.top {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
}
.pill {
  background: var(--soft);
  border-radius: 999px;
  padding: 0 16px;
  height: 44px;
  display: flex;
  align-items: center;
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.progress { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; font-size: 20px; flex: none; }
.icon-btn:active { background: var(--soft); }

main {
  flex: 1;
  overflow-y: auto;
  padding: 0 12px 12px;
  -webkit-overflow-scrolling: touch;
}
.aisle-head { display: flex; align-items: center; gap: 6px; padding: 14px 4px 4px; font-size: 14px; }
.aisle-head b { font-size: 14px; }
.aisle-head .count { color: var(--muted); }
.basket-head { display: flex; align-items: center; padding: 14px 4px 0; color: var(--done); font-weight: 700; font-size: 14px; }
.basket-head button { margin-left: auto; color: var(--muted); padding: 8px; }

/* A row: tap to tick, long-press to edit, swipe left to remove. */
.row-wrap { position: relative; margin: 3px 0; border-radius: 12px; background: var(--danger-soft); overflow: hidden; }
.row-wrap .remove-label {
  position: absolute; inset: 0 20px 0 auto; display: flex; align-items: center;
  color: var(--danger); font-weight: 700; font-size: 14px;
}
.row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 12px 14px;
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  transition: transform 0.2s ease;
}
.row.dragging { transition: none; }
.tick {
  width: 26px; height: 26px; border-radius: 50%; flex: none;
  border: 2px solid #CBD5E1; display: flex; align-items: center; justify-content: center;
  color: white; font-size: 15px; font-weight: 700;
}
.tick.on { background: var(--done); border-color: var(--done); }
.row .name { font-weight: 600; }
.row .amount { color: var(--muted); font-size: 13px; }
.row.checked .name { color: var(--muted); text-decoration: line-through; }
.row .grow { flex: 1; min-width: 0; }

.empty { text-align: center; padding: 56px 24px 0; color: var(--muted); }
.empty .big { font-size: 44px; }
.empty h2 { color: var(--text); font-size: 18px; margin: 8px 0 4px; }

.add-bar {
  margin: 6px 12px calc(env(safe-area-inset-bottom) + 8px);
  background: var(--surface);
  border-radius: 24px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  padding: 4px 6px;
}
.add-row { display: flex; align-items: center; gap: 8px; }
.add-row input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  padding: 12px 10px; font-size: 16px; /* 16px stops iOS zooming in on focus */
}
.add-btn {
  width: 44px; height: 44px; border-radius: 50%; flex: none;
  background: var(--accent); color: white; font-size: 22px;
}
.add-btn:disabled { background: var(--soft); color: white; }
.add-panel { padding: 0 4px 6px; }
.chip {
  background: var(--soft); border-radius: 999px; padding: 8px 12px; font-size: 14px; font-weight: 500;
  color: var(--muted); white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; flex: none;
}
.chip.picked { background: var(--accent-soft); color: var(--accent); }
.hint { font-size: 12px; color: var(--muted); padding: 2px 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 4px; }
.chips .chip { color: var(--text); }

/* Bottom sheets for dialogs (aisle picker, item editor, sync). */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  background: var(--surface); width: 100%; max-width: 560px; max-height: 85dvh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(env(safe-area-inset-bottom) + 16px);
}
.sheet h3 { margin: 0 0 8px; font-size: 20px; }
.sheet p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.sheet label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.sheet input[type=text], .sheet input[type=email], .sheet input[type=password] {
  width: 100%; border: 1px solid #CBD5E1; border-radius: 10px; padding: 12px; font-size: 16px; outline-color: var(--accent);
}
.option {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 14px 4px; border-bottom: 1px solid var(--soft); font-size: 16px;
}
.option.selected { font-weight: 700; color: var(--accent); }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }
.btn { padding: 10px 18px; border-radius: 999px; font-weight: 600; }
.btn.primary { background: var(--accent); color: white; }
.btn.primary:disabled { opacity: 0.5; }
.btn.text { color: var(--accent); }
.btn.danger { color: var(--danger); }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; }
.status-line { font-weight: 700; margin-bottom: 4px; }

.snackbar {
  position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 84px);
  background: #1E293B; color: white; border-radius: 12px; padding: 12px 16px;
  display: flex; align-items: center; gap: 12px; z-index: 20; font-size: 14px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.3);
}
.snackbar[hidden] { display: none; }
.snackbar button { margin-left: auto; color: #93C5FD; font-weight: 700; flex: none; padding: 4px; }

/* --- Tabs and views --- */
.view { flex: 1; display: flex; flex-direction: column; min-height: 0; position: relative; }
.view[hidden] { display: none; }
#list-view main { padding-bottom: 12px; }
#list-view .add-bar { margin-bottom: calc(env(safe-area-inset-bottom) + 72px); }
.top .pill { gap: 8px; }
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(env(safe-area-inset-bottom) + 12px);
  display: flex; padding: 4px; background: var(--surface); border-radius: 999px; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.18); z-index: 5;
}
.tabs button { height: 44px; padding: 0 22px; border-radius: 999px; font-weight: 700; font-size: 15px; color: #475569; white-space: pre; }
.tabs button.on { background: var(--accent); color: white; }
.snackbar { bottom: calc(env(safe-area-inset-bottom) + 136px); }
body.on-map .snackbar { bottom: calc(env(safe-area-inset-bottom) + 72px); }
.aisle-head .off-map { color: var(--skipped); font-size: 12px; }

/* --- Map --- */
.map-area { flex: 1; min-height: 0; background: #E9EDF2; overflow: hidden; touch-action: none; }
.map-svg { width: 100%; height: 100%; display: block; }
.board { fill: white; stroke: #D5DCE4; stroke-width: 1.5; }
.shelf { fill: #CFD8E3; stroke: #9AA8B8; stroke-width: 1; }
.leg { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.leg.casing { stroke: white; stroke-width: 8; }
.leg.walked { stroke: #B4BFCC; stroke-width: 4; }
.leg.ahead { stroke: rgba(37, 99, 235, 0.55); stroke-width: 4; }
.leg.current { stroke: var(--accent); stroke-width: 5; }
.leg.flow { stroke: rgba(255, 255, 255, 0.9); stroke-width: 2; stroke-dasharray: 0.1 12; animation: flow 0.9s linear infinite; }
@keyframes flow { from { stroke-dashoffset: 12.1; } to { stroke-dashoffset: 0; } }
.pin { cursor: pointer; }
.pin .pin-shape { fill: white; stroke: #CBD5E1; stroke-width: 1.5; filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.25)); }
.pin.fixed .pin-shape { fill: #334155; stroke: none; }
.pin.pending .pin-shape { stroke: var(--accent); stroke-width: 2; }
.pin.next .pin-shape { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 3; }
.pin.done .pin-shape { stroke: var(--done); stroke-width: 2; }
.pin.idle { opacity: 0.4; }
.pin.done { opacity: 0.7; }
.pin-label { font-size: 20px; font-weight: 700; text-anchor: middle; dominant-baseline: central; fill: var(--text); pointer-events: none; }
.pin.fixed .pin-label { fill: white; }
.pin-name {
  font-size: 12px; font-weight: 700; text-anchor: middle; fill: var(--accent);
  paint-order: stroke; stroke: white; stroke-width: 4; stroke-linejoin: round; pointer-events: none;
}
.pulse { fill: rgba(37, 99, 235, 0.35); transform-box: fill-box; transform-origin: center; animation: pulse 1.4s ease-out infinite; pointer-events: none; }
@keyframes pulse { from { transform: scale(1); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
.badge { stroke: white; stroke-width: 1.5; }
.badge-blue { fill: var(--accent); }
.badge-green { fill: var(--done); }
.badge-amber { fill: var(--skipped); }
.badge-text { font-size: 12px; font-weight: 700; fill: white; text-anchor: middle; dominant-baseline: central; pointer-events: none; }

/* Next-stop card, just above the tab switcher. */
.stop-card {
  position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 72px);
  background: var(--surface); border-radius: 16px; box-shadow: 0 6px 20px rgba(15, 23, 42, 0.15); overflow: hidden;
}
.trip-bar { height: 3px; background: #D5DCE4; }
.trip-bar div { height: 100%; transition: width 0.3s; }
.stop-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 52px; }
.stop-row.tappable { cursor: pointer; }
.stop-row .grow { flex: 1; min-width: 0; }
.stop-row b { display: block; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stop-icon { width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none; color: var(--done); }
.stop-icon.done { background: rgba(22, 163, 74, 0.12); }
.stop-icon.soft { background: var(--soft); }
.position { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 3px 8px; }
.chev { color: #94A3B8; font-size: 16px; }
.btn.done { background: var(--done); color: white; }
.btn.muted { color: var(--muted); }
.stop-items { max-height: 280px; overflow-y: auto; border-top: 1px solid #D5DCE4; }
.stop-item { display: flex; align-items: center; gap: 14px; min-height: 52px; padding: 0 8px 0 16px; cursor: pointer; }
.stop-item .name { font-size: 17px; font-weight: 600; }
.stop-item.checked .name { color: var(--muted); text-decoration: line-through; }
.stop-item.skipped .name { color: var(--muted); }
.stop-item .grow { flex: 1; min-width: 0; }
.tick.big { width: 28px; height: 28px; }
.skipped-btn { color: var(--skipped); font-size: 12px; }
.stop-actions { display: flex; justify-content: space-between; padding: 8px 12px; }
