/* RayeskeTracker web UI. Hand-written, no build step. */

:root {
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --grad: linear-gradient(135deg, #7c5cff 0%, #5b8cff 50%, #22d3ee 100%);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --r-sm: 10px;
  --r: 14px;
  --r-lg: 22px;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}
[data-theme="dark"] {
  --bg: #0a0d16;
  --bg-2: #0e1322;
  --surface: #121931;
  --surface-2: #19224032;
  --surface-hover: rgba(255, 255, 255, .06);
  --glass: rgba(15, 20, 37, .74);
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .18);
  --text: #eaeefb;
  --muted: #8f99b8;
  --input: rgba(255, 255, 255, .05);
  --shadow: 0 12px 44px rgba(0, 0, 0, .5);
  --on-accent: #fff;
}
[data-theme="light"] {
  --bg: #f1f4fb;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1fa;
  --surface-hover: rgba(15, 21, 48, .05);
  --glass: rgba(255, 255, 255, .8);
  --border: rgba(15, 21, 48, .09);
  --border-strong: rgba(15, 21, 48, .2);
  --text: #0f1530;
  --muted: #5f6987;
  --input: rgba(15, 21, 48, .045);
  --shadow: 0 12px 40px rgba(30, 40, 90, .16);
  --on-accent: #fff;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 28px; letter-spacing: -.02em; }
h2 { font-size: 18px; letter-spacing: -.01em; }
h3 { font-size: 16px; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
code { font-family: var(--mono); font-size: .92em; }
ul { list-style: none; margin: 0; padding: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.block { display: block; }
.grow { flex: 1; min-width: 0; }
.pad { padding: 4px 2px 8px; }
.icon { display: inline-flex; flex: none; align-items: center; justify-content: center; }
:focus-visible { outline: 2px solid var(--accent-2); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 45%, transparent); }
* { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 40%, transparent) transparent; }

.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  backdrop-filter: blur(20px) saturate(1.5);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: var(--r-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: transform .12s var(--ease), box-shadow .2s, background .2s, border-color .2s, opacity .2s;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: translateY(1px) scale(.99); }
.btn.primary { background: var(--grad); color: var(--on-accent); box-shadow: 0 6px 20px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn.primary:hover:not(:disabled) { box-shadow: 0 8px 28px color-mix(in srgb, var(--accent) 60%, transparent); filter: brightness(1.06); }
.btn.ghost { background: var(--input); border-color: var(--border); }
.btn.ghost:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--border-strong); }
.btn.danger { background: color-mix(in srgb, var(--bad) 16%, transparent); border-color: color-mix(in srgb, var(--bad) 45%, transparent); color: var(--bad); }
.btn.danger:hover:not(:disabled) { background: color-mix(in srgb, var(--bad) 26%, transparent); }
.btn.lg { padding: 14px 18px; font-size: 15px; border-radius: var(--r); }
.btn.sm { padding: 7px 11px; font-size: 13px; }
.btn.round { width: 44px; height: 44px; padding: 0; border-radius: 50%; }
.danger-text { color: var(--bad) !important; }
.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0;
  border-radius: 10px; border: 0; background: transparent; color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: grid; gap: 6px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field-hint { font-size: 12px; color: var(--muted); }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--input); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 14px; transition: border-color .15s, box-shadow .15s, background .15s;
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}
input::placeholder { color: color-mix(in srgb, var(--muted) 70%, transparent); }
select { appearance: none; padding-right: 38px; cursor: pointer; }
select option { background: var(--surface); color: var(--text); }
.select-wrap { position: relative; }
.select-wrap::after {
  content: ""; position: absolute; right: 15px; top: 50%; width: 8px; height: 8px; margin-top: -6px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); pointer-events: none;
}
input[type="datetime-local"] { color-scheme: inherit; }
.field-wrap { position: relative; }
.field-wrap input { padding-right: 44px; }
.field-toggle { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.form-error {
  padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px;
  background: color-mix(in srgb, var(--bad) 14%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); color: var(--bad);
}
.stack { display: grid; gap: 16px; }
.form-actions { display: flex; justify-content: flex-end; }
input[type="range"] { padding: 0; height: 22px; background: transparent; border: 0; accent-color: var(--accent); cursor: pointer; }
input[type="range"]:focus { box-shadow: none; }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--input); border: 1px solid var(--border); border-radius: 12px; }
.segmented button {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted);
  padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; transition: all .15s;
}
.segmented button:hover { color: var(--text); }
.segmented button.active { background: var(--grad); color: #fff; box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 40%, transparent); }

/* ---------- Auth screen ---------- */
.auth-page { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow: auto; background: var(--bg); }
.auth-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.auth-bg .orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .55; animation: float 18s ease-in-out infinite; }
.auth-bg .o1 { width: 520px; height: 520px; left: -140px; top: -120px; background: #7c5cff; }
.auth-bg .o2 { width: 460px; height: 460px; right: -120px; bottom: -140px; background: #22d3ee; animation-delay: -6s; opacity: .42; }
.auth-bg .o3 { width: 340px; height: 340px; left: 55%; top: 8%; background: #f43f8e; animation-delay: -11s; opacity: .28; }
[data-theme="light"] .auth-bg .orb { opacity: .35; }
.auth-bg .grid {
  position: absolute; inset: -2px;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, #000 20%, transparent 72%);
  -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 72%);
}
.auth-bg .ping { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--accent-2); box-shadow: 0 0 14px var(--accent-2); }
.auth-bg .ping::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent-2); animation: ring 3s ease-out infinite; }
.auth-bg .p1 { left: 14%; top: 66%; }
.auth-bg .p2 { right: 16%; top: 24%; background: #f43f8e; box-shadow: 0 0 14px #f43f8e; }
.auth-bg .p2::after { border-color: #f43f8e; animation-delay: -1s; }
.auth-bg .p3 { left: 70%; bottom: 14%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
.auth-bg .p3::after { border-color: var(--accent); animation-delay: -2s; }
@keyframes float { 0%, 100% { transform: translate(0, 0) scale(1); } 33% { transform: translate(40px, 30px) scale(1.08); } 66% { transform: translate(-30px, 50px) scale(.95); } }
@keyframes ring { 0% { transform: scale(1); opacity: .9; } 100% { transform: scale(5); opacity: 0; } }

.auth-center { position: relative; width: min(440px, 100%); display: grid; gap: 18px; justify-items: center; }
.auth-card { width: 100%; padding: 34px 32px 30px; border-radius: 26px; background: var(--glass); -webkit-backdrop-filter: blur(24px) saturate(1.6); backdrop-filter: blur(24px) saturate(1.6); border: 1px solid var(--border-strong); box-shadow: var(--shadow), 0 0 0 1px rgba(255, 255, 255, .02) inset; animation: rise .6s var(--ease) both; }
.auth-card.shake { animation: shake .4s; }
@keyframes rise { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
.auth-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.auth-head h1 { font-size: 26px; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.logo-mark { display: inline-flex; flex: none; filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--accent) 55%, transparent)); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 20px; background: var(--input); border: 1px solid var(--border); border-radius: 13px; }
.auth-tabs button { border: 0; background: transparent; color: var(--muted); padding: 9px; border-radius: 10px; font-weight: 600; font-size: 14px; transition: all .18s; }
.auth-tabs button:hover { color: var(--text); }
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 10px rgba(0, 0, 0, .25); }
[data-theme="light"] .auth-tabs button.active { box-shadow: 0 2px 8px rgba(30, 40, 90, .14); }
.auth-card h2 { font-size: 22px; }
.auth-sub { margin: 4px 0 20px; font-size: 14px; }
.auth-form { display: grid; gap: 14px; }
.auth-form .btn { margin-top: 6px; }
.auth-note { display: flex; gap: 8px; align-items: flex-start; margin-top: 18px; font-size: 12.5px; color: var(--muted); }
.auth-note .icon { margin-top: 1px; color: var(--good); }
.auth-foot { font-size: 12.5px; color: var(--muted); text-align: center; }
.boot-error { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; padding: 24px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; height: 100dvh; }
.rail { display: flex; flex-direction: column; gap: 6px; padding: 18px 12px; background: var(--bg-2); border-right: 1px solid var(--border); z-index: 20; }
.rail-brand { display: flex; align-items: center; gap: 11px; padding: 6px 10px 18px; font-weight: 800; font-size: 17px; letter-spacing: -.01em; }
.rail-items { display: grid; gap: 4px; }
.rail-item {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: 12px;
  border: 0; background: transparent; color: var(--muted); font-weight: 600; font-size: 14.5px; text-align: left; width: 100%;
  transition: background .15s, color .15s;
}
.rail-item:hover { background: var(--surface-hover); color: var(--text); }
.rail-item.active { color: var(--text); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.rail-item.active .icon { color: var(--accent-2); }
.rail-item.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
.rail-foot { margin-top: auto; display: grid; gap: 4px; padding-top: 12px; border-top: 1px solid var(--border); }
.rail-user { display: flex; align-items: center; gap: 11px; padding: 8px 10px; border-radius: 12px; transition: background .15s; }
.rail-user:hover { background: var(--surface-hover); }
.rail-user-text { display: grid; line-height: 1.2; min-width: 0; }
.rail-user-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.rail-user-text small { color: var(--muted); font-size: 12px; }
.stage { position: relative; min-width: 0; overflow: hidden; background: var(--bg); }

.avatar {
  display: inline-grid; place-items: center; flex: none; border-radius: 50%; font-weight: 700; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, hsl(var(--h) 85% 60%), hsl(calc(var(--h) + 40) 85% 46%));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .25), 0 3px 10px hsl(var(--h) 80% 40% / .35);
}
.avatar-wrap { position: relative; display: inline-flex; flex: none; }
.dot { position: absolute; right: -1px; bottom: -1px; width: 13px; height: 13px; border-radius: 50%; border: 2.5px solid var(--bg-2); background: var(--muted); }
.dot-live { background: var(--good); }
.dot-recent { background: var(--warn); }
.dot-stale, .dot-none { background: var(--muted); }
.glass .dot, .card .dot { border-color: color-mix(in srgb, var(--surface) 90%, #000); }
em.you { margin-left: 8px; padding: 2px 8px; border-radius: 99px; font-style: normal; font-size: 11px; font-weight: 700; letter-spacing: .03em; background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-2); vertical-align: 1px; }

/* ---------- Map views ---------- */
.map-view, .history-view { position: absolute; inset: 0; }
.map-canvas { position: absolute; inset: 0; z-index: 0; isolation: isolate; background: var(--bg-2); }
.leaflet-container { background: var(--bg-2); font-family: var(--font); }
.tiles-dark { filter: invert(1) hue-rotate(180deg) brightness(.92) contrast(.88) saturate(.55); }
.leaflet-bar { border: 1px solid var(--border) !important; box-shadow: var(--shadow) !important; border-radius: 12px !important; overflow: hidden; }
.leaflet-bar a { background: var(--glass); color: var(--text); border-bottom-color: var(--border); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.leaflet-bar a:hover { background: var(--surface); color: var(--text); }
.leaflet-control-attribution { background: var(--glass) !important; color: var(--muted) !important; border-radius: 10px 0 0 0; font-size: 10.5px; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }
.leaflet-control-attribution a { color: var(--muted) !important; }
.leaflet-tooltip { background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); border-radius: 8px; }
.leaflet-tooltip::before { display: none; }

.map-panel, .history-panel {
  position: absolute; z-index: 5; top: 16px; left: 16px; max-height: calc(100% - 32px); width: 372px; border-radius: var(--r-lg);
  display: flex; flex-direction: column; overflow: hidden; animation: slide-in .5s var(--ease) both;
}
.history-panel { overflow: auto; padding: 20px; gap: 16px; display: grid; align-content: start; }
@keyframes slide-in { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
.sheet-handle { display: none; }
.panel-body { flex: 1; overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.panel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.panel-title .muted { font-size: 13px; }
.member-list { display: grid; gap: 8px; }
.member-card {
  display: flex; align-items: center; gap: 13px; width: 100%; padding: 11px 12px; text-align: left;
  background: var(--input); border: 1px solid var(--border); border-radius: var(--r);
  transition: background .15s, border-color .15s, transform .15s var(--ease);
}
.member-card:hover { background: var(--surface-hover); border-color: var(--border-strong); transform: translateY(-1px); }
.member-main { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.member-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.member-main small { font-size: 12.5px; }
.member-side { display: grid; justify-items: end; gap: 4px; }
.member-side small { font-size: 11.5px; }

.battery { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px 3px 6px; border-radius: 99px; font-size: 12px; font-weight: 700; background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good); }
.battery-mid { background: color-mix(in srgb, var(--warn) 16%, transparent); color: var(--warn); }
.battery-low { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.battery-charging { background: color-mix(in srgb, var(--accent-2) 16%, transparent); color: var(--accent-2); }
.battery .bolt { font-weight: 400; }

.back-btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; color: var(--muted); font-weight: 600; padding: 4px 6px 4px 0; border-radius: 8px; }
.back-btn:hover { color: var(--text); }
.detail-head { display: flex; align-items: center; gap: 16px; }
.detail-head h2 { font-size: 22px; }
.detail-head .dot { width: 16px; height: 16px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat { display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; padding: 12px; border-radius: var(--r); background: var(--input); border: 1px solid var(--border); }
.stat .stat-ico { grid-row: 1; color: var(--accent-2); display: inline-flex; }
.stat small { grid-row: 1; font-size: 12px; }
.stat strong { grid-column: 1 / -1; font-size: 17px; margin-top: 4px; }
.coords { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: var(--r-sm); border: 1px dashed var(--border-strong); background: transparent; color: var(--muted); font-family: var(--mono); font-size: 13px; text-align: left; transition: all .15s; }
.coords span { flex: 1; white-space: nowrap; text-align: left; }
.coords:hover { color: var(--text); border-color: var(--accent); }
.detail-actions { display: grid; gap: 8px; margin-top: 4px; }

.live-chip { position: absolute; z-index: 5; top: 16px; right: 16px; display: inline-flex; align-items: center; gap: 9px; padding: 8px 14px 8px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.live-chip .dot { position: static; width: 9px; height: 9px; border: 0; background: var(--muted); }
.live-chip.live .dot { background: var(--good); animation: blink 1.8s ease-in-out infinite; box-shadow: 0 0 10px var(--good); }
.live-chip.offline .dot { background: var(--bad); }
.live-chip.connecting .dot { background: var(--warn); }
@keyframes blink { 50% { opacity: .35; } }
.map-tools { position: absolute; z-index: 5; right: 10px; bottom: 104px; }
.map-btn { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 12px; color: var(--text); padding: 0; }
.map-btn:hover { color: var(--accent-2); }
.map-waiting { position: absolute; z-index: 4; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(380px, calc(100% - 32px)); padding: 28px; border-radius: var(--r-lg); text-align: center; margin-left: 186px; }

/* Map markers */
.mk-wrap { background: none; border: 0; }
.mk { --c: hsl(var(--h) 85% 58%); --c2: hsl(calc(var(--h) + 40) 85% 46%); position: relative; width: 48px; height: 58px; cursor: pointer; transition: transform .2s var(--ease); }
.mk-face {
  position: absolute; left: 0; top: 0; z-index: 2; display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%;
  font-weight: 800; font-size: 16px; color: #fff; background: linear-gradient(135deg, var(--c), var(--c2));
  border: 3px solid #fff; box-shadow: 0 8px 22px rgba(0, 0, 0, .42);
}
.mk-tip { position: absolute; z-index: 1; left: 50%; top: 42px; width: 13px; height: 13px; margin-left: -6.5px; background: #fff; transform: rotate(45deg); border-radius: 2px; box-shadow: 3px 3px 8px rgba(0, 0, 0, .3); }
.mk-pulse { position: absolute; left: 0; top: 0; width: 48px; height: 48px; border-radius: 50%; background: var(--c); opacity: 0; }
.mk-live .mk-pulse { animation: mk-pulse 2.2s ease-out infinite; }
.mk-stale .mk-face { filter: grayscale(.85) brightness(.9); opacity: .78; }
.mk-stale .mk-tip { opacity: .7; }
.mk.sel { transform: scale(1.14); transform-origin: 50% 100%; }
.mk.sel .mk-face { box-shadow: 0 0 0 5px color-mix(in srgb, var(--c) 40%, transparent), 0 10px 26px rgba(0, 0, 0, .5); }
.mk:hover { transform: translateY(-2px); }
.mk.sel:hover { transform: scale(1.14) translateY(-2px); }
@keyframes mk-pulse { 0% { transform: scale(1); opacity: .55; } 100% { transform: scale(2.6); opacity: 0; } }

/* ---------- History ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 7px 13px; border-radius: 99px; background: var(--input); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--muted); transition: all .15s; }
.chip:hover { color: var(--text); border-color: var(--border-strong); }
.chip.active { background: var(--grad); color: #fff; border-color: transparent; box-shadow: 0 3px 12px color-mix(in srgb, var(--accent) 40%, transparent); }
.custom-range summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--muted); padding: 2px 0; }
.custom-range summary:hover { color: var(--text); }
.range-inputs { display: grid; gap: 10px; margin-top: 12px; }
.legend { display: flex; align-items: center; gap: 10px; }
.legend-bar { flex: 1; height: 6px; border-radius: 99px; background: linear-gradient(90deg, hsl(190 90% 60%), hsl(265 90% 57%), hsl(340 90% 54%)); }
.player { position: absolute; z-index: 5; left: 408px; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 16px; padding: 14px 18px; border-radius: var(--r-lg); animation: rise .5s var(--ease) both; }
.player-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.player-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.player-readout { display: flex; gap: 14px; align-items: baseline; font-size: 14px; }
.player-ends { display: flex; justify-content: space-between; }

/* ---------- Pages ---------- */
.page { height: 100%; overflow: auto; padding: 32px clamp(20px, 4vw, 48px) 48px; display: grid; gap: 22px; align-content: start; animation: rise .45s var(--ease) both; }
.page.narrow > * { width: min(760px, 100%); margin-inline: auto; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.page-head .muted { margin-top: 4px; }
.page-foot { display: flex; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; }
[data-theme="dark"] .card { background: linear-gradient(180deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .012)), var(--surface); }
.card-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.card-head .muted { font-size: 13.5px; margin-top: 2px; }
.card-ico { display: inline-grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent-2); }
.card-ico.sm { width: 36px; height: 36px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.member-tile { display: grid; gap: 16px; transition: transform .2s var(--ease), border-color .2s; }
.member-tile:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.tile-top { display: flex; align-items: center; gap: 14px; }
.tile-top .dot { width: 15px; height: 15px; }
.tile-id { display: grid; gap: 4px; justify-items: start; min-width: 0; }
.tile-id h3 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.role { padding: 2px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--input); color: var(--muted); border: 1px solid var(--border); }
.role.admin { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent-2); border-color: transparent; }
.tile-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: 13.5px; }
.tile-meta > .muted { display: inline-flex; align-items: center; gap: 6px; }
.tile-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.rows { display: grid; gap: 4px; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 8px; border-radius: 12px; }
.row + .row { border-top: 1px solid var(--border); border-radius: 0; }
.code { padding: 6px 12px; border-radius: 9px; background: var(--input); border: 1px solid var(--border); letter-spacing: .12em; font-weight: 700; }
.setting { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.readonly { display: grid; gap: 4px; }
.readonly code, .kv code { padding: 8px 12px; border-radius: 9px; background: var(--input); border: 1px solid var(--border); overflow-wrap: anywhere; }
.kv { display: grid; gap: 6px; }
.kv.wide { gap: 6px; }
.copy-line { display: flex; align-items: center; gap: 8px; }
.copy-line code { flex: 1; padding: 8px 12px; border-radius: 9px; background: var(--input); border: 1px solid var(--border); overflow-wrap: anywhere; }
.warn-note { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: var(--r-sm); font-size: 13.5px; background: color-mix(in srgb, var(--warn) 13%, transparent); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); color: var(--warn); }
.invite-body { display: grid; gap: 16px; }
.invite-code { display: grid; place-items: center; padding: 22px; border-radius: var(--r); background: color-mix(in srgb, var(--accent) 10%, transparent); border: 1px dashed color-mix(in srgb, var(--accent) 55%, transparent); }
.invite-code code { font-size: 34px; font-weight: 800; letter-spacing: .2em; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; padding-left: .2em; }

.empty { display: grid; justify-items: center; gap: 8px; text-align: center; padding: 8px; }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 18px; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent-2); margin-bottom: 6px; }
.empty p { font-size: 14px; }

/* ---------- Modal & toasts ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 20px; background: rgba(5, 8, 16, .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .15s both; }
.modal-overlay.out { opacity: 0; transition: opacity .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { width: min(460px, 100%); max-height: calc(100dvh - 40px); overflow: auto; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); padding: 22px; display: grid; gap: 16px; animation: pop .22s var(--ease) both; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
#toasts { position: fixed; z-index: 4000; right: 18px; top: 18px; display: grid; gap: 10px; justify-items: end; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; max-width: min(380px, calc(100vw - 36px)); padding: 12px 16px; border-radius: 14px; font-size: 14px; font-weight: 500; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); animation: toast-in .3s var(--ease) both; pointer-events: auto; }
.toast.out { opacity: 0; transform: translateX(14px); transition: all .35s; }
.toast-success .icon { color: var(--good); }
.toast-error .icon { color: var(--bad); }
.toast-info .icon { color: var(--accent-2); }
@keyframes toast-in { from { opacity: 0; transform: translateX(20px) scale(.97); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .app { grid-template-columns: 76px 1fr; }
  .rail-brand-name, .rail-item span:not(.icon), .rail-user-text { display: none; }
  .rail { align-items: center; padding-inline: 10px; }
  .rail-brand { padding-inline: 0; }
  .rail-item { justify-content: center; padding: 12px; width: 52px; }
  .rail-item.active::before { left: -10px; }
  .rail-user { padding: 6px; }
}
@media (max-width: 860px) {
  body { overflow: hidden; }
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .rail { order: 2; flex-direction: row; justify-content: space-around; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); gap: 0; }
  .rail-brand, .rail-foot { display: none; }
  .rail-items { display: flex; width: 100%; justify-content: space-around; gap: 0; }
  .rail-item { flex-direction: column; gap: 3px; width: auto; flex: 1; padding: 7px 4px; font-size: 11px; }
  .rail-item span:not(.icon) { display: block; }
  .rail-item.active::before { left: 24%; right: 24%; top: -7px; bottom: auto; width: auto; height: 3px; border-radius: 0 0 4px 4px; }
  .stage { order: 1; }

  .map-panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 52%; min-height: 0; animation: rise .5s var(--ease) both; }
  .map-panel.collapsed { max-height: 34px; }
  .map-panel.collapsed .panel-body { display: none; }
  .sheet-handle { display: grid; place-items: center; width: 100%; height: 28px; flex: none; border: 0; background: transparent; padding: 0; }
  .sheet-handle span { width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); }
  .panel-body { padding: 4px 16px 16px; }
  .live-chip { top: 10px; right: 10px; }
  .map-tools { right: 10px; bottom: auto; top: 58px; }
  .map-waiting { margin-left: 0; top: 40%; }

  .history-view { display: flex; flex-direction: column; }
  .history-panel { position: static; width: auto; margin: 8px; flex: none; max-height: 44%; animation: none; padding: 14px; gap: 12px; }
  .history-view .map-canvas { position: relative; inset: auto; flex: 1; min-height: 240px; }
  .player { left: 12px; right: 12px; bottom: 12px; padding: 10px 12px; gap: 10px; }
  .player-ends { display: none; }
  .page { padding: 20px 16px 28px; }
  h1 { font-size: 24px; }
  .auth-card { padding: 26px 20px 22px; }
  #toasts { left: 12px; right: 12px; top: 12px; justify-items: stretch; }
  .toast { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
