/**
 * Gridspace Master Stylesheet
 * Strict Engineering Standards:
 * - Zero `!important` declarations
 * - Zero `margin` for layout spacing (100% Flexbox/Grid `gap` and `padding`)
 * - GPU-accelerated compositing (`translate3d`, `scale`, `will-change: transform`)
 * - All UI colors, surfaces, borders, and grid tokens are reactive via StyleController
 */

:root {
  /* Category 1: Canvas & Grid Tokens (Default: Miro Daylight) */
  --bg-canvas: #f5f6f8;
  --grid-minor-color: rgba(15, 23, 42, 0.05);
  --grid-major-color: rgba(15, 23, 42, 0.11);
  --origin-color: #000000;
  --origin-axis-color: rgba(0, 0, 0, 0.4);

  /* Category 2: UI Containers & Panels */
  --bg-panel: rgba(255, 255, 255, 0.94);
  --bg-panel-solid: #ffffff;
  --bg-panel-hover: #f1f5f9;
  --border-subtle: rgba(15, 23, 42, 0.10);
  --panel-blur: 10px;
  --panel-radius: 10px;
  --panel-height: 40px;
  --viewport-edge-pad: 18px;

  /* Category 3: Typography & Icons */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Category 4: Tools, Nodes & Connections */
  --accent-primary: #2563eb;
  --accent-text: #ffffff;
  --accent-glow: rgba(37, 99, 235, 0.22);
  --border-focus: rgba(37, 99, 235, 0.6);
  --node-surface: #ffffff;
  --node-border: #cbd5e1;
  --node-radius: 0px;
  --arrow-default: #334155;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body,
h1,
h2,
h3,
p {
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
  user-select: none;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.15s ease, color 0.15s ease;
}

/* Material Symbols Base Standard */
.material-symbols-outlined {
  font-family: 'Material Symbols Outlined';
  font-weight: normal;
  font-style: normal;
  font-size: 18px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-smoothing: antialiased;
}

/* Root Application Shell */
.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Top Floating Header Bar */
.top-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--viewport-edge-pad, 18px);
  pointer-events: none;
}

.top-bar-left,
.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: var(--panel-height, 40px);
  padding: 0 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.brand-icon {
  color: var(--accent-primary);
  font-size: 20px;
}

.brand-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

/* Top-Left Project Switcher & Save Bar */
.project-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--panel-height, 40px);
  padding: 6px;
  box-sizing: border-box;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.project-selector-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 8px;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.project-selector-btn:hover,
.project-selector-btn.is-active {
  background: var(--bg-panel-hover);
  border-color: var(--border-subtle);
}

.project-folder-icon {
  color: var(--accent-primary);
  font-size: 17px;
}

.project-name-text {
  max-width: 190px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-chevron {
  font-size: 16px;
  color: var(--text-muted);
}

.save-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

.save-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.save-status-pill[data-state="dirty"] .save-dot,
.save-status-pill[data-state="saving"] .save-dot {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.6);
}

.save-status-pill[data-state="error"] .save-dot {
  background: #ef4444;
  box-shadow: 0 0 6px rgba(239, 68, 68, 0.6);
}

.controls-hint {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hint-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.hint-chip .material-symbols-outlined {
  font-size: 15px;
  color: var(--text-muted);
}

/* Lower-Left Bottom Style & Grid Nav Container */
.style-dock {
  position: absolute;
  left: var(--viewport-edge-pad, 18px);
  bottom: var(--viewport-edge-pad, 18px);
  z-index: 25;
  display: flex;
  align-items: center;
}

.top-action-btn,
.style-dock-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--panel-height, 40px);
  padding: 0 14px;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.top-action-btn .material-symbols-outlined,
.style-dock-btn .material-symbols-outlined {
  color: var(--accent-primary);
  font-size: 18px;
}

.top-action-btn:hover,
.top-action-btn.is-active,
.style-dock-btn:hover,
.style-dock-btn.is-active {
  background: var(--bg-panel-hover);
  border-color: var(--border-focus);
}

/* Infinite Viewport Surface */
.viewport {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: default;
  outline: none;
  touch-action: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.viewport.is-panning {
  cursor: grabbing;
}

.viewport.is-space-ready {
  cursor: grab;
}

.viewport.is-space-ready.is-panning {
  cursor: grabbing;
}

/* Multi-Scale Infinite Background Grid */
.grid-backdrop {
  position: absolute;
  inset: 0;
  pointer-events: none;
  will-change: background-position, background-size;
}

/* GPU-Accelerated World Plane */
.world-plane {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  transform-origin: 0 0;
  transform: translate3d(0px, 0px, 0px) scale(1);
}

/* World Origin (0, 0) Crosshair Marker (Hidden by Default, Toggleable in Style Configurator) */
.origin-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  display: none;
  pointer-events: none;
}

.origin-axis {
  position: absolute;
  background: var(--origin-color, #000000);
}

.origin-axis-x {
  width: 36px;
  height: 1px;
  left: -18px;
  top: 0;
}

.origin-axis-y {
  width: 1px;
  height: 36px;
  left: 0;
  top: -18px;
}

.origin-label {
  position: absolute;
  left: 6px;
  top: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 600;
  color: var(--origin-color, #000000);
  white-space: nowrap;
}

/* Bottom-Right Telemetry & Zoom HUD */
.hud-bar {
  position: absolute;
  right: var(--viewport-edge-pad, 18px);
  bottom: var(--viewport-edge-pad, 18px);
  z-index: 25;
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--panel-height, 40px);
  padding: 6px;
  box-sizing: border-box;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.coords-readout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 8px;
  color: var(--text-secondary);
  font-size: 12px;
}

.coords-icon {
  font-size: 16px;
  color: var(--accent-primary);
}

.mono-text {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.hud-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
}

.zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  width: 28px;
  padding: 0;
  background: transparent;
  color: var(--text-primary);
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.hud-btn:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-subtle);
}

.hud-btn:active {
  transform: translateY(1px);
}

.hud-btn-with-label {
  width: auto;
  padding: 0 8px;
}

.hud-zoom-pill {
  height: 28px;
  min-width: 58px;
  padding: 0 8px;
  background: var(--bg-panel-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.hud-zoom-pill:hover {
  border-color: var(--border-focus);
}

/* ==========================================================================
   PROJECT HUB MODAL
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.modal-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 84vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 18px 20px;
}

.hub-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: rgba(128, 128, 128, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: calc(var(--panel-radius) - 2px);
}

.hub-action-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.projects-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 380px;
  overflow-y: auto;
}

/* Full width search bar above saved project folders */
.project-search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: var(--bg-surface-elevated, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 6px 12px;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.project-search-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow, rgba(59, 130, 246, 0.2));
}

.project-search-icon {
  font-size: 18px;
  color: var(--text-secondary);
  flex-shrink: 0;
  user-select: none;
}

.project-search-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
}

.project-search-input::placeholder {
  color: var(--text-secondary);
  opacity: 0.8;
}

.project-search-clear-btn {
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: color 0.12s ease;
}

.project-search-clear-btn:hover {
  color: var(--text-primary);
}

.project-search-clear-btn span {
  font-size: 16px;
}

.project-empty-search {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.project-empty-search .material-symbols-outlined {
  font-size: 32px;
  opacity: 0.6;
}

.project-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.project-item-card:hover {
  background: var(--bg-panel-hover);
}

.project-item-card.is-active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.project-item-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

/* Project Thumbnail Box (Max 200px x 200px, fit container centered) */
.project-item-icon {
  width: 52px;
  height: 52px;
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  background: var(--accent-glow);
  color: var(--accent-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.project-item-icon.has-thumb {
  background: #0d0f12;
  border-color: var(--border-subtle);
}

.project-item-thumb-img {
  width: 100%;
  height: 100%;
  max-width: 200px;
  max-height: 200px;
  object-fit: cover;
  object-position: center;
  display: block;
}

.project-placeholder-svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  opacity: 0.85;
}

.project-item-details {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.project-item-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-item-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-active-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--accent-primary);
  color: #ffffff;
}

.project-item-meta {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.project-btn-open {
  flex: 0 0 auto;
}

.project-btn-delete:hover {
  color: #ef4444;
}

/* ==========================================================================
   STYLE & GRID STUDIO DRAWER
   ========================================================================== */

.style-drawer {
  position: absolute;
  top: calc(var(--viewport-edge-pad, 18px) + var(--panel-height, 40px) + 12px);
  right: var(--viewport-edge-pad, 18px);
  bottom: calc(var(--viewport-edge-pad, 18px) + var(--panel-height, 40px) + 12px);
  width: 360px;
  z-index: 35;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  transform: translate3d(400px, 0, 0);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.18s ease;
  overflow: hidden;
}

.style-drawer.is-open {
  transform: translate3d(0, 0, 0);
  opacity: 1;
  pointer-events: auto;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.drawer-header-icon {
  color: var(--accent-primary);
  font-size: 22px;
}

.drawer-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.drawer-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
}

.style-status-toast {
  display: none;
  padding: 8px 14px;
  background: var(--accent-glow);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-focus);
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}

.style-status-toast.is-visible {
  display: block;
}

.drawer-scroll-body {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px 16px;
}

.drawer-scroll-body::-webkit-scrollbar {
  width: 6px;
}

.drawer-scroll-body::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}

.style-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: rgba(128, 128, 128, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: calc(var(--panel-radius) - 2px);
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-subtle);
}

.section-heading .material-symbols-outlined {
  font-size: 16px;
  color: var(--accent-primary);
}

/* Preset Grid & Cards */
.preset-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.preset-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
  transition: border-color 0.12s ease, background-color 0.12s ease;
}

.preset-card:hover {
  background: var(--bg-panel-hover);
}

.preset-card.is-active {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.preset-swatch {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.preset-swatch-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.preset-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preset-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-meta {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sub-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  padding-top: 4px;
}

.user-preset-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preset-empty-note {
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 8px;
  border: 1px dashed var(--border-subtle);
  border-radius: 6px;
  text-align: center;
}

.user-preset-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 4px 6px;
}

.user-preset-row.is-active {
  border-color: var(--accent-primary);
}

.user-preset-apply {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  padding: 4px;
  font-family: var(--font-sans);
}

.user-preset-delete {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 5px;
  display: inline-flex;
}

.user-preset-delete:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.12);
}

.preset-save-row,
.preset-share-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.style-text-input {
  flex: 1;
  height: 32px;
  padding: 0 10px;
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 12px;
  outline: none;
}

.style-text-input:focus {
  border-color: var(--accent-primary);
}

.style-btn {
  flex: 1;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}

.style-btn .material-symbols-outlined {
  font-size: 15px;
}

.style-btn:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-focus);
}

.style-btn-primary {
  flex: 0 0 auto;
  background: var(--accent-primary);
  color: #ffffff;
  border-color: var(--accent-primary);
}

.style-btn-primary:hover {
  filter: brightness(1.08);
  background: var(--accent-primary);
}

/* Individual Token Control Rows */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.control-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
}

.segmented-group {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-panel-solid);
  padding: 3px;
  border-radius: 7px;
  border: 1px solid var(--border-subtle);
}

.seg-btn {
  height: 26px;
  background: transparent;
  color: var(--text-secondary);
  border: none;
  border-radius: 5px;
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn.is-active {
  background: var(--accent-primary);
  color: #ffffff;
}

.color-picker-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.color-slider-combo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.color-input {
  width: 26px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
}

.range-input {
  flex: 1;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.checkbox-input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.mono-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  min-width: 44px;
  text-align: right;
}

@media (max-width: 900px) {
  .controls-hint {
    display: none;
  }
  .style-drawer {
    width: calc(100vw - 36px);
  }
}


/* ==========================================================================
   STAGE 3: GPU BOARD NODES, 8-WAY RESIZE HANDLES, MARQUEE & TOOL DOCK
   ========================================================================== */

.viewport.is-pan-tool {
  cursor: grab;
}

.viewport.is-pan-tool.is-panning {
  cursor: grabbing;
}

/* Marquee Box-Selection Overlay */
.marquee-box {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 15;
  background: var(--accent-glow);
  border: 1.5px solid var(--accent-primary);
  border-radius: 4px;
  display: none;
  will-change: transform, width, height;
}

.marquee-box.is-frame-draw {
  background: rgba(255, 255, 255, 0.15);
  border: 2px dashed #ffffff;
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(0, 0, 0, 0.35);
}

.marquee-box.is-card-draw {
  background: rgba(99, 102, 241, 0.16);
  border: 2px dashed var(--accent-primary, #6366f1);
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.25);
}

.marquee-box.is-audio-draw {
  background: rgba(239, 68, 68, 0.16);
  border: 2px dashed #ef4444;
  border-radius: 8px;
  box-shadow: 0 0 16px rgba(239, 68, 68, 0.25);
}

.marquee-box.is-active {
  display: block;
}

/* Left-Side Vertical Icon-Only Tool Dock */
.tool-dock {
  position: absolute;
  left: var(--viewport-edge-pad, 18px);
  top: 50%;
  transform: translate3d(0, -50%, 0);
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.dock-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dock-divider {
  width: 24px;
  height: 1px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.dock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.dock-btn .material-symbols-outlined {
  font-size: 20px;
}

.dock-btn:hover {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

.dock-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.dock-btn.is-active {
  background: var(--accent-glow);
  color: var(--text-primary);
  border-color: var(--border-focus);
}

.dock-btn.is-active .material-symbols-outlined {
  color: var(--accent-primary);
}

.dock-btn-accent {
  background: var(--accent-primary);
  color: #ffffff;
}

.dock-btn-accent:hover {
  background: var(--accent-primary);
  color: #ffffff;
  filter: brightness(1.1);
}

.dock-selection-actions {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dock-selection-actions.is-visible {
  display: flex;
}

.dock-btn-danger:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
}

/* GPU-Accelerated Board Node Card */
.grid-node {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  background: var(--node-surface);
  color: var(--text-primary);
  border: 1.5px solid var(--node-border);
  border-radius: var(--node-radius);
  box-shadow: none;
  cursor: grab;
  transition: border-color 0.1s ease, opacity 0.12s ease, box-shadow 0.12s ease;
}

.grid-node.is-culled {
  display: none;
}

.grid-node:not(.node-type-frame).is-interacting {
  cursor: grabbing;
  opacity: 1;
  user-select: none;
}

.grid-node:not(.node-type-frame).is-selected {
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1.5px var(--accent-primary);
  opacity: 1;
}

.grid-node:not(.node-type-frame).is-selected:focus-within {
  opacity: 1;
}

.grid-node.node-type-frame {
  opacity: 1;
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(128, 128, 128, 0.04);
  border-top-left-radius: var(--node-radius);
  border-top-right-radius: var(--node-radius);
}

.node-header-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.node-drag-icon {
  font-size: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.node-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  border-radius: var(--node-radius);
  padding: 1px 4px;
}

.node-title[contenteditable="true"] {
  background: var(--bg-panel-solid);
  box-shadow: 0 0 0 1.5px var(--accent-primary);
  cursor: text;
  user-select: text;
}

.node-coords-badge {
  font-size: 10px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.node-body {
  flex: 1;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  outline: none;
}

.node-body[contenteditable="true"] {
  color: var(--text-primary);
  background: rgba(128, 128, 128, 0.04);
  cursor: text;
  user-select: text;
}

/* 8-Way Resize Handles (Visible when Node is Selected) */
.node-resize-handles {
  display: none;
  pointer-events: none;
}

.grid-node.is-selected .node-resize-handles {
  display: block;
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: var(--bg-panel-solid);
  border: 2px solid var(--accent-primary);
  border-radius: 0px;
  pointer-events: auto;
  z-index: 5;
}

.resize-handle:hover {
  background: var(--accent-primary);
  transform: scale(1.2);
}

.handle-nw { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-n  { top: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-ne { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-e  { top: calc(50% - 5px); right: -5px; cursor: ew-resize; }
.handle-se { bottom: -5px; right: -5px; cursor: nwse-resize; }
.handle-s  { bottom: -5px; left: calc(50% - 5px); cursor: ns-resize; }
.handle-sw { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-w  { top: calc(50% - 5px); left: -5px; cursor: ew-resize; }


/* ==========================================================================
   STAGE 4 & 5: DROPZONE OVERLAY, MEDIA NODES (IMAGE/GIF/VIDEO), STICKY & FRAME
   ========================================================================== */

/* Fullscreen Drag-and-Drop Overlay */
.dropzone-overlay {
  position: absolute;
  inset: 16px;
  z-index: 45;
  background: rgba(15, 17, 21, 0.72);
  backdrop-filter: blur(8px);
  border: 2px dashed var(--accent-primary);
  border-radius: calc(var(--panel-radius) + 4px);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.14s ease;
}

.dropzone-overlay.is-active {
  opacity: 1;
}

.dropzone-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 36px;
  background: var(--bg-panel-solid);
  border: 1px solid var(--border-focus);
  border-radius: var(--panel-radius);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.dropzone-icon {
  font-size: 42px;
  color: var(--accent-primary);
}

.dropzone-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.dropzone-sub {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Image, GIF & Video Nodes */
.grid-node.node-type-image,
.grid-node.node-type-video {
  padding: 0;
  overflow: visible;
  background: transparent;
}

.media-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: var(--node-radius);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.04);
}

.node-media-img,
.node-media-video {
  width: 100%;
  height: 100%;
  flex: 1;
  min-height: 0;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.media-caption-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  background: var(--node-surface);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  user-select: none;
}

.media-caption-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 1;
}

.media-caption-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}

.media-caption-btn:hover {
  background: var(--bg-panel-hover);
  color: var(--text-primary);
}

.media-caption-btn .material-symbols-outlined {
  font-size: 15px;
}

.media-type-icon {
  font-size: 15px;
  color: var(--accent-primary);
  flex-shrink: 0;
}

/* Section Frame / Board Nodes (Solid Fill, Default White #ffffff) */
.grid-node.node-type-frame {
  --node-custom-color: #ffffff;
  background: var(--node-custom-color);
  border: 2px solid var(--node-border);
}

.grid-node.node-type-frame.is-selected {
  border-color: var(--accent-primary);
}

.grid-node.node-type-frame.is-locked,
.grid-node.node-type-frame.is-locked.is-selected {
  border-color: var(--node-border);
  box-shadow: none;
}

/* Locked Frame State */
.grid-node.node-type-frame.is-locked {
  cursor: default;
}

.grid-node.node-type-frame.is-locked .resize-handle {
  display: none;
}

.grid-node.node-type-frame.is-locked .frame-backdrop-area {
  pointer-events: auto;
  cursor: default;
}

/* When a frame is locked, its children inside the frame are also locked and cannot be dragged or resized */
.grid-node[data-parent-locked="true"] {
  cursor: default;
}

.grid-node[data-parent-locked="true"] .resize-handle {
  display: none;
}

.grid-node.node-type-frame.is-locked .frame-action-btn.btn-toggle-lock.is-locked-btn {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.frame-action-btn.btn-toggle-lock {
  color: var(--text-secondary);
}

.frame-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 12px;
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  border-top-left-radius: var(--node-radius);
  border-top-right-radius: var(--node-radius);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.frame-header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  flex: 1;
}

.frame-controls-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.frame-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 20px;
  padding: 0;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease;
}

.frame-action-btn:hover {
  background: rgba(255, 255, 255, 0.09);
}

.frame-action-btn:active {
  background: rgba(255, 255, 255, 0.13);
}

.frame-action-btn.is-active-btn {
  background: rgba(99, 102, 241, 0.18);
  color: var(--accent-primary, #6366f1);
  border-color: rgba(99, 102, 241, 0.4);
}

.frame-action-btn .material-symbols-outlined {
  font-size: 14px;
}

.frame-action-btn svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
  display: block;
  shape-rendering: geometricPrecision;
}

.frame-color-picker-label {
  position: relative;
  overflow: hidden;
}

.frame-color-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  padding: 0;
  border: none;
  cursor: pointer;
}

.frame-icon {
  font-size: 16px;
  color: var(--text-secondary);
}

.frame-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text-primary);
  white-space: nowrap;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-title[contenteditable="true"] {
  outline: none;
  background: transparent;
  padding: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  user-select: text;
  cursor: text;
}

.frame-backdrop-area {
  flex: 1;
  background-color: var(--node-custom-color);
  border-bottom-left-radius: var(--node-radius);
  border-bottom-right-radius: var(--node-radius);
  position: relative;
  overflow: hidden;
}

/* Subtle, very low opacity internal grid for Section Board / Frame */
.grid-node.node-type-frame.has-frame-grid .frame-backdrop-area {
  background-image: 
    linear-gradient(to right, rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
  background-size: 24px 24px;
}


/* Frame Drop-Target Border Highlight & Child Count Badge */
.grid-node.node-type-frame.is-drop-target {
  border-color: #10b981;
}

.frame-children-badge {
  display: var(--frame-badge-display, none);
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: var(--node-radius);
  background: var(--accent-glow);
  color: var(--accent-primary);
  border: 1px solid var(--border-focus);
  flex-shrink: 0;
}


/* ==========================================================================
   STAGE 6: FREEFORM CLICK-TO-CLICK ARROW MODE (A), HOVER ENDPOINT CIRCLES,
            WHOLE-ARROW DRAG & TOP-HEADER ARROW STYLE BAR
   ========================================================================== */

/* Top-Header Arrow Settings Bar (Weight, Head Size, Color) */
.arrow-header-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--panel-height, 40px);
  padding: 6px 10px;
  box-sizing: border-box;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
}

.arrow-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 7px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--accent-primary);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
}

.arrow-header-badge:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-subtle);
}

.arrow-header-badge:active {
  transform: translateY(1px);
}

.arrow-header-badge.is-hard,
.arrow-header-badge.is-hard-point {
  color: var(--accent-primary);
}

.arrow-header-icon {
  font-size: 18px;
}

.arrow-edge-pill {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-primary);
  border: none;
}

.arrow-header-badge.is-hard .arrow-edge-pill,
.arrow-header-badge.is-round .arrow-edge-pill {
  background: transparent;
  color: var(--text-primary);
  border: none;
}

.arrow-setting-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.arrow-setting-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.arrow-range-input {
  width: 68px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.arrow-weight-box {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.arrow-number-input {
  width: 44px;
  padding: 2px 5px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  outline: none;
  cursor: text;
  transition: border-color 0.12s ease, background-color 0.12s ease;
  -moz-appearance: textfield;
}

.arrow-number-input::-webkit-outer-spin-button,
.arrow-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.arrow-number-input:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-focus);
}

.arrow-number-input:focus {
  background: var(--bg-panel-solid);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

.arrow-weight-unit {
  font-size: 10px;
  color: var(--text-muted);
  user-select: none;
}

.arrow-readout {
  font-size: 11px;
  color: var(--text-primary);
  min-width: 32px;
  text-align: right;
}

.arrow-color-picker {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

/* Top Header Annotation / Freehand Pen Settings Bar */
.annotation-header-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--panel-height, 40px);
  padding: 6px 10px;
  box-sizing: border-box;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  pointer-events: auto;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.annotation-header-bar.is-active-tool {
  border-color: #f43f5e;
  box-shadow: 0 0 14px rgba(244, 63, 94, 0.25);
}

.annotation-header-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding-right: 4px;
  color: #f43f5e;
  font-size: 12px;
  font-weight: 700;
}

.annotation-header-icon {
  font-size: 18px;
}

.annotation-setting-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.annotation-setting-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.annotation-range-input {
  width: 64px;
  accent-color: #f43f5e;
  cursor: pointer;
}

.annotation-size-box {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.annotation-number-input {
  width: 38px;
  padding: 2px 4px;
  background: rgba(128, 128, 128, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
  outline: none;
  cursor: text;
  transition: border-color 0.12s ease, background-color 0.12s ease;
  -moz-appearance: textfield;
}

.annotation-number-input::-webkit-outer-spin-button,
.annotation-number-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

.annotation-number-input:hover {
  background: var(--bg-panel-hover);
  border-color: var(--border-focus);
}

.annotation-number-input:focus {
  background: var(--bg-panel-solid);
  border-color: #f43f5e;
  box-shadow: 0 0 0 1px #f43f5e;
}

.annotation-size-unit {
  font-size: 10px;
  color: var(--text-muted);
  user-select: none;
}

.annotation-color-picker {
  width: 24px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.annotation-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.annotation-clear-btn:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.35);
}

.annotation-clear-btn .material-symbols-outlined {
  font-size: 18px;
}

.viewport.is-arrow-tool,
.viewport.is-arrow-tool .grid-node {
  cursor: crosshair;
}

.viewport.is-pen-tool,
.viewport.is-pen-tool .grid-node {
  cursor: crosshair;
}

.viewport.is-eraser-tool,
.viewport.is-eraser-tool .grid-node {
  cursor: crosshair;
}

.viewport.is-frame-tool,
.viewport.is-frame-tool .grid-node,
.viewport.is-card-tool,
.viewport.is-card-tool .grid-node,
.viewport.is-audio-tool,
.viewport.is-audio-tool .grid-node {
  cursor: crosshair;
}

/* Infinite Vector SVG Layer & Midpoint Labels Layer inside #world */
.connections-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
  z-index: 9998;
}

.connection-labels-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  overflow: visible;
  pointer-events: none;
  z-index: 9999;
}

/* Stage 7: Real-time Freehand Vector Annotation Layer inside #world */
.annotations-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  overflow: visible;
  pointer-events: none;
  z-index: 10000;
}

.annotation-item {
  pointer-events: none;
  vector-effect: non-scaling-stroke;
}

.annotation-stroke {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.annotation-eraser-cursor {
  fill: rgba(244, 63, 94, 0.12);
  stroke: #f43f5e;
  stroke-width: 1.5px;
  stroke-dasharray: 4 2;
  pointer-events: none;
}

/* Individual SVG Arrow Groups */
.conn-group {
  pointer-events: all;
  cursor: grab;
  transition: filter 0.15s ease;
}

.conn-group.is-selected {
  opacity: 1;
}

.conn-group.is-dragging {
  cursor: grabbing;
  opacity: 1;
}

.world-plane.is-drawing-arrow .conn-group {
  pointer-events: none;
}

.conn-hit-path {
  fill: none;
  stroke: transparent;
  stroke-width: 24px;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: grab;
}

.conn-group.is-dragging .conn-hit-path {
  cursor: grabbing;
}

.conn-outline-path {
  fill: none;
  stroke: rgba(0, 0, 0, 0.3);
  stroke-linecap: var(--conn-line-cap, round);
  stroke-linejoin: var(--conn-line-join, round);
  pointer-events: none;
}

.conn-shell-path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 18px;
  stroke-linecap: var(--conn-line-cap, round);
  stroke-linejoin: var(--conn-line-join, round);
  pointer-events: none;
}

.conn-visible-path {
  fill: none;
  stroke: var(--arrow-default);
  stroke-width: 12px;
  stroke-linecap: var(--conn-line-cap, round);
  stroke-linejoin: var(--conn-line-join, round);
  pointer-events: none;
}

/* Endpoint Drag Hit Circles (Bulletpoints) layered on top of the arrow */
.conn-endpoint-handle {
  fill: #ffffff;
  stroke: var(--accent-primary, #6366f1);
  stroke-width: 2.5px;
  pointer-events: all;
  cursor: grab;
  opacity: 0;
  transform-origin: center;
  transition: opacity 0.16s ease, transform 0.16s cubic-bezier(0.34, 1.56, 0.64, 1), stroke-color 0.12s ease;
}

.conn-endpoint-handle:active,
.conn-group.is-dragging .conn-endpoint-handle {
  cursor: grabbing;
}

/* Display bulletpoints on hover of the arrow, or when selected/dragging */
.conn-group:hover .conn-endpoint-handle,
.conn-group.is-selected .conn-endpoint-handle,
.conn-group.is-dragging .conn-endpoint-handle {
  opacity: 1;
}

.conn-endpoint-handle:hover {
  stroke: #ffffff;
  fill: var(--accent-primary, #6366f1);
  filter: drop-shadow(0 0 3px rgba(99, 102, 241, 0.6));
}

/* Live 2-Click Guide Arrow in Arrow Mode (`A`) */
.conn-guide-group {
  pointer-events: none;
}

.conn-draft-outline-path {
  fill: none;
  stroke: rgba(0, 0, 0, 0.3);
  stroke-linecap: var(--conn-line-cap, round);
  stroke-linejoin: var(--conn-line-join, round);
  pointer-events: none;
}

.conn-draft-shell-path {
  fill: none;
  stroke: #ffffff;
  stroke-width: 18px;
  stroke-linecap: var(--conn-line-cap, round);
  stroke-linejoin: var(--conn-line-join, round);
  pointer-events: none;
}

.conn-draft-path {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 12px;
  stroke-dasharray: 10 7;
  stroke-linecap: var(--conn-line-cap, round);
  pointer-events: none;
}

.conn-guide-start-dot,
.conn-guide-end-ring {
  display: none;
}

/* Midpoint Connection Label Pill */
.conn-label-pill {
  position: absolute;
  top: 0;
  left: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  background: var(--bg-panel-solid);
  color: var(--text-primary);
  border: 1.5px solid var(--conn-accent, var(--arrow-default));
  border-radius: var(--node-radius);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: auto;
  cursor: grab;
  outline: none;
  translate: -50% -50%;
}

.conn-label-pill.has-label {
  display: inline-flex;
}

.conn-label-pill.is-selected {
  border-color: var(--accent-primary);
}

.conn-label-pill.is-editing {
  cursor: text;
  user-select: text;
  min-width: 54px;
  background: var(--bg-panel-solid);
  border-color: var(--accent-primary);
}

/* =========================================================================
   DIAGNOSTIC TELEMETRY, HEALTH PILL & FLIGHT RECORDER DRAWER
   Strict Standards: Zero !important, Zero margin (100% Flex/Grid gap & padding)
   ========================================================================= */

.hud-health-pill {
  width: auto;
  min-width: max-content;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  height: 28px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hud-health-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.18);
}

.health-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.5);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.health-pill-text {
  white-space: nowrap;
  line-height: 1;
}

.hud-health-pill.is-healthy .health-pulse-dot {
  background: #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

.hud-health-pill.is-healthy .health-pill-text {
  color: #34d399;
}

.hud-health-pill.is-warning .health-pulse-dot {
  background: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.7);
}

.hud-health-pill.is-warning .health-pill-text {
  color: #fbbf24;
}

.hud-health-pill.is-critical .health-pulse-dot {
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.9);
  animation: health-pulse 1.4s infinite;
}

.hud-health-pill.is-critical .health-pill-text {
  color: #f87171;
}

.hud-health-pill.is-offline .health-pulse-dot {
  background: #9ca3af;
  box-shadow: none;
}

.hud-health-pill.is-offline .health-pill-text {
  color: #d1d5db;
}

@keyframes health-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.35); opacity: 0.6; }
  100% { transform: scale(1); opacity: 1; }
}

/* Diagnostic Drawer Floating Panel */
.diagnostic-drawer {
  position: fixed;
  bottom: 64px;
  right: var(--viewport-edge-pad);
  width: 480px;
  max-width: calc(100vw - 36px);
  max-height: calc(100vh - 84px);
  background: var(--bg-panel-solid);
  backdrop-filter: blur(var(--panel-blur));
  -webkit-backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1), transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 1000;
  overflow: hidden;
}

.diagnostic-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.diagnostic-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

.diagnostic-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.diagnostic-icon {
  font-size: 24px;
  color: #10b981;
}

.diagnostic-title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.diagnostic-subtitle {
  font-family: var(--font-sans);
  font-size: 11px;
  color: var(--text-muted);
}

.diagnostic-metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.diagnostic-metric-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}

.metric-label {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-val {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

.metric-healthy {
  color: #34d399;
}

.metric-warning {
  color: #fbbf24;
}

.metric-danger {
  color: #f87171;
}

.diagnostic-actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.diagnostic-actions-row .style-btn {
  flex: 1;
  min-width: 120px;
  justify-content: center;
  padding: 6px 10px;
  font-size: 11px;
}

.diagnostic-log-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex: 1;
}

.diagnostic-section-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
}

.diagnostic-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding-right: 4px;
}

.diagnostic-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px 16px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
}

.diagnostic-empty-state .empty-icon {
  font-size: 28px;
  color: #10b981;
}

.diagnostic-empty-state .empty-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  word-break: break-all;
}

.diagnostic-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
}

.diagnostic-item.is-item-critical {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.05);
}

.diagnostic-item.is-item-warning {
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.05);
}

.diagnostic-item-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.diagnostic-badge {
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-critical {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.badge-warning {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.diagnostic-type {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary);
}

.diagnostic-time {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

.diagnostic-msg {
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
  word-break: break-word;
}

.diagnostic-source {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.diagnostic-stack {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.3);
  padding: 6px 8px;
  border-radius: 4px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 120px;
}


/* ==========================================================================
   AUDIO CARD / SOUND RECORDER NODE (type === 'audio')
   ========================================================================== */
.grid-node.node-type-audio {
  display: flex;
  flex-direction: column;
  background: var(--node-surface);
  border: 1.5px solid var(--node-border);
  border-radius: var(--node-radius);
  box-shadow: none;
  overflow: hidden;
  user-select: none;
}

.grid-node.node-type-audio.is-selected {
  border-color: #ef4444;
  box-shadow: 0 0 0 1.5px #ef4444;
}

/* Snug height: hide vertical and corner resize handles so audio capsule stays snug */
.grid-node.node-type-audio .handle-nw,
.grid-node.node-type-audio .handle-n,
.grid-node.node-type-audio .handle-ne,
.grid-node.node-type-audio .handle-se,
.grid-node.node-type-audio .handle-s,
.grid-node.node-type-audio .handle-sw {
  display: none;
}

.audio-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px 2px 12px;
  background: transparent;
  border-bottom: none;
}

.audio-mic-icon {
  font-size: 16px;
  color: #ef4444;
}

.audio-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.audio-duration-badge {
  font-size: 11px;
  color: var(--text-muted);
  background: transparent;
  padding: 0;
  border-radius: 4px;
}

.audio-studio-body {
  padding: 4px 12px 10px 12px;
  background: transparent;
  border-bottom-left-radius: var(--node-radius);
  border-bottom-right-radius: var(--node-radius);
}

.audio-studio-body .is-hidden {
  display: none;
}

.audio-state-record {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 2px 0 0 0;
}

.audio-action-btn.btn-start-record {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 16px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.audio-action-btn.btn-start-record:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.7);
  transform: translateY(-1px);
}

.audio-record-dot {
  font-size: 13px;
  color: #ef4444;
}

.audio-upload-btn.btn-upload-audio-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: rgba(128, 128, 128, 0.08);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.audio-upload-btn.btn-upload-audio-file:hover {
  background: rgba(128, 128, 128, 0.16);
  color: var(--text-primary);
}

.audio-upload-btn.btn-upload-audio-file .material-symbols-outlined {
  font-size: 14px;
}

.audio-state-live {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 0 0 0;
}

.audio-live-hud {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-rec-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  color: #ef4444;
}

.rec-dot-pulsing {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: recPulseAnim 1s infinite alternate ease-in-out;
}

@keyframes recPulseAnim {
  0% { transform: scale(0.85); opacity: 0.6; }
  100% { transform: scale(1.25); opacity: 1; }
}

.audio-rec-wave-anim {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
}

.audio-rec-wave-anim span {
  width: 3px;
  height: 100%;
  background: #ef4444;
  border-radius: 2px;
  animation: waveBarBounce 0.8s infinite ease-in-out alternate;
}

.audio-rec-wave-anim span:nth-child(2) { animation-delay: 0.15s; }
.audio-rec-wave-anim span:nth-child(3) { animation-delay: 0.3s; }
.audio-rec-wave-anim span:nth-child(4) { animation-delay: 0.45s; }
.audio-rec-wave-anim span:nth-child(5) { animation-delay: 0.2s; }
.audio-rec-wave-anim span:nth-child(6) { animation-delay: 0.35s; }
.audio-rec-wave-anim span:nth-child(7) { animation-delay: 0.1s; }
.audio-rec-wave-anim span:nth-child(8) { animation-delay: 0.25s; }

@keyframes waveBarBounce {
  0% { height: 4px; }
  100% { height: 16px; }
}

.audio-action-btn.btn-stop-record {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid #ef4444;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.audio-action-btn.btn-stop-record:hover {
  background: #dc2626;
}

.audio-action-btn.btn-stop-record .material-symbols-outlined {
  font-size: 15px;
}

.audio-state-player {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.audio-player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.audio-playback-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: rgba(128, 128, 128, 0.1);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.audio-playback-btn:hover {
  background: var(--accent-primary, #6366f1);
  border-color: var(--accent-primary, #6366f1);
  color: #ffffff;
}

.audio-playback-btn .material-symbols-outlined {
  font-size: 16px;
}

.audio-time-readout {
  font-size: 11px;
  color: var(--text-secondary);
  flex: 1;
}

.btn-audio-rerecord {
  border-radius: 6px;
  width: 24px;
  height: 24px;
}

.btn-audio-rerecord:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: #ef4444;
  color: #ef4444;
}

.audio-scrubber-track {
  position: relative;
  width: 100%;
  height: 6px;
  background: rgba(128, 128, 128, 0.2);
  border-radius: 3px;
  cursor: pointer;
}

.audio-scrubber-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--accent-primary, #6366f1);
  border-radius: 3px;
  pointer-events: none;
}

.audio-scrubber-handle {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ffffff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.4);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.audio-scrubber-track:hover .audio-scrubber-handle {
  opacity: 1;
}

@keyframes audioSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.audio-spinning {
  display: inline-block;
  animation: audioSpin 0.9s infinite linear;
}

.audio-playback-btn:disabled,
.audio-action-btn:disabled,
.audio-upload-btn:disabled {
  opacity: 0.55;
  cursor: wait;
  pointer-events: none;
}

/* ==========================================================================
   VIEWER / CLIENT PRESENTATION MODE
   ========================================================================== */
body.is-viewer-mode .arrow-header-bar,
body.is-viewer-mode .annotation-header-bar,
body.is-viewer-mode #tool-dock,
body.is-viewer-mode #style-dock,
body.is-viewer-mode #btn-project-hub .project-chevron,
body.is-viewer-mode #btn-save-now,
body.is-viewer-mode #btn-open-folder-top,
body.is-viewer-mode #save-status-pill,
body.is-viewer-mode .node-resize-handles,
body.is-viewer-mode .btn-audio-rerecord,
body.is-viewer-mode .btn-upload-audio-file,
body.is-viewer-mode .btn-start-record,
body.is-viewer-mode .audio-state-record {
  display: none;
}

body.is-viewer-mode #btn-project-hub {
  pointer-events: none;
  cursor: default;
}

body.is-viewer-mode .grid-node {
  cursor: default;
}

body.is-viewer-mode .grid-node:not(.node-type-frame).is-selected {
  border-color: var(--node-border);
  box-shadow: none;
}

/* ==========================================================================
   AUTHENTICATION HUD & ADMIN BADGE
   ========================================================================== */
.is-hidden,
.auth-hud-bar.is-hidden,
.auth-login-btn.is-hidden,
.admin-badge-group.is-hidden,
.modal-backdrop.is-hidden {
  display: none;
}

.auth-hud-bar {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: var(--panel-height, 40px);
  padding: 4px 6px;
  box-sizing: border-box;
  background: var(--bg-panel);
  backdrop-filter: blur(var(--panel-blur));
  border: 1px solid var(--border-subtle);
  border-radius: var(--panel-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.auth-login-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: var(--accent-primary, #6366f1);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-login-btn:hover {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-primary, #6366f1);
}

.auth-login-btn .material-symbols-outlined {
  font-size: 15px;
}

.admin-badge-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #10b981;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}

.auth-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.auth-logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}

.auth-logout-btn .material-symbols-outlined {
  font-size: 18px;
}

/* ==========================================================================
   LOGGED-OFF STATE (GRID REMAINS VISIBLE, NOTHING ELSE EXCEPT CENTER LOGIN)
   ========================================================================== */
body.is-logged-off .top-bar,
body.is-logged-off #tool-dock,
body.is-logged-off #style-dock,
body.is-logged-off .hud-bar,
body.is-logged-off #auth-hud-bar,
body.is-logged-off #world,
body.is-logged-off #connections-layer,
body.is-logged-off #connection-labels-layer,
body.is-logged-off #annotations-layer,
body.is-logged-off #marquee-box,
body.is-logged-off #dropzone-overlay,
body.is-logged-off #style-studio-drawer,
body.is-logged-off #diagnostic-drawer,
body.is-logged-off #project-hub-backdrop {
  display: none;
}

body.is-logged-off .viewport {
  width: 100vw;
  height: 100vh;
  cursor: default;
}

body.is-logged-off .grid-backdrop {
  opacity: 1;
  background-color: var(--bg-canvas, #f5f6f8);
  background-size: 24px 24px, 24px 24px, 120px 120px, 120px 120px;
  background-image:
    linear-gradient(to right, rgba(15, 23, 42, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.05) 1px, transparent 1px),
    linear-gradient(to right, rgba(15, 23, 42, 0.11) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(15, 23, 42, 0.11) 1px, transparent 1px);
}

/* Fullscreen Overlay: Transparent so the infinite canvas grid is 100% visible */
.auth-login-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  z-index: 9999;
  padding: 24px;
  box-sizing: border-box;
}

body.is-logged-off .auth-login-overlay {
  display: flex;
}

body:not(.is-logged-off) .auth-login-overlay.is-hidden {
  display: none;
}

/* Centered Floating Login Window Card */
.auth-window-card {
  width: 100%;
  max-width: 380px;
  background: rgba(18, 21, 28, 0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 18px;
  padding: 32px 28px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(99, 102, 241, 0.25), 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  gap: 24px;
  box-sizing: border-box;
  animation: authFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  color: #f8fafc;
}

@keyframes authFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Header & Brand Identity */
.auth-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
}

.auth-brand-badge {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25) 0%, rgba(129, 140, 248, 0.12) 100%);
  border: 1px solid rgba(99, 102, 241, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-brand-icon {
  font-size: 26px;
  color: #a5b4fc;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: #ffffff;
  line-height: 1.2;
}

.auth-subtitle {
  font-size: 13px;
  font-weight: 400;
  color: #94a3b8;
  line-height: 1.4;
}

/* Form & Input Fields */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #94a3b8;
}

.auth-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-input-icon {
  position: absolute;
  left: 12px;
  font-size: 18px;
  color: #64748b;
  pointer-events: none;
}

.auth-input {
  width: 100%;
  height: 42px;
  padding: 0 14px 0 38px;
  background: rgba(11, 13, 18, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  color: #ffffff;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.auth-input::placeholder {
  color: #64748b;
}

.auth-input:hover {
  border-color: rgba(255, 255, 255, 0.25);
}

.auth-input:focus {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.25);
  background: rgba(11, 13, 18, 1);
}

.auth-input.auth-input-password {
  padding-right: 40px;
}

.auth-password-toggle {
  position: absolute;
  right: 6px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #64748b;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease, background 0.15s ease;
}

.auth-password-toggle:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.auth-password-toggle .material-symbols-outlined {
  font-size: 18px;
}

/* Error Alert Box */
.auth-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  box-sizing: border-box;
}

.auth-error.is-hidden {
  display: none;
}

.auth-error-icon {
  font-size: 18px;
  color: #ef4444;
  flex-shrink: 0;
}

/* Action & Submit Button */
.auth-actions {
  display: flex;
  flex-direction: column;
  padding-top: 4px;
}

.auth-submit-btn {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-sizing: border-box;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease, opacity 0.15s ease;
}

.auth-submit-btn:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  box-shadow: 0 6px 18px rgba(99, 102, 241, 0.45);
}

.auth-submit-btn:active {
  transform: scale(0.985);
}

.auth-submit-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-submit-btn .material-symbols-outlined {
  font-size: 18px;
}

