:root {
  --ink: #162127;
  --muted: #5a6d73;
  --panel: rgba(248, 251, 252, 0.96);
  --line: rgba(22, 33, 39, 0.2);
  --line-soft: rgba(22, 33, 39, 0.1);
  --accent: #0b7ca6;
  --accent-dark: #045779;
  --ok: #2f8e55;
  --danger: #9b1e1e;
  --canvas-top-offset: 70px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--ink);
  background: radial-gradient(circle at 12% 10%, #fef3df 0%, #d8e7ec 54%, #c6dce4 100%);
}

button,
input,
select {
  font: inherit;
}

.workspace {
  position: fixed;
  inset: 0;
}

#wall-canvas {
  position: absolute;
  left: 0;
  right: 0;
  top: var(--canvas-top-offset);
  bottom: 0;
  width: 100%;
  height: calc(100% - var(--canvas-top-offset));
  display: block;
  touch-action: none;
}

.top-dock {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
  right: max(10px, env(safe-area-inset-right));
  z-index: 55;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(248, 252, 254, 0.94);
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 24px rgba(18, 31, 38, 0.18);
  padding: 8px;
}

.dock-launcher {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: auto;
  width: 100%;
}

.dock-launcher .btn {
  border-radius: 999px;
  white-space: nowrap;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  padding: 7px 10px;
  cursor: pointer;
  transition: transform 120ms ease, background-color 120ms ease;
}

.btn:hover {
  transform: translateY(-1px);
  background: #fff;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn.strong,
.panel-tab.active {
  background: linear-gradient(140deg, var(--accent), var(--accent-dark));
  color: #fff;
  border-color: #074c67;
}

.panel-stack {
  position: fixed;
  top: calc(var(--canvas-top-offset) + 10px);
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 20px));
  height: auto;
  z-index: 45;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 44px rgba(15, 28, 34, 0.2);
  padding: 10px;
  overflow: hidden;
  transform: translateX(calc(100% + 20px));
  transition: transform 180ms ease;
  display: flex;
  flex-direction: column;
}

.panel-stack.open {
  transform: translateX(0);
}

.panel-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin-bottom: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.panel-tabs .btn {
  padding: 6px 8px;
  flex: 0 0 auto;
}

.tool-panel {
  display: none;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
  padding: 10px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.tool-panel.active {
  display: grid;
  gap: 10px;
  align-content: start;
}

#frame-panel {
  padding-bottom: 10px;
}

#delete-frame {
  position: static;
  margin-top: 2px;
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(155, 30, 30, 0.42);
}

#delete-frame-preset {
  border-color: rgba(141, 86, 21, 0.38);
}

#delete-object {
  border-color: rgba(155, 30, 30, 0.32);
}

.tool-panel h2 {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
  font-size: 1rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.84rem;
}

.row {
  display: grid;
  gap: 8px;
}

.row.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.align-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

input,
select {
  width: 100%;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 8px 10px;
  background: #fff;
}

input[type="color"] {
  padding: 4px;
  min-height: 42px;
}

.inline-toggle {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.inline-toggle input {
  width: auto;
}

.upload-list {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
}

.upload-card {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 6px;
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 8px;
  align-items: center;
  background: rgba(255, 255, 255, 0.85);
}

.upload-card img {
  width: 54px;
  height: 54px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(0, 0, 0, 0.16);
}

.upload-meta {
  min-width: 0;
}

.upload-meta p {
  margin: 0 0 5px;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  position: fixed;
  left: 10px;
  bottom: 10px;
  margin: 0;
  z-index: 50;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(251, 255, 255, 0.92);
  font-size: 0.83rem;
  color: var(--ok);
  box-shadow: 0 8px 24px rgba(10, 22, 30, 0.14);
}

.trash-zone {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  bottom: 12px;
  z-index: 50;
  border: 1px solid rgba(155, 30, 30, 0.45);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 242, 242, 0.92);
  color: #8d1d1d;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(22, 12, 12, 0.14);
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.trash-zone.visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.trash-zone.active {
  background: rgba(155, 30, 30, 0.92);
  border-color: rgba(155, 30, 30, 0.95);
  color: #fff;
}

.mini-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.81rem;
}

.wizard {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  background: rgba(8, 16, 19, 0.46);
  backdrop-filter: blur(4px);
}

.wizard.hidden {
  display: none;
}

.wizard-card {
  width: min(560px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(249, 252, 253, 0.98);
  padding: 16px;
  display: grid;
  gap: 10px;
  box-shadow: 0 24px 54px rgba(7, 16, 20, 0.34);
}

.wizard-card h2 {
  margin: 0;
  font-family: "Space Grotesk", "Avenir Next", sans-serif;
}

@media (max-width: 920px) {
  .top-dock {
    top: max(8px, env(safe-area-inset-top));
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
  }

  .dock-launcher {
    gap: 6px;
  }

  .panel-stack {
    top: calc(var(--canvas-top-offset) + 8px);
    left: 8px;
    right: 8px;
    width: auto;
    bottom: max(8px, env(safe-area-inset-bottom));
    max-height: calc(100vh - 70px);
  }

  .row.two {
    grid-template-columns: 1fr;
  }

  .align-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-pill {
    left: 8px;
    right: 8px;
    border-radius: 10px;
  }

  .trash-zone {
    left: 50%;
    transform: translateX(-50%);
    bottom: 8px;
  }
}
