:root {
  --bg: #11151c;
  --panel: #1a2030;
  --panel2: #222a3d;
  --line: #2c3650;
  --text: #e6ecf5;
  --muted: #8a96b1;
  --accent: #5b8def;
  --accent2: #7be0c7;
  --warn: #f5a05a;
  --danger: #ef5b6e;
  --ok: #5fd28a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

button {
  font: inherit;
  color: inherit;
  background: var(--panel2);
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { background: #2c3650; }
button.active { background: var(--accent); border-color: var(--accent); color: white; }
button.danger { background: #3a1e25; border-color: #5a2c34; }
button.danger:hover { background: #4a262e; }

input, select, textarea {
  font: inherit;
  color: inherit;
  background: #0e1320;
  border: 1px solid var(--line);
  padding: 5px 7px;
  border-radius: 5px;
  width: 100%;
}
select { width: auto; padding: 5px 6px; }

label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

hr { border: none; border-top: 1px solid var(--line); margin: 10px 0; }

.app {
  display: grid;
  grid-template-rows: 48px 1fr 28px;
  grid-template-columns: 240px 1fr 280px;
  grid-template-areas:
    "header header header"
    "left center right"
    "footer footer footer";
  height: 100vh;
}

header.toolbar {
  grid-area: header;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
header.toolbar .title { font-weight: 700; margin-right: 12px; }
header.toolbar .sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
header.toolbar .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.left {
  grid-area: left;
  background: var(--panel);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px;
}

.center {
  grid-area: center;
  position: relative;
  background: #0a0e16;
  overflow: hidden;
}

.right {
  grid-area: right;
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  padding: 10px;
}

.footer {
  grid-area: footer;
  background: var(--panel);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 12px;
  font-size: 11px;
  color: var(--muted);
}

h3 {
  margin: 6px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--muted);
  font-weight: 600;
}

.lib-group { margin-bottom: 6px; }
.lib-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-bottom: 4px;
  cursor: grab;
  font-size: 12px;
}
.lib-item:active { cursor: grabbing; }
.lib-item .dim { color: var(--muted); font-size: 10px; }
.lib-item .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 6px;
  display: inline-block;
  vertical-align: middle;
}

.tool-btn { display: inline-flex; align-items: center; gap: 5px; }

#canvasHost { width: 100%; height: 100%; }

.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
  min-width: 380px;
  max-width: 90vw;
  max-height: 88vh;
  overflow: auto;
}
.modal h2 { margin-top: 0; font-size: 14px; }

.row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.row > * { flex: 1; }
.row label { flex: 0 0 80px; color: var(--muted); }

.swatches { display: flex; flex-wrap: wrap; gap: 5px; }
.swatches button { width: 24px; height: 24px; padding: 0; border-radius: 4px; }
.swatches button.sel { outline: 2px solid white; }

.notes { font-size: 11px; color: var(--muted); line-height: 1.5; }

.layout-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-bottom: 4px;
  font-size: 12px;
}
.layout-item.active { border-color: var(--accent); background: #1c2746; }
.layout-item .name { flex: 1; cursor: pointer; }

.kbd {
  display: inline-block;
  background: #0e1320;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 10px;
  color: var(--text);
}

textarea { resize: vertical; min-height: 200px; font-family: ui-monospace, Menlo, monospace; font-size: 11px; }

.scale-tip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  display: none;
  z-index: 50;
  max-width: 560px;
}
.scale-tip.show { display: block; }
.scale-tip .tip-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; font-weight: 400; }
.scale-tip input[type=range] { flex: 1; accent-color: white; }
.scale-tip button {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
  color: white;
  padding: 3px 8px;
  font-size: 11px;
}
.scale-tip button:hover { background: rgba(255, 255, 255, 0.3); }

#loupe {
  position: absolute;
  width: 180px;
  height: 180px;
  pointer-events: none;
  display: none;
  z-index: 60;
  border-radius: 50%;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  background: #0a0e16;
}

#cropOverlay {
  position: absolute;
  border: 2px dashed var(--accent);
  background: rgba(91, 141, 239, 0.12);
  pointer-events: none;
  display: none;
  z-index: 55;
}

.add-furn { display: grid; grid-template-columns: 1fr 50px 50px; gap: 5px; margin-top: 6px; }

details summary {
  cursor: pointer;
  padding: 4px 0;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
details[open] summary { color: var(--text); }

.muted { color: var(--muted); }
.tag {
  display: inline-block;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  color: var(--muted);
  margin-right: 4px;
}

.btn-row { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-row button { flex: 1; font-size: 11px; padding: 5px 6px; }
