/* ShelfQuest — styles. Brand palette, responsive, light/dark, roomy. */

:root {
  --brand-primary: #E0542A;
  --brand-navy: #1F2D3D;
  --accent-teal: #2E8B82;
  --accent-yellow: #F0A91E;
  --accent-red: #E0492B;

  --bg: #F7F3EC;
  --surface: #ffffff;
  --surface-2: #f1ece2;
  --text: #1F2D3D;
  --muted: #6b7480;
  --border: #e2dccf;
  --shadow: 0 1px 3px rgba(31,45,61,.07), 0 10px 30px rgba(31,45,61,.06);

  --radius: 14px;
  --maxw: 100%;
  --gap: 1.5rem;
}

:root[data-theme="dark"], :root[data-theme="auto"] { color-scheme: light dark; }
:root[data-theme="dark"] {
  --bg: #0E1116; --surface: #171c24; --surface-2: #1f2630;
  --text: #F2F4F7; --muted: #9aa4b2; --border: #2a323d;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.4);
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0E1116; --surface: #171c24; --surface-2: #1f2630;
    --text: #F2F4F7; --muted: #9aa4b2; --border: #2a323d;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 12px 32px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; }
/* the hidden attribute must always win, even over display:flex/grid/etc. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.6; -webkit-font-smoothing: antialiased;
}

/* header */
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2.5rem); max-width: var(--maxw); margin: 0 auto;
}
.brand { display: inline-flex; align-items: center; text-decoration: none; }
.brand-logo { height: 40px; width: auto; display: block; }
.logo-dark { display: none; }
[data-theme="dark"] .logo-light { display: none; }
[data-theme="dark"] .logo-dark { display: block; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .logo-light { display: none; }
  [data-theme="auto"] .logo-dark { display: block; }
}

.header-actions { display: flex; align-items: center; gap: .6rem; }
.lang-switch { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.lang-btn { border: 0; background: transparent; color: var(--muted); font-weight: 700; font-size: .8rem; padding: .4rem .7rem; border-radius: 999px; cursor: pointer; }
.lang-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.icon-btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); width: 38px; height: 38px; border-radius: 11px; cursor: pointer; font-size: 1rem; line-height: 1; }
.icon-btn:hover { border-color: var(--brand-primary); }
.icon-btn.sm { width: 30px; height: 30px; font-size: .85rem; border-radius: 8px; }
.icon-btn.danger:hover { color: #fff; background: var(--accent-red); border-color: var(--accent-red); }

/* main */
.app-main { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem) 3rem; }
.tagline { color: var(--muted); margin: .25rem 0 1.75rem; font-size: 1.05rem; }

.layout { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: var(--gap); align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.6rem; box-shadow: var(--shadow); }
.panel + .panel, .layout + .cabinet-panel { margin-top: var(--gap); }
.cabinet-panel { margin-top: var(--gap); }
.panel h2 { font-size: 1.05rem; margin: 0 0 .4rem; }
.panel h2 + .muted { margin-top: 0; }
.muted { color: var(--muted); font-size: .88rem; }
.muted.small { font-size: .78rem; }
.section-gap { height: 1.5rem; }

/* dims inputs */
.dims { display: grid; grid-template-columns: repeat(3, 1fr); gap: .7rem; margin: .8rem 0 0; }
.cabinet-panel .dims, .cab-builder .dims { grid-template-columns: repeat(2, 1fr); margin-bottom: 1rem; }
.dims.compact { margin: .7rem 0; }
.dims label { display: flex; flex-direction: column; gap: .3rem; font-size: .76rem; color: var(--muted); position: relative; }
.dims input, .search input, .manual-form input, .meta-row input, .players-row input, #groupBy {
  width: 100%; padding: .6rem .65rem; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg); color: var(--text); font-size: .92rem;
}
.dims input:focus, .search input:focus, .manual-form input:focus, .meta-row input:focus, .players-row input:focus, #groupBy:focus {
  outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); outline-offset: 1px; border-color: var(--brand-primary);
}
.dims label em { position: absolute; right: .55rem; bottom: .62rem; font-style: normal; font-size: .7rem; color: var(--muted); pointer-events: none; }

/* search + results */
.search { display: flex; gap: .5rem; margin: .5rem 0; }
.search input { flex: 1; }
.results, .game-list, .issues { list-style: none; margin: .35rem 0 0; padding: 0; }
.results { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; max-height: 260px; overflow-y: auto; }
.result-item { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .55rem .7rem; border-bottom: 1px solid var(--border); }
.result-item:last-child { border-bottom: 0; }
.result-name { font-size: .88rem; }

.manual { margin: 1rem 0; }
.manual summary { cursor: pointer; font-size: .88rem; color: var(--brand-primary); font-weight: 600; padding: .2rem 0; }
.manual-form { margin-top: .8rem; display: grid; gap: .6rem; }
.meta-row { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.players-row { display: flex; align-items: center; gap: .5rem; }
.players-row .minlabel { color: var(--muted); font-size: .76rem; }
.players-row input { width: 80px; }
.players-row .dash { color: var(--muted); }

/* group control */
.group-control { display: flex; align-items: center; gap: .6rem; margin: 1.25rem 0 .25rem; }
.group-control label { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
#groupBy { max-width: 220px; }

/* buttons */
.btn { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: .6rem .9rem; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: .88rem; }
.btn:hover { border-color: var(--brand-primary); }
.btn-sm { padding: .3rem .6rem; }
.btn-primary { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.btn-primary:hover { filter: brightness(1.06); }

/* game list */
.game-list { display: grid; gap: .6rem; margin-top: 1rem; }
.group-head { display: flex; align-items: center; gap: .5rem; margin: .8rem 0 .1rem; font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.group-head:first-child { margin-top: 0; }
.group-dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.game-item { display: flex; align-items: center; gap: .7rem; padding: .65rem; border: 1px solid var(--border); border-radius: 11px; background: var(--bg); }
.game-item .swatch { width: 12px; height: 30px; border-radius: 3px; flex: 0 0 auto; }
.game-meta { flex: 1; min-width: 0; }
.game-name { font-size: .9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-sub { font-size: .74rem; color: var(--muted); margin-top: .1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-dims { display: flex; gap: .4rem; margin-top: .4rem; }
.minlabel { display: flex; align-items: center; gap: .25rem; font-size: .72rem; color: var(--muted); }
.minlabel input { width: 56px; padding: .25rem .35rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font-size: .78rem; }
.empty { padding: .6rem 0; }

/* result panel */
.result-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(88px, 1fr)); gap: .7rem; margin-bottom: 1.1rem; }
.stat { background: var(--bg); border: 1px solid var(--border); border-radius: 11px; padding: .7rem; text-align: center; }
.stat-val { display: block; font-size: 1.3rem; font-weight: 800; }
.stat-key { display: block; font-size: .72rem; color: var(--muted); }

.viz { background: var(--bg); border: 1px dashed var(--border); border-radius: 11px; min-height: 280px; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.empty-hint { color: var(--muted); font-size: .92rem; text-align: center; }
.shelf-svg { width: 100%; height: auto; max-height: 62vh; }
.shelf-frame { fill: color-mix(in srgb, var(--brand-navy) 6%, transparent); stroke: var(--muted); stroke-width: .5; }
.shelf-line { stroke: var(--muted); stroke-width: .25; stroke-dasharray: 1 1; opacity: .6; }
.spine { stroke: rgba(0,0,0,.18); stroke-width: .12; }
.spine-label { fill: #fff; font-family: system-ui, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }

.issues { margin-top: 1rem; display: grid; gap: .35rem; }
.issues-head { font-weight: 700; font-size: .88rem; }
.issue { font-size: .82rem; color: var(--accent-red); }

/* cabinet builder */
.cab-add { display: flex; gap: .5rem; flex-wrap: wrap; }
.cabinet-layout { display: grid; grid-template-columns: minmax(0, 320px) 1fr; gap: var(--gap); align-items: start; margin-top: 1rem; }
@media (max-width: 860px) { .cabinet-layout { grid-template-columns: 1fr; } }
.cab-parts { display: grid; gap: .7rem; margin-bottom: .6rem; }
.part-card { border: 1px solid var(--border); border-radius: 12px; background: var(--bg); padding: .7rem; cursor: grab; }
.part-card.dragging { opacity: .5; }
.part-card.drop-target { border-color: var(--brand-primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-primary) 35%, transparent); }
.part-head { display: flex; align-items: center; gap: .5rem; }
.part-grip { color: var(--muted); cursor: grab; font-size: .9rem; }
.part-badge { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: .2rem .45rem; border-radius: 999px; color: #fff; }
.part-badge.part-shelf { background: var(--accent-teal); }
.part-badge.part-drawer { background: var(--brand-primary); }
.part-badge.part-rack { background: var(--accent-yellow); color: #3a2c08; }
.part-label { flex: 1; min-width: 0; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .85rem; }
.part-controls { display: flex; gap: .25rem; }
.part-dims { display: flex; gap: .8rem; margin-top: .6rem; }
.part-dims .minlabel { gap: .3rem; }
.part-dims input { width: 64px; }

.cab-view-wrap { min-width: 0; }
.cab-view { background: var(--bg); border: 1px dashed var(--border); border-radius: 12px; min-height: 380px; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.cab-svg { width: 100%; height: auto; max-height: 78vh; touch-action: none; }
.cab-frame { fill: color-mix(in srgb, var(--brand-navy) 12%, var(--surface)); stroke: var(--brand-navy); stroke-width: .9; }
.cab-part { cursor: grab; }
.cab-part.dragging { opacity: .6; }
.cab-part-band { fill: transparent; }
.cab-part:hover .cab-part-band { fill: color-mix(in srgb, var(--brand-primary) 8%, transparent); }
.comp-cell { fill: color-mix(in srgb, var(--brand-navy) 22%, var(--bg)); stroke: var(--brand-navy); stroke-width: .3; }
.cab-game { stroke: rgba(0,0,0,.3); stroke-width: .16; }
.cab-game-label { fill: #fff; font-family: system-ui, sans-serif; font-weight: 600; text-anchor: middle; dominant-baseline: middle; paint-order: stroke; stroke: rgba(0,0,0,.4); stroke-width: .14; pointer-events: none; }
.cab-part-accent { opacity: .95; }
.cab-part-pill { opacity: .96; }
.cab-part-label { fill: #fff; font-family: system-ui, sans-serif; font-weight: 700; pointer-events: none; }
.cab-insert { stroke: var(--brand-primary); stroke-width: 1; stroke-dasharray: 2 1.2; }

/* footer + toast */
.app-footer { max-width: var(--maxw); margin: 0 auto; padding: 1.25rem clamp(1rem,4vw,2.5rem) 2.5rem; color: var(--muted); font-size: .82rem; display: flex; gap: .55rem; flex-wrap: wrap; }
.app-footer .dot { opacity: .5; }
.app-footer .version { font-variant-numeric: tabular-nums; opacity: .7; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--brand-navy); color: #fff; padding: .65rem 1.1rem; border-radius: 11px; font-size: .85rem; box-shadow: var(--shadow); z-index: 50; max-width: 90vw; }

@media (prefers-reduced-motion: no-preference) {
  .btn, .icon-btn, .lang-btn, .part-card { transition: border-color .15s, background .15s, color .15s, opacity .15s; }
}

/* data bar (export / import / autosave) */
.data-bar { display: flex; align-items: center; gap: .6rem; margin: 0 0 1.5rem; flex-wrap: wrap; }
.autosave { font-size: .78rem; color: var(--muted); }
.data-spacer { flex: 1; }
.import-label { display: inline-flex; align-items: center; cursor: pointer; }

/* type chips */
.type-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .45rem; align-items: center; }
.type-chip { display: inline-flex; align-items: center; gap: .25rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .12rem .2rem .12rem .55rem; font-size: .72rem; }
.chip-text { line-height: 1.2; }
.chip-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: .85rem; line-height: 1; padding: 0 .2rem; border-radius: 50%; }
.chip-x:hover { color: #fff; background: var(--accent-red); }
.type-add { width: 92px; padding: .22rem .45rem; border: 1px dashed var(--border); border-radius: 999px; background: var(--bg); color: var(--text); font-size: .72rem; }
.chip-clear { border: 0; background: transparent; color: var(--accent-red); cursor: pointer; font-size: .72rem; text-decoration: underline; padding: 0 .2rem; }

/* part-card overflow fix (delete button was hidden behind the cabinet view) */
.cab-builder { min-width: 0; }
.part-card { overflow: hidden; }
.part-head { flex-wrap: wrap; }
.part-label { min-width: 0; flex: 1 1 110px; }
.part-controls { flex-shrink: 0; margin-left: auto; }

/* ---------- add-games hero ---------- */
.add-hero { border-top: 3px solid var(--brand-primary); }
.add-hero-head { margin-bottom: 1rem; }
.add-hero-head h2 { font-size: 1.35rem; margin: 0 0 .2rem; letter-spacing: -.01em; }
.add-search { display: flex; align-items: center; gap: .6rem; position: relative; flex-wrap: wrap; }
.add-search-icon { position: absolute; left: 1rem; top: 50%; transform: translateY(-50%); font-size: 1.3rem; color: var(--muted); pointer-events: none; }
.add-search-input {
  flex: 1 1 320px; min-width: 0; padding: .95rem 1rem .95rem 2.6rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text);
  font-size: 1.05rem;
}
.add-search-input:focus { outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); outline-offset: 1px; border-color: var(--brand-primary); }
.btn-lg { padding: .85rem 1.3rem; font-size: .98rem; border-radius: 12px; }
@media (max-width: 620px) { .add-search { flex-direction: column; align-items: stretch; } .add-search-icon { top: 1.5rem; transform: none; } .btn-lg { width: 100%; } }

/* result cards grid */
.result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .7rem; margin-top: 1.1rem; }
.result-msg { grid-column: 1 / -1; padding: .6rem 0; }
.result-card { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .8rem .9rem; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
.result-card:hover { border-color: var(--brand-primary); }
.result-info { min-width: 0; }
.result-card .result-name { font-size: .92rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.result-year { font-size: .76rem; color: var(--muted); margin-top: .1rem; }
.result-add { flex-shrink: 0; }

/* manual panel */
.manual-panel { margin-top: 1.1rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.manual-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.manual-grid .name-field { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: .3rem; font-size: .78rem; color: var(--muted); }
.field input { padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font-size: .92rem; }
.field input:focus { outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); outline-offset: 1px; border-color: var(--brand-primary); }
.field .players-row { gap: .4rem; }
.field .players-row input { width: 100%; }
.btn.active { border-color: var(--brand-primary); color: var(--brand-primary); }

/* spacing fix: clear gap below the add-hero so it never touches the layout */
.add-hero { margin-bottom: var(--gap); }
.add-hero + .layout { margin-top: var(--gap); }

/* about button in header */
.about-btn { white-space: nowrap; }

/* ---------- modal / about ---------- */
body.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 1.5rem; background: rgba(15, 20, 28, .55); backdrop-filter: blur(2px);
}
.modal {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); max-width: 640px; width: 100%;
  max-height: 88vh; overflow-y: auto; padding: 2rem clamp(1.25rem, 4vw, 2.25rem);
}
.modal-close {
  position: absolute; top: .9rem; right: .9rem; width: 34px; height: 34px; border-radius: 9px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-size: 1.1rem; line-height: 1;
}
.modal-close:hover { color: #fff; background: var(--accent-red); border-color: var(--accent-red); }
.modal-brand { margin-bottom: 1rem; }
.modal-brand .brand-logo { height: 48px; }
.modal h2 { font-size: 1.5rem; margin: 0 0 .4rem; letter-spacing: -.01em; }
.modal > .muted { margin: 0 0 1.25rem; font-size: .95rem; }
.about-features { list-style: none; margin: 0 0 1.25rem; padding: 0; display: grid; gap: .9rem; }
.about-feature { display: grid; gap: .15rem; padding-left: 1.1rem; position: relative; }
.about-feature::before {
  content: ""; position: absolute; left: 0; top: .45rem; width: 8px; height: 8px; border-radius: 2px;
  background: var(--brand-primary);
}
.about-feature-t { font-size: .98rem; }
.about-feature-d { font-size: .86rem; color: var(--muted); }
.about-foot { font-size: .85rem; margin: 0; padding-top: .75rem; border-top: 1px solid var(--border); }

/* per-game placement flags */
.game-flags { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem .9rem; margin-top: .45rem; }
.flag { display: inline-flex; align-items: center; gap: .3rem; font-size: .72rem; color: var(--muted); cursor: pointer; }
.flag input[type="checkbox"] { width: 14px; height: 14px; accent-color: var(--brand-primary); cursor: pointer; }
.flag-sel { padding: .15rem .35rem; border: 1px solid var(--border); border-radius: 7px; background: var(--surface); color: var(--text); font-size: .72rem; }

/* ---------- v0.9.0: collection, groups, cabinets, room ---------- */
.collection-head { display: flex; align-items: center; gap: .5rem; }
.collection-head h2 { margin: 0; }
.collection-count { font-size: .72rem; font-weight: 700; color: #fff; background: var(--brand-primary); border-radius: 999px; padding: .05rem .5rem; }
.collection-filter { width: 100%; margin: .6rem 0 .25rem; padding: .55rem .65rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: .9rem; }
.collection-filter:focus { outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); outline-offset: 1px; border-color: var(--brand-primary); }
.group-head { cursor: pointer; user-select: none; }
.group-head .caret { font-size: .7rem; color: var(--muted); width: .8rem; }

/* custom groups manager */
.groups-panel { border: 1px solid var(--border); border-radius: 11px; padding: .75rem; margin: .5rem 0 .25rem; background: var(--bg); }
.groups-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; font-weight: 700; font-size: .82rem; }
.groups-list { list-style: none; margin: .5rem 0 0; padding: 0; display: grid; gap: .4rem; }
.group-row { display: flex; align-items: center; gap: .35rem; }
.group-name { flex: 1; min-width: 0; padding: .35rem .5rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font-size: .82rem; }

/* cabinet tabs */
.cab-tabs-row { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.cab-tabs { display: flex; gap: .4rem; flex-wrap: wrap; }
.cab-tab { border: 1px solid var(--border); background: var(--surface-2); color: var(--text); padding: .4rem .8rem; border-radius: 999px; cursor: pointer; font-weight: 600; font-size: .82rem; }
.cab-tab.active { background: var(--brand-primary); color: #fff; border-color: var(--brand-primary); }
.cab-builder-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin: .25rem 0 1rem; }
.btn-danger-ghost { color: var(--accent-red); border-color: color-mix(in srgb, var(--accent-red) 40%, var(--border)); background: transparent; }
.btn-danger-ghost:hover { background: var(--accent-red); color: #fff; border-color: var(--accent-red); }

/* room view */
.room-hint { margin: 0 0 .5rem; }
.room-svg { width: 100%; height: auto; min-height: 420px; max-height: 80vh; touch-action: none; cursor: grab; display: block; }
.room-svg:active { cursor: grabbing; }
.room-cab-name { fill: var(--text); font-family: system-ui, sans-serif; font-weight: 700; }
.room-cab-sel { fill: none; stroke: transparent; stroke-width: .6; }
.room-cab.active .room-cab-sel { stroke: var(--brand-primary); stroke-dasharray: 1.6 1; }
.room-cab-hit { cursor: pointer; }

/* ---------- v0.11.0: compartment picker + clickable compartments ---------- */
.space-pick { display: flex; align-items: center; gap: .6rem; margin: .85rem 0 0; }
.space-pick label { font-size: .82rem; color: var(--muted); font-weight: 600; white-space: nowrap; }
#spaceCompartment { flex: 1; min-width: 0; padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font-size: .86rem; }
#spaceCompartment:focus { outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); outline-offset: 1px; border-color: var(--brand-primary); }

.room-cab-sel { pointer-events: none; }
.room-cab-name { cursor: pointer; }
.comp-hit { cursor: pointer; }
.comp-hit:hover { fill: color-mix(in srgb, var(--brand-primary) 10%, transparent) !important; }
.comp-selected { fill: none; stroke: var(--brand-primary); stroke-width: .9; }

/* ---------- v0.12.0: room sizing + reorderable tabs ---------- */
.room-svg { height: 68vh; min-height: 420px; }
.cab-tab { user-select: none; }
.cab-tab[draggable="true"] { cursor: grab; }
.cab-tab.dragging { opacity: .5; }
.cab-tab.drop-target { box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-primary) 45%, transparent); }
#roomFitBtn:disabled { opacity: .45; cursor: not-allowed; }
.cabinet-panel > h2 { margin-bottom: .75rem; }

/* ---------- v0.13.0: dashboard layout + density pass ---------- */
.dashboard { display: grid; grid-template-columns: minmax(340px, 440px) 1fr; gap: var(--gap); align-items: start; }
@media (max-width: 1000px) { .dashboard { grid-template-columns: 1fr; } }
.dashboard .cabinet-panel { margin-top: 0; }
.dashboard > .panel { min-width: 0; }

.panel { padding: 1.25rem; }
.tagline { margin: .2rem 0 1rem; font-size: 1rem; }
.data-bar { margin-bottom: 1rem; }
.add-hero-head { margin-bottom: .7rem; }
.add-hero-head h2 { font-size: 1.2rem; }

/* compact "Your space" */
.space-pick { margin: .6rem 0 .2rem; }

/* compact collection cards */
.game-list { gap: .55rem; margin-top: .8rem; }
.game-item { align-items: stretch; gap: .65rem; padding: .65rem .75rem; }
.game-item .swatch { width: 6px; height: auto; align-self: stretch; }
.game-item > .icon-btn.danger { align-self: flex-start; }
.game-flags { gap: .45rem .8rem; margin-top: .5rem; }
.game-dims { margin-top: .5rem; }
.collection-filter { margin: .5rem 0 .5rem; }
.collection-head { margin-bottom: .35rem; }

/* compact cabinet builder + room column */
.cabinet-layout { grid-template-columns: minmax(0, 300px) 1fr; }
.part-card { padding: .6rem; }
.part-dims input { width: 58px; }
.cab-tabs-row { margin: .4rem 0 1rem; }
.cab-builder-actions { margin: .25rem 0 .9rem; }
.room-svg { height: 72vh; }

/* ---------- v0.14.0: discrete group labels in the room view ---------- */
.group-tag { opacity: .95; stroke: rgba(0,0,0,.25); stroke-width: .12; }
.group-tag-label { fill: #fff; font-family: system-ui, sans-serif; font-weight: 700; text-anchor: middle; paint-order: stroke; stroke: rgba(0,0,0,.35); stroke-width: .12; pointer-events: none; }

/* ---------- v0.15.0: room stage + collapsible game sidebar ---------- */
.cab-controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .7rem; margin: .25rem 0 .8rem; }
.cab-controls .field { gap: .25rem; font-size: .76rem; color: var(--muted); }
.cab-controls .field input { padding: .5rem .55rem; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font-size: .9rem; }
.cab-controls .field input:focus { outline: 2px solid color-mix(in srgb, var(--brand-primary) 55%, transparent); outline-offset: 1px; border-color: var(--brand-primary); }
.cab-name-field { min-width: 180px; flex: 1 1 180px; }
.cab-controls .field:not(.cab-name-field) input { width: 90px; }

/* room on the left, cabinet builder column on the right */
.room-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 320px); gap: var(--gap); align-items: start; }
.cab-side { display: flex; flex-direction: column; gap: .2rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem; align-self: stretch; }
.cab-side .cab-tabs-row { margin: 0 0 .7rem; }
.cab-side .cab-controls { margin: 0 0 .7rem; }
@media (max-width: 980px) { .room-row { grid-template-columns: 1fr; } }

.stage { position: relative; min-height: 72vh; }
.cab-view-wrap { width: 100%; }
.cab-view { min-height: 72vh; }

/* sticky overlay layer so the games sidebar stays in view while scrolling */
.sidebar-layer { position: sticky; top: .8rem; height: 0; z-index: 6; }
.sidebar { position: absolute; top: 0; left: 0; width: min(560px, 96%); height: 72vh; max-height: calc(100vh - 1.6rem); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 6; overflow: hidden; transition: transform .25s ease, visibility 0s; }
.sidebar.collapsed { transform: translateX(calc(-100% - 1.3rem)); pointer-events: none; box-shadow: none; visibility: hidden;
  transition: transform .25s ease, visibility 0s linear .25s; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .7rem .9rem; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.sidebar-head strong { font-size: .95rem; }
.sidebar-body { overflow-y: auto; padding: 1rem; display: grid; gap: 1.1rem; }
.side-block + .side-block { border-top: 1px solid var(--border); padding-top: 1rem; }
.side-block h3 { font-size: 1rem; margin: 0 0 .5rem; }
.side-block.add-hero { border-top: 0; }

.sidebar-handle { position: fixed; top: 8px; left: 0; z-index: 30; display: inline-flex; align-items: center;
  background: var(--brand-primary); color: #fff; border: 0; border-radius: 0 10px 10px 0; padding: .6rem .75rem; cursor: pointer; font-size: 1.05rem; box-shadow: var(--shadow); }
.sidebar-handle:hover { filter: brightness(1.06); }

/* search inside the wider sidebar */
.sidebar .add-search { flex-wrap: wrap; }
.sidebar .add-search-input { flex: 1 1 100%; padding-left: 2.4rem; font-size: .95rem; }
.sidebar .add-search-icon { top: 1.35rem; transform: none; }
.sidebar .result-grid { grid-template-columns: repeat(2, 1fr); max-height: 320px; overflow-y: auto; }
.sidebar .manual-grid { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 560px) { .sidebar .result-grid, .sidebar .manual-grid { grid-template-columns: 1fr; } }

/* ---------- v0.16.0: drag games onto shelves (pinning) ---------- */
.cab-game-hit { cursor: grab; }
.dragging-game { cursor: grabbing; }
.dragging-game .cab-game-hit { pointer-events: none; }   /* let drops reach the compartment under the cursor */
.drag-ghost { pointer-events: none; opacity: .82; stroke: rgba(0,0,0,.35); stroke-width: .15; }
.comp-hit.drop-hot { fill: color-mix(in srgb, var(--brand-primary) 20%, transparent) !important; }
.comp-hit.drop-bad { fill: rgba(224,73,43,.24) !important; stroke: rgba(224,73,43,.7); stroke-width: .3; }
.drag-tip { position: fixed; z-index: 60; background: var(--brand-navy, #1F2D3D); color: #fff; font-size: .78rem; padding: .35rem .6rem; border-radius: 8px; box-shadow: var(--shadow); pointer-events: none; max-width: 240px; }

.pin-row { display: flex; align-items: center; gap: .4rem; margin-top: .25rem; }
.pin-badge { font-size: .72rem; color: var(--brand-primary); font-weight: 600; }
.pin-unpin { font-size: .72rem; padding: .1rem .4rem; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--muted); cursor: pointer; }
.pin-unpin:hover { color: var(--text); border-color: var(--brand-primary); }

/* ---------- v0.17.0: "does not fit" list + optimize ---------- */
.optimize-hero { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .35rem; margin: .2rem 0 1.4rem; }
.optimize-btn { font-size: 1.15rem; font-weight: 700; padding: .9rem 2.6rem; border-radius: 14px; box-shadow: var(--shadow); letter-spacing: .01em; }
.optimize-btn:hover { filter: brightness(1.05); }
.optimize-sub { font-size: .85rem; margin: 0; max-width: 46ch; }
.leftover-actions { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.leftover-actions .pin-unpin { font-size: .72rem; }
.leftover-panel { border: 1px solid color-mix(in srgb, var(--brand-accent, #E0542A) 45%, var(--border)); border-radius: 10px; padding: .7rem .8rem; margin: 0 0 .8rem; background: color-mix(in srgb, var(--brand-accent, #E0542A) 8%, transparent); }
.leftover-panel h3 { margin: 0 0 .25rem; font-size: .95rem; }
.leftover-list { list-style: none; margin: .4rem 0 0; padding: 0; display: grid; gap: .45rem; }
.leftover-item { border: 1px solid var(--border); border-radius: 8px; padding: .4rem .55rem; background: var(--surface); }
.leftover-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.leftover-name { font-weight: 600; font-size: .85rem; }
.leftover-why { display: block; font-size: .74rem; color: var(--muted); margin-top: .15rem; }

.warn-text { background: color-mix(in srgb, var(--brand-accent, #E0542A) 12%, transparent); border: 1px solid color-mix(in srgb, var(--brand-accent, #E0542A) 40%, var(--border)); border-radius: 10px; padding: .7rem .85rem; color: var(--text); font-size: .9rem; }
.optimize-actions { display: flex; flex-wrap: wrap; gap: .6rem; margin-top: 1rem; }
.optimize-actions .btn { flex: 1 1 auto; }
.optimize-cabinets { margin-top: 1rem; }
.optcab-list { display: flex; flex-direction: column; gap: .35rem; margin-top: .4rem; }
.optcab-row { display: flex; align-items: center; gap: .5rem; font-size: .9rem; cursor: pointer; }
.optcab-row input { width: auto; }

/* overhang: per-cabinet toggle + red hatch over boxes that stick out */
.check-field { flex-direction: row; align-items: center; gap: .4rem; font-size: .78rem; color: var(--muted); }
.check-field input { width: auto; }
.cab-game-overhang { pointer-events: none; stroke: rgba(224,73,43,.6); stroke-width: .12; }

/* ---------- v0.21.0: share link + read-only viewer ---------- */
.share-row { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.share-link { flex: 1 1 240px; padding: .55rem .6rem; border: 1px solid var(--border); border-radius: 9px; background: var(--bg); color: var(--text); font-size: .85rem; }

.cab-tab-wrap { display: inline-flex; align-items: center; gap: .1rem; }
.cab-eye { background: transparent; border: 0; color: var(--muted); cursor: pointer; font-size: .68rem; line-height: 1; padding: .2rem .3rem; border-radius: 6px; }
.cab-eye:hover { color: var(--text); background: color-mix(in srgb, var(--border) 50%, transparent); }
.cab-tab-wrap.hidden-cab .cab-tab { opacity: .45; text-decoration: line-through; }

.viewer-banner { background: var(--brand-primary); color: #fff; text-align: center; padding: .5rem .8rem; border-radius: 10px; margin-bottom: .9rem; font-size: .9rem; font-weight: 600; }
body.viewer-mode .data-bar,
body.viewer-mode .optimize-hero,
body.viewer-mode .sidebar,
body.viewer-mode .sidebar-handle,
body.viewer-mode .cab-controls,
body.viewer-mode #cabParts,
body.viewer-mode #cabAddCabinet,
body.viewer-mode #leftoverPanel,
body.viewer-mode [data-i18n="cab.dragHint"],
body.viewer-mode [data-i18n="room.dragHint"] { display: none !important; }
.export-status { margin-left: 1rem; opacity: .85; }
.export-status::before { content: "·"; margin-right: 1rem; opacity: .6; }
