:root {
  --bg: #0b0b0d;
  --panel: #141417;
  --surface: #1e1e22;
  --line: #2a2a30;
  --text: #f4f4f5;
  --muted: #9a9aa3;
  --accent: #ff8c1a;
  --danger: #ef4444;
  --radius: 12px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
#map { position: fixed; inset: 0 0 0 380px; }
button, .button, select, input { font: inherit; color: inherit; }
button, .button {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px;
  cursor: pointer; text-align: center; transition: background .15s, border-color .15s;
}
button:hover, .button:hover { border-color: #3a3a42; background: #25252a; }
button:disabled { opacity: .45; cursor: default; }
.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
.primary:hover { background: #ff9d3a; }
.danger { color: #ff8080; }

.panel {
  position: fixed; left: 0; top: 0; bottom: 0; width: 380px; overflow-y: auto; z-index: 3;
  background: var(--panel); border-right: 1px solid var(--line); padding: 16px 18px 24px;
  display: flex; flex-direction: column; gap: 14px;
}
.panel > * { flex-shrink: 0; }
.grab { display: none; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { border-radius: 8px; }
.brand > div:not(.langSwitch) { display: flex; flex-direction: column; line-height: 1.1; flex: 1; }
.brand strong { font-size: 19px; }
.brand span { color: var(--muted); font-size: 13px; }
.homeLink { display: flex; }
.langSwitch { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 2px; }
.langSwitch button { border: 0; background: transparent; border-radius: 999px; padding: 4px 8px; font-size: 12px; font-weight: 700; color: var(--muted); }
.langSwitch button.on { background: var(--accent); color: #111; }
.pill { border-radius: 999px; padding: 6px 12px; font-size: 13px; white-space: nowrap; }
.pill.linked { border-color: #22c55e; color: #4ade80; }
.name { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-weight: 600; }
section h3 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.modes button { padding: 8px 4px; font-size: 13px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.modes button i { width: 22px; height: 4px; border-radius: 2px; display: block; }
.modes button.on { border-color: var(--accent); background: #2a1b0c; }
.share { margin-top: 10px; }
.share .row { display: flex; justify-content: space-between; font-size: 14px; }
.share b { color: var(--accent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border-radius: var(--radius); overflow: hidden; }
.stats div { background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; }
.stats b { font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.surface { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface); gap: 2px; }
.surface i { display: block; height: 100%; }
.legend { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend span i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.legend em { font-style: normal; margin-left: auto; color: var(--text); }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; margin-top: 8px; color: var(--muted); }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.actions button, .actions .button { font-size: 13.5px; }
#sendBtn { padding: 14px; font-size: 16px; border-radius: var(--radius); }
#routeList { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
#routeList li { display: flex; align-items: center; gap: 8px; background: var(--surface); border-radius: 10px; padding: 8px 10px; font-size: 13.5px; }
#routeList li span { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#routeList li small { color: var(--muted); }
#routeList li button { padding: 4px 8px; font-size: 12px; }
.foot { margin-top: auto; color: #6b6b74; font-size: 11.5px; }
.foot a { color: var(--muted); }

.mapTools { position: fixed; top: 12px; left: 392px; right: 12px; z-index: 2; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; }
.mapTools > * { pointer-events: auto; }
.search { position: relative; flex: 0 1 360px; }
.search input { width: 100%; background: rgba(20,20,23,.95); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.search ul { position: absolute; top: 44px; left: 0; right: 0; margin: 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.search li { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px; }
.search li:hover { background: var(--surface); }
.styles { margin-left: auto; display: flex; gap: 4px; background: rgba(20,20,23,.95); border: 1px solid var(--line); border-radius: 10px; padding: 4px; }
.styles button { border: 0; padding: 6px 10px; font-size: 13px; background: transparent; }
.styles button.on { background: var(--accent); color: #111; font-weight: 700; }

.profile { position: fixed; left: 392px; right: 12px; bottom: 12px; height: 150px; z-index: 2;
  background: rgba(20,20,23,.95); border: 1px solid var(--line); border-radius: var(--radius); }
.profile canvas { width: 100%; height: 100%; display: block; cursor: crosshair; }
.tip { position: absolute; top: 6px; padding: 4px 8px; background: #000; border-radius: 6px; font-size: 12px; pointer-events: none; white-space: nowrap; }
.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 9; background: #000; border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 18px; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.here { position: fixed; left: calc(50% + 190px); top: 64px; transform: translateX(-50%); z-index: 5; background: var(--panel); border-color: var(--accent);
  border-radius: 999px; padding: 9px 16px; font-weight: 600; white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,.45); }
.busy { position: fixed; right: 16px; top: 64px; z-index: 9; background: var(--accent); color: #111; font-weight: 700; border-radius: 999px; padding: 6px 14px; font-size: 13px; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 20px; width: min(420px, 92vw); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin: 0 0 8px; font-size: 20px; }
dialog label { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; font-size: 14px; }
dialog select { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px; }
.code { width: 100%; font-size: 30px; letter-spacing: .3em; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-variant-numeric: tabular-nums; }
.dialogActions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.pairCheck { background: #2a1b0c; border: 1px solid #4a2c10; border-radius: 10px; padding: 10px 12px; font-size: 14px; color: #f5d4b0; }
.pairCheck b { color: var(--accent); font-size: 18px; }
.error { color: #ff8080; font-size: 13.5px; }

.loopPicker { position: fixed; left: 392px; bottom: 12px; z-index: 4; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 300px; }
#loopOptions { display: flex; flex-direction: column; gap: 6px; }
#loopOptions button { display: flex; justify-content: space-between; gap: 16px; text-align: left; }
#loopOptions button i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 8px; }

.wp { width: 22px; height: 22px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center; font: 700 10px/1 sans-serif; color: #111; cursor: grab; }
.wp.start { background: #22c55e; border-color: #fff; color: #fff; }
.wp.end { background: #111; border-color: #fff; color: #fff; }
.wp.fixed { cursor: default; width: 14px; height: 14px; border-width: 2px; }
.cursorDot { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 3px solid #fff; box-shadow: 0 0 0 2px rgba(0,0,0,.4); }

@media (max-width: 760px) {
  #map { inset: 0 0 42vh 0; }
  .panel { top: auto; height: 46vh; width: 100%; border-right: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; padding-top: 8px; }
  .panel.expanded { height: 88vh; }
  .grab { display: block; width: 42px; height: 5px; border-radius: 3px; background: #3a3a42; margin: 0 auto 4px; cursor: pointer; }
  .mapTools { left: 10px; right: 10px; top: 10px; flex-wrap: wrap; }
  .search { flex: 1 1 100%; }
  .styles { margin-left: 0; flex-wrap: wrap; }
  .profile { left: 10px; right: 10px; bottom: calc(46vh + 8px); height: 100px; }
  .here { left: 50%; top: 104px; white-space: nowrap; font-size: 13.5px; padding: 8px 14px; }
  .loopPicker { left: 10px; right: 10px; bottom: calc(46vh + 8px); }
}
