/* Diorama builder: full-bleed stage, a bottom sheet of big buttons, toy-shop display-case feel. */
.dio { position: relative; width: 100%; height: calc(100dvh - 84px - env(safe-area-inset-bottom)); min-height: 480px; overflow: hidden; background: var(--paper-2); isolation: isolate; user-select: none; -webkit-user-select: none; font-family: var(--body); }
.dio.standalone { height: 100dvh; }
.dio-stage { position: absolute; inset: 0; }
.dio-canvas { display: block; width: 100%; height: 100%; touch-action: none; outline: none; }
.dio-canvas:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--tag); }
.dio.is-carrying .dio-canvas { cursor: copy; }

.dio-btn { -webkit-appearance: none; appearance: none; border: 0; border-radius: 999px; min-height: 44px; min-width: 44px; padding: 0 16px; background: var(--card); color: var(--ink); font: 600 15px/1 var(--display); display: inline-flex; align-items: center; justify-content: center; gap: 8px; box-shadow: var(--shadow); transition: transform .12s, background .15s, color .15s; }
.dio-btn:active { transform: scale(.94); }
.dio-btn:disabled { opacity: .4; pointer-events: none; }
.dio-btn.icon { padding: 0; width: 44px; }
.dio-btn.primary { background: var(--jade); color: #fff; }
.dio-btn.danger { color: var(--danger); }
.dio-btn.small { min-height: 38px; font-size: 14px; }
.dio-btn.big { min-height: 54px; padding: 0 24px; font-size: 17px; }
.dio-btn.is-on { background: var(--jade); color: #fff; }

/* top bar */
.dio-top { position: absolute; top: 0; left: 0; right: 0; padding: calc(10px + env(safe-area-inset-top)) 12px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 3; }
.dio-top > * { pointer-events: auto; }
.dio-roomnav { display: flex; align-items: center; gap: 2px; background: color-mix(in oklab, var(--card) 85%, transparent); backdrop-filter: blur(10px); border-radius: 999px; padding: 3px; box-shadow: var(--shadow); flex: 1 1 auto; min-width: 0; max-width: 200px; }
.dio-roomnav .dio-btn { box-shadow: none; background: transparent; width: 34px; min-width: 34px; min-height: 38px; }
.dio-roomname { border: 0; background: transparent; color: var(--ink); font: 600 16px/1.1 var(--display); padding: 8px 4px; min-height: 38px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.dio-tools { display: flex; gap: 4px; flex: 0 0 auto; }
.dio-tools .dio-btn { width: 38px; min-width: 38px; min-height: 38px; background: color-mix(in oklab, var(--card) 85%, transparent); backdrop-filter: blur(10px); }
.dio-tools .dio-btn.is-on { background: var(--jade); color: #fff; }

.dio-hint { position: absolute; left: 50%; top: calc(66px + env(safe-area-inset-top)); transform: translate(-50%, -8px); background: var(--ink); color: var(--paper); padding: 8px 14px; border-radius: 999px; font: 600 13px/1.2 var(--body); opacity: 0; transition: .25s; pointer-events: none; z-index: 3; max-width: 90%; text-align: center; }
.dio-hint.show { opacity: 1; transform: translate(-50%, 0); }

/* selection action bar: floats just above the sheet */
.dio-sel { position: absolute; left: 8px; right: 8px; bottom: max(calc(8px + env(safe-area-inset-bottom)), calc(var(--sheet-h, 290px) - 96px)); z-index: 6; background: color-mix(in oklab, var(--card) 94%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-radius: 20px; box-shadow: var(--shadow); padding: 6px 6px 6px; transition: bottom .25s; }
.dio.sheet-collapsed .dio-sel { --sheet-h: 64px; }
/* docked over the top of the sheet so the room stays clear; a scrim dims the panel underneath */
.dio.has-sel .dio-sheet::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: color-mix(in oklab, var(--card) 70%, transparent); pointer-events: none; }
.dio-empty-cta { margin-top: 10px; }
.dio-sel-name { font: 600 13px/1 var(--display); color: var(--ink-2); padding: 4px 8px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dio-sel-row { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; justify-content: space-between; }
.dio-sel-row::-webkit-scrollbar { display: none; }
.dio-sel-row .act { flex: 1 0 auto; flex-direction: column; gap: 3px; box-shadow: none; background: transparent; min-width: 44px; min-height: 52px; padding: 4px 4px 2px; border-radius: 14px; font: 600 10.5px/1 var(--body); color: var(--ink); }
.dio-sel-row .act svg { width: 22px; height: 22px; }
.dio-sel-row .act:active { background: var(--paper-2); }
.dio-sel-row .act.danger { color: var(--danger); }
.dio-sel-row .act.done { color: var(--jade); }
.dio-sel-row .act.pose .pose-name { font: 700 14px/22px var(--display); color: var(--jade); }
.dio-sel-row .act.colour { position: relative; }
.dio-sel-row .act.colour .dot { width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .15); }
.dio-sel-row .act.colour input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

/* bottom sheet */
.dio-sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 5; background: var(--card); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 30px -16px rgba(0, 0, 0, .35); display: grid; grid-template-rows: auto auto 1fr; height: var(--sheet-h, 240px); max-height: 56%; transition: height .25s ease; --sheet-h: 290px; }
.dio-sheet.is-collapsed { height: 64px; }
.dio-handle { width: 100%; min-height: 18px; height: 18px; border: 0; background: transparent; padding: 6px 0 0; display: grid; place-items: center; box-shadow: none; border-radius: 22px 22px 0 0; }
.dio-handle .bar { width: 40px; height: 5px; border-radius: 3px; background: var(--line); display: block; }
.dio-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 2px 10px 4px; }
.dio-tabs::-webkit-scrollbar { display: none; }
.dio-tabs .tab { box-shadow: none; background: transparent; color: var(--ink-2); min-height: 40px; padding: 0 6px; font-size: 15px; }
.dio-tabs .tab.is-on { background: var(--jade-tint); color: var(--jade); }
.dio-panel { overflow-y: auto; overscroll-behavior: contain; padding: 6px 12px calc(12px + env(safe-area-inset-bottom)); }
.dio-sheet.is-collapsed .dio-panel { display: none; }
.dio-sec { margin-bottom: 14px; }
.dio-sec-head { display: flex; align-items: center; gap: 8px; margin: 2px 0 8px; }
.dio-sec-head h3 { margin-right: auto !important; }
.dio-sec-head .dio-select { min-width: 0; flex: 0 1 auto; max-width: 46%; }
.dio-sec h3 { font-size: 15px; color: var(--ink-2); font-weight: 600; margin: 0; }
.dio-note { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.dio-empty { margin: 10px 0; color: var(--ink-2); font-size: 14px; grid-column: 1 / -1; }

.dio-filters { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.dio-select { border: 0; background: var(--paper-2); color: var(--ink); border-radius: 999px; min-height: 36px; padding: 0 12px; font: 600 14px var(--display); max-width: 100%; }
.dio-seg { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 3px; gap: 2px; }
.dio-seg .seg { box-shadow: none; background: transparent; min-height: 30px; min-width: 40px; padding: 0 10px; font-size: 13px; color: var(--ink-2); }
.dio-seg .seg.is-on { background: var(--card); color: var(--jade); }

/* horizontal strips: two rows of tiles that scroll sideways; a vertical drag lifts a tile into the room */
.dio-strip { display: grid; grid-auto-flow: column; grid-template-rows: repeat(2, auto); grid-auto-columns: 82px; gap: 8px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; margin: 0 -12px; padding: 2px 12px 4px; touch-action: pan-x; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.dio-strip::-webkit-scrollbar { display: none; }
.dio-strip.one { grid-template-rows: auto; grid-auto-columns: max-content; }
.dio-strip > * { scroll-snap-align: start; }
.dio-strip .dio-empty { grid-row: 1 / -1; width: calc(100vw - 48px); max-width: 520px; white-space: normal; }
.dio-tile { position: relative; border: 0; border-radius: 16px; background: var(--paper-2); padding: 6px 4px 6px; display: grid; justify-items: center; align-content: center; gap: 3px; min-height: 88px; color: var(--ink); touch-action: pan-x; transition: transform .12s, background .15s; cursor: grab; }
.dio-tile.small { min-height: 74px; min-width: 70px; }
.dio-tile:active { transform: scale(.95); background: var(--jade-tint); }
.dio-tile .fig { pointer-events: none; }
.dio-tile .fig .count { position: absolute; top: -4px; right: -6px; background: var(--tag); color: var(--tag-ink); font: 700 11px/1 var(--body); padding: 3px 6px; border-radius: 999px; }
.dio-tile-name { font: 600 11px/1.15 var(--body); text-align: center; color: var(--ink-2); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dio-thumb { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in oklab, var(--c, var(--jade-tint)) 55%, var(--card)); font-size: 24px; }
.dio-flag { position: absolute; top: 6px; right: 6px; font: 700 9px/1 var(--body); text-transform: uppercase; letter-spacing: .04em; color: var(--jade); background: var(--jade-tint); padding: 3px 5px; border-radius: 999px; }
.dio-sticker { width: 48px; height: 48px; }
.dio-cats { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -12px 10px; padding: 2px 12px; }
.dio-cats::-webkit-scrollbar { display: none; }
.dio-cats .cat { flex: 0 0 auto; box-shadow: none; background: var(--paper-2); min-height: 38px; padding: 0 12px 0 8px; font-size: 13px; }
.dio-cats .cat .ic { font-size: 18px; }
.dio-cats .cat.is-on { background: var(--jade); color: #fff; }

.dio-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.swatch { width: 34px; height: 34px; min-width: 34px; min-height: 34px; border-radius: 50%; padding: 0; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); position: relative; }
.swatch.is-on::after { content: ""; position: absolute; inset: -5px; border-radius: 50%; border: 3px solid var(--jade); }
.swatch.hex { background: conic-gradient(#f25f5c, #ffd54a, #5fbf93, #6fb6ff, #c98cff, #f25f5c); display: grid; place-items: center; }
.swatch.hex input { opacity: 0; width: 100%; height: 100%; position: absolute; inset: 0; }
.swatch.hex::before { content: "+"; color: #fff; font: 800 18px/1 var(--display); text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.dio-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.dio-chips .chip { box-shadow: none; background: var(--paper-2); min-height: 36px; font-size: 13px; text-transform: capitalize; }
.dio-chips.big .chip { min-height: 44px; font-size: 15px; }
.dio-chips .chip.is-on { background: var(--jade); color: #fff; }
.dio-chips .chip:has(.chip-tex) { display: inline-flex; align-items: center; gap: 7px; padding-left: 5px; }
.chip-tex { width: 26px; height: 26px; border-radius: 8px; flex: none; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12), 0 1px 2px rgba(0, 0, 0, .18); background: var(--paper-2); }
.chip.is-on .chip-tex { box-shadow: 0 0 0 2px #fff, 0 1px 2px rgba(0, 0, 0, .25); }
.dio-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.dio-row .lbl { font: 600 13px var(--body); color: var(--ink-2); flex-basis: 100%; }

.dio-strip.themes .theme { box-shadow: none; background: var(--paper-2); border-radius: 14px; padding: 6px; width: 92px; min-height: 72px; flex-direction: column; gap: 6px; font-size: 12px; }
.dio-strip.themes .theme .sw { width: 100%; height: 32px; border-radius: 8px; background: linear-gradient(180deg, var(--wall) 0 62%, var(--floor) 62%); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); }
.dio-strip .is-on { outline: 3px solid var(--jade); outline-offset: -3px; color: var(--ink); background: var(--jade-tint) !important; }
.dio-strip.lights .light { box-shadow: none; background: var(--paper-2); border-radius: 14px; min-height: 44px; padding: 0 12px 0 6px; gap: 8px; font-size: 13px; white-space: nowrap; }
.dio-strip.lights .light .sky { width: 32px; height: 26px; border-radius: 8px; background: radial-gradient(circle at 70% 30%, var(--sun) 0 5px, transparent 6px), var(--sky); }
.dio-details { margin: 0 0 14px; border-radius: 14px; background: var(--paper-2); padding: 0 12px; }
.dio-details summary { font: 600 15px/1 var(--display); color: var(--ink); min-height: 46px; display: flex; align-items: center; cursor: pointer; list-style: none; }
.dio-details summary::-webkit-details-marker { display: none; }
.dio-details summary::after { content: "+"; margin-left: auto; font-size: 20px; color: var(--ink-2); }
.dio-details[open] summary::after { content: "–"; }
.dio-details[open] { padding-bottom: 10px; }
.dio-details h4 { margin: 6px 0 4px; font: 600 13px var(--body); color: var(--ink-2); }
.dio-details .chip { background: var(--card); }
.dio-nameplate { display: flex; gap: 8px; margin: 8px 0; }
.dio-nameplate input { flex: 1; min-width: 0; border: 0; background: var(--paper-2); color: var(--ink); border-radius: 999px; min-height: 40px; padding: 0 14px; font: 600 14px var(--body); }
.dio-rooms { display: grid; gap: 8px; }
.roomcard { box-shadow: none; background: var(--paper-2); border-radius: 14px; justify-content: flex-start; min-height: 56px; padding: 6px 12px 6px 6px; text-align: left; }
.roomcard .sw { width: 44px; height: 44px; border-radius: 10px; background: linear-gradient(180deg, var(--wall) 0 62%, var(--floor) 62%); flex: 0 0 auto; }
.roomcard .nm { flex: 1; font-size: 15px; }
.roomcard .ct { font: 600 12px var(--body); color: var(--ink-2); }
.roomcard.is-on { outline: 3px solid var(--jade); outline-offset: -3px; }
.dio-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* photo / visit */
.dio-photobar { position: absolute; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); display: flex; justify-content: center; gap: 10px; z-index: 5; }
.dio-visit { position: absolute; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(0, 0, 0, .45); color: #fff; padding: 8px 14px; border-radius: 999px; font: 600 13px var(--body); z-index: 5; pointer-events: none; }
.dio-flash { position: absolute; inset: 0; background: #fff; z-index: 9; animation: dio-flash .5s ease-out forwards; pointer-events: none; }
@keyframes dio-flash { from { opacity: .9; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) { .dio-sheet, .dio-sel, .dio-btn, .dio-tile { transition: none; } .dio-flash { animation-duration: .1s; } }
@media (min-width: 600px) { .dio { border-radius: 0 0 20px 20px; } .dio-sheet { --sheet-h: 300px; } .dio-sel { --sheet-h: 300px; left: 50%; right: auto; transform: translateX(-50%); width: min(560px, calc(100% - 16px)); } }
