/* =========================================================================
   WebBoardView — liquid-glass instrument panel
   ---------------------------------------------------------------------
   The board is the product; the chrome is instrumentation floating over
   it, the way a heads-up display sits over the thing it is measuring.
   Every panel is frosted glass — translucent, blurred, lit from the top
   edge — over a full-bleed canvas. Data (coordinates, counts, net names)
   is set in a monospace face throughout, matching what the canvas itself
   already draws, so the chrome reads as the same instrument as the board
   rather than a UI skinned on top of it.
   ========================================================================= */

:root {
  /* -- palette --------------------------------------------------------
     Neutral near-black: the page base is almost #000, and the chrome is a
     barely-lifted charcoal glass so panels still separate from the board
     without the old blue-grey cast. Accents are unchanged. */
  --void: #030304;
  --void-2: #08080a;
  --canvas-bg: #050607;

  /* Foreground tint used for every subtle hover/border/highlight overlay
     (rgba(var(--fg-tint), alpha)). It is the one knob that makes the whole
     "frosted glass" system reusable for a light theme: swap the triplet from
     white to near-black and every hover state, divider and inset highlight
     in the chrome darkens to match, with no other rule touching color. */
  --fg-tint: 255, 255, 255;

  --glass: rgba(11, 11, 13, 0.74);
  --glass-strong: rgba(9, 9, 11, 0.92);
  --glass-soft: rgba(var(--fg-tint), 0.045);
  --glass-soft-hover: rgba(var(--fg-tint), 0.09);
  --glass-border: rgba(var(--fg-tint), 0.09);
  --glass-border-soft: rgba(var(--fg-tint), 0.06);
  --glass-highlight: rgba(var(--fg-tint), 0.08);

  --text: #e6edf3;
  --text-dim: #aeb7c2;
  --text-muted: #838d99;

  --blue: #58a6ff;      /* T side / primary accent */
  --amber: #d29922;     /* B side */
  --orange: #ff8c1a;    /* selection (was purple) */
  --cyan: #00d9ff;      /* highlight / active toggle (was teal) */
  --red: #f85149;
  --select: #ff4d4f;    /* selection (canvas + list rows, was orange) */
  --select-soft: rgba(255, 77, 79, 0.14);
  --select-line: rgba(255, 77, 79, 0.4);

  --radius-xl: 10px;
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-sm: 8px;

  --blur: 24px;
  --blur-modal: 32px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Microsoft YaHei", "微软雅黑", ui-monospace, "SF Mono", "Cascadia Code", Consolas,
    "Liberation Mono", Menlo, monospace;

  --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

  color-scheme: dark;
}

/* =========================================================================
   Light theme — same glass system, same accent colors, palette flipped.
   The base :root above is already the dark palette, so data-theme="dark"
   needs no block of its own; only "light" overrides anything. Toggled by
   setting data-theme on <html> (see assets/js/ui.js, initThemeToggle).
   ========================================================================= */
:root[data-theme="light"] {
  --void: #eef1f5;
  --void-2: #e4e8ee;
  --canvas-bg: #e9edf2;

  /* Same overlay system, dark tint instead of white — every hover/border/
     highlight rule above inherits this automatically. */
  --fg-tint: 15, 23, 32;

  --glass: rgba(255, 255, 255, 0.62);
  --glass-strong: rgba(255, 255, 255, 0.86);

  --text: #1b2129;
  --text-dim: #4a5568;
  --text-muted: #6b7684;

  --select: #cf222e;
  --select-soft: rgba(207, 34, 46, 0.12);
  --select-line: rgba(207, 34, 46, 0.38);

  color-scheme: light;
}

/* No stored preference yet: follow the OS setting instead of forcing dark. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --void: #eef1f5;
    --void-2: #e4e8ee;
    --canvas-bg: #e9edf2;
    --fg-tint: 15, 23, 32;
    --glass: rgba(255, 255, 255, 0.62);
    --glass-strong: rgba(255, 255, 255, 0.86);
    --text: #1b2129;
    --text-dim: #4a5568;
    --text-muted: #6b7684;
    --select: #cf222e;
    --select-soft: rgba(207, 34, 46, 0.12);
    --select-line: rgba(207, 34, 46, 0.38);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
  color: var(--text);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  /* A horizontal scrollbar on the page itself would be noise: the topbar
     scrolls internally, and with a dropdown open (.menu-open) it lets its
     own content overflow instead of clipping the panel. */
  overflow-x: hidden;
  background:
    radial-gradient(1200px 700px at 18% -10%, rgba(88, 166, 255, 0.05), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, rgba(0, 217, 255, 0.04), transparent 60%),
    var(--void);
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

::selection { background: rgba(88, 166, 255, 0.35); }

/* The `hidden` attribute is how ui.js shows/hides the search-clear button, the
   suggestion box, the board-manager modal and the conflict dialog. Several
   rules below set `display` on those same elements (flex, for layout), and an
   author rule beats the browser's built-in `[hidden]{display:none}` at equal
   specificity — so without this, `hidden` stopped actually hiding anything
   and the modal, once opened, could never be closed again. This restores it
   with top priority, ahead of every other display rule in this file. */
[hidden] { display: none !important; }

/* thin, translucent scrollbars everywhere glass content scrolls */
* { scrollbar-width: thin; scrollbar-color: rgba(var(--fg-tint),0.18) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(var(--fg-tint), 0.14);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(var(--fg-tint), 0.24); background-clip: padding-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* -- shared glass surface ------------------------------------------------ */

.glass {
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow:
    0 1px 0 var(--glass-highlight) inset,
    0 18px 40px -12px rgba(0, 0, 0, 0.55),
    0 2px 10px rgba(0, 0, 0, 0.35);
}

/* =========================================================================
   Layout — canvas fills the viewport; every chrome panel floats on top
   ========================================================================= */

.main { position: static; }

/* Sidebar width lives in one variable so the collapse handle can sit just
   outside the panel at every breakpoint. */
:root { --sb-w: 304px; }

.canvas-area {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--canvas-bg);
}

#boardCanvas { display: block; width: 100%; height: 100%; touch-action: none; }

/* =========================================================================
   Topbar
   ========================================================================= */

.topbar {
  position: fixed;
  top: 4px;
  left: 14px;
  right: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 50px;
  padding: 0 5px;
  /* Narrow windows scroll the bar sideways instead of wrapping — one row
     keeps the layout predictable. overflow-y hides the dropdown panels, so
     any open dropdown switches the bar to .menu-open (overflow: visible)
     for as long as it is up. */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}
/* Nothing in the bar may shrink below its content and get clipped; the
   search box is the one element allowed to give up width first. */
.topbar > * { flex: 0 0 auto; }
.topbar > .search-wrap,
.topbar > .boardsel-wrap { flex-shrink: 1; }
.topbar.menu-open { overflow: visible; }
.topbar {
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);

}

.logo {
  flex: 0 0 auto;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  padding: 0 14px 0 6px;
  margin-right: 4px;
  border-right: 1px solid var(--glass-border-soft);
  background: linear-gradient(135deg, #7cc4ff, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  white-space: nowrap;
}

.topbar .spacer { flex: 1 1 auto; min-width: 8px; }

/* Shared SVG icon sizing. The icons come from assets/icons.svg and inherit
   currentColor, so they follow each button's hover/active palette. */
.icon {
  display: block;
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  pointer-events: none;
}
.btn .icon, .seg-btn .icon { width: 14px; height: 14px; }
.seg-btn { gap: 6px; }
.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.tab .icon { width: 14px; height: 14px; }

/* Board picker: a glass chip that opens the same kind of dropdown the search
   box uses (`.suggest` panel + `.sg-item` rows), so the two pickers in the
   topbar look and behave alike. The native <select> popup could not be
   styled to match, which is why this is an input + panel. */
.boardsel-wrap {
  position: relative;
  flex: 0 1 260px;
  min-width: 120px;
  height: 34px;
}

.boardsel {
  width: 100%;
  height: 100%;
  padding: 0 54px 0 34px;
  border-radius: var(--radius-sm);
  background-color: var(--glass-soft);
  background-repeat: no-repeat, no-repeat;
  background-position: right 11px center, left 12px center;
  background-size: 10px 6px, 14px 14px;
  background-image:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="10" height="6"><path d="M0 0l5 6 5-6z" fill="%238b949e"/></svg>'),
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%238b949e" stroke-width="2.2"><rect x="3" y="4" width="18" height="16" rx="2"/><path d="M3 9h18M8 4v5M16 4v5"/></svg>');
  border: 1px solid var(--glass-border-soft);
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: text;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.boardsel:hover { background-color: var(--glass-soft-hover); border-color: var(--glass-border); }
.boardsel:focus,
.boardsel:focus-visible,
.boardsel[aria-expanded="true"] {
  outline: none;
  background-color: rgba(88, 166, 255, 0.08);
  border-color: rgba(88, 166, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}
.boardsel::placeholder { color: var(--text-muted); }
/* The chevron already lives at right:11px, so the clear button sits left of
   it instead of at the generic .search-clear position. */
.boardsel-wrap .search-clear { right: 26px; }

/* The panel itself comes from `.suggest`; these are only the sizing tweaks
   that anchor it to the chip instead of the search box. */
.boardsel-menu {
  width: 100%;
  min-width: 300px;
}

/* The board currently on the canvas, marked inside the list. */
.sg-item.board-item {
  /* Overrides the default single-row .sg-item layout: name gets its own
     full-width line, with the (now much shorter) meta line stacked below
     instead of squeezed onto the same line. */
  display: block;
}
.sg-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.sg-item.board-item .sg-name { display: block; }
.sg-item.board-item .sg-sub { display: block; margin-top: 2px; }
.sg-item.board-item.current .sg-name { color: var(--cyan); }
.sg-current-mark { flex: 0 0 auto; color: var(--cyan); font-size: 12px; }

/* =========================================================================
   Buttons — the redesigned control: frosted chip, lift on hover,
   press-and-ripple on click, glowing accent when toggled on.
   ========================================================================= */

.btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px;
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  color: var(--text-dim);
  background: var(--glass-soft);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 0 rgba(var(--fg-tint), 0.05) inset;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    background-color 0.16s var(--ease),
    border-color 0.16s var(--ease),
    color 0.16s var(--ease),
    box-shadow 0.16s var(--ease),
    transform 0.12s var(--ease);
}

.btn:hover {
  background: var(--glass-soft-hover);
  border-color: var(--glass-border);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 8px 18px -6px rgba(0, 0, 0, 0.5), 0 1px 0 rgba(var(--fg-tint), 0.06) inset;
}

.btn:active {
  transform: translateY(0) scale(0.96);
  transition-duration: 0.08s;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4) inset;
}

.btn:focus-visible {
  outline: 2px solid rgba(88, 166, 255, 0.6);
  outline-offset: 1px;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Toggled-on state (引脚 / 测试针 / 标注 / 连线) — reads as "live", so it gets
   the same cyan the canvas uses for a highlighted net rather than a neutral
   grey pressed-look. */
.btn.active {
  color: #eafff9;
  background: linear-gradient(180deg, rgba(0, 217, 255, 0.22), rgba(0, 217, 255, 0.1));
  border-color: rgba(0, 217, 255, 0.45);
  box-shadow:
    0 0 0 1px rgba(0, 217, 255, 0.2) inset,
    0 6px 18px -6px rgba(0, 217, 255, 0.35);
}
.btn.active:hover {
  background: linear-gradient(180deg, rgba(0, 217, 255, 0.3), rgba(0, 217, 255, 0.14));
  border-color: rgba(0, 217, 255, 0.6);
}

.btn.danger { color: #ffb4ad; border-color: rgba(248, 81, 73, 0.35); }
.btn.danger:hover { background: rgba(248, 81, 73, 0.14); border-color: rgba(248, 81, 73, 0.55); color: #fff; }

.btn.small { height: 27px; padding: 0 10px; font-size: 12px; border-radius: 7px; }

#btnManage { border-color: rgba(255, 140, 26, 0.3); }
#btnManage:hover { background: rgba(255, 140, 26, 0.14); border-color: rgba(255, 140, 26, 0.5); }

/* =========================================================================
   Segmented display-options group — 引脚 / 测试针 / 标注 / 连线 merged into one
   glass control instead of four separate floating chips. 标注 and 连线 are
   genuine split buttons: the main face still cycles through its states on
   click (and the L / C shortcuts still work), but the caret opens a small
   menu to jump straight to a state instead of clicking through the cycle
   blind. 引脚 / 测试针 are plain two-state segments, no caret needed.
   ========================================================================= */

.seg-group {
  display: flex;
  align-items: stretch;
  height: 34px;
  flex: 0 0 auto;
  background: var(--glass-soft);
  border: 1px solid var(--glass-border-soft);
  border-radius: var(--radius-sm);
  /* The caret dropdowns are positioned relative to their own .seg-split and
     need to escape this box — overflow:hidden here would clip them exactly
     like the topbar's overflow used to clip .suggest. */
  overflow: visible;
}

.seg-group > .seg-btn:not(:last-child),
.seg-group > .seg-split:not(:last-child) {
  border-right: 1px solid var(--glass-border-soft);
}

.seg-btn {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  padding: 0 12px;
  border: none;
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.1px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.16s var(--ease), color 0.16s var(--ease);
}
.seg-btn:hover { background: var(--glass-soft-hover); color: var(--text); }
.seg-btn:active { transform: scale(0.96); transition-duration: 0.08s; }
.seg-btn:focus-visible { outline: 2px solid rgba(88, 166, 255, 0.6); outline-offset: -2px; }

.seg-btn.active {
  color: #eafff9;
  background: linear-gradient(180deg, rgba(0, 217, 255, 0.22), rgba(0, 217, 255, 0.1));
}
.seg-btn.active:hover { background: linear-gradient(180deg, rgba(0, 217, 255, 0.3), rgba(0, 217, 255, 0.14)); }
.seg-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Momentary click confirmation for actions with no persistent on/off state of
   their own (翻板面, 旋转) — a quick teal flash that fades on its own, restarted
   from scratch by _flashButton() on every click. */
.seg-btn.flash { animation: seg-flash 0.5s var(--ease); }
@keyframes seg-flash {
  0% { background: rgba(0, 217, 255, 0.4); color: #eafff9; }
  100% { background: transparent; color: var(--text-dim); }
}

/* Rounds only the outer corners of each group, matching .seg-group's own
   radius — works for either a plain segment or a split segment's .seg-main
   sitting at the end, regardless of which buttons a given group holds. */
.seg-group > .seg-btn:first-child,
.seg-group > .seg-split:first-child .seg-main {
  border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm);
}
.seg-group > .seg-btn:last-child,
.seg-group > .seg-split:last-child .seg-main {
  border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm);
}

.seg-split { position: relative; display: flex; align-items: stretch; }

/* The split segment's own face is the trigger now (no separate caret — one
   fewer 22px segment per control, and one fewer thing to click precisely).
   The chevron is just a visual hint that it opens something; it rotates and
   goes teal while the menu is open, same language as the caret used to speak. */
.seg-main::after {
  content: '⌄';
  margin-left: 7px;
  font-size: 9px;
  color: var(--text-muted);
  display: inline-block;
  transition: color 0.15s var(--ease), transform 0.15s var(--ease);
}
.seg-main:hover::after { color: var(--text-dim); }
.seg-main[aria-expanded="true"] {
  background: rgba(0, 217, 255, 0.16);
  color: #eafff9;
}
.seg-main[aria-expanded="true"]::after { color: var(--cyan); transform: rotate(180deg); }

.seg-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 118px;
  z-index: 50;
  padding: 5px;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.65), 0 1px 0 var(--glass-highlight) inset;
}

.seg-menu-item {
  position: relative;
  overflow: hidden;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-dim);
  cursor: pointer;
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}
.seg-menu-item:hover { background: var(--glass-soft-hover); color: var(--text); }
.seg-menu-item.active { color: var(--cyan); background: rgba(0, 217, 255, 0.12); }

/* =========================================================================
   "更多" overflow menu
   -------------------------------------------------------------------------
   Below the topbar breakpoints the view / display groups leave the row and
   continue here, so the bar never needs a horizontal scrollbar. Same glass
   panel and row anatomy as .seg-menu, only taller and grouped.
   ========================================================================= */

.more-wrap { position: relative; display: block; flex: 0 0 auto; }

.more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 208px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
  z-index: 55;
  padding: 6px;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.65), 0 1px 0 var(--glass-highlight) inset;
}

.more-group-label {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.more-item {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}
.more-item:hover { background: var(--glass-soft-hover); color: var(--text); }
.more-item .more-label { flex: 1 1 auto; }
.more-item.active { color: var(--cyan); background: rgba(0, 217, 255, 0.12); }
.more-item.active::after {
  content: '✓';
  font-size: 11px;
  color: var(--cyan);
}

/* Click/press ripple — spawned by assets/js/fx.js on pointerdown. Requires
   the target to be position:relative + overflow:hidden, which every
   .btn / .tab / list row already is. */
.ripple {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(var(--fg-tint), 0.55), rgba(var(--fg-tint), 0) 70%);
  transform: scale(0);
  opacity: 1;
  pointer-events: none;
  animation: ripple-expand 0.55s var(--ease) forwards;
  mix-blend-mode: screen;
}
@keyframes ripple-expand {
  to { transform: scale(1); opacity: 0; }
}

/* =========================================================================
   Search
   ========================================================================= */

.search-wrap {
  position: relative;
  flex: 0 1 320px;
  min-width: 140px;
  height: 34px;
}

.search {
  width: 100%;
  height: 100%;
  padding: 0 30px 0 30px;
  border-radius: var(--radius-sm);
  background-color: var(--glass-soft);
  background-repeat: no-repeat;
  background-position: 10px center;
  background-size: 14px 14px;
  background-image:
    url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="%238b949e" stroke-width="2.4"><circle cx="11" cy="11" r="7"/><path d="M21 21l-4.3-4.3"/></svg>');
  border: 1px solid var(--glass-border-soft);
  color: var(--text);
  font-size: 13px;
  transition: background-color 0.16s var(--ease), border-color 0.16s var(--ease), box-shadow 0.16s var(--ease);
}
.search::placeholder { color: var(--text-muted); }
.search:hover { background-color: var(--glass-soft-hover); border-color: var(--glass-border); }
.search:focus {
  outline: none;
  background-color: rgba(88, 166, 255, 0.08);
  border-color: rgba(88, 166, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(var(--fg-tint), 0.08);
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.search-clear:hover { background: rgba(248, 81, 73, 0.25); color: #fff; }

.suggest {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(340px, 90vw);
  max-height: min(60vh, 480px);
  overflow-y: auto;
  z-index: 50;
  padding: 6px;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 20px 44px -14px rgba(0, 0, 0, 0.65), 0 1px 0 var(--glass-highlight) inset;
}

.sg-group {
  padding: 8px 10px 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.sg-item {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color 0.12s var(--ease);
}
.sg-item:hover, .sg-item.active { background: var(--glass-soft-hover); }

.sg-badge {
  flex: 0 0 auto;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 5px;
  background: rgba(var(--fg-tint), 0.08);
  color: var(--text-muted);
}
.sg-badge.kind-part { color: var(--blue); background: rgba(88, 166, 255, 0.14); }
.sg-badge.kind-net { color: var(--select); background: rgba(255, 77, 79, 0.14); }
.sg-badge.kind-nail { color: var(--amber); background: rgba(210, 153, 34, 0.16); }
.sg-badge.kind-board { color: var(--orange); background: rgba(255, 140, 26, 0.16); }
.sg-badge.side { color: var(--text-dim); }
.sg-badge.recent {
  color: #7fe9ff;
  background: rgba(0, 217, 255, 0.16);
}

.sg-name { flex: 1 1 auto; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sg-sub { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

/* =========================================================================
   Sidebar
   ========================================================================= */

.sidebar {
  position: fixed;
  top: 80px;
  left: 4px;
  bottom: 70px;
  width: var(--sb-w);
  z-index: 30;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  transition: transform 0.24s var(--ease), opacity 0.24s var(--ease);
}
/* Collapsed: the panel slides off-screen; the handle (a sibling, not a child)
   stays behind and flips its arrow. */
body.sb-collapsed .sidebar {
  transform: translateX(calc(-1 * var(--sb-w) - 24px));
  opacity: 0;
  pointer-events: none;
}

/* Drawer handle: parked just outside the panel's right edge, vertically
   centred on the tabs row. Fixed positioning + the shared width variable
   keep it glued to the edge at every breakpoint. */
.sb-handle {
  position: fixed;
  top: 92px;
  left: calc(14px + var(--sb-w) + 6px);
  z-index: 31;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: left 0.24s var(--ease), background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.sb-handle:hover { background: var(--glass-soft-hover); color: var(--text); }
body.sb-collapsed .sb-handle { left: 14px; }

.tabs {
  flex: 0 0 auto;
  display: flex;
  padding: 10px 10px 0;
  gap: 4px;
  border-bottom: 1px solid var(--glass-border-soft);
}

.tab {
  position: relative;
  overflow: hidden;
  flex: 1 1 0;
  text-align: center;
  padding: 9px 6px 11px;
  font-size: 12.5px;
  color: var(--text-muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  cursor: pointer;
  transition: color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.tab::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transform: scaleX(0);
  transition: transform 0.2s var(--ease);
}
.tab:hover { color: var(--text); background: rgba(var(--fg-tint), 0.04); }
.tab.active { color: var(--text); }
.tab.active::after { transform: scaleX(1); }

/* Sidebar search: docks under the tabs and filters that tab's own list.
   Each tab remembers its own keyword, so the box text follows the switch. */
.sb-search {
  position: relative;
  flex: 0 0 auto;
  margin: 8px 10px 0;
}
.sb-search .search {
  height: 30px;
  padding-right: 30px;
  font-size: 12.5px;
}
.sb-search .suggest {
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  width: auto;
  max-height: 240px;
}

.tab-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.info-panel {
  flex: 0 1 auto;
  max-height: 46%;
  overflow-y: auto;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--glass-border-soft);
  background: rgba(var(--fg-tint), 0.012);
}

.info-panel h4 {
  margin: 14px 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--text-muted);
}
.info-panel h4:first-child { margin-top: 0; }

.row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  font-size: 12.5px;
  border-bottom: 1px dashed var(--glass-border-soft);
}
.row span:first-child { color: var(--text-muted); }
.row span:last-child { font-family: var(--font-mono); color: var(--text); text-align: right; word-break: break-all; }

.hint {
  margin-top: 8px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-dim);
  background: rgba(88, 166, 255, 0.08);
  border: 1px solid rgba(88, 166, 255, 0.2);
  border-radius: var(--radius-sm);
}

.empty {
  padding: 18px 4px;
  font-size: 12.5px;
  color: var(--text-muted);
  text-align: center;
}

.btn-row { margin-top: 10px; display: flex; gap: 8px; }

/* -- list rows shared by parts/nets/nails/pins tabs ---------------------- */

.list-filter {
  margin: 2px 4px 8px;
  padding: 6px 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.list-item, .pin-item {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: 3px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color 0.14s var(--ease), border-color 0.14s var(--ease);
}
.list-item:hover, .pin-item:hover { background: var(--glass-soft-hover); }
.list-item.active, .pin-item.active {
  background: var(--select-soft);
  border-color: var(--select-line);
}

.pin-name { flex: 1 1 auto; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-net { flex: 0 0 auto; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }

.list-empty {
  padding: 18px 4px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
}
.list-more {
  padding: 8px 4px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
}

.name { color: var(--text); }
.meta { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.side {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 5px;
  background: rgba(var(--fg-tint), 0.08);
  color: var(--text-dim);
}

/* =========================================================================
   Bottom status bar
   ========================================================================= */

.bottombar {
  position: fixed;
  bottom: 2px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px;
  font-size: 12px;
  color: var(--text-dim);
  background: var(--glass);
  backdrop-filter: blur(var(--blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(160%);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  white-space: nowrap;
}

.bb-item { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.bb-item span { font-family: var(--font-mono); color: var(--text); }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.18);
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.dot.B { background: var(--amber); box-shadow: 0 0 0 3px rgba(210, 153, 34, 0.2); }

/* =========================================================================
   Tooltip
   ========================================================================= */

.tooltip {
  position: absolute;
  z-index: 25;
  display: none;
  min-width: 140px;
  max-width: 260px;
  padding: 9px 11px;
  pointer-events: none;
  font-size: 12px;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px -10px rgba(0, 0, 0, 0.6), 0 1px 0 var(--glass-highlight) inset;
}
.tt-title { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.tt-row { color: var(--text-muted); }
.tt-row span { font-family: var(--font-mono); color: var(--text-dim); }

/* =========================================================================
   Loading overlay
   ========================================================================= */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: radial-gradient(900px 600px at 50% 40%, rgba(8, 8, 10, 0.72), rgba(2, 2, 3, 0.9));
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.loading-overlay .text {
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-dim);
}

/* The <noscript> fallback reuses .loading-overlay, but that rule defaults to
   display:none for the JS-driven overlay. Without this line the "enable
   JavaScript" message was rendered but invisible — a blank page with no
   explanation at all. */
noscript .loading-overlay { display: flex; }
.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto;
  border-radius: 50%;
  border: 3px solid rgba(var(--fg-tint), 0.12);
  border-top-color: var(--cyan);
  animation: spin 0.85s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   Board manager modal + conflict dialog
   ========================================================================= */

.bm-modal, .conflict-dialog {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(2, 2, 3, 0.62);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

/* Conflict/password dialogs stack above the manager/trash modals: they are
   summoned *from inside* those modals, and with equal z-index the later DOM
   node (the modal) would otherwise paint over the dialog. */
.conflict-dialog { z-index: 120; }

.bm-panel {
  width: min(560px, 92vw);
  /* Fixed height so the modal doesn't grow with the list — the list area
     scrolls internally instead, keeping the toolbar / drop-zone / status
     line pinned. */
  height: min(720px, 88vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-modal)) saturate(170%);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 70px -18px rgba(0, 0, 0, 0.7), 0 1px 0 var(--glass-highlight) inset;
}

.bm-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--glass-border-soft);
}
/* Header controls (e.g. the trash modal's "empty trash" + close) stay on one
   row instead of stretching the title. */
.bm-header-actions { display: flex; align-items: center; gap: 8px; }
.bm-title { font-size: 15px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.bm-count {
  font-size: 12px; font-weight: 500; color: var(--text-dim);
  background: rgba(var(--fg-tint),0.08); padding: 1px 8px; border-radius: 999px;
}

.bm-body { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; padding: 16px 18px; }

/* Toolbar above the drop zone: board list search + admin-mode switch. The
   search reuses the topbar `.search` look; the switch is a checkbox styled
   as a slider — admin mode is off by default so stray clicks stay read-only. */
.bm-toolbar { display: flex; align-items: center; gap: 10px; height: 34px; margin-bottom: 14px; }
.bm-search-wrap { position: relative; flex: 1 1 auto; height: 100%; min-width: 0; }
.bm-search { width: 100%; height: 100%; }
.bm-toggle { display: inline-flex; align-items: center; gap: 8px; flex: 0 0 auto; font-size: 12px; color: var(--text-dim); cursor: pointer; user-select: none; }
.bm-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.bm-switch {
  position: relative;
  width: 34px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(var(--fg-tint), 0.14);
  transition: background-color 0.16s var(--ease);
}
.bm-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.16s var(--ease);
}
.bm-toggle input:checked + .bm-switch { background: rgba(0, 217, 255, 0.55); }
.bm-toggle input:checked + .bm-switch::after { transform: translateX(16px); }
.bm-toggle input:focus-visible + .bm-switch { box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.25); }

/* Typing-confirm input inside the delete dialog. */
.bm-confirm-input {
  width: 100%;
  height: 34px;
  margin: 12px 0 16px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border-soft);
  background-color: var(--glass-soft);
  color: var(--text);
  font-size: 13px;
}
.bm-confirm-input:focus {
  outline: none;
  border-color: rgba(248, 81, 73, 0.6);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.15);
}

/* Small muted note inside the trash modal (purge needs admin mode). */
.trash-hint { margin-bottom: 10px; font-size: 12px; color: var(--text-muted); }

.bm-drop {
  position: relative;
  padding: 26px 16px;
  text-align: center;
  border: 1.5px dashed var(--glass-border);
  border-radius: var(--radius-lg);
  background: rgba(var(--fg-tint), 0.02);
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease);
}
.bm-drop.dragover {
  border-color: rgba(88, 166, 255, 0.7);
  background: rgba(88, 166, 255, 0.08);
}
.bm-drop-text { font-size: 13.5px; color: var(--text); margin-bottom: 4px; }
.bm-drop-sub { font-size: 11.5px; color: var(--text-muted); margin-bottom: 14px; }

.bm-status {
  position: relative;
  margin-top: 10px;
  height: 40px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: rgba(var(--fg-tint), 0.04);
  color: var(--text-muted);
}
.bm-status.bm-busy { color: var(--blue); }
.bm-status.bm-ok { color: var(--cyan); }
.bm-status.bm-error { color: var(--red); }
.bm-bar {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
  background: linear-gradient(90deg, rgba(88, 166, 255, 0.35), rgba(0, 217, 255, 0.35));
  transition: width 0.2s var(--ease);
}

.bm-list { margin-top: 14px; flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.bm-empty { padding: 22px 4px; text-align: center; font-size: 12.5px; color: var(--text-muted); }

/* Pagination bar pinned below the scrollable list. Only renders when the
   filtered result set has more than one page. */
.bm-pager {
  flex: 0 0 auto;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
}
.bm-pager-info { white-space: nowrap; }
.bm-pager-btns { display: flex; gap: 6px; }
.bm-pager-btns .btn { min-width: 64px; }
.bm-pager-btns .btn:disabled { opacity: 0.4; cursor: not-allowed; }

.bm-row {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(var(--fg-tint), 0.03);
  border: 1px solid var(--glass-border-soft);
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.bm-row:hover { background: rgba(var(--fg-tint), 0.055); }
.bm-row.current { border-color: rgba(0, 217, 255, 0.4); background: rgba(0, 217, 255, 0.06); }

.bm-head { display: flex; align-items: center; gap: 8px; }
.bm-name { font-size: 13.5px; font-weight: 500; }
.bm-cur {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 6px;
  color: #eafff9;
  background: rgba(0, 217, 255, 0.18);
  border: 1px solid rgba(0, 217, 255, 0.4);
}
.bm-meta { margin-top: 3px; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.bm-actions { margin-top: 9px; display: flex; gap: 6px; }

.conflict-panel {
  width: min(400px, 90vw);
  padding: 20px;
  background: var(--glass-strong);
  backdrop-filter: blur(var(--blur-modal)) saturate(170%);
  -webkit-backdrop-filter: blur(var(--blur-modal)) saturate(170%);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 30px 70px -18px rgba(0, 0, 0, 0.7), 0 1px 0 var(--glass-highlight) inset;
}
.conflict-title { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.conflict-msg { font-size: 13px; color: var(--text-dim); line-height: 1.6; margin-bottom: 18px; }
.conflict-name { color: var(--text); font-family: var(--font-mono); }
.conflict-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* =========================================================================
   Responsive
   ========================================================================= */

/* ---- Responsive ---------------------------------------------------------
   The topbar is one row and never scrolls sideways: controls drop out of it
   in order of how rarely they are reached, and from 1400 down the "更多"
   menu carries the ones that left. Labels collapse to icon-only before a
   whole control disappears, so nothing moves twice in a row. */

/* 1366/1280-class laptops: view transforms keep their buttons, lose words. */
@media (max-width: 1600px) {
  #viewControls .label-full { display: none; }
}

/* Tablets and small laptops: view transforms move into 更多. */
@media (max-width: 1400px) {
  #viewControls { display: none; }
}

/* Display toggles always live in 更多 now — the buttons stay in the DOM (the
   keyboard shortcuts and the state sync still drive them) but never take top
   bar space at any width. */
#displayControls { display: none; }

/* The standalone 管理 / 主题 / 重置 buttons are the last to leave the row;
   all three also live in 更多, so nothing becomes unreachable. */
@media (max-width: 900px) {
  #btnManage, #btnTheme, #btnReset { display: none; }
  .more-wrap .label-full { display: none; }
  .more-wrap .btn { padding: 0 10px; }
}

@media (max-width: 1100px) {
  :root { --sb-w: 280px; }
}

/* Short viewports: the sidebar keeps its chrome compact so the list itself
   still gets the majority of the height. */
@media (max-height: 720px) {
  .sidebar { top: 66px; bottom: 56px; }
  .sb-handle { top: 78px; }
  .tabs { padding-top: 6px; }
  .tab { padding: 7px 6px 9px; }
}

@media (max-width: 860px) {
  :root { --sb-w: min(320px, calc(100vw - 28px)); }
  .sidebar { bottom: 62px; }
  .logo { display: none; }
  .search-wrap { flex-basis: 180px; }
}

@media (max-width: 620px) {
  .topbar {
    top: 10px; left: 10px; right: 10px; height: 48px;
    padding: 0 10px; border-radius: var(--radius-lg);
  }
  .sidebar { top: 76px; left: 10px; right: auto; width: var(--sb-w); bottom: 56px; border-radius: var(--radius-lg); }
  .sb-handle { top: 58px; }
  .bottombar { left: 10px; right: 10px; bottom: 10px; gap: 14px; border-radius: var(--radius-md); }
  .btn span.label-full { display: none; }
}

/* ---- Full-screen drag-and-drop overlay -------------------------------
   Shown whenever a folder is dragged anywhere over the page, so boards
   can be uploaded without opening the manager modal first. Fixed above
   everything (z-index just below the board-manager modal so a drop that
   lands on the open modal is still handled by its own zone). */
.global-drop-overlay {
  position: fixed; inset: 0; z-index: 105;
  display: flex; align-items: center; justify-content: center;
  background: rgba(3, 3, 4, 0.78);
  backdrop-filter: blur(3px);
  animation: gdo-fade 0.12s ease-out;
}
@keyframes gdo-fade { from { opacity: 0; } to { opacity: 1; } }
.gdo-panel {
  padding: 44px 56px;
  border: 2px dashed rgba(88, 166, 255, 0.7);
  border-radius: var(--radius-lg);
  background: rgba(10, 10, 12, 0.92);
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
}
.gdo-icon {
  font-size: 42px; line-height: 1; margin-bottom: 12px;
  color: rgba(88, 166, 255, 0.9);
}
.gdo-text { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.gdo-sub { font-size: 12.5px; color: var(--text-muted); }

/* Dev-only performance overlay (F9 or ?perf=1). Hidden unless WBV.PerfHud
   creates it, so it has no effect on normal use. */
.perf-hud {
  position: fixed;
  right: 10px;
  bottom: 10px;
  z-index: 9999;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #9ae6b4;
  font: 11px/1.4 ui-monospace, Consolas, monospace;
  pointer-events: none;
  white-space: nowrap;
}

/* Minimap / overview map: whole-board thumbnail with the current viewport. */
.minimap {
  position: absolute;
  right: 16px;
  bottom: 12px;
  width: 180px;
  height: 140px;
  z-index: 8;
  overflow: hidden;
  border: 1px solid rgba(125, 133, 144, 0.35);
  border-radius: 8px;
  background: var(--canvas-bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  cursor: crosshair;
  touch-action: none;
  transform-origin: bottom right;
  transition: transform 0.18s ease, border-color 0.18s ease,
              box-shadow 0.18s ease, bottom 0.22s ease;
  will-change: transform;
}
.minimap[hidden] { display: none; }
/* The dev HUD lives in the bottom-right corner; make room for it. */
body.hud-on .minimap {
  bottom: 38px;
}
.minimap canvas {
  display: block;
  width: 100%;
  height: 100%;
  transition: filter 0.18s ease;
}
@media (hover: hover) {
  .minimap:hover {
    z-index: 9;
    transform: scale(1.5);
    border-color: rgba(88, 166, 255, 0.65);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.4);
  }
  .minimap:hover canvas {
    filter: contrast(1.18) brightness(1.06);
  }
}
@media (max-width: 720px) {
  .minimap { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .minimap, .minimap canvas { transition: none; }
  .minimap:hover { transform: none; }
}
