/* Planner screen: toolbar, catalog panel, 3D viewport, shelf editor, layout properties. */
body.full #view { height: calc(100vh - var(--head-h)); overflow: hidden; }
.planner { display: flex; flex-direction: column; height: 100%; }
.pl-toolbar { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-bottom: 1px solid var(--line); background: var(--paper-2); flex-wrap: wrap; }
.pl-toolbar .back svg { width: 18px; height: 18px; }
.pl-title { display: flex; flex-direction: column; line-height: 1.15; }
.pl-title b { font-size: var(--fs-14); } .pl-title small { color: var(--ink-2); font-size: var(--fs-12); }
.pl-toolbar .modes .btn { gap: 6px; }
.pl-toolbar .acts .btn span { margin-left: 2px; }
.pl-toolbar .cat-toggle { display: none; }
.pl-main { display: flex; flex: 1; min-height: 0; }
.pl-catalog { width: var(--catalog-w); flex: none; display: flex; flex-direction: column; background: var(--sheet); border-right: 1px solid var(--line); }
.mode-layout .pl-catalog, .mode-execute .pl-catalog { display: none; }
.pl-center { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; isolation: isolate; z-index: 0; }
.pl-viewport { position: relative; flex: 1; min-height: 0; }
.pl-viewport canvas { display: block; }
.pl-hint { position: absolute; left: 12px; top: 10px; z-index: 5; background: rgba(255,253,248,.9); border: 1px solid var(--line); border-radius: var(--r-2); padding: 5px 9px; font-size: var(--fs-12); color: var(--ink-2); pointer-events: none; max-width: calc(100% - 24px); }
.pl-legend { position: absolute; right: 12px; top: 10px; z-index: 5; display: flex; gap: 12px; background: rgba(255,253,248,.9); border: 1px solid var(--line); border-radius: var(--r-2); padding: 5px 9px; font-size: var(--fs-12); color: var(--ink-2); }
.pl-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.pl-props { width: 340px; flex: none; background: var(--sheet); border-left: 1px solid var(--line); overflow: auto; padding: 14px; }
.props-empty { display: flex; flex-direction: column; gap: 14px; color: var(--ink-2); padding-top: 8px; }
.props { display: flex; flex-direction: column; gap: 10px; }
.props-head { display: flex; align-items: center; justify-content: space-between; }
.props .form-grid { gap: 8px; }

[hidden] { display: none !important; }

/* labels rendered by CSS2DRenderer */
.fx-label { background: rgba(255,253,248,.94); border: 1px solid var(--line-strong); border-radius: 5px; padding: 2px 7px; font-size: 11px; white-space: nowrap; pointer-events: auto; cursor: pointer; box-shadow: var(--shadow-1); color: var(--ink); }
.fx-label:hover { border-color: var(--accent); color: var(--accent-ink); }
.fx-label.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
.fx-label b { color: var(--ink-2); font-weight: 600; margin-right: 4px; } .fx-label.selected b { color: rgba(255,255,255,.8); }
.fx-label.blk { background: rgba(255,253,248,.75); color: var(--ink-2); border-color: transparent; box-shadow: none; }
.zone-label { font-size: 12px; font-weight: 700; color: rgba(60,58,50,.5); letter-spacing: .8px; text-transform: uppercase; white-space: nowrap; }

/* catalog panel */
.cat-head { padding: 10px 10px 6px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; }
.cat-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.cat-filters .input { font-size: var(--fs-12); min-height: 30px; padding: 4px 8px; }
.cat-count { font-size: var(--fs-12); }
.cat-list { flex: 1; overflow-y: auto; padding: 6px; }
.card { display: grid; grid-template-columns: 52px 1fr auto; gap: 8px; align-items: center; padding: 6px; border: 1px solid transparent; border-radius: var(--r-2); cursor: grab; user-select: none; }
.card:hover { background: var(--paper); border-color: var(--line); }
.card.selected { background: var(--accent-soft); border-color: var(--accent); }
.card:active { cursor: grabbing; }
.card img { width: 52px; height: 52px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: var(--r-1); }
.card .name { font-weight: 600; font-size: var(--fs-13); line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card .meta { color: var(--ink-2); font-size: var(--fs-12); margin-top: 2px; }
.card .meta b { color: var(--ink); }
.card .add { opacity: 0; }
.card:hover .add, .card:focus-within .add { opacity: 1; }

/* shelf panel */
.pl-shelf { position: relative; z-index: 10; flex: 0 0 54%; min-height: 0; background: var(--sheet); border-top: 1px solid var(--line); display: flex; flex-direction: column; box-shadow: 0 -4px 16px rgba(29,27,23,.08); }
.pl-shelf.collapsed { display: none; }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-title { font-weight: 600; font-size: var(--fs-14); }
.panel-title #shelf-sub { margin-left: 8px; font-weight: 400; font-size: var(--fs-12); }
.panel-head .zoom { display: flex; align-items: center; gap: 6px; font-size: var(--fs-12); margin-left: auto; }
.panel-head input[type=range] { accent-color: var(--accent); width: 120px; }
.panel-body { flex: 1; overflow: auto; background: var(--paper); padding: 14px 16px 22px 6px; }
.panel-foot { padding: 5px 12px; border-top: 1px solid var(--line); color: var(--ink-2); font-size: var(--fs-12); display: flex; gap: 14px; flex-wrap: wrap; }
.panel-foot b { color: var(--ink); } .panel-foot .warn { color: var(--danger); font-weight: 600; }

.shelf-wrap { display: flex; align-items: flex-end; gap: 6px; width: max-content; }
.gutter { position: relative; width: 150px; flex: none; }
.gutter .lvl { position: absolute; right: 0; transform: translateY(-100%); display: flex; align-items: flex-end; gap: 6px; padding-right: 4px; }
.gutter .lvl-text { font-size: 10.5px; color: var(--ink-2); text-align: right; line-height: 1.15; white-space: nowrap; }
.gutter .lvl b { color: var(--ink); }
.lvl-done { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line-strong); background: var(--sheet); color: transparent; cursor: pointer; position: relative; }
.lvl-done input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.lvl-done svg { width: 14px; height: 14px; }
.lvl-done.on { background: var(--done); border-color: var(--done); color: #fff; }
.mode-execute .lvl-done { width: 28px; height: 28px; }
.stage { position: relative; background: #d8dad6; border: 1px solid #a9aca7; box-shadow: var(--shadow-1); }
.stage.wood { background: #c9a980; } .stage.cooler { background: #dfe9f1; } .stage.produce { background: #dfe3dd; } .stage.freezer { background: #e4e6e2; }
.stage .headroom { position: absolute; left: 0; right: 0; top: 0; background: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 6px, transparent 6px 12px); border-bottom: 1px dashed #9a9d98; }
.stage .upright { position: absolute; top: 0; bottom: 0; background: #7e817c; }
.stage .board { position: absolute; left: 0; right: 0; background: #8f928d; border-top: 1px solid #5e615d; box-shadow: 0 1px 0 rgba(0,0,0,.25); }
.stage .board.tilt { background: linear-gradient(#a2a5a0, #7e817c); }
.stage .body-base { position: absolute; left: 0; right: 0; bottom: 0; background: #5a5d5a; }
.stage .body-chest { position: absolute; left: 0; right: 0; bottom: 0; background: #efe8d8; border-top: 4px solid #a9d3c1; }
.stage .body-table { position: absolute; left: 0; right: 0; bottom: 0; background: #b08a63; }
.stage .body-counter { position: absolute; left: 0; right: 0; bottom: 0; background: #c9bfae; border-top: 3px solid #b9c9d3; }
.stage .chest-glass { position: absolute; left: 0; right: 0; background: rgba(143,188,224,.18); border-top: 1px solid rgba(90,140,180,.5); pointer-events: none; }
.stage .zone { position: absolute; left: 0; right: 0; }
.stage .zone.over { background: rgba(15,107,82,.14); outline: 2px dashed var(--accent); outline-offset: -2px; }
.mode-execute .stage .zone.done { background: rgba(47,122,77,.12); }
.stage .item { position: absolute; border: 1px solid rgba(0,0,0,.35); background-color: #fff; background-repeat: repeat; background-position: left bottom; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.stage .item[draggable=false] { cursor: pointer; }
.stage .item:hover { border-color: var(--accent); z-index: 3; }
.stage .item.selected { outline: 2px solid var(--accent); z-index: 4; }
.stage .item.warn { outline: 2px solid var(--danger); }
.stage .item .badge-f { position: absolute; right: 0; bottom: 0; background: rgba(29,27,23,.65); color: #fff; font-size: 9.5px; padding: 0 4px; border-radius: 3px 0 0 0; line-height: 1.4; pointer-events: none; font-family: var(--font-mono); }
.stage .item .tip { display: none; }
.stage .item:hover .tip { display: block; position: absolute; left: 0; bottom: 100%; margin-bottom: 4px; background: var(--ink); color: #fff; font-size: 11px; padding: 4px 7px; border-radius: 4px; white-space: nowrap; z-index: 10; pointer-events: none; }
.stage .item .rot { position: absolute; background-repeat: repeat; background-position: left bottom; transform: rotate(-90deg); pointer-events: none; }
.stage .fill { position: absolute; left: 0; height: 3px; background: rgba(15,107,82,.35); pointer-events: none; }
.stage .fill.full { background: rgba(169,58,46,.5); }
.stage .bay-label { position: absolute; bottom: -18px; font-size: 10.5px; color: var(--ink-2); text-align: center; }

/* placement dialog */
.prod { display: grid; grid-template-columns: 90px 1fr; gap: 12px; margin-bottom: 12px; }
.prod img { width: 90px; height: 90px; object-fit: contain; border: 1px solid var(--line); border-radius: var(--r-2); background: #fff; }
.prod .pname { font-weight: 600; } .prod .pmeta { color: var(--ink-2); font-size: var(--fs-12); margin-top: 3px; }
.pl-form { border: 0; padding: 0; margin: 0; min-width: 0; }
.pl-summary { background: var(--paper-2); border-radius: var(--r-2); padding: 8px 10px; font-size: var(--fs-12); margin-top: 12px; }
.pl-summary .bad { color: var(--danger); font-weight: 600; }
.seg.orient .btn { flex-direction: column; gap: 0; padding: 4px 8px; min-height: 40px; }
.seg.orient small { font-size: 10px; color: var(--ink-3); font-family: var(--font-mono); }
.seg.orient .btn.on small { color: var(--accent-ink); }

/* tablet / phone */
@media (max-width: 1000px) {
  .pl-toolbar .acts .btn span, .pl-toolbar .modes .btn span { display: none; }
  .pl-toolbar .views { display: none; }
  .pl-toolbar .cat-toggle { display: inline-flex; }
  .pl-catalog { position: absolute; z-index: 20; top: 0; bottom: 0; left: 0; width: min(360px, 92vw); transform: translateX(-100%); transition: transform var(--t-med) var(--ease); box-shadow: var(--shadow-2); }
  .planner.catalog-open .pl-catalog { transform: none; }
  .pl-main { position: relative; }
  .pl-props { position: absolute; z-index: 15; right: 0; top: 0; bottom: 0; width: min(340px, 92vw); }
  .pl-shelf { flex-basis: 60%; }
  .panel-head .zoom { display: none; }
  .gutter { width: 110px; }
}
@media (max-width: 600px) {
  .pl-title small { display: none; }
  .pl-shelf { flex-basis: 66%; }
}

/* ---- round 2: orientation tiles, history sidebar, geometry editor, mobile sheets */
.orient-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.orient-tile { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--r-2); background: var(--sheet); cursor: pointer; text-align: left; min-width: 0; }
.orient-tile:hover { border-color: var(--ink-3); }
.orient-tile.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.orient-tile .ot-name { font-weight: 600; font-size: var(--fs-13); }
.orient-tile .ot-dims { font-size: var(--fs-12); color: var(--ink-2); }
.orient-tile.on .ot-dims, .orient-tile.on .ot-deep { color: var(--accent-ink); }
.orient-tile .ot-deep { font-size: 10.5px; color: var(--ink-3); }
.pl-history .hist-filter { margin: 8px 0; }
.hist-list { display: flex; flex-direction: column; }
.hist-day { font-size: var(--fs-12); font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .4px; margin: 12px 0 4px; }
.hist-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 8px; align-items: start; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.hist-row.restore .hist-text { color: var(--info); }
.hist-time { font-size: var(--fs-12); color: var(--ink-2); padding-top: 2px; }
.hist-text { font-size: var(--fs-13); line-height: 1.3; }
.hist-who { font-size: var(--fs-12); color: var(--ink-2); margin-top: 2px; }
.hist-acts { display: flex; gap: 2px; }
.rev-detail { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.rev-detail pre { margin: 0; padding: 10px; background: var(--paper-2); border-radius: var(--r-2); font-size: 11px; max-height: 320px; overflow: auto; font-family: var(--font-mono); }
.rev-detail h4 { margin-bottom: 6px; color: var(--ink-2); font-size: var(--fs-13); }
.nudge { display: inline-flex; gap: 2px; }
.geo-block { border: 1px solid var(--line); border-radius: var(--r-2); padding: 10px 12px; margin: 10px 0; }
.geo-block legend, .geo-block summary { font-weight: 600; font-size: var(--fs-13); color: var(--ink-2); padding: 0 4px; cursor: default; }
.geo-block summary { cursor: pointer; }
.geo-row { display: grid; grid-template-columns: 40px 1fr 1fr 1.6fr 34px; gap: 6px; align-items: center; margin-bottom: 4px; }
.geo-row.head { font-size: var(--fs-12); color: var(--ink-2); }
.geo-row.zone { grid-template-columns: 1.6fr 1fr 1fr 34px; }
.geo-row .input { min-height: 30px; padding: 3px 8px; font-size: var(--fs-13); }
.table-wrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
@media (hover: none) { .card .add { opacity: 1; } }
@media (max-width: 1000px) {
  .pl-props { position: absolute; z-index: 15; left: 0; right: 0; top: auto; bottom: 0; width: auto; height: 46%; border-left: 0; border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(29,27,23,.08); }
  .orient-grid { grid-template-columns: repeat(2, 1fr); }
  .rev-detail { grid-template-columns: 1fr; }
  .geo-row { grid-template-columns: 30px 1fr 1fr 1.4fr 30px; }
  .hide-sm { display: none; }
}

.hist-scope { display: flex; align-items: center; gap: 8px; margin: 6px 0 2px; }
.hist-row.completion .hist-text { color: var(--ok); }
