:root {
  --fluxgeo-shell-z: 40;
  --fluxgeo-shell-surface: rgba(249, 249, 247, 0.95);
  --fluxgeo-shell-surface-strong: rgba(255, 255, 255, 0.98);
  --fluxgeo-shell-drawer-surface: rgba(252, 252, 251, 0.98);
  --fluxgeo-shell-card-surface: rgba(255, 255, 255, 0.82);
  --fluxgeo-shell-input-surface: rgba(255, 255, 255, 0.62);
  --fluxgeo-shell-session-surface: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(244, 247, 252, 0.95));
  --fluxgeo-shell-toggle-thumb: #fff;
  --fluxgeo-shell-border: rgba(18, 24, 38, 0.10);
  --fluxgeo-shell-shadow: 0 18px 42px rgba(17, 24, 39, 0.16);
  --fluxgeo-shell-text: #18212f;
  --fluxgeo-shell-muted: #637082;
  --fluxgeo-shell-accent: #1f6feb;
  --fluxgeo-shell-accent-soft: rgba(31, 111, 235, 0.12);
  --fluxgeo-shell-danger: #d64545;
  --fluxgeo-shell-danger-soft: rgba(214, 69, 69, 0.14);
}

:root[data-fluxgeo-theme='dark'] {
  --fluxgeo-shell-surface: rgba(30, 36, 47, 0.94);
  --fluxgeo-shell-surface-strong: rgba(22, 27, 36, 0.98);
  --fluxgeo-shell-drawer-surface: rgba(18, 23, 31, 0.98);
  --fluxgeo-shell-card-surface: rgba(28, 36, 48, 0.9);
  --fluxgeo-shell-input-surface: rgba(12, 16, 24, 0.72);
  --fluxgeo-shell-session-surface: linear-gradient(135deg, rgba(22, 27, 36, 0.98), rgba(26, 34, 46, 0.96));
  --fluxgeo-shell-toggle-thumb: #f5f8ff;
  --fluxgeo-shell-border: rgba(220, 227, 238, 0.12);
  --fluxgeo-shell-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
  --fluxgeo-shell-text: #eef3fb;
  --fluxgeo-shell-muted: #9eadc3;
  --fluxgeo-shell-accent: #72a7ff;
  --fluxgeo-shell-accent-soft: rgba(114, 167, 255, 0.18);
  --fluxgeo-shell-danger: #ff8080;
  --fluxgeo-shell-danger-soft: rgba(255, 128, 128, 0.18);
  color-scheme: dark;
}

:root[data-fluxgeo-theme='light'] {
  color-scheme: light;
}

body.fluxgeo-dom-shell-active {
  background: transparent !important;
  background-color: transparent !important;
}

#fluxgeo-mobile-shell {
  position: fixed;
  inset: 0;
  z-index: var(--fluxgeo-shell-z);
  background: transparent !important;
  background-color: transparent !important;
  pointer-events: none;
}

#fluxgeo-mobile-shell[hidden] {
  display: none;
}

.fluxgeo-shell-topbar,
.fluxgeo-shell-selection,
.fluxgeo-shell-session,
.fluxgeo-shell-tool-drawer,
.fluxgeo-shell-drawer,
.fluxgeo-shell-scrim {
  pointer-events: auto;
}

.fluxgeo-shell-topbar,
.fluxgeo-shell-title,
.fluxgeo-shell-selection-copy,
.fluxgeo-shell-tool-drawer-body,
.fluxgeo-panel-header,
.fluxgeo-panel-body {
  background: transparent !important;
  background-color: transparent !important;
}

.fluxgeo-shell-button,
.fluxgeo-shell-tool,
.fluxgeo-shell-drawer-button,
.fluxgeo-shell-tool-drawer-handle,
.fluxgeo-panel,
.fluxgeo-panel-backdrop,
.fluxgeo-panel-close,
.fluxgeo-panel-handle,
.fluxgeo-selection-context-btn {
  pointer-events: auto;
}

.fluxgeo-shell-topbar {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  z-index: calc(var(--fluxgeo-shell-z) + 1);
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}

.fluxgeo-shell-cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 24px;
  background: var(--fluxgeo-shell-surface);
  border: 1px solid var(--fluxgeo-shell-border);
  box-shadow: var(--fluxgeo-shell-shadow);
  backdrop-filter: blur(18px);
}

.fluxgeo-shell-cluster-left {
  grid-column: 1;
  justify-self: start;
}

.fluxgeo-shell-cluster-right {
  grid-column: 3;
  justify-self: end;
}

.fluxgeo-shell-toolbar {
  position: absolute;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 10px));
  transform: translateX(-50%);
  padding: 8px 10px;
  gap: 6px;
  max-width: calc(100vw - 24px);
  overflow-x: auto;
  scrollbar-width: thin;
}

.fluxgeo-shell-tool-drawer {
  position: absolute;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: calc(var(--fluxgeo-shell-z) + 1);
  width: min(100vw - 16px, 680px);
  max-height: min(80vh, calc(100dvh - max(84px, env(safe-area-inset-top)) - 8px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--fluxgeo-shell-border);
  border-radius: 22px;
  background: var(--fluxgeo-shell-surface-strong);
  box-shadow: var(--fluxgeo-shell-shadow);
  backdrop-filter: blur(18px);
  will-change: transform;
}

.fluxgeo-shell-tool-drawer.is-animating {
  transition: transform 220ms cubic-bezier(0.24, 0.8, 0.2, 1);
}

.fluxgeo-shell-tool-drawer.is-dragging {
  transition: none;
}

.fluxgeo-shell-tool-drawer-handle {
  appearance: none;
  width: 100%;
  border: 0;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 14px 12px;
  cursor: pointer;
  touch-action: none;
}

.fluxgeo-shell-tool-drawer-grip {
  width: 40px;
  height: 4px;
  border-radius: 999px;
  background: rgba(18, 24, 38, 0.20);
}

.fluxgeo-shell-tool-drawer-title {
  color: var(--fluxgeo-shell-muted);
  font: 700 0.72rem/1 "Segoe UI", "Helvetica Neue", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.fluxgeo-shell-tool-drawer-peek {
  flex-shrink: 0;
  padding: 0 0 12px;
  border-bottom: 1px solid rgba(18, 24, 38, 0.06);
}

.fluxgeo-shell-tool-drawer-body {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(74px, 82px);
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding: 0 12px 2px;
}

.fluxgeo-shell-tool-drawer-body::-webkit-scrollbar {
  display: none;
}

.fluxgeo-shell-tool-drawer .fluxgeo-shell-tool {
  min-width: 0;
  padding: 10px 6px 8px;
}

.fluxgeo-shell-tool-drawer-body .fluxgeo-shell-tool {
  min-width: 74px;
}

.fluxgeo-shell-tool-drawer-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 10px calc(max(12px, env(safe-area-inset-bottom)) + 8px);
}

.fluxgeo-shell-tool-drawer-content .fluxgeo-shell-drawer-section {
  margin-top: 12px;
}

.fluxgeo-shell-tool-drawer[data-snap='collapsed'] .fluxgeo-shell-tool-drawer-content {
  pointer-events: none;
}

.fluxgeo-shell-selection {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(126px, calc(env(safe-area-inset-bottom) + 118px));
  z-index: calc(var(--fluxgeo-shell-z) + 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 22px;
  background: var(--fluxgeo-shell-surface-strong);
  border: 1px solid var(--fluxgeo-shell-border);
  box-shadow: var(--fluxgeo-shell-shadow);
  backdrop-filter: blur(18px);
}

.fluxgeo-shell-selection[hidden] {
  display: none;
}

.fluxgeo-shell-session {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: max(126px, calc(env(safe-area-inset-bottom) + 118px));
  z-index: calc(var(--fluxgeo-shell-z) + 1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 20px;
  background: var(--fluxgeo-shell-session-surface);
  border: 1px solid var(--fluxgeo-shell-border);
  box-shadow: var(--fluxgeo-shell-shadow);
  backdrop-filter: blur(18px);
}

.fluxgeo-shell-session[hidden] {
  display: none;
}

.fluxgeo-shell-selection-copy {
  min-width: 0;
}

.fluxgeo-shell-session-copy {
  min-width: 0;
  flex: 1 1 auto;
}

.fluxgeo-shell-selection-title {
  color: var(--fluxgeo-shell-text);
  font: 600 0.92rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fluxgeo-shell-selection-subtitle {
  margin-top: 2px;
  color: var(--fluxgeo-shell-muted);
  font: 500 0.78rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-shell-session-title {
  color: var(--fluxgeo-shell-text);
  font: 700 0.96rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fluxgeo-shell-session-subtitle {
  margin-top: 3px;
  color: var(--fluxgeo-shell-muted);
  font: 500 0.8rem/1.25 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-shell-session-controls {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  flex: 0 0 auto;
}

.fluxgeo-shell-session-snap,
.fluxgeo-shell-session-constraint,
.fluxgeo-shell-session-assist-buttons,
.fluxgeo-shell-session-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.fluxgeo-shell-session-assist {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  max-width: 34ch;
}

.fluxgeo-shell-session-assist-label {
  color: var(--fluxgeo-shell-text);
  font: 700 0.76rem/1.1 "Segoe UI", "Helvetica Neue", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fluxgeo-shell-session-assist-hint {
  color: var(--fluxgeo-shell-muted);
  font: 500 0.72rem/1.25 "Segoe UI", "Helvetica Neue", sans-serif;
  text-align: right;
}

.fluxgeo-shell-session-assist-buttons {
  width: 100%;
}

.fluxgeo-shell-session-chip,
.fluxgeo-shell-session-action {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 7px 10px;
  font: 600 0.73rem/1 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-text);
  background: rgba(16, 24, 40, 0.06);
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, opacity 140ms ease, color 140ms ease;
  white-space: nowrap;
}

.fluxgeo-shell-session-chip:hover,
.fluxgeo-shell-session-chip:focus-visible,
.fluxgeo-shell-session-action:hover,
.fluxgeo-shell-session-action:focus-visible {
  background: rgba(16, 24, 40, 0.1);
  outline: none;
}

.fluxgeo-shell-session-chip:active,
.fluxgeo-shell-session-action:active {
  transform: scale(0.97);
}

.fluxgeo-shell-session-chip.is-active,
.fluxgeo-shell-session-action.is-active {
  background: var(--fluxgeo-shell-accent-soft);
  color: var(--fluxgeo-shell-accent);
}

.fluxgeo-shell-session-action.is-danger {
  background: var(--fluxgeo-shell-danger-soft);
  color: var(--fluxgeo-shell-danger);
}

.fluxgeo-shell-session-chip[disabled],
.fluxgeo-shell-session-action[disabled] {
  opacity: 0.4;
  cursor: default;
}

.fluxgeo-shell-title {
  min-width: 0;
  text-align: center;
  color: var(--fluxgeo-shell-text);
  display: none;
}

.fluxgeo-shell-title-main {
  display: block;
  font: 600 0.95rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fluxgeo-shell-title-sub {
  display: block;
  margin-top: 2px;
  color: var(--fluxgeo-shell-muted);
  font: 500 0.72rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-shell-button,
.fluxgeo-shell-tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fluxgeo-shell-text);
  cursor: pointer;
  transition: transform 140ms ease, background-color 140ms ease, opacity 140ms ease;
}

.fluxgeo-shell-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fluxgeo-shell-button:hover,
.fluxgeo-shell-button:focus-visible,
.fluxgeo-shell-tool:hover,
.fluxgeo-shell-tool:focus-visible,
.fluxgeo-shell-drawer-button:hover,
.fluxgeo-shell-drawer-button:focus-visible {
  background: rgba(16, 24, 40, 0.06);
  outline: none;
}

.fluxgeo-shell-button:active,
.fluxgeo-shell-tool:active,
.fluxgeo-shell-drawer-button:active {
  transform: scale(0.96);
}

.fluxgeo-shell-button[disabled],
.fluxgeo-shell-tool[disabled],
.fluxgeo-shell-drawer-button[disabled] {
  opacity: 0.38;
  cursor: default;
}

.fluxgeo-shell-icon {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
}

.fluxgeo-shell-icon-svg-container {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.fluxgeo-shell-svg {
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.fluxgeo-shell-svg *[fill]:not([fill="none"]) {
  fill: var(--fluxgeo-shell-text) !important;
  transition: fill 140ms ease;
}

.fluxgeo-shell-svg *[stroke]:not([stroke="none"]) {
  stroke: var(--fluxgeo-shell-text) !important;
  transition: stroke 140ms ease;
}

.fluxgeo-shell-tool.is-active .fluxgeo-shell-svg *[fill]:not([fill="none"]),
.fluxgeo-shell-button.is-active .fluxgeo-shell-svg *[fill]:not([fill="none"]),
.fluxgeo-shell-drawer-button.is-active .fluxgeo-shell-svg *[fill]:not([fill="none"]) {
  fill: var(--fluxgeo-shell-accent) !important;
}

.fluxgeo-shell-tool.is-active .fluxgeo-shell-svg *[stroke]:not([stroke="none"]),
.fluxgeo-shell-button.is-active .fluxgeo-shell-svg *[stroke]:not([stroke="none"]),
.fluxgeo-shell-drawer-button.is-active .fluxgeo-shell-svg *[stroke]:not([stroke="none"]) {
  stroke: var(--fluxgeo-shell-accent) !important;
}

.fluxgeo-shell-danger .fluxgeo-shell-svg *[fill]:not([fill="none"]) {
  fill: var(--fluxgeo-shell-danger) !important;
}

.fluxgeo-shell-danger .fluxgeo-shell-svg *[stroke]:not([stroke="none"]) {
  stroke: var(--fluxgeo-shell-danger) !important;
}

.fluxgeo-shell-tool {
  min-width: 62px;
  padding: 9px 9px 8px;
  border-radius: 18px;
  display: grid;
  justify-items: center;
  gap: 5px;
  background: transparent;
}

.fluxgeo-shell-tool.is-active {
  background: var(--fluxgeo-shell-accent-soft);
  color: var(--fluxgeo-shell-accent);
}

.fluxgeo-shell-button.is-active {
  background: var(--fluxgeo-shell-accent-soft);
  color: var(--fluxgeo-shell-accent);
}

.fluxgeo-shell-tool-label {
  font: 600 0.71rem/1 "Segoe UI", "Helvetica Neue", sans-serif;
  white-space: nowrap;
}

.fluxgeo-shell-danger {
  color: var(--fluxgeo-shell-danger);
}

.fluxgeo-shell-danger.is-active,
.fluxgeo-shell-danger:hover,
.fluxgeo-shell-danger:focus-visible {
  background: var(--fluxgeo-shell-danger-soft);
}

.fluxgeo-shell-scrim {
  position: absolute;
  inset: 0;
  z-index: calc(var(--fluxgeo-shell-z) + 2);
  background: rgba(11, 18, 32, 0.28);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.fluxgeo-shell-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.fluxgeo-shell-drawer {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: calc(var(--fluxgeo-shell-z) + 3);
  width: min(320px, calc(100vw - 28px));
  padding: calc(max(18px, env(safe-area-inset-top)) + 54px) 16px calc(max(18px, env(safe-area-inset-bottom)) + 12px);
  background: var(--fluxgeo-shell-drawer-surface);
  border-right: 1px solid var(--fluxgeo-shell-border);
  box-shadow: 0 18px 52px rgba(15, 23, 42, 0.22);
  transform: translateX(-104%);
  transition: transform 180ms ease;
  overflow-y: auto;
}

.fluxgeo-shell-drawer.is-open {
  transform: translateX(0);
}

/* Floating three-dots button shown near selected object on mobile/tablet */
.fluxgeo-selection-context-btn {
  position: fixed;
  z-index: calc(var(--fluxgeo-shell-z) + 2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--fluxgeo-shell-border);
  background: var(--fluxgeo-shell-surface-strong);
  color: var(--fluxgeo-shell-text);
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(12px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font: 700 21px/1 "Segoe UI", "Helvetica Neue", sans-serif;
  cursor: pointer;
  pointer-events: auto;
  touch-action: none;
  transition: transform 120ms ease, background-color 120ms ease;
  will-change: transform;
}

.fluxgeo-selection-context-btn:hover,
.fluxgeo-selection-context-btn:focus-visible {
  background: rgba(16, 24, 40, 0.08);
  outline: none;
}

.fluxgeo-selection-context-btn:active {
  transform: scale(0.95);
}

.fluxgeo-shell-drawer-section + .fluxgeo-shell-drawer-section {
  margin-top: 18px;
}

.fluxgeo-shell-drawer-heading {
  margin: 0 0 10px;
  color: var(--fluxgeo-shell-muted);
  font: 700 0.72rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fluxgeo-shell-drawer-grid {
  display: grid;
  gap: 10px;
}

.fluxgeo-shell-drawer-grid.tools {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.fluxgeo-shell-drawer-button {
  appearance: none;
  border: 1px solid var(--fluxgeo-shell-border);
  border-radius: 16px;
  background: var(--fluxgeo-shell-surface-strong);
  color: var(--fluxgeo-shell-text);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  font: 600 0.9rem/1.15 "Segoe UI", "Helvetica Neue", sans-serif;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
}

.fluxgeo-shell-drawer-button.is-active {
  border-color: rgba(31, 111, 235, 0.22);
  background: var(--fluxgeo-shell-accent-soft);
  color: var(--fluxgeo-shell-accent);
}

/* Compact override for action buttons (Clear / Delete) inside the selection strip.
   The drawer button is designed for the hamburger menu; inside a tight pill we
   reduce its size so it does not dominate the drawing area. */
.fluxgeo-shell-selection .fluxgeo-shell-drawer-button {
  padding: 8px 12px;
  border-radius: 12px;
  box-shadow: none;
  font-size: 0.82rem;
  gap: 8px;
}

.fluxgeo-shell-drawer-button-copy {
  display: grid;
  gap: 3px;
  text-align: left;
}

.fluxgeo-shell-drawer-button-subtitle {
  color: var(--fluxgeo-shell-muted);
  font: 500 0.76rem/1.15 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-shell-tool-groups {
  display: grid;
  gap: 10px;
}

.fluxgeo-shell-tool-group {
  border: 1px solid var(--fluxgeo-shell-border);
  border-radius: 14px;
  background: var(--fluxgeo-shell-card-surface);
  box-shadow: 0 7px 16px rgba(15, 23, 42, 0.05);
  overflow: clip;
}

.fluxgeo-shell-tool-group-summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  color: var(--fluxgeo-shell-muted);
  font: 700 0.77rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}

.fluxgeo-shell-tool-group-summary::-webkit-details-marker {
  display: none;
}

.fluxgeo-shell-tool-group-summary::after {
  content: " +";
  float: right;
  font: 700 0.88rem/1 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-shell-tool-group[open] .fluxgeo-shell-tool-group-summary {
  color: var(--fluxgeo-shell-text);
}

.fluxgeo-shell-tool-group[open] .fluxgeo-shell-tool-group-summary::after {
  content: " -";
}

.fluxgeo-shell-tool-group-grid {
  padding: 0 10px 10px;
}

@media (max-width: 599px) {
  .fluxgeo-shell-session {
    flex-direction: column;
    align-items: stretch;
  }

  .fluxgeo-shell-session-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .fluxgeo-shell-session-snap,
  .fluxgeo-shell-session-constraint,
  .fluxgeo-shell-session-assist,
  .fluxgeo-shell-session-assist-buttons,
  .fluxgeo-shell-session-actions {
    justify-content: flex-start;
  }

  .fluxgeo-shell-session-assist {
    align-items: stretch;
    max-width: none;
  }
}

@media (min-width: 600px) and (max-width: 1023px) {
  .fluxgeo-shell-toolbar {
    bottom: max(22px, calc(env(safe-area-inset-bottom) + 14px));
  }

  .fluxgeo-shell-selection {
    left: 18px;
    right: 18px;
  }

  .fluxgeo-shell-session {
    left: 18px;
    right: 18px;
  }
}

/* ============================================================
   DOM PANEL — bottom-sheet panel container used by Algebra
   and Properties panels.
   ============================================================ */

.fluxgeo-panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: calc(var(--fluxgeo-shell-z) + 1);
  max-height: 72vh;
  display: flex;
  flex-direction: column;
  background: var(--fluxgeo-shell-surface-strong);
  border-top: 1px solid var(--fluxgeo-shell-border);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -12px 40px rgba(15, 23, 42, 0.18);
  transform: translateY(100%);
  transition: transform 260ms cubic-bezier(0.32, 0.72, 0, 1);
  will-change: transform;
  overscroll-behavior: contain;
}

.fluxgeo-panel.is-open {
  transform: translateY(0);
}

/* Drag handle pill */
.fluxgeo-panel-handle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 0 4px;
  cursor: grab;
  touch-action: none;
}

.fluxgeo-panel-handle::before {
  content: '';
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(18, 24, 38, 0.20);
}

/* Panel header row */
.fluxgeo-panel-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 10px;
}

.fluxgeo-panel-title {
  font: 700 1rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-text);
}

.fluxgeo-panel-close {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--fluxgeo-shell-muted);
  font-size: 1.1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  transition: background 120ms;
}

.fluxgeo-panel-close:hover,
.fluxgeo-panel-close:focus-visible {
  background: rgba(18, 24, 38, 0.07);
  outline: none;
}

/* Scrollable body */
.fluxgeo-panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 0 calc(max(18px, env(safe-area-inset-bottom)) + 4px);
}

/* ---- Algebra panel rows ---- */

.fluxgeo-algebra-category {
  padding: 8px 16px 2px;
  color: var(--fluxgeo-shell-muted);
  font: 700 0.72rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fluxgeo-algebra-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(18, 24, 38, 0.055);
  transition: background 100ms;
  -webkit-tap-highlight-color: transparent;
}

.fluxgeo-algebra-row:active,
.fluxgeo-algebra-row.is-selected {
  background: var(--fluxgeo-shell-accent-soft);
}

.fluxgeo-algebra-row.is-hidden {
  opacity: 0.45;
}

/* Color dot */
.fluxgeo-algebra-dot {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.10);
}

/* Object name + value */
.fluxgeo-algebra-copy {
  flex: 1;
  min-width: 0;
}

.fluxgeo-algebra-label {
  font: 600 0.9rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fluxgeo-algebra-type {
  font: 500 0.76rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-muted);
  text-transform: capitalize;
}

/* Visibility toggle button */
.fluxgeo-algebra-vis {
  flex-shrink: 0;
  appearance: none;
  border: 0;
  background: transparent;
  padding: 6px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--fluxgeo-shell-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  transition: background 100ms;
  -webkit-tap-highlight-color: transparent;
}

.fluxgeo-algebra-vis:active {
  background: rgba(18, 24, 38, 0.08);
}

.fluxgeo-algebra-vis svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* ---- Properties panel ---- */

.fluxgeo-props-section {
  padding: 14px 16px 4px;
}

.fluxgeo-props-section + .fluxgeo-props-section {
  border-top: 1px solid rgba(18, 24, 38, 0.08);
}

.fluxgeo-props-label {
  display: block;
  margin-bottom: 8px;
  color: var(--fluxgeo-shell-muted);
  font: 700 0.72rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

/* Color row: swatch + hex input */
.fluxgeo-props-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.fluxgeo-props-color-swatch {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1.5px solid rgba(18, 24, 38, 0.12);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
}

.fluxgeo-props-color-swatch input[type="color"] {
  position: absolute;
  inset: -4px;
  width: calc(100% + 8px);
  height: calc(100% + 8px);
  border: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
}

.fluxgeo-props-color-swatch-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* Generic row: label + value or control */
.fluxgeo-props-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(18, 24, 38, 0.055);
}

.fluxgeo-props-row:last-child {
  border-bottom: 0;
}

.fluxgeo-props-row-label {
  font: 500 0.88rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-text);
}

/* Thickness / range sliders */
.fluxgeo-props-range {
  width: 120px;
  accent-color: var(--fluxgeo-shell-accent);
}

/* Toggle switch */
.fluxgeo-props-toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.fluxgeo-props-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.fluxgeo-props-toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: rgba(18, 24, 38, 0.16);
  transition: background 160ms;
  cursor: pointer;
}

.fluxgeo-props-toggle input:checked + .fluxgeo-props-toggle-track {
  background: var(--fluxgeo-shell-accent);
}

.fluxgeo-props-toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fluxgeo-shell-toggle-thumb);
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
  transition: transform 160ms;
}

.fluxgeo-props-toggle input:checked + .fluxgeo-props-toggle-track::after {
  transform: translateX(18px);
}

/* Rename input */
.fluxgeo-props-input {
  flex: 1;
  min-width: 0;
  max-width: 160px;
  padding: 6px 10px;
  border: 1.5px solid var(--fluxgeo-shell-border);
  border-radius: 10px;
  background: var(--fluxgeo-shell-surface-strong);
  font: 500 0.9rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-text);
  outline: none;
  transition: border-color 140ms;
}

.fluxgeo-props-input:focus {
  border-color: var(--fluxgeo-shell-accent);
}

/* Line style pill buttons */
.fluxgeo-props-linestyle {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.fluxgeo-props-linestyle-btn {
  appearance: none;
  border: 1.5px solid var(--fluxgeo-shell-border);
  border-radius: 8px;
  background: var(--fluxgeo-shell-surface-strong);
  padding: 5px 10px;
  font: 500 0.78rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
  color: var(--fluxgeo-shell-text);
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
}

.fluxgeo-props-linestyle-btn.is-active {
  background: var(--fluxgeo-shell-accent-soft);
  border-color: rgba(31, 111, 235, 0.35);
  color: var(--fluxgeo-shell-accent);
}

/* Panel backdrop (dark overlay when panel is open) */
.fluxgeo-panel-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--fluxgeo-shell-z);
  background: rgba(11, 18, 32, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.fluxgeo-panel-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.fluxgeo-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: calc(var(--fluxgeo-shell-z) + 12);
  background: rgba(8, 12, 18, 0.38);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.fluxgeo-modal-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.fluxgeo-modal-sheet {
  position: fixed;
  left: 50%;
  bottom: max(8px, env(safe-area-inset-bottom));
  transform: translate3d(-50%, 110%, 0);
  width: min(100vw - 16px, 680px);
  max-height: min(82vh, calc(100dvh - max(84px, env(safe-area-inset-top)) - 8px));
  z-index: calc(var(--fluxgeo-shell-z) + 13);
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  border: 1px solid var(--fluxgeo-shell-border);
  background: var(--fluxgeo-shell-surface-strong);
  box-shadow: var(--fluxgeo-shell-shadow);
  overflow: hidden;
  transition: transform 220ms cubic-bezier(0.24, 0.8, 0.2, 1);
}

.fluxgeo-modal-sheet.is-open {
  transform: translate3d(-50%, 0, 0);
}

.fluxgeo-modal-header,
.fluxgeo-modal-body,
.fluxgeo-modal-footer {
  padding-left: 16px;
  padding-right: 16px;
}

.fluxgeo-modal-header {
  padding-top: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--fluxgeo-shell-border);
}

.fluxgeo-modal-title {
  margin: 0;
  color: var(--fluxgeo-shell-text);
  font: 700 1rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-modal-subtitle {
  margin-top: 6px;
  color: var(--fluxgeo-shell-muted);
  font: 500 0.84rem/1.4 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-modal-body {
  padding-top: 14px;
  padding-bottom: 14px;
  overflow-y: auto;
  display: grid;
  gap: 12px;
}

.fluxgeo-modal-row {
  display: grid;
  gap: 8px;
}

.fluxgeo-modal-row-label {
  color: var(--fluxgeo-shell-text);
  font: 600 0.84rem/1.2 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-modal-input,
.fluxgeo-modal-textarea,
.fluxgeo-modal-select {
  width: 100%;
  border-radius: 14px;
  border: 1px solid var(--fluxgeo-shell-border);
  background: var(--fluxgeo-shell-input-surface);
  color: var(--fluxgeo-shell-text);
  padding: 11px 12px;
  font: 500 0.96rem/1.35 "Segoe UI", "Helvetica Neue", sans-serif;
  box-sizing: border-box;
}

:root[data-fluxgeo-theme='dark'] .fluxgeo-modal-input,
:root[data-fluxgeo-theme='dark'] .fluxgeo-modal-textarea,
:root[data-fluxgeo-theme='dark'] .fluxgeo-modal-select {
  background: var(--fluxgeo-shell-input-surface);
}

.fluxgeo-modal-textarea {
  min-height: 132px;
  resize: vertical;
}

.fluxgeo-modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.fluxgeo-modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 12px;
  padding-bottom: calc(max(14px, env(safe-area-inset-bottom)) + 4px);
  border-top: 1px solid var(--fluxgeo-shell-border);
}

.fluxgeo-modal-button {
  appearance: none;
  border: 1px solid var(--fluxgeo-shell-border);
  border-radius: 14px;
  background: var(--fluxgeo-shell-surface);
  color: var(--fluxgeo-shell-text);
  padding: 10px 14px;
  font: 700 0.9rem/1 "Segoe UI", "Helvetica Neue", sans-serif;
}

.fluxgeo-modal-button.is-primary {
  background: var(--fluxgeo-shell-accent);
  color: #fff;
  border-color: transparent;
}

@media (max-width: 520px) {
  .fluxgeo-modal-grid {
    grid-template-columns: 1fr;
  }
}
