:root {
  --bg-app: #0b0f17;
  --bg-panel: #111827;
  --bg-elevated: #1a2234;
  --bg-hover: #243047;
  --border: #263147;
  --border-strong: #374765;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 8px;
  --radius-sm: 6px;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", "Fira Code", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

code,
kbd {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-secondary);
  font-size: 11px;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
  margin: 0 4px;
  flex-shrink: 0;
}

.toolbar-spacer {
  flex: 1;
}

.brand-group {
  gap: 10px;
  margin-right: 4px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: #60a5fa;
  display: grid;
  place-items: center;
  border: 1px solid rgba(96, 165, 250, 0.25);
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.plan-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, opacity 0.14s ease;
  white-space: nowrap;
}

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

.btn-lg {
  height: 38px;
  padding: 0 18px;
  font-size: 13.5px;
}

.btn-compact {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-primary);
  font-size: 15px;
}

.btn-icon:hover:not(:disabled) {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn-primary {
  background: var(--accent);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
}

.btn-toggle {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-secondary);
}

.btn-toggle.active {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.45);
  color: #93c5fd;
}

.tool-segmented {
  background: var(--bg-app);
  padding: 3px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  gap: 2px;
}

.btn-tool {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.btn-tool:hover {
  color: var(--text-primary);
}

.btn-tool.active {
  background: var(--accent);
  color: #ffffff;
}

.btn-tool.active kbd {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

.danger-text {
  color: #f87171;
}

.danger-text:hover:not(:disabled) {
  background: var(--danger-soft);
  color: #fca5a5;
}

/* Main Workspace */
.workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

.canvas-container {
  position: relative;
  flex: 1;
  min-width: 0;
  background-color: #0b0f17;
  background-image: radial-gradient(rgba(148, 163, 184, 0.14) 1px, transparent 1px);
  background-size: 20px 20px;
  overflow: hidden;
  user-select: none;
}

#planCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Empty State */
.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(15, 23, 42, 0.72), rgba(11, 15, 23, 0.92));
}

.empty-card {
  max-width: 560px;
  text-align: center;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 36px 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45);
}

.empty-icon {
  width: 68px;
  height: 68px;
  margin: 0 auto 16px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: #60a5fa;
  display: grid;
  place-items: center;
  border: 1px solid rgba(96, 165, 250, 0.28);
}

.empty-card h1 {
  margin: 0 0 10px;
  font-size: 20px;
  font-weight: 700;
}

.empty-card p {
  margin: 0 0 22px;
  color: var(--text-secondary);
  font-size: 13.5px;
}

.empty-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

.empty-hint {
  margin: 0 !important;
  font-size: 12px !important;
  color: var(--text-muted) !important;
}

/* Floating Banners & HUD */
.floating-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background: rgba(30, 41, 59, 0.95);
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: 8px;
  color: #fde68a;
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.drop-overlay {
  position: absolute;
  inset: 12px;
  border: 2px dashed #60a5fa;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.8);
  display: grid;
  place-items: center;
  z-index: 30;
  pointer-events: none;
}

.drop-overlay-box {
  padding: 18px 28px;
  border-radius: 10px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  font-size: 15px;
  font-weight: 600;
}

.hud-pill {
  position: absolute;
  bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 11.5px;
  backdrop-filter: blur(6px);
  pointer-events: none;
}

.hud-bottom-left {
  left: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
}

.hud-bottom-center {
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
}

.hud-sep {
  color: var(--text-muted);
}

/* Sidebar */
.sidebar {
  width: 310px;
  flex-shrink: 0;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.sidebar-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-title-row h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
}

.room-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.room-list-empty {
  padding: 24px 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
}

.room-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.room-item:hover {
  background: var(--bg-elevated);
}

.room-item.selected {
  background: var(--accent-soft);
  border-color: rgba(59, 130, 246, 0.45);
}

.room-item.is-hidden {
  opacity: 0.5;
}

.room-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.room-item-info {
  flex: 1;
  min-width: 0;
}

.room-item-name {
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.room-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.room-item-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-mini-btn {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 13px;
}

.icon-mini-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
}

/* Inspector */
.inspector {
  border-top: 1px solid var(--border);
  padding: 12px 14px;
  background: rgba(26, 34, 52, 0.55);
  max-height: 48%;
  overflow-y: auto;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.inspector-header h3 {
  margin: 0;
  font-size: 12.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
}

.field-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.text-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-app);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
}

.text-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.inspector-rename-row {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.inspector-rename-row .text-input {
  height: 28px;
  font-size: 12.5px;
}

.field-error {
  color: #f87171;
  font-size: 11.5px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.swatch-btn {
  width: 22px;
  height: 22px;
  border-radius: 5px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.swatch-btn:hover {
  transform: scale(1.1);
}

.swatch-btn.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px var(--accent);
}

.inspector-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.points-list {
  max-height: 110px;
  overflow-y: auto;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px 8px;
}

.sidebar-footer {
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-panel);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
}

.modal-card-wide {
  max-width: 720px;
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 17px;
}

.modal-subtitle {
  margin: 0 0 16px;
  color: var(--text-secondary);
  font-size: 12.5px;
}

.modal-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.export-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-secondary);
  cursor: pointer;
}

.code-preview {
  margin: 0;
  padding: 14px;
  max-height: 320px;
  overflow: auto;
  background: #070b12;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  color: #cbd5e1;
  white-space: pre;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  right: 330px;
  padding: 10px 16px;
  border-radius: 8px;
  background: #1e293b;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 60;
}

.toast.toast-error {
  border-color: rgba(239, 68, 68, 0.6);
  background: #3f1519;
  color: #fecaca;
}

.toast.toast-success {
  border-color: rgba(16, 185, 129, 0.55);
  background: #0e2e25;
  color: #a7f3d0;
}

@media (max-width: 900px) {
  .sidebar {
    width: 240px;
  }
  .hud-bottom-center {
    display: none;
  }
  .toast {
    right: 20px;
  }
}
