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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

#app { display: flex; height: 100vh; }

/* Sidebar */
#sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

#sidebar-header h1 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: 0.02em;
  margin-bottom: 2px;
}

#sidebar-header p { font-size: 10px; color: var(--text3); }

#palette-wrap, #furniture-wrap {
  padding: 10px 10px 6px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 200px;
  overflow-y: auto;
}

.palette-label, .section-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin-bottom: 6px;
}

.room-btn {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  cursor: grab;
  margin-bottom: 3px;
  font-size: 11.5px;
  color: var(--text);
  transition: background 0.1s, border-color 0.1s;
  user-select: none;
}

.room-btn:hover { background: var(--bg3); border-color: var(--border2); }

/* Saved plans */
#plans-wrap {
  padding: 10px 10px 8px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  max-height: 190px;
  overflow-y: auto;
}
.plans-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}
.plans-new {
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  cursor: pointer;
}
.plans-new:hover { background: var(--accent); color: #fff; }
.plans-new:disabled { opacity: 0.4; cursor: not-allowed; }
.plan-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  margin-bottom: 4px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.plan-item:hover { background: var(--bg3); border-color: var(--border2); }
.plan-item.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.plan-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
}
.plan-item.active .plan-dot { background: var(--accent); }
.plan-info { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.plan-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.plan-meta { font-size: 9.5px; color: var(--text3); }
.plan-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.1s; flex-shrink: 0; }
.plan-item:hover .plan-actions, .plan-item.active .plan-actions { opacity: 1; }
.plan-act {
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 11px;
  padding: 2px 4px;
  border-radius: 4px;
  line-height: 1;
}
.plan-act:hover { background: var(--bg); color: var(--text); }
.plan-act-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* Cloud sync bar */
.cloud-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
}
.cloud-signin {
  width: 100%;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
}
.cloud-signin:hover { background: var(--accent); color: #fff; }
.cloud-bar.signed-out { flex-direction: column; align-items: stretch; gap: 4px; }
.cloud-hint { font-size: 10px; color: var(--text3); text-align: center; line-height: 1.3; }
.cloud-bar.signed-in {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
}
.cloud-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text3);
}
.cloud-status.cloud-synced { background: var(--success); }
.cloud-status.cloud-syncing { background: var(--warning); }
.cloud-status.cloud-error { background: var(--danger); }
.cloud-email {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text2);
}
.cloud-state { color: var(--text3); font-size: 10px; }
.cloud-out {
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  font-size: 10.5px;
  padding: 2px 4px;
  border-radius: 4px;
}
.cloud-out:hover { background: var(--bg3); color: var(--text); }

/* Floor mini buttons next to the floor selector */
.floor-mini-btn {
  border: 1px solid var(--border2);
  background: var(--surface);
  color: var(--text2);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  padding: 3px 6px;
  margin-left: 2px;
}
.floor-mini-btn:hover { background: var(--bg3); color: var(--text); }
.floor-mini-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.floor-mini-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.room-btn:active { cursor: grabbing; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}

.room-btn .def-size {
  margin-left: auto;
  font-size: 10px;
  color: var(--text3);
  font-family: var(--font-mono);
}

#props-wrap {
  padding: 10px 10px 6px;
  overflow-y: auto;
  flex: 1;
}

.prop-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
  gap: 4px;
}

.prop-row label { font-size: 11px; color: var(--text2); white-space: nowrap; }

.prop-row input[type=text],
.prop-row input[type=number],
.prop-row select {
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  background: var(--bg2);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.prop-row input[type=number] { width: 72px; text-align: right; }
.prop-row input[type=text] { width: 90px; }
.prop-row select { width: 90px; max-width: 100px; }
.prop-row input:focus, .prop-row select:focus { border-color: var(--accent); }

.area-display {
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
  margin: 5px 0 8px;
  padding: 4px 7px;
  background: var(--bg2);
  border-radius: 5px;
}

.sep { border-top: 1px solid var(--border); margin: 8px 0; }

.stats-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 4px;
}

.stats-row span:first-child { color: var(--text3); }
.stats-row span:last-child { color: var(--text); font-weight: 500; font-family: var(--font-mono); }

.btn {
  display: block;
  width: 100%;
  padding: 5px 8px;
  margin-bottom: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-size: 11px;
  cursor: pointer;
  text-align: center;
  transition: background 0.1s, border-color 0.1s;
}

.btn:hover { background: var(--bg3); }
.btn-accent { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.btn-accent:hover { background: var(--accent); color: #fff; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { display: inline-block; width: auto; padding: 3px 8px; margin-right: 4px; margin-bottom: 4px; }

#empty-props { font-size: 11px; color: var(--text3); line-height: 1.5; }

/* Canvas area */
#canvas-wrap {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: var(--canvas-bg);
}

canvas {
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
}

/* Toolbar */
#toolbar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 5px 7px;
  z-index: 20;
  box-shadow: var(--shadow);
  max-width: calc(100% - 240px);
}

.tool-btn {
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  color: var(--text2);
  transition: all 0.12s;
  white-space: nowrap;
}

.tool-btn:hover { background: var(--bg2); color: var(--text); }
.tool-btn.active {
  background: var(--bg3);
  border-color: var(--border2);
  color: var(--text);
}

.tool-sep {
  width: 1px;
  background: var(--border);
  margin: 2px 2px;
  align-self: stretch;
}

/* Top-right controls */
#top-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  z-index: 20;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 5px 10px;
  font-size: 11px;
  box-shadow: var(--shadow);
}

.control-group label { color: var(--text2); font-weight: 500; white-space: nowrap; }

.control-group select {
  padding: 2px 5px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  background: var(--bg2);
  color: var(--text);
  outline: none;
}

.theme-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  transition: transform 0.1s, border-color 0.1s;
}

.theme-btn:hover { transform: scale(1.1); }
.theme-btn.active { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }

.theme-btn[data-theme-pick="light"] { background: linear-gradient(135deg, #fff 50%, #f5f4f0 50%); }
.theme-btn[data-theme-pick="dark"] { background: linear-gradient(135deg, #2c2c2a 50%, #1a1a18 50%); }
.theme-btn[data-theme-pick="colorful"] { background: linear-gradient(135deg, #ffedd5 50%, #ea580c 50%); }

/* Status bar */
#statusbar {
  position: absolute;
  bottom: 8px;
  left: 8px;
  font-size: 11px;
  color: var(--text3);
  font-family: var(--font-mono);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  z-index: 20;
  pointer-events: none;
  display: flex;
  gap: 12px;
}

#hint {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 10px;
  color: var(--text3);
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 5px;
  border: 1px solid var(--border);
  z-index: 20;
  pointer-events: none;
  max-width: 420px;
  text-align: right;
  line-height: 1.4;
}

#save-indicator {
  color: var(--success);
  opacity: 0;
  transition: opacity 0.3s;
}

#save-indicator.visible { opacity: 1; }

/* Toggle row */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  font-size: 11px;
  color: var(--text2);
}

.toggle-row input[type=checkbox] { accent-color: var(--accent); }

.bulk-actions { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }

.door-item {
  padding: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 4px;
}
.door-item .prop-row { margin-bottom: 4px; }
.door-item .btn-sm { width: 100%; margin: 2px 0 0; }

.note-input {
  width: 100%;
  min-height: 56px;
  resize: vertical;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg2);
  color: var(--text);
  font-family: var(--font);
  font-size: 11.5px;
  line-height: 1.4;
  outline: none;
  margin-bottom: 8px;
}
.note-input:focus { border-color: var(--accent); }
.note-input.has-note {
  border-color: #f59e0b;
  background: #fffbeb;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.15);
}
[data-theme="dark"] .note-input.has-note { background: #422006; }
.section-label.notes-active { color: #b45309; }

/* Notes — sidebar entry + floating badge */
.notes-sidebar-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  border-color: var(--border2);
  background: var(--surface2);
}
.notes-sidebar-btn:hover { border-color: var(--accent); background: var(--accent-bg); }
.notes-sidebar-btn.has-notes {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent-bg);
}
.notes-sidebar-num {
  min-width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  background: var(--bg3);
  color: var(--text3);
  flex-shrink: 0;
}
.notes-sidebar-btn.has-notes .notes-sidebar-num {
  background: var(--accent);
  color: #fff;
}
.notes-sidebar-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.notes-sidebar-text strong { font-size: 13px; color: var(--text); }
.notes-sidebar-text span { font-size: 10px; color: var(--text3); line-height: 1.3; }

#notes-fab {
  position: absolute;
  top: 52px;
  right: 12px;
  z-index: 25;
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 8px 8px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 4px var(--accent-bg);
  cursor: pointer;
  font-family: var(--font);
  transition: transform 0.15s, box-shadow 0.15s;
}
#notes-fab.visible { display: flex; }
#notes-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.16), 0 0 0 4px var(--accent-bg);
}
#notes-fab-num {
  min-width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
#notes-fab-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  text-align: left;
}
#notes-fab-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
#notes-fab-sub {
  font-size: 10px;
  color: var(--text3);
  line-height: 1.2;
}

#notes-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px 16px;
}
#notes-overlay.open { display: flex; }

#notes-panel {
  width: 100%;
  max-width: 520px;
  max-height: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.notes-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
#notes-header-num {
  min-width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
#notes-header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
#notes-header-sub {
  font-size: 11px;
  color: var(--text3);
  margin-top: 2px;
}

#notes-body { padding: 12px 14px; overflow-y: auto; }

.notes-floor {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text3);
  margin: 10px 0 6px;
}
.notes-floor:first-child { margin-top: 0; }

.note-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-bottom: 6px;
  background: var(--bg2);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.note-card:hover { background: var(--bg3); border-color: var(--accent); }

.note-card-head { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.note-card-head .note-card-go { margin-left: auto; color: var(--accent); font-size: 11px; }
.note-card-preview {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 4px;
}
.note-card-body { font-size: 11.5px; color: var(--text2); line-height: 1.4; white-space: pre-wrap; }

#quick-edit {
  position: fixed;
  z-index: 50;
  display: none;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 6px 8px;
  box-shadow: var(--shadow);
}
#quick-edit.open { display: flex; }
#quick-edit .qe-label { font-size: 11px; color: var(--text3); font-weight: 600; }
#quick-edit .qe-x { color: var(--text3); }
#quick-edit .qe-unit { font-size: 10px; color: var(--text3); }
#quick-edit input {
  width: 64px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 12px;
  background: var(--bg2);
  color: var(--text);
  outline: none;
  text-align: right;
}
#quick-edit input:focus { border-color: var(--accent); }
