/* ============ Apple-style design tokens ============ */
:root {
  --accent: #007aff;
  --accent-soft: rgba(0, 122, 255, .12);
  --red: #ff3b30;
  --orange: #ff9500;
  --yellow: #ffcc00;
  --green: #34c759;
  --indigo: #5856d6;
  --purple: #af52de;
  --pink: #ff2d55;
  --gray: #8e8e93;
  --teal: #30b0c7;
  --brown: #a2845e;
  --label: #1d1d1f;
  --label2: rgba(60, 60, 67, .62);
  --label3: rgba(60, 60, 67, .32);
  --sep: rgba(60, 60, 67, .14);
  --fill: rgba(120, 120, 128, .12);
  --fill2: rgba(120, 120, 128, .08);
  --group: rgba(255, 255, 255, .78);
  --glass: rgba(246, 246, 248, .72);
  --glass-strong: rgba(250, 250, 252, .9);
  --glass-border: rgba(255, 255, 255, .6);
  --shadow: 0 10px 40px rgba(0, 0, 0, .12), 0 1px 3px rgba(0, 0, 0, .06);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .1);
  --bubble-them: #e9e9eb;
  --radius: 14px;
  --sbw: 400px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, "Segoe UI", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, .2);
    --red: #ff453a; --orange: #ff9f0a; --green: #30d158; --indigo: #5e5ce6; --purple: #bf5af2; --pink: #ff375f; --gray: #98989d; --teal: #40c8e0; --brown: #ac8e68;
    --label: #f5f5f7;
    --label2: rgba(235, 235, 245, .6);
    --label3: rgba(235, 235, 245, .3);
    --sep: rgba(84, 84, 88, .5);
    --fill: rgba(120, 120, 128, .28);
    --fill2: rgba(120, 120, 128, .18);
    --group: rgba(44, 44, 46, .72);
    --glass: rgba(30, 30, 32, .72);
    --glass-strong: rgba(36, 36, 38, .92);
    --glass-border: rgba(255, 255, 255, .08);
    --shadow: 0 10px 40px rgba(0, 0, 0, .5), 0 1px 3px rgba(0, 0, 0, .3);
    --bubble-them: #3a3a3c;
    color-scheme: dark;
  }
  body[data-map-style="amap"] .leaflet-tile-pane { filter: brightness(.75) contrast(1.05); }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #e9e9ec; }
body { font-family: var(--font); color: var(--label); font-size: 15px; letter-spacing: -0.01em; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--label2); font-size: 13px; }
.err { color: var(--red); font-size: 14px; min-height: 1em; margin: 0; }
.ic { flex: none; display: block; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(180%) blur(28px);
  backdrop-filter: saturate(180%) blur(28px);
  border: 0.5px solid var(--glass-border);
  box-shadow: var(--shadow);
}

/* ============ Buttons ============ */
button { cursor: pointer; border: none; background: none; padding: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px; border-radius: 999px; background: var(--fill); color: var(--accent);
  font-weight: 600; font-size: 14.5px; white-space: nowrap; transition: transform .12s, background .15s, opacity .15s;
}
.btn:hover { background: rgba(120, 120, 128, .18); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13.5px; }
.btn.danger { color: var(--red); }
.btn.plain { background: none; padding: 0 8px; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center; color: var(--accent);
  background: var(--fill); transition: background .15s, transform .12s;
}
.icon-btn:hover { background: rgba(120, 120, 128, .2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--accent); color: #fff; }
.icon-btn.ghost { background: none; color: var(--label2); width: 30px; height: 30px; }
.icon-btn.ghost:hover { background: var(--fill); color: var(--accent); }

/* ============ Inputs ============ */
input, select, textarea {
  width: 100%; border: none; outline: none; border-radius: 10px; padding: 9px 12px; background: var(--fill2);
  transition: box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus { box-shadow: 0 0 0 3.5px var(--accent-soft), inset 0 0 0 1px var(--accent); background: transparent; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e93' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
textarea { resize: vertical; }

/* ============ Segmented control ============ */
.segmented { display: flex; background: var(--fill); border-radius: 10px; padding: 2px; gap: 2px; }
.segmented button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 5px; height: 30px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--label); transition: background .2s, box-shadow .2s;
}
.segmented button.active, .segmented button.on { background: var(--glass-strong); box-shadow: 0 2px 6px rgba(0, 0, 0, .12), 0 0 0 .5px rgba(0, 0, 0, .04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .segmented button.active, .segmented button.on { background: #636366; } }
.segmented.mini button { height: 26px; padding: 0 9px; font-size: 12.5px; }

/* ============ Map ============ */
#mapWrap { position: fixed; inset: 0; }
#map { position: absolute; inset: 0; background: #e9e9ec; }
.leaflet-container { font-family: var(--font); }
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow-sm) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-control-zoom a { width: 36px !important; height: 36px !important; line-height: 36px !important; background: var(--glass-strong) !important; color: var(--label) !important; border-color: var(--sep) !important; backdrop-filter: blur(20px); font-weight: 400; }
.leaflet-control-scale-line { background: var(--glass) !important; border-color: var(--label2) !important; color: var(--label); font-size: 10.5px; backdrop-filter: blur(10px); }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--label2) !important; font-size: 10px; border-radius: 8px 0 0 0; backdrop-filter: blur(10px); }
.leaflet-control-attribution a { color: var(--label2) !important; }
.leaflet-bottom.leaflet-right { margin-bottom: 4px; }

/* Apple-Maps style pins */
.apin { position: relative; width: 32px; height: 40px; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, .3)); transition: transform .15s; }
.apin:hover { transform: scale(1.1) translateY(-2px); }
.apin .head { width: 32px; height: 32px; border-radius: 50%; background: var(--c, var(--red)); border: 2.5px solid #fff; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13.5px; }
.apin::after { content: ''; position: absolute; left: 50%; top: 29px; width: 3px; height: 10px; margin-left: -1.5px; background: #fff; border-radius: 0 0 2px 2px; box-shadow: 0 0 0 .5px rgba(0, 0, 0, .15); }
.poi { width: 24px; height: 24px; border-radius: 50%; background: var(--orange); border: 2px solid #fff; display: grid; place-items: center; color: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .28); transition: transform .15s; }
.poi:hover { transform: scale(1.18); }
.poi svg { fill: #fff; stroke: none; }

/* Leaflet popups → Apple callouts */
.leaflet-popup-content-wrapper { background: var(--glass-strong); backdrop-filter: saturate(180%) blur(28px); -webkit-backdrop-filter: saturate(180%) blur(28px); color: var(--label); border-radius: 16px; box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--glass-strong); box-shadow: none; }
.leaflet-popup-content { margin: 14px 16px; font-size: 14px; line-height: 1.45; min-width: 220px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--label2); top: 6px; right: 6px; font-size: 20px; }
.pop-title { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.pop-sub { color: var(--label2); font-size: 13px; }
.popup-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }

/* ============ Sidebar ============ */
#sidebar {
  position: fixed; z-index: 1000; left: 12px; top: 12px; bottom: 12px; width: var(--sbw);
  border-radius: 22px; display: flex; flex-direction: column; overflow: hidden;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1), opacity .25s;
}
body.sb-collapsed #sidebar { transform: translateX(calc(-100% - 24px)); opacity: 0; pointer-events: none; }
#expandBtn.floating { position: fixed; z-index: 1000; left: 12px; top: 12px; width: 42px; height: 42px; border-radius: 13px; }
.sheet-grabber { display: none; }
.sb-head { display: flex; flex-wrap: wrap; align-items: center; column-gap: 10px; padding: 18px 16px 12px 20px; }
.sb-head .subtitle { flex-basis: 100%; margin-top: 1px; }
.sb-title { flex: 1; min-width: 0; }
.trip-picker { position: relative; display: inline-flex; align-items: center; gap: 6px; max-width: 100%; cursor: pointer; }
#tripName { font-size: 24px; font-weight: 700; letter-spacing: -0.03em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trip-picker .ic { color: var(--label2); margin-top: 3px; }
.trip-picker select { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.subtitle { color: var(--label2); font-size: 13px; margin-top: 2px; }
.head-acts { display: flex; gap: 6px; padding-top: 2px; }
.head-acts .icon-btn { width: 32px; height: 32px; }
.tabs { margin: 0 16px 10px; }
.sb-body { position: relative; flex: 1; min-height: 0; }
.tab-body { position: absolute; inset: 0; overflow-y: auto; padding: 4px 16px 20px; scrollbar-width: thin; }
#tab-ai { display: flex; flex-direction: column; padding: 0; }
#tab-ai.hidden { display: none; }
#splitter { position: absolute; top: 0; right: 0; bottom: 0; width: 8px; cursor: ew-resize; }
#splitter:hover::after, body.resizing #splitter::after { content: ''; position: absolute; right: 2px; top: 50%; height: 44px; margin-top: -22px; width: 4px; border-radius: 2px; background: var(--label3); }
body.resizing { user-select: none; cursor: ew-resize; }

/* Grouped lists (iOS Settings style) */
.section-h { display: flex; align-items: baseline; gap: 8px; margin: 18px 4px 6px; }
.section-h .t { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--label2); }
.section-h .s { flex: 1; font-size: 13px; color: var(--label2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.section-h .icon-btn { width: 24px; height: 24px; }
.group { background: var(--group); border-radius: var(--radius); overflow: hidden; box-shadow: 0 0 0 .5px var(--sep); }
.row-i { display: flex; align-items: center; gap: 12px; padding: 10px 12px; position: relative; min-height: 50px; }
.row-i + .row-i::before { content: ''; position: absolute; top: 0; right: 0; left: 54px; border-top: .5px solid var(--sep); }
.row-i .main { flex: 1; min-width: 0; }
.row-i .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-i .meta { color: var(--label2); font-size: 13px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row-i .trail { color: var(--label2); font-size: 13.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-i .acts { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.row-i:hover .acts { opacity: 1; }
@media (hover: none) { .row-i .acts { opacity: 1; } }
.row-i.clickable { cursor: pointer; }
.row-i.clickable:hover { background: var(--fill2); }
.badge { width: 30px; height: 30px; border-radius: 8px; background: var(--c, var(--gray)); color: #fff; display: grid; place-items: center; flex: none; font-weight: 700; font-size: 13px; }
.badge.round { border-radius: 50%; }
.empty-row { padding: 12px 14px; color: var(--label3); font-size: 14px; }
.group.empty { background: transparent; box-shadow: none; border: 1.5px dashed var(--sep); }
.group.empty .empty-row { padding: 9px 14px; font-size: 13px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--label2); }
.empty-state .big { width: 64px; height: 64px; border-radius: 18px; background: var(--fill); color: var(--label2); display: grid; place-items: center; margin: 0 auto 14px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 4px; }

/* Timeline */
.item[draggable="true"] { cursor: grab; }
.item.dragging { opacity: .35; }
.day.drop-on .group { box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); }
.hint-row { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 12.5px; color: var(--label2); background: var(--fill2); }
.hint-row .ic { color: var(--orange); }

/* Routes card */
.route-total { display: flex; gap: 14px; padding: 12px; border-top: .5px solid var(--sep); font-size: 13.5px; }
.route-total b { font-size: 15px; display: block; color: var(--label); }
.route-total div { color: var(--label2); }

/* Tips */
.tip { align-items: flex-start; }
.tip .main { font-size: 14px; line-height: 1.4; padding-top: 4px; }

/* ============ Chat (iMessage) ============ */
#chatHead { display: flex; align-items: center; gap: 10px; padding: 4px 16px 10px; font-size: 14px; border-bottom: .5px solid var(--sep); }
#chatHead .ctx { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
#chatHead .ctx span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatHead .ctx .badge { width: 26px; height: 26px; border-radius: 7px; }
#chatLog { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.msg { max-width: 85%; padding: 8px 13px; border-radius: 19px; line-height: 1.42; font-size: 14.5px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--bubble-them); border-bottom-left-radius: 6px; }
.msg + .msg.user, .msg + .msg.assistant { margin-top: 4px; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin: 0; }
.msg ul { margin: 4px 0 6px; padding-left: 18px; } .msg h4 { margin: 8px 0 3px; font-size: 14.5px; }
.msg a { color: inherit; text-decoration: underline; }
.typing-dots { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--label3); animation: blink 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: .2s; } .typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .35; transform: none; } 30% { opacity: 1; transform: translateY(-2px); } }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 4px 16px 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; font-size: 13px; padding: 7px 12px; border-radius: 999px; background: var(--fill); color: var(--label); white-space: nowrap; }
.chips button:hover { background: var(--accent-soft); color: var(--accent); }
#chatForm { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px 14px; border-top: .5px solid var(--sep); }
#chatInput { border-radius: 19px; padding: 9px 14px; resize: none; max-height: 140px; background: var(--fill2); box-shadow: inset 0 0 0 .5px var(--sep); }
.send-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.send-btn:active { transform: scale(.94); }

/* ============ Top right controls ============ */
#topRight { position: fixed; z-index: 900; top: 12px; right: 12px; display: flex; align-items: center; gap: 8px; padding: 6px; border-radius: 16px; }
#topRight .icon-btn { width: 32px; height: 32px; }
#topRight .lang { min-width: 84px; }

/* ============ Map desk toolbox ============ */
#toolbox { position: fixed; z-index: 900; top: 66px; right: 12px; display: flex; flex-direction: row-reverse; gap: 8px; align-items: flex-start; }
#toolbox .tools { display: flex; flex-direction: column; padding: 5px; gap: 2px; border-radius: 16px; }
#toolbox .tools button { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--label); touch-action: none; transition: background .15s, color .15s; }
#toolbox .tools button:hover { background: var(--fill); }
#toolbox .tools button.on { background: var(--accent); color: #fff; }
#toolbox .tools button:disabled { opacity: .3; cursor: default; }
#toolbox .tools .sep { height: .5px; background: var(--sep); margin: 3px 6px; }
#toolbox .draggable-tool { cursor: grab; }
.tool-opts { padding: 6px; display: flex; flex-direction: column; gap: 3px; border-radius: 16px; align-items: center; }
.tool-opts .mode { width: 38px; height: 36px; border-radius: 10px; display: grid; place-items: center; color: var(--label); }
.tool-opts .mode:hover { background: var(--fill); }
.tool-opts .mode.on { background: var(--mc, var(--accent)); color: #fff; }
.swatch, .note-swatch { width: 26px; height: 26px; border-radius: 50%; cursor: pointer; margin: 3px; box-shadow: inset 0 0 0 .5px rgba(0, 0, 0, .15); transition: transform .12s; }
.swatch:hover, .note-swatch:hover { transform: scale(1.1); }
.swatch.on, .note-swatch.on { box-shadow: 0 0 0 2px var(--glass-strong), 0 0 0 4px var(--label2); }
.note-swatch.n-yellow { background: #fff2a8; } .note-swatch.n-pink { background: #ffd6e2; } .note-swatch.n-blue { background: #d3e8ff; } .note-swatch.n-green { background: #d6f5cf; }
.sticker-grid { display: grid; grid-template-columns: repeat(3, 38px); gap: 2px; }
.sticker-pick { font-size: 22px; text-align: center; cursor: grab; border-radius: 10px; padding: 4px 0; touch-action: none; user-select: none; }
.sticker-pick:hover, .sticker-pick.on { background: var(--fill); }
.drag-ghost { position: fixed; z-index: 5000; pointer-events: none; font-size: 30px; color: var(--accent); transform: translate(-50%, -80%) rotate(-6deg); filter: drop-shadow(0 8px 10px rgba(0, 0, 0, .3)); }
.drag-ghost svg { width: 34px; height: 34px; }
#map[data-tool="pin"], #map[data-tool="note"], #map[data-tool="sticker"], #map[data-tool="line"], #map[data-tool="pen"] { cursor: crosshair; }
#map[data-tool="pen"] { touch-action: none; }
#map[data-tool="erase"] { cursor: cell; }
/* While drawing, pins and ★ let clicks through to the map (route points snap to them instead) */
#map:not([data-tool="move"]):not([data-tool="erase"]) .m-poi, #map:not([data-tool="move"]):not([data-tool="erase"]) .m-pin { pointer-events: none; }
#map[data-tool="erase"] .m-pin, #map[data-tool="erase"] .m-poi { cursor: cell; }

.map-hint {
  position: fixed; z-index: 800; bottom: 24px; left: calc(50% + (var(--sbw) + 12px) / 2); transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 500; color: var(--label); pointer-events: none; white-space: nowrap;
  transition: left .35s cubic-bezier(.2, .9, .3, 1);
}
body.sb-collapsed .map-hint { left: 50%; }

/* Sticky notes (Freeform style) */
.sticky { position: relative; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18), 0 1px 2px rgba(0, 0, 0, .1); display: flex; flex-direction: column; color: #1d1d1f; }
.sticky.n-yellow { background: #fff2a8; } .sticky.n-pink { background: #ffd6e2; } .sticky.n-blue { background: #d3e8ff; } .sticky.n-green { background: #d6f5cf; }
.sgrip { height: 24px; display: flex; align-items: center; gap: 4px; padding: 0 5px 0 8px; cursor: grab; touch-action: none; opacity: .55; transition: opacity .15s; }
.sticky:hover .sgrip { opacity: 1; }
.sgrip:active { cursor: grabbing; }
.sdots { flex: 1; height: 4px; max-width: 30px; background: radial-gradient(circle, rgba(0,0,0,.3) 1.2px, transparent 1.5px) 0 0 / 6px 4px repeat-x; }
.sgrip .grow { flex: 1; }
.scolor { width: 13px; height: 13px; border-radius: 50%; background: conic-gradient(#ffcc00 0 25%, #ff2d55 0 50%, #007aff 0 75%, #34c759 0); cursor: pointer; }
.sbtn { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: rgba(0, 0, 0, .55); }
.sbtn:hover { background: rgba(0, 0, 0, .08); color: #000; }
.sticky textarea { flex: 1; border: none; background: transparent; resize: none; font: 500 14.5px/1.38 var(--font); padding: 2px 10px 8px; outline: none; box-shadow: none; color: #1d1d1f; border-radius: 0; }
.sticky textarea:focus { box-shadow: none; }
.sticky textarea::placeholder { color: rgba(0, 0, 0, .35); }
.sresize { position: absolute; right: 0; bottom: 0; width: 18px; height: 18px; cursor: nwse-resize; touch-action: none; }
.sresize::after { content: ''; position: absolute; right: 5px; bottom: 5px; width: 7px; height: 7px; border-right: 2px solid rgba(0, 0, 0, .25); border-bottom: 2px solid rgba(0, 0, 0, .25); border-radius: 0 0 3px 0; }
.sticker { font-size: 32px; line-height: 40px; text-align: center; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, .3)); cursor: grab; transition: transform .15s; }
.sticker:hover { transform: scale(1.15) rotate(-6deg); }

/* Route lines */
.rlabel {
  display: inline-flex; align-items: center; gap: 5px; transform: translate(-50%, -50%); cursor: pointer; white-space: nowrap;
  background: var(--glass-strong); backdrop-filter: blur(16px); border-radius: 999px; padding: 4px 10px 4px 5px;
  font-size: 12px; font-weight: 600; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); color: var(--label);
}
.mi { width: 20px; height: 20px; border-radius: 50%; background: var(--mc, var(--accent)); color: #fff; display: inline-grid; place-items: center; flex: none; }
.vhandle { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); cursor: grab; }
.vhandle.mid { width: 12px; height: 12px; border: 2px solid var(--gray); opacity: .85; }
.leaflet-tooltip.draft-tip { font-weight: 600; font-family: var(--font); border-radius: 10px; border: none; box-shadow: var(--shadow-sm); background: var(--glass-strong); color: var(--label); display: flex; align-items: center; gap: 6px; }
.leaflet-tooltip.draft-tip::before { display: none; }
.calc-head { display: flex; align-items: center; gap: 8px; }
.calc-main { display: flex; align-items: baseline; gap: 10px; margin: 8px 0 2px; flex-wrap: wrap; }
.calc-main .big { font-size: 22px; font-weight: 700; letter-spacing: -0.03em; }
.calc-main .unit { color: var(--label2); font-size: 13px; }
table.calc { width: 100%; border-collapse: collapse; margin: 8px 0 6px; font-size: 13px; }
table.calc td { padding: 6px 6px; border-top: .5px solid var(--sep); white-space: nowrap; }
table.calc td:first-child { display: flex; align-items: center; gap: 8px; }
table.calc td:not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
table.calc tr { cursor: pointer; }
table.calc tr:hover td { background: var(--fill2); }
table.calc tr.cur td { color: var(--accent); font-weight: 600; }
.tagx { font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 6px; margin-left: 4px; vertical-align: 1px; }
.tagx.fast { background: rgba(255, 149, 0, .16); color: var(--orange); }
.tagx.cheap { background: rgba(52, 199, 89, .16); color: var(--green); }

/* ============ Modal sheet ============ */
dialog { border: none; border-radius: 22px; padding: 0; width: min(480px, 94vw); background: var(--glass-strong); color: var(--label); box-shadow: 0 24px 80px rgba(0, 0, 0, .3); backdrop-filter: blur(30px); }
dialog[open] { animation: sheetIn .28s cubic-bezier(.2, .9, .3, 1.1); }
@keyframes sheetIn { from { opacity: 0; transform: translateY(16px) scale(.97); } }
dialog::backdrop { background: rgba(0, 0, 0, .28); backdrop-filter: blur(2px); }
#modalForm { padding: 22px; display: flex; flex-direction: column; gap: 12px; }
#modalForm h3 { margin: 0 0 4px; font-size: 20px; letter-spacing: -0.02em; }
#modalForm label { font-size: 12.5px; font-weight: 500; color: var(--label2); display: flex; flex-direction: column; gap: 5px; }
#modalForm label input, #modalForm label select, #modalForm label textarea { color: var(--label); font-size: 15px; font-weight: 400; }
.frow { display: flex; gap: 10px; } .frow > * { flex: 1; min-width: 0; }
.modal-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.plan-preview { max-height: 42vh; overflow-y: auto; }
.plan-preview .row-i { min-height: 44px; }

/* ============ Login + toast ============ */
#login { position: fixed; inset: 0; z-index: 4000; display: grid; place-items: center; background: rgba(0, 0, 0, .2); backdrop-filter: blur(20px); }
#loginForm { width: min(340px, 90vw); display: flex; flex-direction: column; gap: 12px; text-align: center; padding: 30px 26px; border-radius: 24px; }
#loginForm h2 { margin: 4px 0 8px; font-size: 22px; letter-spacing: -0.02em; }
.app-icon { width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(160deg, #ff6259, #ff3b30); color: #fff; display: grid; place-items: center; margin: 0 auto; box-shadow: 0 8px 20px rgba(255, 59, 48, .35); }
#toast {
  position: fixed; z-index: 5000; top: 18px; left: 50%; transform: translate(-50%, -20px); opacity: 0; pointer-events: none;
  background: var(--glass-strong); backdrop-filter: blur(24px); color: var(--label); box-shadow: var(--shadow);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; transition: opacity .25s, transform .3s cubic-bezier(.2, .9, .3, 1.2);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ Phone: bottom sheet ============ */
@media (max-width: 820px) {
  .desktop-only { display: none !important; }
  #sidebar {
    left: 0; right: 0; bottom: 0; top: auto; width: auto !important; height: var(--sheet-h, 48vh);
    border-radius: 22px 22px 0 0; transition: height .3s cubic-bezier(.2, .9, .3, 1); padding-bottom: env(safe-area-inset-bottom);
  }
  #sidebar.dragging { transition: none; }
  .sheet-grabber { display: block; padding: 8px 0 2px; cursor: grab; touch-action: none; }
  .sheet-grabber span { display: block; width: 38px; height: 5px; border-radius: 3px; background: var(--label3); margin: 0 auto; }
  .sb-head { padding: 6px 14px 10px 18px; }
  #tripName { font-size: 21px; }
  .tabs { margin: 0 12px 8px; }
  .segmented button span { font-size: 12.5px; }
  .tab-body { padding: 2px 12px 20px; }
  #splitter, .map-hint { display: none; }
  #topRight { top: max(10px, env(safe-area-inset-top)); right: 10px; left: 10px; justify-content: flex-end; }
  .date-pill { margin-right: auto; }
  #layersPop { right: 10px; left: 10px; width: auto; top: calc(max(10px, env(safe-area-inset-top)) + 54px); }
  #dayChip { top: calc(max(10px, env(safe-area-inset-top)) + 56px); left: 10px; transform: none; }
  #drawBar { bottom: calc(var(--sheet-h, 48vh) + 12px); left: 10px; right: 10px; transform: none; flex-wrap: wrap; justify-content: center; }
  #toolbox { top: calc(max(10px, env(safe-area-inset-top)) + 54px); right: 10px; }
  #toolbox .tools button { width: 36px; height: 36px; }
  .leaflet-bottom { bottom: var(--sheet-h, 48vh); }
  .leaflet-control-scale { display: none; }
  .row-i .acts { opacity: 1; }
}

/* ============ Search ============ */
.search { position: relative; margin: 0 16px 10px; }
.search > .ic { position: absolute; left: 11px; top: 50%; margin-top: -8px; color: var(--label2); pointer-events: none; }
.search input { padding-left: 34px; background: var(--fill); height: 36px; }
#searchResults { position: absolute; z-index: 20; left: 0; right: 0; top: 42px; border-radius: 14px; max-height: 60vh; overflow-y: auto; padding: 4px 0; background: var(--glass-strong); }
.sgroup { padding: 8px 14px 4px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--label2); }
.sres { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; }
.sres .badge { width: 26px; height: 26px; }
.sres .main { min-width: 0; flex: 1; }
.sres .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sres .meta { color: var(--label2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sres:hover, .sres.active { background: var(--accent-soft); }

/* ============ Date pill (temperature date) ============ */
.date-pill { display: flex; align-items: center; background: var(--fill); border-radius: 12px; height: 34px; }
.date-pill .icon-btn.ghost { width: 28px; height: 30px; border-radius: 9px; }
.date-mid { position: relative; display: flex; align-items: center; gap: 6px; padding: 0 4px; cursor: pointer; color: var(--pink); }
.date-mid span { display: flex; flex-direction: column; line-height: 1.05; color: var(--label); }
.date-mid b { font-size: 13px; white-space: nowrap; }
.date-mid small { font-size: 10.5px; color: var(--label2); font-weight: 500; }
.date-mid small:empty { display: none; }
.date-mid input { position: absolute; inset: 0; opacity: 0; cursor: pointer; padding: 0; }
.date-mid input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

/* ============ Layers popover ============ */
#layersPop { position: fixed; z-index: 950; top: 62px; right: 12px; width: 300px; border-radius: 18px; padding: 12px; max-height: calc(100vh - 80px); overflow-y: auto; }
.lp-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; color: var(--label2); margin: 6px 4px 6px; }
.lp-title:not(:first-child) { margin-top: 14px; }
.lp-note { margin: 6px 4px 0; font-size: 12px; }
.lrow { display: flex; align-items: center; gap: 10px; padding: 8px 10px; position: relative; cursor: pointer; }
.lrow + .lrow::before, .lsub + .lrow::before { content: ''; position: absolute; top: 0; left: 46px; right: 0; border-top: .5px solid var(--sep); }
.lrow .badge { width: 26px; height: 26px; border-radius: 7px; }
.lrow .grow { flex: 1; font-size: 14px; }
.lrow.small { padding: 6px 0 2px; }
.lrow.small .grow { font-size: 13px; color: var(--label2); }
.lsub { padding: 0 10px 8px 46px; }
.chipset { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12.5px; font-weight: 500; padding: 5px 11px; border-radius: 999px; background: var(--fill); color: var(--label2); }
.chip.on { background: var(--orange); color: #fff; }
input.switch { appearance: none; width: 44px; height: 27px; border-radius: 999px; background: var(--fill); position: relative; cursor: pointer; transition: background .2s; padding: 0; flex: none; box-shadow: none !important; }
input.switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 23px; height: 23px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.2,.9,.3,1.2); }
input.switch:checked { background: var(--green); }
input.switch:checked::after { transform: translateX(17px); }

/* ============ Weather on the map ============ */
.wxb { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; background: var(--glass-strong); backdrop-filter: blur(12px); color: var(--label);
  font-size: 11.5px; font-weight: 700; padding: 2px 7px 2px 4px; border-radius: 999px; box-shadow: 0 2px 6px rgba(0,0,0,.2); font-variant-numeric: tabular-nums; }
.wxb i { font-style: normal; font-weight: 600; color: var(--label2); font-size: 10.5px; }
.wx-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: .5px solid var(--sep); font-size: 13.5px; }
.wx-day { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--label); font-variant-numeric: tabular-nums; white-space: nowrap; }
.wx-day .lo { color: var(--label2); font-weight: 500; margin-left: 2px; }

/* ============ Day focus ============ */
.section-h.clickable { cursor: pointer; border-radius: 8px; padding: 2px 4px; transition: background .15s; }
.section-h.clickable:hover { background: var(--fill2); }
.day.focused .section-h .t { color: var(--accent); }
.day.focused .group { box-shadow: 0 0 0 2px var(--accent); }
.apin.dim { opacity: .35; filter: grayscale(.6) drop-shadow(0 2px 3px rgba(0,0,0,.2)); transform: scale(.82); }
#dayChip { position: fixed; z-index: 850; top: 64px; left: calc(50% + (var(--sbw) + 12px) / 2); transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  padding: 5px 5px 5px 12px; border-radius: 999px; font-size: 14px; color: var(--accent); }
#dayChip b { color: var(--label); } #dayChip span { color: var(--label2); }
body.sb-collapsed #dayChip { left: 50%; }

/* ============ Route drawing bar ============ */
#drawBar { position: fixed; z-index: 960; bottom: 22px; left: calc(50% + (var(--sbw) + 12px) / 2); transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 14px; border-radius: 999px; font-size: 13.5px; white-space: nowrap; }
#drawBar .stats { display: flex; align-items: center; gap: 8px; font-weight: 600; }
#drawBar .stats .muted { font-weight: 500; }
body.sb-collapsed #drawBar { left: 50%; }
body.drawing .map-hint { display: none; }

/* ============ Offline ============ */
#offlineBar { position: fixed; z-index: 3000; bottom: 18px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  background: #1d1d1f; color: #fff; padding: 8px 16px; border-radius: 999px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }

/* ============ Food tab ============ */
.segmented.tabs button { gap: 4px; }
.meal-day { padding: 10px 12px; position: relative; }
.meal-day + .meal-day::before { content: ''; position: absolute; top: 0; left: 12px; right: 0; border-top: .5px solid var(--sep); }
.meal-day .md-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 7px; }
.meal-day .md-head b { font-size: 14px; }
.meal-day .md-head span { color: var(--label2); font-size: 13px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.slot { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 7px 9px; border-radius: 10px; background: var(--fill2); font-size: 13px; cursor: pointer; text-align: left; color: var(--label); }
.slot .ic { flex: none; color: var(--sc); }
.slot span { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot.empty { background: none; box-shadow: inset 0 0 0 1px var(--sep); color: var(--label2); border-style: dashed; }
.slot.empty .ic { color: var(--label3); }
.slot:hover { background: var(--accent-soft); }
.dish .zh { color: var(--label2); font-weight: 400; margin-left: 4px; }
.dish .acts { opacity: 1; }
.toggle-ic { color: var(--label3); }
.toggle-ic.on.want { color: var(--pink); }
.toggle-ic.on.tried { color: var(--green); }
.toggle-ic.on.want svg { fill: currentColor; }
details.more summary { cursor: pointer; list-style: none; }
details.more summary::-webkit-details-marker { display: none; }

/* ============ Tab bar: icon above label (6 tabs) ============ */
.segmented.tabs button { flex-direction: column; height: 44px; gap: 2px; font-size: 11px; padding: 0 2px; }
.segmented.tabs button .ic { width: 17px; height: 17px; }

/* ============ Folds ============ */
details.fold > summary { cursor: pointer; list-style: none; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary .ic, details.more > summary .ic { transition: transform .2s; color: var(--label2); }
details.fold:not([open]) > summary .ic, details.more:not([open]) > summary .ic { transform: rotate(-90deg); }

/* ============ Budget ============ */
.conv { display: flex; align-items: center; gap: 8px; padding: 10px 12px; }
.conv label { flex: 1; display: flex; align-items: center; gap: 6px; background: var(--fill2); border-radius: 10px; padding-left: 10px; }
.conv label span { font-weight: 700; color: var(--label2); }
.conv input { background: none; font-size: 17px; font-weight: 600; padding-left: 2px; }
.conv input:focus { box-shadow: none; }
.conv-eq { color: var(--label3); font-size: 18px; }
.budget-card { padding: 14px 12px; }
.bnums { display: flex; gap: 8px; }
.bnums > div { flex: 1; display: flex; flex-direction: column; min-width: 0; border-radius: 10px; padding: 2px 4px; }
.bnums b { font-size: 19px; letter-spacing: -0.02em; white-space: nowrap; }
.bnums span { font-size: 12px; color: var(--label2); }
.bnums .clickable { cursor: pointer; }
.bnums .clickable:hover { background: var(--fill2); }
.bnums .clickable span { color: var(--accent); }
.progress { height: 8px; border-radius: 4px; background: var(--fill); overflow: hidden; margin-top: 10px; }
.progress span { display: block; height: 100%; border-radius: 4px; transition: width .4s; }
.catbar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; margin-top: 14px; }
.catlegend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 8px; font-size: 12px; color: var(--label2); }
.catlegend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.chip-check { display: inline-flex; cursor: pointer; }
.chip-check input { display: none; }
.chip-check span { font-size: 13px; font-weight: 500; padding: 6px 12px; border-radius: 999px; background: var(--fill); color: var(--label2); }
.chip-check input:checked + span { background: var(--accent); color: #fff; }

/* ============ Packing ============ */
.pk-progress { display: flex; align-items: center; gap: 10px; margin: 12px 4px 0; }
.pk-progress .progress { flex: 1; margin: 0; }
.check-row { min-height: 44px; }
.check-row + .check-row::before, .check-row + .add-row::before { left: 46px; }
.checkbox { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--label3); display: grid; place-items: center; color: #fff; flex: none; transition: background .15s, box-shadow .15s; }
.checkbox.on { background: var(--green); box-shadow: none; }
.checkbox.ghost { box-shadow: none; color: var(--accent); }
.check-row.done .title { color: var(--label3); text-decoration: line-through; }
.check-row .meta.late { color: var(--red); font-weight: 600; }
.who { width: 24px; height: 24px; border-radius: 50%; font-size: 11px; font-weight: 700; background: var(--fill); color: var(--label3); flex: none; }
.who.on { background: var(--indigo); color: #fff; }
.add-row { min-height: 42px; }
.add-row::before { left: 46px !important; }
.add-input { background: none; padding: 6px 0; }
.add-input:focus { box-shadow: none; background: none; }
.tipchips { margin: 0 2px 4px; }
.tipchips .chip { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); }
.tipchips .chip small { color: var(--label2); font-weight: 400; }

/* ============ Undo toast ============ */
#toast { display: flex; align-items: center; gap: 12px; }
#toast.has-act { pointer-events: auto; padding-right: 8px; }
.toast-act { color: var(--accent); font-weight: 700; padding: 4px 10px; border-radius: 999px; background: var(--accent-soft); }
.icon-btn.danger, .icon-btn.ghost.danger:hover { color: var(--red); }
.modal-acts .grow { flex: 1; }
.modal-acts { flex-wrap: wrap; }
.opt { color: var(--label3); font-weight: 400; }
.msg.error { background: rgba(255, 59, 48, .12); color: var(--red); }
.info-card { margin-top: 6px; }
.hidden-list { display: flex; flex-wrap: wrap; gap: 4px; margin: 8px 0 2px; }
.hidden-list .chip { display: inline-flex; align-items: center; gap: 4px; }
.sticker-grid.pop { grid-template-columns: repeat(6, 32px); margin-top: 8px; justify-content: center; }
.add-btn { flex: none; height: 28px; padding: 0 10px; }

/* ============ Route tab ============ */
.route-list .stop { gap: 8px; padding-left: 4px; background: var(--group); }
.route-list .stop + .leg, .route-list .leg + .stop { position: relative; }
.route-list .stop.dragging { opacity: .9; box-shadow: 0 10px 30px rgba(0,0,0,.2); transform: scale(1.02); z-index: 2; border-radius: 12px; }
.route-list.sorting .leg { visibility: hidden; height: 6px; padding: 0; }
.grip { width: 26px; height: 40px; display: grid; place-items: center; color: var(--label3); cursor: grab; touch-action: none; flex: none; }
.grip:active { cursor: grabbing; color: var(--accent); }
.stop .main.clickable { cursor: pointer; }
.stepper { display: flex; align-items: center; background: var(--fill); border-radius: 9px; flex: none; }
.stepper button { width: 28px; height: 28px; font-size: 17px; font-weight: 600; color: var(--accent); border-radius: 9px; }
.stepper button:disabled { color: var(--label3); }
.stepper span { display: inline-flex; align-items: center; gap: 3px; min-width: 30px; justify-content: center; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--indigo); }
.leg { display: flex; align-items: center; gap: 6px; padding: 3px 12px 3px 46px; font-size: 12px; color: var(--label2); background: var(--fill2); }
.leg .ic { color: var(--label3); }
.opt-nums { display: flex; align-items: center; gap: 14px; margin: 4px 0 10px; }
.opt-nums div { display: flex; flex-direction: column; }
.opt-nums b { font-size: 20px; letter-spacing: -0.02em; }
.opt-nums span { font-size: 12px; color: var(--label2); }

/* ============ Touch: bigger targets ============ */
@media (pointer: coarse) {
  .icon-btn.ghost { width: 36px; height: 36px; }
  .sbtn { width: 30px; height: 30px; }
  .scolor { width: 22px; height: 22px; }
  .sresize { width: 30px; height: 30px; }
  .vhandle { width: 22px; height: 22px; }
  .vhandle.mid { width: 18px; height: 18px; }
  .checkbox { width: 28px; height: 28px; }
  .who { width: 30px; height: 30px; }
  .stepper button { width: 34px; height: 34px; }
  .grip { width: 32px; height: 44px; }
}
@media (max-width: 820px) {
  body.tool-active .map-hint { display: block; bottom: calc(var(--sheet-h, 48vh) + 12px); left: 50%; max-width: calc(100vw - 24px); white-space: normal; text-align: center; }
  body.drawing.tool-active .map-hint { display: none; }
}

/* Route rows on phones: name on the first line, nights + actions below */
@media (max-width: 820px) {
  .route-list .stop { flex-wrap: wrap; row-gap: 2px; padding-bottom: 8px; }
  .route-list .stop .main { flex: 1 1 calc(100% - 90px); }
  .route-list .stop .stepper { margin-left: 74px; }
  .route-list .stop .acts { margin-left: auto; }
}

/* ============ Chinese names ============ */
.zh-line { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 2px; }
.zh-line .zh { font-size: 17px; font-weight: 600; letter-spacing: .02em; font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", var(--font); }
.zh-line .py { color: var(--label2); font-size: 13px; font-style: italic; }
.zh-inline { margin-left: 6px; font-weight: 500; color: var(--label2); font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", var(--font); }
.tr-row { cursor: default; background: rgba(88, 86, 214, .08); }
.tr-row .badge { font-weight: 700; font-size: 14px; }
.tr-row .title { white-space: normal; }
.typing-dots.small span { width: 4px; height: 4px; }
.typing-dots.small { margin-left: 6px; padding: 0; vertical-align: middle; }

/* ============ Performance: blur only on the few big panels ============ */
.wxb, .rlabel, .leaflet-control-zoom a, .leaflet-control-scale-line, .leaflet-control-attribution, #toast, .leaflet-tooltip.draft-tip {
  -webkit-backdrop-filter: none !important; backdrop-filter: none !important;
}
.wxb, .rlabel { background: var(--glass-strong); }
.apin { filter: none; }
.apin .head { box-shadow: 0 2px 6px rgba(0, 0, 0, .35); }
.apin.dim { filter: grayscale(.6); }
.poi { box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.leaflet-marker-icon { will-change: auto; }

/* ============ Province names ============ */
.prov-label { display: flex; flex-direction: column; align-items: center; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap; line-height: 1.1; }
.prov-label span { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6a2fb5;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 6px #fff; }
.prov-label b { font-size: 11px; font-weight: 600; color: #6a2fb5; opacity: .8; text-shadow: 0 0 3px #fff, 0 0 3px #fff;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", var(--font); }
@media (prefers-color-scheme: dark) {
  .prov-label span, .prov-label b { color: #e2c8ff; text-shadow: 0 0 3px #000, 0 0 3px #000, 0 0 6px #000; }
}
body[data-map-style="satellite"] .prov-label span, body[data-map-style="satellite"] .prov-label b { color: #fff; text-shadow: 0 0 3px #000, 0 0 4px #000; }

/* =====================================================================
   Readable colours (WCAG AA): Apple "Increase Contrast" palette.
   Fill colours carry white text (≥ 4.5:1); *-text colours are for text on the panels.
   ===================================================================== */
:root {
  --accent: #0064d2; --accent-bg: #0064d2; --accent-soft: rgba(0, 100, 210, .12);
  --red: #d70015; --orange: #c93400; --yellow: #a05a00; --green: #248a3d; --indigo: #3634a3;
  --purple: #8944ab; --pink: #d30f45; --teal: #0071a4; --brown: #7f6545; --gray: #6e6e73;
  --red-text: #c20012; --orange-text: #b23000; --green-text: #1d7a35; --indigo-text: #3634a3;
  --label: #1d1d1f; --label2: #55555b; --label3: #8a8a8f;
  --sep: rgba(60, 60, 67, .2); --fill: rgba(118, 118, 128, .14); --fill2: rgba(118, 118, 128, .09);
  --group: #ffffff; --glass: rgba(246, 246, 248, .94); --glass-strong: rgba(252, 252, 253, .98);
  --bubble-them: #e9e9eb;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #5aaeff; --accent-bg: #0a68d8; --accent-soft: rgba(90, 174, 255, .18);
    --red: #d70015; --orange: #c93400; --yellow: #a05a00; --green: #248a3d; --indigo: #4e4cc8;
    --purple: #8944ab; --pink: #d30f45; --teal: #0071a4; --brown: #7f6545; --gray: #6e6e73;
    --red-text: #ff7b72; --orange-text: #ffb340; --green-text: #4cd964; --indigo-text: #a8a6ff;
    --label: #f5f5f7; --label2: #b8b8bf; --label3: #8e8e93;
    --sep: rgba(255, 255, 255, .16); --fill: rgba(118, 118, 128, .32); --fill2: rgba(118, 118, 128, .2);
    --group: #2c2c2e; --glass: rgba(28, 28, 30, .95); --glass-strong: rgba(36, 36, 38, .98);
    --bubble-them: #3a3a3c;
  }
}
/* filled accent surfaces use the button blue (white text stays readable in dark mode too) */
.btn.primary, .icon-btn.on, #toolbox .tools button.on, .send-btn, .msg.user, .chip-check input:checked + span { background: var(--accent-bg); color: #fff; }
.tool-opts .mode.on { background: var(--mc, var(--accent-bg)); }
.badge { --c: var(--gray); }
/* coloured text */
.err, .btn.danger, .icon-btn.danger, .icon-btn.ghost.danger:hover, .check-row .meta.late, .msg.error { color: var(--red-text); }
.tagx.fast { color: var(--orange-text); background: rgba(201, 52, 0, .12); }
.tagx.cheap { color: var(--green-text); background: rgba(36, 138, 61, .12); }
.stepper span { color: var(--indigo-text); }
.chip { color: var(--label2); }
.tipchips .chip { color: var(--accent); }
.tipchips .chip small { color: var(--label2); }
/* secondary text never uses the decorative grey */
.empty-row, .group.empty .empty-row, .opt, .who, .grip, .conv-eq, .leg, .leg .ic, .sdots { color: var(--label2); }
.who.on { color: #fff; }
.sticky textarea::placeholder { color: rgba(0, 0, 0, .55); }
.sgrip { opacity: .8; }
.search input::placeholder, #chatInput::placeholder, .add-input::placeholder { color: var(--label2); opacity: 1; }
/* map overlays: solid enough to read on any map colour */
.leaflet-control-attribution { background: var(--glass-strong) !important; color: var(--label2) !important; }
.leaflet-control-attribution a { color: var(--label2) !important; }
.wxb { background: var(--glass-strong); color: var(--label); box-shadow: 0 1px 4px rgba(0, 0, 0, .35); }
.wxb i { color: var(--label2); }
.rlabel { background: var(--glass-strong); }
.map-hint { background: var(--glass-strong); color: var(--label); }
.apin .head { border-width: 2.5px; }
.prov-label span, .prov-label b { color: #5a1fa3; }
@media (prefers-color-scheme: dark) { .prov-label span, .prov-label b { color: #e6d2ff; } }
.segmented button { color: var(--label); }
.segmented.tabs button:not(.active) { color: var(--label2); }
.section-h .t, .section-h .s, .sgroup, .lp-title, .subtitle, .muted, .row-i .meta, .row-i .trail { color: var(--label2); }
/* blue text on grey buttons/chips needs a slightly deeper blue to reach 4.5:1 */
:root { --accent-strong: #0057b8; }
@media (prefers-color-scheme: dark) { :root { --accent-strong: #6cb6ff; } }
.btn:not(.primary):not(.danger), .tipchips .chip, #dayChip, .bnums .clickable span, .toast-act { color: var(--accent-strong); }
.stepper button:disabled { color: var(--label2); opacity: .7; }
@media (prefers-color-scheme: dark) {
  .stepper { background: rgba(255, 255, 255, .07); }
  .stepper button { color: var(--accent-strong); }
  .stepper span { color: #c9c7ff; }
}
