:root {
  --bg: #0f1115;
  --panel: #171a20;
  --panel-2: #20242d;
  --line: #303642;
  --text: #e7eaf0;
  --muted: #98a2b3;
  --accent: #67d7b5;
  --blue: #76b7ff;
  --warn: #f5bd5f;
  --bad: #f17878;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 13px/1.45 ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
}
#app { display: grid; grid-template-columns: 300px 1fr 280px; height: 100vh; min-width: 0; }
aside {
  min-width: 0; overflow: auto; background: var(--panel);
  border-color: var(--line); border-style: solid;
}
#left { border-width: 0 1px 0 0; }
#right { border-width: 0 0 0 1px; }
.head { padding: 14px 16px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.back { color: var(--accent); text-decoration: none; font-size: 12px; }
h1 { margin: 6px 0 0; font-size: 20px; line-height: 1.15; }
section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
h2 {
  margin: 0 0 10px; font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
button, input, select {
  font: inherit; color: var(--text); border: 1px solid var(--line);
  background: #11141a; border-radius: 5px;
}
button { padding: 6px 10px; cursor: pointer; }
button:hover { background: #242a34; }
input, select { width: 100%; padding: 7px 8px; }
label { display: block; color: var(--muted); font-size: 12px; margin: 8px 0; }
label input { margin-top: 4px; color: var(--text); }
.room-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
#search { margin-bottom: 8px; }
#category { margin-bottom: 10px; }
#library { display: grid; gap: 6px; max-height: 56vh; overflow: auto; padding-right: 2px; }
.lib-item {
  display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center;
  padding: 8px; border: 1px solid var(--line); border-radius: 6px;
  background: #12161d;
}
.lib-item:hover { border-color: var(--accent); }
.lib-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { color: var(--muted); font: 11px ui-monospace, monospace; }
.lib-add { background: #12362d; border-color: #1d6b57; }
#stage-wrap { position: relative; min-width: 0; overflow: hidden; background: #0c0f13; }
#toolbar {
  position: absolute; z-index: 5; top: 10px; left: 10px;
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border: 1px solid var(--line); border-radius: 7px;
  background: rgba(17,20,26,.92); box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
#toolbar button { min-width: 34px; padding: 5px 9px; }
#toolbar button.active { background: #12362d; border-color: #1d6b57; color: #d7fff2; }
#zoom-label { min-width: 46px; text-align: center; color: var(--muted); font: 11px ui-monospace, monospace; }
#plan, #view3d { width: 100%; height: 100%; display: block; }
#plan { cursor: grab; }
#view3d { cursor: grab; }
#plan.dragging { cursor: grabbing; }
#toast {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%);
  padding: 7px 12px; border-radius: 6px; background: rgba(0,0,0,.72);
  color: var(--text); opacity: 0; transition: opacity .15s; pointer-events: none;
}
#toast.show { opacity: 1; }
.hidden { display: none !important; }
.hint { color: var(--muted); font-size: 12px; }
#sel-name { font-size: 16px; font-weight: 750; line-height: 1.25; margin-bottom: 6px; }
#sel-size { color: var(--muted); font: 12px ui-monospace, monospace; margin-bottom: 10px; }
#sel-rot-label { color: var(--muted); font: 12px ui-monospace, monospace; }
#view-3d {
  display: inline-block; color: var(--blue); text-decoration: none;
  margin-top: 12px; border-bottom: 1px solid rgba(118,183,255,.35);
}
.stats { display: grid; gap: 6px; color: var(--muted); font: 12px ui-monospace, monospace; margin-bottom: 10px; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  #left, #right { max-height: 34vh; border-width: 0 0 1px; }
  #right { border-width: 1px 0 0; }
  #stage-wrap { min-height: 52vh; }
  #toolbar { right: 10px; flex-wrap: wrap; }
  #library { max-height: 20vh; }
}
