:root {
  color-scheme: dark;
  --bg: #121314;
  --panel: #1a1b1d;
  --panel-2: #212225;
  --line: #2c2d31;
  --line-2: #393a3f;
  --text: #ebe8e2;
  --muted: #9b9891;
  --faint: #6e6c67;
  --accent: #f0a04b;
  --accent-soft: rgba(240, 160, 75, .16);
  --owned: #7cc47f;
  --planned: #6aa8e8;
  --idea: #b58ce8;
  --generic: #8c8a85;
  --warn: #e8b64c;
  --error: #ec6a5e;
  --paper: #efebe3;
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); display: flex; flex-direction: column; overflow: hidden; }
button { font: inherit; color: inherit; background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 6px;
  padding: 5px 10px; cursor: pointer; line-height: 1.2; }
button:hover { border-color: #55565c; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px; }
button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: #ffd9ae; }
button:disabled { opacity: .4; cursor: default; }
button.ghost, a.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover, a.ghost:hover { color: var(--text); background: var(--panel-2); }
a.ghost { padding: 5px 10px; border-radius: 6px; text-decoration: none; line-height: 1.2; }
button.icon { width: 30px; height: 30px; padding: 0; display: inline-grid; place-items: center; background: transparent; border-color: transparent; color: var(--muted); }
button.icon:hover { color: var(--text); background: var(--panel-2); }
button.icon svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
button.danger { color: #ffb3ab; border-color: #5a2f2b; background: #2a1b1a; }
button.primary { background: var(--accent); color: #1b1307; border-color: var(--accent); font-weight: 600; }
input, select, textarea { font: inherit; color: var(--text); background: #111214; border: 1px solid var(--line-2); border-radius: 6px; padding: 5px 8px; }
kbd { font: 11px ui-monospace, SFMono-Regular, Menlo, monospace; padding: 1px 5px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 4px; background: var(--panel-2); color: var(--text); }

/* ---------------------------------------------------------------- header */
.top { height: 48px; flex: none; display: flex; align-items: center; gap: 6px; padding: 0 12px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 650; letter-spacing: .01em; margin-right: 10px; }
.sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 6px; }
.spacer { flex: 1; }
.layout-picker { position: relative; }
.picker { display: inline-flex; align-items: center; gap: 8px; min-width: 260px; justify-content: space-between; background: #111214; font-weight: 550; }
.picker svg { width: 12px; height: 12px; fill: none; stroke: var(--muted); stroke-width: 1.6; }
.save-state { color: var(--faint); font-size: 12px; min-width: 90px; margin-left: 6px; }
.save-state.unsaved { color: var(--warn); }
.save-state.error { color: var(--error); }
.segmented { display: inline-flex; border: 1px solid var(--line-2); border-radius: 7px; overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: transparent; color: var(--muted); padding: 5px 12px; }
.segmented button[aria-pressed="true"] { background: var(--panel-2); color: var(--text); }

.menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: 420px; max-height: 70vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; padding: 6px; box-shadow: 0 18px 50px rgba(0,0,0,.5); }
.menu-item { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 8px; padding: 6px; }
.menu-item:hover, .menu-item[aria-current="true"] { background: var(--panel-2); border-color: var(--line-2); }
.menu-item svg.mini { width: 96px; height: 52px; border-radius: 5px; background: var(--paper); }
.menu-item .meta { color: var(--muted); font-size: 12px; }
.menu-item .name { font-weight: 550; }
.menu-foot { display: flex; gap: 6px; padding: 8px 4px 2px; border-top: 1px solid var(--line); margin-top: 6px; }

/* ------------------------------------------------------------- workspace */
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 264px minmax(0, 1fr) 300px; }
.library, .inspector { background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
.library { border-right: 1px solid var(--line); }
.inspector { border-left: 1px solid var(--line); overflow: auto; padding: 14px; }
.library-head { padding: 12px; border-bottom: 1px solid var(--line); display: grid; gap: 8px; }
.library-head input { width: 100%; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chips button { padding: 3px 8px; font-size: 12px; border-radius: 999px; display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: var(--generic); flex: none; }
.dot.owned { background: var(--owned); } .dot.planned { background: var(--planned); } .dot.idea { background: var(--idea); }
.library-list { overflow: auto; flex: 1; padding: 4px 8px 12px; }
.library-list h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 14px 4px 6px; font-weight: 600; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tile { display: grid; grid-template-rows: 78px auto; gap: 4px; padding: 6px; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; cursor: grab; text-align: left; touch-action: none; user-select: none; }
.tile:hover { border-color: #56575d; background: #26272a; }
.tile img { width: 100%; height: 78px; object-fit: contain; pointer-events: none; }
.tile .t-name { font-size: 11.5px; line-height: 1.25; display: flex; gap: 5px; align-items: baseline; }
.tile .t-name .dot { transform: translateY(-1px); }
.tile .t-size { font-size: 10.5px; color: var(--faint); }
.library-hint { margin: 0; padding: 8px 12px; color: var(--faint); font-size: 11.5px; border-top: 1px solid var(--line); }
.drag-ghost { position: fixed; z-index: 50; pointer-events: none; width: 90px; height: 90px; opacity: .85; transform: translate(-50%, -50%); }

/* ------------------------------------------------------------------ views */
.views { position: relative; display: grid; grid-template-columns: var(--split, 50%) 6px minmax(0, 1fr); min-width: 0; min-height: 0; }
.workspace[data-mode="plan"] .views { grid-template-columns: 1fr 0 0; }
.workspace[data-mode="3d"] .views { grid-template-columns: 0 0 1fr; }
.workspace[data-mode="plan"] .view-pane, .workspace[data-mode="3d"] .plan-pane,
.workspace:not([data-mode="split"]) .divider-handle { visibility: hidden; }
.pane { position: relative; overflow: hidden; min-width: 0; }
.plan-pane { background: #d9d4c8; }
.view-pane { background: #202123; }
.layer { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; }
.layer.interactive { pointer-events: auto; outline: none; }
#planOver { cursor: default; }
#planOver.panning { cursor: grabbing; }
#planOver.measuring { cursor: crosshair; }
.divider-handle { background: var(--line); cursor: col-resize; }
.divider-handle:hover, .divider-handle.dragging { background: var(--accent); }
.pane-tools { position: absolute; top: 10px; left: 10px; right: 10px; display: flex; flex-wrap: wrap; gap: 4px; pointer-events: none; }
.pane-tools > * { pointer-events: auto; }
.pane-tools button { background: rgba(26,27,29,.88); backdrop-filter: blur(6px); font-size: 12px; padding: 4px 9px; }
.pane-tools .divider { width: 8px; }
.plan-pane .pane-tools button:not([aria-pressed="true"]) { background: rgba(255,255,255,.82); color: #2a2927; border-color: rgba(0,0,0,.14); }
.scale-bar { position: absolute; left: 12px; bottom: 12px; pointer-events: none; font-size: 11px; color: #3b3935; }
.scale-bar div { height: 5px; border: 1.5px solid #3b3935; border-top: 0; margin-bottom: 3px; }
.tip { position: absolute; z-index: 5; pointer-events: none; background: rgba(20,20,22,.92); color: var(--text); padding: 5px 8px;
  border-radius: 6px; font-size: 12px; white-space: nowrap; transform: translate(12px, 14px); }
.loading { position: absolute; inset: auto 12px 12px auto; color: var(--muted); font-size: 12px; background: rgba(0,0,0,.5); padding: 5px 9px; border-radius: 6px; }
.walk-help { position: absolute; left: 12px; bottom: 12px; background: rgba(0,0,0,.72); padding: 6px 10px; border-radius: 6px; font-size: 12px; }

/* --------------------------------------------------------------- inspector */
.inspector h2 { font-size: 15px; margin: 0 0 2px; font-weight: 620; }
.inspector h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); margin: 18px 0 8px; font-weight: 600; }
.inspector .sub { color: var(--muted); font-size: 12px; }
.inspector .thumb { width: 100%; height: 130px; object-fit: contain; background: #222326; border-radius: 8px; margin-bottom: 10px; }
.status-row { display: flex; gap: 8px; align-items: center; margin: 6px 0 2px; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); }
.fields { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.fields.two { grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 3px; font-size: 11px; color: var(--muted); }
.field input { width: 100%; padding: 5px 6px; font-variant-numeric: tabular-nums; }
.field input.changed { border-color: #6b5a3c; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.row + .row { margin-top: 6px; }
.row button { font-size: 12px; }
.inspector textarea { width: 100%; min-height: 64px; resize: vertical; }
.inspector .note { color: var(--muted); font-size: 12px; margin: 8px 0 0; }
.warnings { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.warnings li { display: grid; grid-template-columns: 8px 1fr; gap: 8px; align-items: baseline; padding: 6px 8px; border-radius: 6px; background: var(--panel-2); cursor: pointer; font-size: 12px; }
.warnings li:hover { background: #292a2e; }
.warnings .sev { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.warnings .sev.error { background: var(--error); }
.item-list { display: grid; gap: 2px; }
.item-list button { display: grid; grid-template-columns: 8px 1fr auto; gap: 8px; align-items: center; text-align: left; background: transparent; border-color: transparent; padding: 4px 6px; }
.item-list button:hover { background: var(--panel-2); }
.item-list .count { color: var(--faint); font-size: 11.5px; }
.empty { color: var(--muted); }
.missing { display: flex; flex-wrap: wrap; gap: 4px; }
.missing button { font-size: 11.5px; padding: 3px 8px; }

/* ------------------------------------------------------------------ modal */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(0,0,0,.45); }
.modal[hidden] { display: none; }
.dialog { width: min(440px, calc(100vw - 32px)); background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 18px; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.dialog h3 { margin: 0 0 10px; font-size: 15px; }
.dialog label { display: grid; gap: 4px; color: var(--muted); font-size: 12px; margin: 10px 0; }
.dialog input, .dialog textarea { width: 100%; }
.dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.shortcuts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 12.5px; }
.shortcuts dt { text-align: right; white-space: nowrap; }
.shortcuts dd { margin: 0; color: var(--muted); }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr) 260px; }
  .picker { min-width: 180px; }
}
