* { box-sizing: border-box; }
input[type="text"], input[type="search"], input[type="url"], input[type="time"], input[type="number"] {
  -webkit-appearance: none; appearance: none;
  min-height: 44px; padding: 8px 12px; border-radius: 12px; font-size: var(--font); font-family: inherit;
  color: var(--text); background: rgba(0,0,0,0.35); border: 1px solid var(--border); outline: none;
}
input:focus { border-color: var(--accent); }
input::placeholder { color: var(--muted); }
button { font-family: inherit; }
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; user-select: none; -webkit-user-select: none; touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%; }

/* ---- theme: futuristic dark glass, cyan glow. Night = deeper black + dimmer amber, map tiles inverted. ---- */
:root {
  --btn-size: 44px;
  --font: 15px;
  --bg: #05070d;
  --bg2: #0a1020;
  --panel: rgba(14, 22, 40, 0.72);
  --glass: rgba(120, 200, 255, 0.06);
  --text: #dff3ff;
  --muted: rgba(223, 243, 255, 0.55);
  --accent: #22d3ee;
  --accent2: #a78bfa;
  --glow: rgba(34, 211, 238, 0.45);
  --border: rgba(120, 200, 255, 0.14);
  --danger: #ff4d6d;
}
[data-theme="night"] {
  --bg: #000;
  --bg2: #07070a;
  --panel: rgba(12, 10, 8, 0.8);
  --glass: rgba(255, 170, 90, 0.06);
  --text: #ffb877;
  --muted: rgba(255, 184, 119, 0.5);
  --accent: #ff9a3d;
  --accent2: #ff5f6d;
  --glow: rgba(255, 154, 61, 0.35);
  --border: rgba(255, 170, 90, 0.14);
}
body {
  background: radial-gradient(1200px 600px at 10% -10%, var(--bg2), var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", Roboto, system-ui, sans-serif;
  letter-spacing: 0.01em;
}
[data-mode="driving"] { --btn-size: 64px; --font: 19px; }

/* ---- app shell: nav + main. Nav placement via data-navbar on <html>. ---- */
#app { display: flex; flex-direction: column; height: 100%; width: 100%; }
html[data-navbar="left"] #app { flex-direction: row; }
html[data-navbar="right"] #app { flex-direction: row-reverse; }
html[data-navbar="bottom"] #app { flex-direction: column-reverse; }
#main { flex: 1; position: relative; display: flex; min-width: 0; min-height: 0; }

/* ---- master nav ---- */
/* fixed sizing: driving mode enlarges in-pane targets but must not resize the nav */
#topbar {
  --btn-size: 48px; --font: 15px;
  position: relative; z-index: 2000; flex-shrink: 0;
  display: flex; align-items: center; gap: 10px; padding: 8px 14px;
  background: var(--panel); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 var(--glow), 0 8px 30px rgba(0, 0, 0, 0.5);
  overflow: auto; white-space: nowrap;
}
html[data-navbar="bottom"] #topbar { border-bottom: 0; border-top: 1px solid var(--border); box-shadow: 0 -1px 0 var(--glow), 0 -8px 30px rgba(0,0,0,0.5); }
html[data-navbar="left"] #topbar, html[data-navbar="right"] #topbar { flex-direction: column; padding: 14px 8px; border-bottom: 0; }
html[data-navbar="left"] #topbar { border-right: 1px solid var(--border); box-shadow: 1px 0 0 var(--glow), 8px 0 30px rgba(0,0,0,0.5); }
html[data-navbar="right"] #topbar { border-left: 1px solid var(--border); box-shadow: -1px 0 0 var(--glow), -8px 0 30px rgba(0,0,0,0.5); }
.nav-spacer { flex: 1; }

#date-time { display: flex; flex-direction: column; line-height: 1; padding-right: 6px; font-variant-numeric: tabular-nums; }
#clock { font-size: 26px; font-weight: 300; letter-spacing: 0.04em; text-shadow: 0 0 14px var(--glow); }
#date { font-size: 11px; color: var(--muted); letter-spacing: 0.2em; margin-top: 4px; }
html[data-navbar="left"] #date-time, html[data-navbar="right"] #date-time { align-items: center; padding: 0 0 6px; }

#mode-badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase;
  padding: 6px 12px; border-radius: 999px; color: var(--accent);
  border: 1px solid var(--accent); box-shadow: 0 0 12px var(--glow) inset, 0 0 10px var(--glow);
}
#topbar #mode-badge { border-radius: 999px; padding: 0 12px; min-height: 34px; width: auto; min-width: 116px; padding: 0 16px; white-space: nowrap; text-align: center; justify-content: center; font-size: 12px; background: transparent; border-color: var(--accent); }
#mode-badge { display: inline-flex; align-items: center; gap: 8px; }
#mode-badge svg { width: 18px; height: 18px; flex-shrink: 0; }
/* side navbar: icon only so the bar stays narrow (label is in the title) */
html[data-navbar="left"] #topbar #mode-badge, html[data-navbar="right"] #topbar #mode-badge { min-width: var(--btn-size); width: var(--btn-size); min-height: var(--btn-size); height: var(--btn-size); padding: 0; border-radius: 50%; }
html[data-navbar="left"] #mode-badge span, html[data-navbar="right"] #mode-badge span { display: none; }
#btn-night { position: relative; }
#btn-night.auto::after { content: "A"; position: absolute; right: -2px; bottom: -2px; width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; color: var(--bg); background: var(--muted); }
[data-mode="driving"] #topbar #mode-badge { color: var(--danger); border-color: var(--danger); box-shadow: 0 0 12px rgba(255,77,109,0.4) inset, 0 0 10px rgba(255,77,109,0.4); }

/* ---- shared controls ---- */
#topbar button, #drawer-close, .tile, .chip, .layout-option, .pane-override-parked {
  min-height: var(--btn-size); min-width: var(--btn-size);
  font-size: var(--font); color: var(--text); cursor: pointer;
  background: var(--glass); border: 1px solid var(--border); border-radius: 14px;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
#topbar button, #drawer-close { border-radius: 50%; padding: 0; display: flex; align-items: center; justify-content: center; }
#topbar button svg, #drawer-close svg { width: 22px; height: 22px; display: block; }
#topbar button.active { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px var(--glow); }
button:active { transform: scale(0.94); }
.chip { padding: 6px 14px; display: inline-flex; align-items: center; gap: 6px; }
.chip svg { width: 18px; height: 18px; }
.chip.active, .tile.active, .layout-option.active {
  border-color: var(--accent); color: var(--accent);
  background: linear-gradient(180deg, rgba(34,211,238,0.14), rgba(34,211,238,0.03));
  box-shadow: 0 0 18px var(--glow);
}
[data-theme="night"] .chip.active, [data-theme="night"] .tile.active, [data-theme="night"] .layout-option.active { background: rgba(255,154,61,0.1); }

/* ---- pane grid: tracks/cells set inline per layout (lib.DATA.layouts) ---- */
#panes { flex: 1; display: grid; gap: 6px; padding: 6px; overflow: hidden; }
/* isolation: Leaflet panes use z-index 400–1000; keep them trapped inside their pane */
.pane {
  position: relative; isolation: isolate; overflow: hidden; min-width: 0; min-height: 0;
  background: #000; border-radius: 16px; border: 1px solid var(--border);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6), 0 10px 30px rgba(0,0,0,0.45);
}
.pane-content, .pane-content iframe { width: 100%; height: 100%; border: 0; display: block; }
.pane-empty-add {
  width: 100%; height: 100%; border: 1px dashed var(--border); border-radius: 16px; color: var(--accent);
  background: repeating-linear-gradient(45deg, transparent 0 12px, var(--glass) 12px 13px);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.pane-empty-add svg { width: 22%; height: 22%; min-width: 48px; min-height: 48px; filter: drop-shadow(0 0 10px var(--glow)); }

/* ---- map: dark mode inverts raster tiles (no dark Google tile style without an API key) ---- */
.leaflet-container { background: #0b0f14; }
[data-theme="night"] .leaflet-container { background: #111; }
[data-theme="night"] .leaflet-container img.leaflet-tile { filter: invert(90%) hue-rotate(180deg) brightness(95%) contrast(85%); }

/* ---- map navigation UI ---- */
.map-wrap { position: relative; width: 100%; height: 100%; }
.map-canvas { position: absolute; inset: 0; }
.map-top { position: absolute; top: 10px; left: 10px; right: 10px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.map-top > * { pointer-events: auto; }
.map-nav-btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; min-height: 52px; padding: 0 20px 0 16px; border-radius: 999px; font-size: 16px; font-weight: 600; color: #001018; background: var(--accent); border: 0; box-shadow: 0 0 20px var(--glow), 0 6px 20px rgba(0,0,0,0.5); cursor: pointer; }
.map-nav-btn svg { width: 22px; height: 22px; }
.map-search { min-height: 0; display: flex; flex-direction: column; max-height: calc(100% - 20px); border-radius: 16px; overflow: hidden; background: rgba(8, 12, 24, 0.94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border: 1px solid var(--accent); box-shadow: 0 0 24px var(--glow), 0 10px 30px rgba(0,0,0,0.6); animation: sheet-in 0.15s ease-out; }
.map-top { bottom: 10px; }
.map-search-row { display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 14px; border-bottom: 1px solid var(--border); }
.map-search-icon svg { width: 20px; height: 20px; color: var(--accent); display: block; }
.map-search-row input { color: var(--text); caret-color: var(--accent); flex: 1; min-width: 0; background: transparent; border: 0; box-shadow: none; font-size: 18px; padding: 10px 8px; }
.map-search-row input, .map-search-row input:focus { border: 0; outline: none; box-shadow: none; }
input[type="search"]::-webkit-search-cancel-button { display: none; }
.map-search-row input::placeholder { color: var(--muted); }
.map-search-close { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--glass); color: var(--text); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.map-search-close svg { width: 20px; height: 20px; }
.map-quick { display: flex; gap: 8px; padding: 10px 12px; overflow-x: auto; flex-shrink: 0; }
.map-quick .chip { white-space: nowrap; min-height: 42px; flex-shrink: 0; }
.map-suggest { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: flex; flex-direction: column; }
.map-suggest > * { flex-shrink: 0; }
.map-suggest:empty { display: none; }
.sug-row { display: flex; border-top: 1px solid var(--border); }
.sug-star { flex-shrink: 0; width: 60px; display: flex; align-items: center; justify-content: center; color: var(--muted); background: transparent; border: 0; border-left: 1px solid var(--border); cursor: pointer; }
.sug-star svg { width: 24px; height: 24px; }
.sug-star.on { color: #fbbf24; }
.sug-star.on svg { fill: currentColor; }
.sug-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 60px; text-align: left; color: var(--text); background: transparent; border: 0; font-size: var(--font); cursor: pointer; }
.sug-main:active, .sug-star:active { background: var(--glass); }
.sug-icon svg { width: 22px; height: 22px; color: var(--accent); display: block; }
.sug-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sug-text b, .sug-text small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sug-text small { color: var(--muted); font-size: 12px; }
.sug-dist { flex-shrink: 0; font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }
.sug-head { padding: 10px 14px 4px; font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted); }
.sug-msg { padding: 16px; text-align: center; color: var(--muted); }
.nav-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 14px; background: linear-gradient(135deg, rgba(8,145,178,0.95), rgba(14,22,40,0.95)); border: 1px solid var(--accent); box-shadow: 0 0 24px var(--glow); color: #fff; }
[data-theme="night"] .nav-banner { background: linear-gradient(135deg, rgba(160,80,20,0.95), rgba(10,8,6,0.95)); }
.nav-turn { font-size: 20px; font-weight: 600; }
.nav-dist { font-size: 26px; font-weight: 300; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nav-bottom { position: absolute; left: 10px; right: 10px; bottom: 10px; z-index: 1000; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--panel); backdrop-filter: blur(12px); border: 1px solid var(--border); }
.nav-remain { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-cancel { min-height: 40px; padding: 0 16px; border-radius: 999px; color: #fff; background: var(--danger); border: 0; font-size: var(--font); cursor: pointer; }
.cam-alert { position: absolute; left: 10px; bottom: 70px; right: 80px; width: fit-content; z-index: 1000; padding: 10px 14px; border-radius: 14px; font-size: 20px; font-weight: 700; color: #fff; background: rgba(255,77,109,0.9); box-shadow: 0 0 20px rgba(255,77,109,0.5); animation: pulse 1.2s ease-in-out infinite; }
.map-ctrls { position: absolute; right: 10px; bottom: 70px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.map-ctrls[hidden] { display: none; }
.map-ctrls button { width: 56px; height: 56px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--text); background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--border); box-shadow: 0 6px 20px rgba(0,0,0,0.5); cursor: pointer; }
.map-ctrls button svg { width: 26px; height: 26px; }
.map-north svg { transition: transform 0.2s; }
.heading-up .map-heading { color: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px var(--glow); }
.map-recenter { color: var(--muted) !important; border-radius: 50% !important; margin-top: 6px; }
.free-pan .map-recenter { color: var(--accent) !important; border-color: var(--accent) !important; box-shadow: 0 0 14px var(--glow) !important; }
.map-canvas { transition: transform 0.25s ease; }
.car-marker, .cam-marker { background: none; border: 0; }
.car-marker svg { filter: drop-shadow(0 0 6px rgba(34,211,238,0.9)); transition: transform 0.3s ease; }
.cam-marker { font-size: 20px; line-height: 26px; text-align: center; }

/* ---- HUD: info strip on top, speed dominant in the middle, alerts pinned bottom ---- */
.hud {
  width: 100%; height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 14px 18px;
  position: relative; overflow: hidden; background: #000;
}
/* backdrop: accent glow + receding road grid (pure CSS, follows the color scheme via --glow) */
.hud::before {
  content: ""; position: absolute; left: -100%; right: -100%; bottom: 0; height: 200%; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, var(--glow) 0 1px, transparent 1px 60px),
    repeating-linear-gradient(0deg, var(--glow) 0 1px, transparent 1px 40px);
  opacity: 0.6; transform: perspective(400px) rotateX(75deg); transform-origin: bottom;
  -webkit-mask-image: linear-gradient(to top, #000 20%, transparent); mask-image: linear-gradient(to top, #000 20%, transparent);
}
.hud::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, var(--glow), transparent 55%), linear-gradient(180deg, rgba(255,255,255,0.03), transparent 40%);
  opacity: 0.45;
}
.hud > * { position: relative; z-index: 1; }
.hud-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.hud-location { font-size: 17px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hud-location::before { content: "◉ "; color: var(--accent); }
.hud-gps-status { flex-shrink: 0; font-size: 11px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--muted); padding: 4px 10px; border-radius: 999px; border: 1px solid currentColor; }
.hud-gps-ok { color: #34f5a4; }
.hud-gps-lost { color: var(--danger); }
.hud-main { flex: 1; display: flex; align-items: center; justify-content: center; gap: 28px; min-height: 0; }
.hud-speed { display: flex; align-items: baseline; gap: 8px; line-height: 1; }
.hud-speed-num { font-size: clamp(64px, 14vmin, 140px); font-weight: 200; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px var(--glow); }
.hud-speed-unit { font-size: 14px; color: var(--muted); letter-spacing: 0.25em; text-transform: uppercase; }
.hud-side { display: flex; flex-direction: column; gap: 10px; padding-left: 22px; border-left: 1px solid var(--border); }
.hud-heading { font-size: 18px; color: var(--accent); }
.hud-cam { font-size: 17px; font-weight: 700; padding: 10px 14px; border-radius: 12px; text-align: center; color: #fff; background: rgba(255,77,109,0.85); box-shadow: 0 0 20px rgba(255,77,109,0.5); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 4px rgba(255,77,109,0.3); } }
.hud-weather { font-size: 16px; font-weight: 500; padding: 10px 14px; border-radius: 12px; text-align: center; border: 1px solid var(--border); background: rgba(0,0,0,0.4); }
.hud-weather.rain { font-weight: 600; border-color: var(--accent2); color: var(--accent2); background: rgba(167,139,250,0.1); }

/* ---- Weather pane: place strip, big current temp, AQI banner, hourly strip, rain alert ---- */
.wxpane {
  width: 100%; height: 100%; display: flex; flex-direction: column; gap: 12px; padding: 18px 22px; overflow: hidden;
  background: radial-gradient(ellipse at 50% 35%, var(--glow), transparent 60%), #000;
}
.wx-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border); }
.wx-place { font-size: 17px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.wx-extra { flex-shrink: 0; font-size: 14px; color: var(--muted); }
.wx-now { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 18px; overflow: hidden; }
.wx-icon { font-size: 64px; line-height: 1; }
.wx-main { display: flex; flex-direction: column; min-width: 0; }
.wx-temp { font-size: 96px; font-weight: 200; line-height: 1; font-variant-numeric: tabular-nums; text-shadow: 0 0 30px var(--glow); }
.wx-text { font-size: 20px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wx-aqi { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 14px; border: 1px solid currentColor; background: rgba(255,255,255,0.04); }
.wx-aqi-num { font-size: 30px; font-weight: 600; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.wx-aqi-body { display: flex; flex-direction: column; min-width: 0; }
.wx-aqi-text { font-size: 15px; }
.wx-aqi-tip { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.aqi-1 { color: #34d399; } .aqi-2 { color: #facc15; } .aqi-3 { color: #fb923c; }
.aqi-4 { color: #f87171; } .aqi-5 { color: #c084fc; } .aqi-6 { color: #e11d48; }
.wx-hours { display: flex; gap: 6px; }
.wx-hours:empty { display: none; }
.wx-hour { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border-radius: 12px; border: 1px solid var(--border); background: rgba(255,255,255,0.04); font-size: 13px; color: var(--muted); }
.wx-hour b { font-size: 17px; font-weight: 500; color: var(--text); }
.wx-hour-icon { font-size: 20px; }
.wx-hour-p.wet { color: var(--accent2); font-weight: 600; }
.wx-rain { font-size: 16px; font-weight: 600; padding: 10px 14px; border-radius: 12px; text-align: center; border: 1px solid var(--accent2); color: var(--accent2); background: rgba(167,139,250,0.1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* small panes (toggled by fitWeatherPane): shrink, drop secondary bits, then the hourly strip */
.wxpane.compact { gap: 8px; padding: 10px 14px; }
.wxpane.compact .wx-head { padding-bottom: 6px; }
.wxpane.compact .wx-place { font-size: 15px; }
.wxpane.compact .wx-extra, .wxpane.compact .wx-aqi-tip, .wxpane.compact .wx-hour-icon { display: none; }
.wxpane.compact .wx-icon { font-size: 40px; }
.wxpane.compact .wx-temp { font-size: 60px; }
.wxpane.compact .wx-text { font-size: 16px; }
.wxpane.compact .wx-aqi { padding: 6px 12px; gap: 10px; }
.wxpane.compact .wx-aqi-num { font-size: 22px; }
.wxpane.compact .wx-hour { padding: 5px 2px; font-size: 12px; }
.wxpane.compact .wx-hour b { font-size: 14px; }
.wxpane.compact .wx-rain { font-size: 13px; padding: 6px 10px; }
.wxpane.tiny .wx-hours, .wxpane.tiny .wx-text, .wxpane.tiny .wx-rain { display: none; }

/* ---- driving overlay ---- */
.driving-overlay {
  position: absolute; inset: 0; z-index: 1100; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 12px;
  background: rgba(0,0,0,0.85); backdrop-filter: blur(6px); text-align: center; padding: 16px;
}
.pane.video-blocked .driving-overlay { display: flex; }
.pane.video-blocked iframe { filter: blur(14px); }
.pane-bar {
  position: absolute; inset: 0; z-index: 1200; display: none; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(3px); border: 2px solid var(--accent); border-radius: 16px; box-shadow: inset 0 0 30px var(--glow);
}
#panes.editing .pane-bar { display: flex; }
#layout-quick { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 1300; display: flex; gap: 10px; padding: 10px; border-radius: 18px; background: var(--panel); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border: 1px solid var(--accent); box-shadow: 0 8px 30px rgba(0,0,0,0.6); }
#layout-quick[hidden] { display: none; }
#layout-quick { align-items: center; }
.split-btn { width: 56px; display: flex; align-items: center; justify-content: center; color: var(--accent); }
.split-btn svg { width: 26px; height: 26px; }
.split-btn:disabled { opacity: 0.3; }
.split-pct { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; color: var(--text); }
.quick-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.pane-bar button { display: inline-flex; align-items: center; gap: 8px; padding: 12px 22px; min-height: var(--btn-size); font-size: var(--font); color: var(--accent); background: var(--glass); border: 1px solid var(--accent); border-radius: 999px; cursor: pointer; }
.pane-bar svg { width: 20px; height: 20px; }
.drive-controls { display: flex; align-items: center; gap: 18px; }
.drive-controls button { width: 60px; height: 60px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text); background: var(--glass); border: 1px solid var(--border); cursor: pointer; }
.drive-controls .drive-play { width: 80px; height: 80px; color: #001018; background: var(--accent); border: 0; box-shadow: 0 0 24px var(--glow); }
.drive-controls svg { width: 26px; height: 26px; }
.drive-controls .drive-play svg { width: 34px; height: 34px; }
.pane-media-btn { display: none; position: absolute; top: 10px; right: 10px; z-index: 1150; width: 48px; height: 48px; border-radius: 50%; align-items: center; justify-content: center; color: var(--accent); background: rgba(0,0,0,0.6); border: 1px solid var(--border); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); cursor: pointer; }
.pane-media-btn svg { width: 22px; height: 22px; }
.pane.is-media .pane-media-btn { display: flex; }
.driving-overlay.confirming .drive-confirm { display: flex; }
/* now playing: blurred thumbnail backdrop, thumb + title/author + controls side by side (wraps when narrow) */
.drive-bg { position: absolute; inset: -40px; z-index: -1; background: center / cover no-repeat; filter: blur(30px) brightness(0.35) saturate(1.3); }
.drive-player { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 18px 24px; max-width: 640px; width: 100%; }
.drive-thumb { width: min(240px, 42%); min-width: 140px; aspect-ratio: 16 / 9; border-radius: 14px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; color: var(--accent); background: var(--glass) center / cover no-repeat; border: 1px solid var(--border); box-shadow: 0 12px 30px rgba(0,0,0,0.6); }
.drive-thumb svg { width: 40px; height: 40px; opacity: 0.7; }
.has-track .drive-thumb svg { display: none; }
.drive-side { flex: 1 1 220px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 14px; text-align: left; }
.drive-meta { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; }
.drive-title { font-size: 18px; font-weight: 600; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.drive-author { font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drive-show { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px; border-radius: 999px; font-size: 14px; color: var(--muted); background: rgba(255,255,255,0.06); border: 1px solid var(--border); cursor: pointer; }
.drive-show svg { width: 18px; height: 18px; }
/* warning card */
.drive-confirm { display: none; flex-direction: column; align-items: center; gap: 12px; max-width: 480px; padding: 22px 22px 16px; border-radius: 20px; background: rgba(12, 14, 22, 0.92); border: 1px solid rgba(245,158,11,0.5); box-shadow: 0 0 40px rgba(245,158,11,0.15), 0 16px 40px rgba(0,0,0,0.6); }
.drive-confirm > b { font-size: 20px; color: #fbbf24; }
.drive-confirm p { margin: 0; font-size: 15px; line-height: 1.45; color: var(--muted); }
.drive-warn-icon { width: 48px; height: 48px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: #1a1000; background: #f59e0b; box-shadow: 0 0 24px rgba(245,158,11,0.5); }
.drive-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; width: 100%; margin-top: 4px; }
.drive-actions button { flex: 1 1 180px; min-height: 52px; padding: 0 16px; border-radius: 14px; font-size: 15px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.drive-back { color: #001018; background: var(--accent); border: 0; box-shadow: 0 0 20px var(--glow); }
.drive-back svg { width: 18px; height: 18px; }
.drive-actions .pane-override-parked { color: #fbbf24 !important; background: transparent !important; border: 1px solid rgba(245,158,11,0.6) !important; font-size: 14px !important; font-weight: 500; }
.drive-noask { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; color: var(--muted); text-align: left; cursor: pointer; }
.drive-noask input { width: 22px; height: 22px; flex-shrink: 0; accent-color: #f59e0b; }
.drive-noask small { display: block; font-size: 12px; opacity: 0.8; }
.driving-overlay.confirming .drive-player, .pane.no-yt .drive-controls { display: none; }
.radio { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px; background: radial-gradient(circle at 50% 40%, var(--glow), transparent 60%); }
.radio-icon svg { width: 56px; height: 56px; color: var(--accent); }
.radio-name { font-size: 24px; font-weight: 600; }
.radio-status { color: var(--muted); }
.radio-play { width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #001018; background: var(--accent); border: 0; box-shadow: 0 0 24px var(--glow); cursor: pointer; }
.radio-play svg { width: 34px; height: 34px; }
.set-row select { min-height: 44px; max-width: 60%; padding: 0 12px; border-radius: 12px; font-size: var(--font); color: var(--text); background: rgba(0,0,0,0.35); border: 1px solid var(--border); }
.set-row select option { background: var(--bg2); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; }
.swatches button { width: 44px; height: 44px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.swatches button.active { border-color: var(--text); box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--text); }

#toast { position: absolute; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 1400; max-width: 90%; padding: 12px 20px; border-radius: 14px; font-size: 16px; color: var(--text); background: rgba(12,14,22,0.94); border: 1px solid #f59e0b; box-shadow: 0 10px 30px rgba(0,0,0,0.6); pointer-events: none; }
#toast[hidden] { display: none; }
/* ---- page sheet: covers the panes only, nav stays visible and fixed ---- */
#drawer {
  position: absolute; inset: 0; z-index: 1500; display: none; flex-direction: column; overflow: hidden;
  background: rgba(5, 8, 16, 0.92); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
}
[data-theme="night"] #drawer { background: rgba(0,0,0,0.94); }
#drawer.open { display: flex; animation: sheet-in 0.18s ease-out; }
@keyframes sheet-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
#drawer-header { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
#drawer-title { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; color: var(--muted); }
#drawer-body { flex: 1; overflow-y: auto; padding: 16px; }

.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 12px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; aspect-ratio: 1.25; min-height: 90px; padding: 8px; text-align: center; }
.tile .emoji { font-size: 28px; }
.tile .emoji svg { width: 30px; height: 30px; color: var(--accent); filter: drop-shadow(0 0 6px var(--glow)); }

.drawer-section { font-size: 11px; font-weight: 600; letter-spacing: 0.25em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.drawer-section:first-child { margin-top: 0; }

/* ---- settings: grouped cards, label left / control right ---- */
.settings-page { max-width: 760px; margin: 0 auto; }
.settings-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.settings-head h3 { margin: 0; font-size: 22px; font-weight: 500; }
.settings-back { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: var(--text); background: var(--glass); border: 1px solid var(--border); cursor: pointer; }
.settings-back svg { width: 22px; height: 22px; }
.set-group-title { margin: 22px 4px 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.set-group { border-radius: 16px; overflow: hidden; background: var(--glass); border: 1px solid var(--border); }
.set-group-note { margin: 8px 4px 0; font-size: 13px; color: var(--muted); }
.set-row { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 68px; padding: 12px 16px; color: var(--text); font-size: var(--font); text-align: left; background: transparent; border: 0; flex-wrap: wrap; }
.set-row + .set-row, .set-group > * + .set-row { border-top: 1px solid var(--border); }
.set-nav { cursor: pointer; flex-wrap: nowrap; }
.set-nav:active { background: var(--glass); }
.set-nav > svg { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.set-icon { width: 40px; height: 40px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--accent); background: rgba(34,211,238,0.1); border: 1px solid var(--border); }
[data-theme="night"] .set-icon { background: rgba(255,154,61,0.1); }
.set-icon svg { width: 22px; height: 22px; }
.set-label { flex: 1; min-width: 180px; display: flex; flex-direction: column; gap: 3px; }
.set-label b { font-weight: 500; }
.set-label small { font-size: 13px; color: var(--muted); }
.set-label small:empty { display: none; }
.set-group .layout-grid { padding: 14px 16px; margin: 0; }

/* toggle switch (native checkbox underneath for a11y) */
.switch { position: relative; flex-shrink: 0; width: 60px; height: 34px; cursor: pointer; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: rgba(255,255,255,0.12); border: 1px solid var(--border); transition: background 0.2s, box-shadow 0.2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,0.4); transition: transform 0.2s; }
.switch input:checked + span { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px var(--glow); }
.switch input:checked + span::after { transform: translateX(26px); }
.switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

/* segmented control */
.segmented { display: inline-flex; flex-shrink: 0; padding: 3px; gap: 3px; border-radius: 12px; background: rgba(0,0,0,0.35); border: 1px solid var(--border); }
.segmented button { min-height: 40px; padding: 0 16px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-size: var(--font); cursor: pointer; }
.segmented button.active { color: #001018; background: var(--accent); box-shadow: 0 0 12px var(--glow); font-weight: 600; }

/* stepper */
.stepper { display: inline-flex; align-items: center; flex-shrink: 0; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: rgba(0,0,0,0.35); }
.stepper button { width: 46px; height: 44px; border: 0; background: transparent; color: var(--accent); font-size: 22px; cursor: pointer; }
.stepper span { min-width: 84px; text-align: center; font-variant-numeric: tabular-nums; }

input[type="time"] { flex-shrink: 0; }

/* ---- layout picker: visual previews only ---- */
.layout-grid { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.layout-option { padding: 10px; }
.layout-preview { display: grid; gap: 3px; width: 72px; height: 48px; }
.layout-preview div { background: currentColor; opacity: 0.55; border-radius: 3px; }

/* ---- media search ---- */
.media-search { display: flex; gap: 8px; margin-bottom: 8px; }
.media-search input { flex: 1; }
.yt-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin: 10px 0 8px; }
.yt-results:empty { display: none; }
.yt-results .sug-msg { grid-column: 1 / -1; }
.yt-item { position: relative; display: flex; flex-direction: column; padding: 0; overflow: hidden; text-align: left; color: var(--text); background: var(--glass); border: 1px solid var(--border); border-radius: 14px; cursor: pointer; font-size: 15px; }
.yt-item img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; display: block; background: #000; }
.yt-len { position: absolute; top: 8px; right: 8px; padding: 2px 6px; border-radius: 6px; font-size: 12px; background: rgba(0,0,0,0.8); color: #fff; }
.yt-len:empty { display: none; }
.yt-text { display: flex; flex-direction: column; gap: 3px; padding: 10px 12px 12px; }
.yt-text b { font-weight: 500; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.yt-text small { color: var(--muted); font-size: 12px; }

/* ---- settings tip + phone pairing guide ---- */
.announce { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 18px; border-radius: 16px; border: 1px solid var(--accent2); background: linear-gradient(135deg, rgba(167,139,250,0.14), rgba(34,211,238,0.06)); }
.announce-icon svg { width: 32px; height: 32px; color: var(--accent2); }
.announce-text { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 4px; }
.announce-text span { color: var(--muted); font-size: 14px; }
.remote-layout { display: flex; align-items: center; justify-content: center; gap: 28px; flex-wrap: wrap; }
.remote-guide { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.remote-guide li { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--glass); border: 1px solid var(--border); }
.remote-guide li > div:last-child { display: flex; flex-direction: column; gap: 3px; }
.remote-guide li span { color: var(--muted); font-size: 14px; }
.guide-icon { position: relative; flex-shrink: 0; width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; border: 1px solid var(--accent); box-shadow: 0 0 12px var(--glow); }
.guide-icon svg { width: 28px; height: 28px; color: var(--accent); }
.guide-num { position: absolute; top: -8px; left: -8px; width: 22px; height: 22px; border-radius: 50%; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; color: #000; background: var(--accent); }
#qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px; }
#qr-canvas { background: #fff; padding: 10px; border-radius: 14px; box-shadow: 0 0 30px var(--glow); }
.hint { color: var(--muted); font-size: 13px; }
