/* Roles de color — Apple Liquid Glass / Vibrancy System */
:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --page: #f2f2ee;
  --text-primary: #1d1d1f;
  --text-secondary: #515154;
  --text-muted: #6e6e73;
  --gridline: #e5e5ea;
  --baseline: #c6c6c8;
  --border: rgba(0, 0, 0, 0.09);
  --hud-bg: rgba(255, 255, 255, 0.72);
  --hud-bg-hover: rgba(255, 255, 255, 0.88);
  --hud-border: rgba(0, 0, 0, 0.08);
  --hud-border-inner: inset 0 1px 0.5px rgba(255, 255, 255, 0.9), inset 0 -1px 0.5px rgba(0, 0, 0, 0.03);
  --hud-shadow: 0 10px 32px -4px rgba(0, 0, 0, 0.08), 0 2px 8px -2px rgba(0, 0, 0, 0.04);
  --hud-shadow-lg: 0 18px 48px -6px rgba(0, 0, 0, 0.14), 0 4px 14px -2px rgba(0, 0, 0, 0.06);
  --pill-active-bg: rgba(0, 0, 0, 0.08);
  --pill-active-color: #1d1d1f;
  --other: #6e6e73;
  --accent: #ff8000;
  /* Procedencia de un resultado del buscador: colección cloud o marcadores del navegador. */
  --source-collection: #38bdf8;
  --source-bookmarks: #fb923c;
  --series-1: #0071e3;
  --series-2: #ff6433;
  --series-3: #28cd41;
  --series-4: #ff9f0a;
  --series-5: #ff375f;
  --series-6: #30d158;
  --series-7: #5e5ce6;
  --series-8: #ff453a;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-1: #1c1c1e;
    --page: #000000;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-muted: #86868b;
    --gridline: #2c2c2e;
    --baseline: #3a3a3c;
    --border: rgba(255, 255, 255, 0.1);
    --hud-bg: rgba(28, 28, 30, 0.72);
    --hud-bg-hover: rgba(44, 44, 46, 0.82);
    --hud-border: rgba(255, 255, 255, 0.12);
    --hud-border-inner: inset 0 1px 0.5px rgba(255, 255, 255, 0.18), inset 0 -1px 0.5px rgba(0, 0, 0, 0.4);
    --hud-shadow: 0 12px 36px -4px rgba(0, 0, 0, 0.55), 0 2px 10px -2px rgba(0, 0, 0, 0.35);
    --hud-shadow-lg: 0 20px 54px -6px rgba(0, 0, 0, 0.7), 0 4px 16px -2px rgba(0, 0, 0, 0.45);
    --pill-active-bg: rgba(255, 255, 255, 0.14);
    --pill-active-color: #ffffff;
    --other: #86868b;
    --accent: #ff9000;
    --series-1: #0a84ff;
    --series-2: #ff6433;
    --series-3: #30d158;
    --series-4: #ffd60a;
    --series-5: #ff375f;
    --series-6: #32d74b;
    --series-7: #bf5af2;
    --series-8: #ff453a;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

html, body {
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* --- Floating HUD Elements (Apple Vision / macOS Floating Islands) --- */
.hud-capsule {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  background: var(--hud-bg);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--hud-border);
  box-shadow: var(--hud-shadow), var(--hud-border-inner);
  border-radius: 999px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.hud-capsule:hover {
  background: var(--hud-bg-hover);
}

.hud-panel {
  pointer-events: auto;
  background: var(--hud-bg);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--hud-border);
  box-shadow: var(--hud-shadow), var(--hud-border-inner);
  border-radius: 14px;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}
.hud-panel:hover {
  background: var(--hud-bg-hover);
}

#topbar {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  justify-content: center;
  align-items: center;
  pointer-events: none;
}
#topbar > * {
  pointer-events: auto;
}

/* Chakra Petch, empaquetada: el manifest declara que no se carga código ni
   recursos remotos, así que la fuente viaja en la extensión. Solo el peso 600
   y el subconjunto latino — 11 KB. SIL Open Font License 1.1. */
@font-face {
  font-family: 'Chakra Petch';
  src: url('fonts/chakra-petch-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: block;
}

/* El logotipo: proporciones en `em` para que todo escale con el font-size.
   El símbolo mide 0.73 em de ancho por 1.16 de alto y baja 0.025 em sobre la
   línea base, igual que en el resto del material de marca. */
.brand-logo {
  display: inline-flex;
  align-items: center;
  font-family: 'Chakra Petch', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1;
  color: var(--text-primary);
  white-space: nowrap;
  font-synthesis: none;
}

.brand-mark {
  width: 0.73em;
  height: 1.16em;
  margin: 0 0.015em 0 0.09em;
  flex: 0 0 auto;
  overflow: visible;
  translate: 0 0.025em;
}

/* --- Omnibar Capsule Search --- */
#searchwrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px 4px 8px;
}
#searchwrap:focus-within {
  box-shadow: var(--hud-shadow-lg), var(--hud-border-inner), 0 0 0 1px color-mix(in srgb, var(--accent) 40%, var(--hud-border));
}

/* Solid monta la píldora aquí dentro: el host no participa en el flex de la cápsula. */
#search-scope-host {
  display: contents;
}

.search-scope-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  background: color-mix(in srgb, var(--text-primary) 5%, transparent);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s, color 0.15s, background 0.15s, transform 0.1s ease;
  white-space: nowrap;
  flex: none;
}
.search-scope-pill:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
}
.search-scope-pill:active {
  transform: scale(0.96);
}
.search-scope-pill.all {
  border-color: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}
.search-scope-pill.custom {
  border-color: color-mix(in srgb, var(--source-collection) 35%, transparent);
  color: var(--source-collection);
  background: color-mix(in srgb, var(--source-collection) 10%, transparent);
}

#results {
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 25;
  width: min(560px, 88vw);
  max-height: 62vh;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--hud-bg);
  backdrop-filter: blur(36px) saturate(200%);
  -webkit-backdrop-filter: blur(36px) saturate(200%);
  border: 1px solid var(--hud-border);
  border-radius: 18px;
  box-shadow: var(--hud-shadow-lg), var(--hud-border-inner);
}
#results li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12.5px;
  transition: background 0.1s ease;
}
#results li.sel { background: color-mix(in srgb, var(--text-primary) 10%, transparent); }
#results .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
/* el icono de un comando ocupa el hueco del punto, sin ser un punto */
#results .dot.cmd { width: auto; min-width: 8px; background: none; font-size: 12px; text-align: center; }
#results .rt {
  flex: 1;
  min-width: 0;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#results .kind {
  flex: none;
  font-size: 10.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 7px;
}
#results .kind.source-badge {
  color: #0284c7;
  border-color: color-mix(in srgb, currentColor 35%, var(--border));
  background: color-mix(in srgb, currentColor 8%, transparent);
  font-weight: 500;
}
#results .kind.bm-badge {
  color: #c2410c;
  border-color: color-mix(in srgb, currentColor 35%, var(--border));
  background: color-mix(in srgb, currentColor 8%, transparent);
}
@media (prefers-color-scheme: dark) {
  #results .kind.source-badge { color: var(--source-collection); }
  #results .kind.bm-badge { color: var(--source-bookmarks); }
}

#search {
  width: 320px;
  max-width: 44vw;
  flex: none;
  padding: 6px 12px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  outline: none;
  transition: width 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
#search:focus {
  width: 440px;
  max-width: 55vw;
}

/* --- Left Floating Islands Stack (Anchored to Bottom-Left) --- */
.hud-left-stack {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  inset-inline-start: max(20px, env(safe-area-inset-left));
  z-index: 20;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 215px;
}

.hud-left-stack > * {
  pointer-events: auto;
  width: 100%;
}

.hud-brand-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px 7px 14px;
}
.hud-brand-panel .hud-brand-mark {
  user-select: none;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.hud-brand-panel #settings-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.hud-brand-panel #settings-btn:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}
.hud-brand-panel #settings-btn:active {
  transform: scale(0.92);
}
.hud-brand-panel .settings-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.hud-vertical-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  padding: 5px;
  user-select: none;
}
.hud-vertical-panel:not(:has(button:not([hidden]))) {
  display: none;
}

#windows, #views, #sources, #layouts, #legend {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: 100%;
}

.hud-filter-sep {
  height: 1px;
  background: var(--border);
  margin: 3px 5px;
  flex: none;
}
#hud-windows-island:has(#tabcount[hidden]) #tabcount-sep,
#hud-windows-island:not(:has(#windows button:not([hidden]))) #tabcount-sep {
  display: none;
}

/* `.views-source` es el selector de ORIGEN; `.views-picker`, el de vistas
   guardadas. Comparten forma —ancla de un desplegable inline— y nada más: darles
   la misma clase hacía que un selector por `.views-source` alcanzara los dos. */
.views-source,
.views-picker {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  gap: 2px;
}
.views-source > button:first-child,
.views-picker > button:first-child {
  flex: 1;
  min-width: 0;
}

.views-menu {
  position: absolute;
  bottom: 0;
  inset-inline-start: calc(100% + 8px);
  z-index: 95;
  min-width: 220px;
  max-height: min(420px, calc(100vh - 80px));
  overflow-y: auto;
  overscroll-behavior: contain;
  display: grid;
  gap: 3px;
  padding: 6px;
  background: var(--hud-bg);
  backdrop-filter: blur(36px) saturate(200%);
  -webkit-backdrop-filter: blur(36px) saturate(200%);
  border: 1px solid var(--hud-border);
  border-radius: 16px;
  box-shadow: var(--hud-shadow-lg), var(--hud-border-inner);
}
.views-menu button {
  display: flex;
  align-items: center;
  text-align: start;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
}
.views-menu button:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}
.views-menu button.active {
  color: var(--pill-active-color);
  background: var(--pill-active-bg);
  font-weight: 600;
}
.views-menu button:disabled {
  color: var(--text-muted);
  cursor: not-allowed;
  opacity: 0.48;
}
.views-menu button:disabled:hover {
  color: var(--text-muted);
  background: transparent;
}
.layout-icon {
  display: inline-flex;
  width: 16px;
  flex: none;
  align-items: center;
  justify-content: center;
  color: currentColor;
  font-size: 14px;
  line-height: 1;
}
.layout-picker .chip-sub {
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.views-menu-sep {
  height: 1px;
  margin: 3px 6px;
  background: var(--border);
}
.views-menu-empty {
  padding: 6px 11px;
  font-size: 12px;
  color: var(--text-muted);
}
.views-menu button.danger {
  color: #d03b3b;
}
/* El punto acompaña al nombre de cada vista con borrador; el nombre accesible
   evita que el estado dependa solo del color. */
.view-dirty {
  flex: none;
  margin-inline-start: 4px;
  font-size: 9px;
  line-height: 1;
  color: var(--accent);
}
.view-missing {
  flex: none;
  margin-inline-start: 4px;
  font-size: 11px;
  line-height: 1;
  color: #d98b1f;
}
/* `.chip-row` es la misma fila fuera de un menú: el navbar lista ahí las sesiones guardadas. */
.views-menu-row,
.chip-row { display: flex; gap: 2px; align-items: center; }
.views-menu-row > button:first-child,
.chip-row > button:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.views-menu .pin,
.hud-vertical-panel .pin {
  flex: none;
  padding: 4px 8px;
  font-size: 11px;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.35;
  filter: grayscale(1);
  transition: opacity 0.15s ease, filter 0.15s ease, background 0.15s ease;
}
.views-menu .pin:hover,
.hud-vertical-panel .pin:hover {
  opacity: 0.7;
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}
.views-menu .pin.active,
.hud-vertical-panel .pin.active {
  opacity: 1;
  filter: none;
}
.chip-delete-btn,
.views-menu button.chip-delete-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  color: #c9342f;
  background: color-mix(in srgb, #c9342f 9%, transparent);
  border: 0;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.78;
  transition: opacity 0.15s ease, color 0.15s ease, background 0.15s ease;
  align-self: center;
}
.views-menu-row:hover .chip-delete-btn,
.chip-row:hover .chip-delete-btn {
  opacity: 1;
}
.chip-delete-btn:hover,
.views-menu button.chip-delete-btn:hover {
  opacity: 1;
  color: #b4231f;
  background: color-mix(in srgb, #c9342f 18%, transparent);
}

@media (prefers-color-scheme: dark) {
  .chip-delete-btn,
  .views-menu button.chip-delete-btn { color: #ff6961; }
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 11px;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  text-align: start;
  justify-content: flex-start;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.chip:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 8%, transparent);
}
.chip:active {
  transform: scale(0.97);
}
.chip.active {
  color: var(--pill-active-color);
  background: var(--pill-active-bg);
  font-weight: 600;
}
/* Mientras se mira el historial, su chip se tiñe de acento y lleva la ✕ que
   vuelve adonde se estaba. El texto mezcla el acento con el color de texto
   para que se lea sobre el tinte en los dos temas. */
.history-chip {
  display: flex;
  align-items: center;
  gap: 2px;
  width: 100%;
  border-radius: 10px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.history-chip > .chip {
  flex: 1;
  min-width: 0;
}
.history-chip.active {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--accent);
}
.history-chip.active > .chip,
.history-chip.active > .chip:hover {
  color: color-mix(in srgb, var(--accent) 62%, var(--text-primary));
  background: transparent;
}
.history-exit {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-inline-end: 4px;
  padding: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  color: color-mix(in srgb, var(--accent) 62%, var(--text-primary));
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease, transform 0.1s ease;
}
.history-exit:hover {
  color: #fff;
  background: var(--accent);
}
.history-exit:active {
  transform: scale(0.92);
}
.history-exit:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.chip.warn {
  color: #ff453a;
  background: color-mix(in srgb, #ff453a 12%, transparent);
}
.chip .chip-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-inline-start: 4px;
  flex: none;
}
.chip:hover .chip-sub,
.chip.active .chip-sub {
  color: var(--text-secondary);
}
.chip-arrow {
  margin-inline-start: auto;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  flex: none;
  line-height: 1;
}
.chip.active .chip-arrow {
  color: currentColor;
}
.chip-kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  margin-inline-start: auto;
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-primary) 8%, var(--surface-1));
  border: 1px solid var(--border);
  border-radius: 5px;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
  line-height: 1;
  flex: none;
}
.chip.active .chip-kbd {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 14%, transparent);
  border-color: color-mix(in srgb, var(--text-primary) 15%, transparent);
}
.chip .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
}
.chip .n { color: var(--text-muted); font-size: 10.5px; margin-inline-start: auto; }

/* --- Canvas Stage (Edge-to-Edge) --- */
#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 1;
}
#graph { display: block; width: 100%; height: 100%; cursor: grab; }
#graph.dragging { cursor: grabbing; }
#graph.pointing { cursor: pointer; }
#graph.selecting { cursor: crosshair; }

#tooltip {
  position: fixed;
  z-index: 50;
  max-width: 340px;
  padding: 8px 12px;
  background: var(--hud-bg);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--hud-border);
  border-radius: 12px;
  box-shadow: var(--hud-shadow-lg), var(--hud-border-inner);
  pointer-events: none;
  font-size: 12.5px;
  line-height: 1.4;
}
#tooltip .t { font-weight: 600; color: var(--text-primary); }
#tooltip .u {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
#tooltip .tags {
  display: block;
  margin-top: 2px;
  color: var(--text-secondary);
  font-size: 11.5px;
}

#empty[hidden] { display: none; }
#empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  text-align: center;
}
#empty code { color: var(--text-primary); }

#ctxmenu {
  max-height: calc(100dvh - 16px);
  max-width: calc(100vw - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
  position: fixed;
  z-index: 95; /* por encima del velo de la guía */
  min-width: 190px;
  padding: 5px;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.3);
}
#ctxmenu button {
  display: block;
  width: 100%;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--text-primary);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
#ctxmenu button:hover { background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
#ctxmenu button.danger { color: #d03b3b; }
#ctxmenu .sep { height: 1px; margin: 5px 8px; background: var(--border); }

#dlg {
  max-height: calc(100dvh - 24px);
  overflow-y: auto;
  /* el reset * {margin:0} anula el margin:auto con el que el UA centra los dialog */
  margin: auto;
  min-width: 340px;
  max-width: 440px;
  padding: 20px 22px;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.35);
}
#dlg::backdrop { background: rgba(0, 0, 0, 0.45); }
#dlg h3 { font-size: 15px; margin-bottom: 14px; }

/* Diálogos anchos: higiene (listas largas) y ajustes (maestro-detalle). */
#dlg.wide { min-width: min(600px, 92vw); max-width: 92vw; }
/* ancho y alto fijos: el modal no debe cambiar de tamaño al cambiar de sección */
#dlg.settings { width: min(680px, 94vw); min-width: 0; max-width: 94vw; padding: 0; }
#dlg.journey {
  width: min(1120px, 96vw);
  min-width: 0;
  max-width: 96vw;
  height: min(760px, 90vh);
  max-height: 90vh;
  padding: 0;
  overflow: hidden;
}
#dlg .journey-shell { display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto; height: 100%; }
#dlg .journey-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px 14px;
  border-bottom: 1px solid var(--border);
}
#dlg .journey-heading { min-width: 0; }
#dlg .journey-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
#dlg.journey .journey-heading h3 {
  margin: 0;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#dlg .journey-close {
  flex: none;
  width: 30px;
  height: 30px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  font: 22px/1 system-ui, sans-serif;
  cursor: pointer;
}
#dlg .journey-close:hover { color: var(--text-primary); border-color: var(--border); background: var(--page); }
#dlg .journey-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 58px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
#dlg .journey-segmented {
  display: flex;
  flex: none;
  gap: 2px;
  padding: 2px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 9px;
}
#dlg .journey-segmented legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
#dlg .journey-segmented button {
  padding: 5px 11px;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
#dlg .journey-segmented button.active { color: var(--text-primary); background: var(--surface-1); font-weight: 600; }
#dlg label.journey-range {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  white-space: nowrap;
}
#dlg .journey-range select { width: auto; min-width: 145px; margin: 0; padding: 5px 28px 5px 9px; }
#dlg .journey-stats { display: flex; gap: 13px; margin-inline-start: auto; color: var(--text-muted); font-size: 11.5px; white-space: nowrap; }
#dlg .journey-content { min-height: 0; overflow: hidden; }
#dlg .journey-content > :not(.journey-state) { height: 100%; }
#dlg .journey-state {
  display: flex;
  height: 100%;
  min-height: 300px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 30px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
#dlg .journey-state strong { color: var(--text-primary); font-size: 15px; }
#dlg .journey-state.error { color: #d03b3b; }
#dlg .journey-sessions {
  float: left;
  width: 224px;
  height: 100%;
  padding: 13px 10px;
  overflow-y: auto;
  border-inline-end: 1px solid var(--border);
}
#dlg .journey-sessions-title { padding: 2px 9px 9px; color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
#dlg .journey-sessions button {
  display: flex;
  width: 100%;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 9px;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 8px;
  font: inherit;
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
}
#dlg .journey-sessions button:hover { color: var(--text-primary); background: var(--page); }
#dlg .journey-sessions button.active { color: var(--text-primary); background: var(--page); font-weight: 600; }
#dlg .journey-sessions small { flex: none; color: var(--text-muted); font-size: 10.5px; font-weight: 400; }
#dlg .journey-stage { height: 100%; margin-inline-start: 224px; overflow: hidden; }
#dlg .journey-session-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
}
#dlg .journey-session-head strong { color: var(--text-secondary); font-size: 12px; }
#dlg .journey-graph-scroll { height: calc(100% - 42px); overflow: auto; background-color: var(--page); background-image: radial-gradient(var(--gridline) 0.7px, transparent 0.7px); background-size: 18px 18px; }
#dlg .journey-graph { display: block; min-width: 100%; min-height: 100%; }
#dlg .journey-edge { fill: none; stroke: var(--series-1); stroke-width: 1.6; opacity: 0.7; }
#dlg .journey-edge.unknown { stroke: var(--text-muted); stroke-dasharray: 5 5; opacity: 0.55; }
#dlg #journey-arrow path { fill: var(--series-1); }
#dlg .journey-node { outline: none; }
#dlg .journey-node.interactive { cursor: pointer; }
#dlg .journey-node circle { fill: var(--surface-1); stroke: var(--text-muted); stroke-width: 1.5; }
#dlg .journey-node.target circle { fill: color-mix(in srgb, var(--series-1) 18%, var(--surface-1)); stroke: var(--series-1); stroke-width: 2; }
#dlg .journey-node.unknown circle { fill: var(--page); stroke-dasharray: 4 3; }
#dlg .journey-node.interactive:hover circle, #dlg .journey-node.interactive:focus circle { stroke-width: 3; filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.18)); }
#dlg .journey-node text { pointer-events: none; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
#dlg .journey-node-symbol { fill: var(--text-secondary); font-size: 13px; }
#dlg .journey-node.target .journey-node-symbol { fill: var(--series-1); }
#dlg .journey-node-title { fill: var(--text-primary); font-size: 10.5px; font-weight: 600; }
#dlg .journey-node-url, #dlg .journey-node-time { fill: var(--text-muted); font-size: 9.5px; }
#dlg .journey-footer { padding: 9px 20px; color: var(--text-muted); border-top: 1px solid var(--border); font-size: 10.5px; }

@media (max-width: 720px) {
  #dlg.journey { width: 98vw; max-width: 98vw; height: 94vh; max-height: 94vh; }
  #dlg .journey-toolbar { flex-wrap: wrap; gap: 8px; }
  #dlg .journey-stats { width: 100%; margin-inline-start: 0; }
  #dlg .journey-sessions { float: none; width: 100%; height: 96px; display: flex; gap: 4px; border-inline-end: 0; border-bottom: 1px solid var(--border); }
  #dlg .journey-sessions-title { display: none; }
  #dlg .journey-sessions button { min-width: 180px; }
  #dlg .journey-stage { height: calc(100% - 96px); margin-inline-start: 0; }
  #dlg .journey-session-head span { display: none; }
}
#dlg.settings h3 {
  margin: 0;
  padding: 16px 22px 14px;
  border-bottom: 1px solid var(--border);
}
#dlg .master-detail { display: flex; align-items: stretch; height: min(58vh, 430px); }
#dlg .md-nav {
  flex: none;
  width: 196px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  border-inline-end: 1px solid var(--border);
}
#dlg .md-tab {
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  text-align: left;
  color: var(--text-secondary);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}
#dlg .md-tab:hover { color: var(--text-primary); background: var(--page); }
#dlg .md-tab.active { color: var(--text-primary); background: var(--page); font-weight: 600; }
#dlg .md-pane {
  flex: 1;
  min-width: 0;
  padding: 18px 22px 20px;
  overflow-y: auto;
}
#dlg .md-section { margin-bottom: 26px; scroll-margin-top: 2px; }
#dlg .md-section:last-child { margin-bottom: 0; }
#dlg .md-pane h4 { font-size: 13.5px; margin-bottom: 3px; }
#dlg .md-pane .pane-hint { margin-bottom: 16px; font-size: 12px; color: var(--text-muted); }
#dlg.settings .actions {
  margin: 0;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
}
#dlg label {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
#dlg input, #dlg select {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 7px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
}
#dlg input:focus, #dlg select:focus { border-color: var(--baseline); }

/* Editor de vista: las casillas y los radios comparten fila con su etiqueta,
   así que no heredan el `display: block` ni el ancho completo de los campos. */
#dlg.view-editor .view-editor-group {
  margin-bottom: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
}
#dlg.view-editor .view-editor-group legend {
  padding: 0 4px;
  font-size: 12px;
  color: var(--text-secondary);
}
#dlg.view-editor .view-editor-option {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
}
#dlg.view-editor .view-editor-option input {
  display: inline-block;
  width: auto;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}
#dlg .tagcloud {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: -4px 0 12px;
  max-height: 110px;
  overflow-y: auto;
}
#dlg .tagcloud button {
  padding: 3px 9px;
  font: inherit;
  font-size: 11.5px;
  color: var(--text-secondary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
}
#dlg .tagcloud button:hover { color: var(--text-primary); border-color: var(--baseline); }

#dlg .opt-group { margin-bottom: 4px; }
#dlg .opt-head {
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}
#dlg .opt {
  display: flex;
  gap: 11px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.5;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
}
#dlg .opt:hover { border-color: var(--baseline); }
#dlg .opt:has(input:checked) { border-color: var(--baseline); background: var(--page); }
#dlg .opt input[type='radio'], #dlg .opt input[type='checkbox'] {
  display: inline-block;
  width: auto;
  margin: 2px 0 0;
  accent-color: var(--text-primary);
}
#dlg .opt-title { font-size: 13px; color: var(--text-primary); }
#dlg .opt-desc { margin-top: 2px; font-size: 12px; color: var(--text-muted); }

#dlg .kbd-list { margin-bottom: 8px; font-size: 12px; }
#dlg .kbd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
  color: var(--text-secondary);
}
#dlg .kbd {
  padding: 2px 7px;
  font-size: 11px;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: nowrap;
}
#dlg .kbd.unset { color: var(--text-muted); background: none; border-style: dashed; }

#dlg .hyg-list {
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 8px;
  font-size: 12px;
}
#dlg .hyg-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0;
  color: var(--text-secondary);
}
#dlg .hyg-row .hyg-path, #dlg .hyg-row.hyg-path { color: var(--text-muted); white-space: nowrap; }
#dlg .opt-btn {
  padding: 5px 12px;
  margin-bottom: 4px;
  font: inherit;
  font-size: 12px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
#dlg .opt-btn:hover { color: var(--text-primary); border-color: var(--baseline); }
#dlg .opt-btn.danger { color: #d03b3b; }
#dlg .opt-btn.danger:hover { border-color: #d03b3b; }

#dlg .account-card { display: grid; gap: 12px; }
/* Derechos sobre los datos: separados del bloque de sesión por una línea, para
   que borrar la cuenta no quede pegado al botón de cerrar sesión. */
#dlg .account-telemetry { padding-top: 12px; border-top: 1px solid var(--border); }
#dlg .account-rights { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
#dlg .actions-inline { display: flex; flex-wrap: wrap; gap: 8px; }
#dlg .account-identity { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
#dlg .account-identity span { color: var(--text-muted); font-size: 12px; }
#dlg .account-error { color: #d03b3b; font-size: 12px; }
/* Suscripción: mismo tratamiento que los derechos —una línea la separa del
   bloque de sesión— porque es otra decisión sobre la cuenta, no un ajuste. */
#dlg .billing-card { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); }
#dlg .billing-plans { display: flex; flex-wrap: wrap; gap: 8px; }
#dlg .billing-plans .opt-btn { flex: 1 1 auto; }

#dlg .note {
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  max-height: 50vh;
  overflow-y: auto;
}
#dlg .actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
#dlg .actions button {
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--text-secondary);
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
#dlg .actions button:hover { color: var(--text-primary); border-color: var(--baseline); }
#dlg .actions .primary {
  color: var(--page);
  background: var(--text-primary);
  border-color: var(--text-primary);
}
#dlg .actions .primary:hover { color: var(--page); opacity: 0.85; }
#dlg .actions .primary.danger { background: #d03b3b; border-color: #d03b3b; color: #fff; }

/* --- Notification Toast Banner (Floating Bottom-Right) --- */
#toast {
  position: fixed;
  bottom: max(22px, env(safe-area-inset-bottom));
  inset-inline-end: max(20px, env(safe-area-inset-right));
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(440px, calc(100vw - 40px));
  padding: 10px 12px 10px 14px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--hud-bg);
  backdrop-filter: blur(36px) saturate(200%);
  -webkit-backdrop-filter: blur(36px) saturate(200%);
  border: 1px solid var(--hud-border);
  border-radius: 18px;
  box-shadow: var(--hud-shadow-lg), var(--hud-border-inner);
  animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}
#toast[hidden] { display: none; }

.toast-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--series-1);
  box-shadow: 0 0 8px color-mix(in srgb, var(--series-1) 60%, transparent);
  flex: none;
}

.toast-msg {
  flex: 1;
  min-width: 0;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.45;
}

.toast-action {
  flex: none;
  padding: 4px 11px;
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--text-primary) 12%, transparent);
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, transform 0.1s ease;
}
.toast-action:hover {
  background: color-mix(in srgb, var(--text-primary) 18%, transparent);
}
.toast-action:active {
  transform: scale(0.95);
}

.toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  font-size: 10px;
  color: var(--text-muted);
  background: color-mix(in srgb, var(--text-primary) 6%, transparent);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  flex: none;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.toast-close:hover {
  color: var(--text-primary);
  background: color-mix(in srgb, var(--text-primary) 14%, transparent);
}
.toast-close:active {
  transform: scale(0.92);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Touch owns canvas gestures; the surrounding controls retain native scrolling. */
#graph { touch-action: none; -webkit-touch-callout: none; user-select: none; }
#ctxmenu .mobile-context-close { display: none; }
.mobile-panel-toggle, .mobile-edit-bar button, .mobile-edit-entry {
  font: inherit;
  color: var(--text-primary);
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  cursor: pointer;
}
.mobile-panel-toggle {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  box-shadow: var(--hud-shadow-lg);
  backdrop-filter: blur(24px);
}
.mobile-panel-toggle[aria-expanded='true'] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, var(--hud-bg));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent), 0 0 24px color-mix(in srgb, var(--accent) 24%, transparent);
}
.mobile-panel-toggle[aria-expanded='true'] svg { filter: drop-shadow(0 0 5px var(--accent)); }
.mobile-panel-toggle:focus-visible, .mobile-edit-bar button:focus-visible,
.compact-ui button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.mobile-panel-scrim {
  position: fixed;
  inset: 0;
  z-index: 19;
  border: 0;
  background: rgb(0 0 0 / 30%);
  touch-action: manipulation;
}
.mobile-edit-bar {
  position: fixed;
  z-index: 96;
  top: max(12px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 4px 4px 4px 16px;
  max-width: calc(100vw - 24px);
  white-space: nowrap;
  color: var(--text-primary);
  background: var(--hud-bg);
  border: 1px solid var(--accent);
  border-radius: 16px;
  box-shadow: var(--hud-shadow-lg);
  backdrop-filter: blur(24px);
  font-size: 14px;
}
.mobile-edit-bar button {
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  color: var(--page);
  background: var(--text-primary);
}
.map-editing #topbar { top: calc(max(12px, env(safe-area-inset-top)) + 64px); }
.compact-ui .hud-left-stack {
  top: max(12px, env(safe-area-inset-top));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
  left: max(16px, env(safe-area-inset-left));
  right: auto;
  width: min(344px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  pointer-events: auto;
  transform: translateX(calc(-100% - 32px - env(safe-area-inset-left)));
  visibility: hidden;
  transition: transform 180ms ease, visibility 180ms;
}
.compact-ui.panel-open .hud-left-stack { transform: none; visibility: visible; }
.compact-ui.panel-open.submenu-open .hud-left-stack {
  transform: translateX(calc(-100% - 32px - env(safe-area-inset-left)));
  visibility: hidden;
}
.compact-ui.panel-open #topbar { visibility: hidden; pointer-events: none; }
.compact-ui.map-editing .hud-left-stack { top: calc(max(12px, env(safe-area-inset-top)) + 64px); }
.compact-ui .hud-left-stack > * { flex-shrink: 0; }
.compact-ui .hud-left-stack > #hud-brand-island + * { margin-top: auto; }
.compact-ui .hud-brand-panel { flex-wrap: wrap; gap: 8px; }
.compact-ui .hud-brand-mark { font-size: 23px; }
.compact-ui .hud-brand-panel #settings-btn { width: 48px; height: 48px; }
.mobile-edit-entry {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  border-radius: 18px;
  font-size: 16px;
  box-shadow: var(--hud-shadow-lg);
  backdrop-filter: blur(24px);
}
.compact-ui .chip, .compact-ui .views-menu button {
  min-height: 48px;
  font-size: 16px;
  padding: 10px 14px;
}
.compact-ui .chip-delete-btn, .compact-ui .views-menu .pin,
.compact-ui .views-menu button.chip-delete-btn {
  min-width: 48px;
  min-height: 48px;
  opacity: 1;
}
.compact-ui .views-menu-row { gap: 8px; }
.compact-ui .views-menu button { overflow-wrap: anywhere; }
.compact-ui .views-menu-empty { font-size: 15px; padding: 16px; }
.compact-ui .mobile-nav-menu {
  position: fixed;
  z-index: 94;
  top: max(12px, env(safe-area-inset-top));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
  left: max(16px, env(safe-area-inset-left));
  right: auto;
  width: min(344px, calc(100vw - 32px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  min-width: 0;
  max-height: none;
  display: flex;
  flex-direction: column;
  background: var(--surface-1);
}
.compact-ui:not(.panel-open) .mobile-nav-menu:not(.closing) { display: none; }
.compact-ui .mobile-nav-menu { animation: nav-menu-in 180ms ease; }
.compact-ui .mobile-nav-menu.closing { animation: nav-menu-out 180ms ease forwards; pointer-events: none; }
@keyframes nav-menu-in {
  from { transform: translateX(calc(100% + 32px)); opacity: 0; }
}
@keyframes nav-menu-out {
  to { transform: translateX(calc(100% + 32px)); opacity: 0; }
}
.compact-ui.map-editing .mobile-nav-menu { top: calc(max(12px, env(safe-area-inset-top)) + 64px); }
.mobile-nav-menu > * { flex-shrink: 0; }
.compact-ui .mobile-nav-menu > .mobile-menu-title + * { margin-top: auto; }
.mobile-menu-title { padding: 12px 14px; font-size: 17px; font-weight: 600; color: var(--text-primary); }
.compact-ui .mobile-menu-back { position: sticky; top: 0; background: var(--surface-1); z-index: 1; }
.compact-ui #ctxmenu {
  left: max(12px, env(safe-area-inset-left)) !important;
  right: max(12px, env(safe-area-inset-right));
  top: auto !important;
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 72px);
  min-width: 0;
  width: min(400px, calc(100vw - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100dvh - 168px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  border-radius: 18px;
  padding: 8px;
}
.compact-ui #ctxmenu button { min-height: 48px; font-size: 16px; }
.compact-ui #ctxmenu .mobile-context-close {
  display: block;
  position: sticky;
  top: -8px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  border-radius: 0;
}
.compact-ui #searchwrap { width: min(540px, calc(100vw - 24px)); min-height: 48px; }
.compact-ui #search, .compact-ui #search:focus { width: 100%; max-width: none; min-width: 0; font-size: 16px; }
.compact-ui .search-scope-pill { max-width: 42%; min-height: 40px; font-size: 14px; overflow: hidden; }
.compact-ui .search-scope-pill span:last-child { overflow: hidden; text-overflow: ellipsis; }
.compact-ui #results { width: min(560px, calc(100vw - 24px)); max-height: min(56dvh, 480px); }
.compact-ui #results li { min-height: 48px; font-size: 16px; }
.compact-ui #dlg, .compact-ui #dlg.wide {
  min-width: 0;
  width: min(680px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.compact-ui #dlg input, .compact-ui #dlg select { font-size: 16px; min-height: 44px; }
.compact-ui #dlg button { min-height: 44px; }
.compact-ui #dlg .opt input { min-height: 0; }
.compact-ui #dlg .master-detail { flex-direction: column; height: min(65dvh, 600px); }
.compact-ui #dlg .md-nav {
  width: 100%;
  flex-direction: row;
  overflow-x: auto;
  border-inline-end: 0;
  border-bottom: 1px solid var(--border);
  padding: 8px;
}
.compact-ui #dlg .md-tab { flex: none; font-size: 15px; }
.compact-ui #dlg .md-pane { padding: 16px; min-height: 0; overscroll-behavior: contain; }
.compact-ui #dlg .opt-title { font-size: 16px; }
.compact-ui #dlg .opt-desc, .compact-ui #dlg .pane-hint { font-size: 14px; }
.compact-ui #toast {
  top: calc(max(16px, env(safe-area-inset-top)) + 60px);
  bottom: auto;
  left: 12px;
  right: 12px;
  width: auto;
  max-width: none;
  transform: none;
}
.compact-ui.map-editing #toast { top: calc(max(12px, env(safe-area-inset-top)) + 124px); }
.compact-ui.panel-open #toast { top: max(12px, env(safe-area-inset-top)); }
.compact-ui:has(#toast:not([hidden])) #results { top: calc(100% + var(--toast-height, 64px) + 20px); }
.compact-ui .toast-close { width: 44px; height: 44px; flex-shrink: 0; }
@media (max-width: 600px) {
  .compact-ui .hud-left-stack, .compact-ui .mobile-nav-menu {
    left: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
    width: calc(100vw - 2 * max(16px, env(safe-area-inset-left), env(safe-area-inset-right)));
  }
}
@media (prefers-reduced-motion: reduce) {
  .compact-ui .hud-left-stack { transition: none; }
  .compact-ui .mobile-nav-menu { animation: none; }
  .compact-ui .mobile-nav-menu.closing { display: none; }
}

#results li:has(.search-result), #results li.search-expand { padding: 0; }
#results .search-result, #results .search-expand button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  padding: 10px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-primary);
  font: inherit;
  text-align: start;
  cursor: pointer;
}
#results .search-result:focus-visible, #results .search-expand button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
#results li.search-expand { border-top: 1px solid var(--border); margin-top: 6px; }
#results .search-expand button { color: var(--accent); }
#results li.search-section { border-top: 1px solid var(--border); margin-top: 8px; border-radius: 0; font-weight: 600; }
#results li.search-empty, #results li.search-section { cursor: default; color: var(--text-muted); }
.compact-ui #results .search-result, .compact-ui #results .search-expand button { min-height: 48px; }
.compact-ui #results .kind { max-width: 38%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
