/* Door Shop Simulator - FreeForm builder (CAD-style 3D editor). Overrides the old builder rules in style.css. */
#ffb { --ffb-acc: #f5c518; --ffb-rail: 58px; user-select: none; -webkit-user-select: none; }
#ffb button { min-width: 40px; min-height: 40px; }
body.ffb-on .toast { pointer-events: none; top: 52px; bottom: auto; opacity: .92; max-width: min(560px, 80vw); font-size: 14px; padding: 8px 14px; z-index: 60; }

/* header: 44px, one row */
#ffb .ffb-top { height: 46px; flex: none; flex-wrap: nowrap; gap: 4px; padding: 3px 6px; padding-left: calc(6px + var(--safe-l)); padding-right: calc(6px + var(--safe-r)); overflow: hidden; }
#ffb .ffb-title { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; flex: 0 1 auto; }
.ffb-ib { width: 40px; height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); color: #fff; font-size: 19px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; padding: 0; flex: none; }
.ffb-ib:disabled { opacity: .4; }
.ffb-ib.txt { font-family: var(--hd); font-size: 12px; font-weight: 700; letter-spacing: .04em; }
.ffb-ib.sm { width: 40px; height: 40px; font-size: 16px; }
.ffb-chip { height: 40px; border-radius: 20px; border: 1px solid var(--line); background: #0f1823; color: #dbe7f3; padding: 0 12px; font-size: 14px; white-space: nowrap; flex: none; }
.ffb-chip b.bad { color: #ff7b72; } .ffb-chip b.good { color: #3fb950; }
#ffbChk { font-weight: 700; color: #ffd866; border-color: #8a7420; }
#ffbChk.done { color: #3fb950; border-color: #2e8b57; }
.ffb-go { height: 40px; border-radius: 10px; border: 1px solid #1a7a43; background: linear-gradient(#2ecc71, var(--go2)); color: #fff; font-family: var(--hd); font-weight: 800; font-size: 16px; padding: 0 14px; flex: none; white-space: nowrap; }
.ffb-go:disabled { background: #34495e; border-color: var(--line); color: #a9b7c6; }

/* body: tool rail | canvas + sheet | view rail */
#ffb .ffb-body { flex: 1; display: flex; flex-direction: row; min-height: 0; position: relative; }
.ffb-rail { width: var(--ffb-rail); flex: none; display: flex; flex-direction: column; gap: 2px; padding: 3px 4px; padding-left: calc(4px + var(--safe-l)); background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; box-sizing: content-box; }
.ffb-rail button { height: 46px; flex: none; border-radius: 9px; border: 1px solid transparent; background: transparent; color: #dbe7f3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; padding: 0; }
.ffb-rail button span { font-size: 20px; line-height: 1.05; } .ffb-rail button small { font-size: 11px; line-height: 1.1; letter-spacing: -.01em; }
.ffb-rail button.on { background: var(--steel); border-color: var(--ffb-acc); }
.ffb-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#ffb .ffb-cvw { flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none; background: #dfe6ee; }
#ffb .ffb-cvw canvas { position: absolute; inset: 0; display: block; touch-action: none; }
.ffb-ov { position: absolute; inset: 0; pointer-events: none; }
.ffb-tag { position: absolute; transform: translateX(-50%); background: rgba(18,28,40,.88); color: #fff; font-size: 13px; font-weight: 600; padding: 4px 9px; border-radius: 7px; white-space: nowrap; border: 1px solid #2ecc71; }
.ffb-tag.bad { border-color: #e74c3c; color: #ffd0cb; }
.ffb-cross { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; margin: -17px 0 0 -17px; pointer-events: none; border: 2px solid rgba(29,42,56,.75); border-radius: 50%; }
.ffb-cross::before, .ffb-cross::after { content: ''; position: absolute; background: rgba(29,42,56,.75); }
.ffb-cross::before { left: 50%; top: -8px; bottom: -8px; width: 2px; margin-left: -1px; } .ffb-cross::after { top: 50%; left: -8px; right: -8px; height: 2px; margin-top: -1px; }

/* bottom sheet */
.ffb-sheet { flex: none; background: var(--panel); border-top: 1px solid var(--line); display: flex; flex-direction: column; }
.ffb-sh-top { display: flex; align-items: center; gap: 4px; padding: 2px 4px; min-height: 44px; }
.ffb-subs { display: flex; gap: 3px; flex: none; }
.ffb-subs button { height: 40px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel2); color: #dbe7f3; font-size: 13px; font-weight: 600; padding: 0 8px; display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.ffb-subs button span { font-size: 16px; }
.ffb-subs button.on { border-color: var(--ffb-acc); background: var(--steel); color: #fff; }
.ffb-hint { flex: 1; min-width: 0; font-size: 12.5px; color: #9fb0c2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 4px; cursor: pointer; }
.ffb-quick { display: flex; align-items: center; gap: 5px; padding: 2px 6px 4px; overflow-x: auto; overflow-y: hidden; white-space: nowrap; min-height: 46px; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, #000 92%, transparent); mask-image: linear-gradient(90deg, #000 92%, transparent); }
.ffb-quick::-webkit-scrollbar { display: none; }
.ffb-quick:empty { display: none; }
.ffb-q { height: 40px; flex: none; border-radius: 9px; border: 1px solid var(--line); background: #0f1823; color: #eef3f8; font-size: 13.5px; font-weight: 600; padding: 0 10px; white-space: nowrap; }
.ffb-q small { font-size: 11px; color: #9fb0c2; font-weight: 500; margin-left: 3px; }
.ffb-q.on { border-color: var(--ffb-acc); box-shadow: 0 0 0 1px var(--ffb-acc) inset; background: var(--steel); }
.ffb-q.go { background: #2e8b57; border-color: #2e8b57; color: #fff; }
.ffb-q.bad { background: #8e2a20; border-color: #b8382b; color: #fff; }
.ffb-q:disabled { opacity: .45; }
.ffb-qt { flex: none; font-size: 13px; color: #c9d6e3; padding: 0 2px; }
.ffb-qt .bad, .ffb-qt b.bad { color: #ff7b72; }
.ffb-detail { max-height: 30dvh; overflow-y: auto; background: var(--os-bg); color: var(--os-text); padding: 6px 12px; font-size: 13px; }
.ffb-detail .ffb-card { margin: 4px 0; }
.ffb-detail input[type=range] { width: 100%; height: 32px; }

/* view rail + cube */
.ffb-vrail { width: 52px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 4px 4px; padding-right: calc(4px + var(--safe-r)); background: var(--panel); border-left: 1px solid var(--line); overflow-y: auto; box-sizing: content-box; }
.ffb-cube { width: 50px; height: 50px; flex: none; perspective: 240px; display: flex; align-items: center; justify-content: center; margin-bottom: 2px; }
.ffb-cube .cb { width: 34px; height: 34px; position: relative; transform-style: preserve-3d; }
.ffb-cube i { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-style: normal; font-family: var(--hd); font-weight: 700; font-size: 11px; color: #1d2a38; background: rgba(236,240,244,.95); border: 1px solid #7f8c9a; backface-visibility: hidden; cursor: pointer; letter-spacing: .02em; }
.ffb-cube i:hover { background: #ffe680; }
.ffb-cube .f-front { transform: translateZ(17px); } .ffb-cube .f-back { transform: rotateY(180deg) translateZ(17px); }
.ffb-cube .f-right { transform: rotateY(90deg) translateZ(17px); } .ffb-cube .f-left { transform: rotateY(-90deg) translateZ(17px); }
.ffb-cube .f-top { transform: rotateX(90deg) translateZ(17px); background: #fff3b0; } .ffb-cube .f-bot { transform: rotateX(-90deg) translateZ(17px); }

/* popovers */
.ffb-pop { position: absolute; z-index: 8; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.45); display: grid; gap: 4px; }
#ffbViews { right: 62px; top: 60px; grid-template-columns: 1fr 1fr; width: 200px; }
.ffb-pop button { height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel2); color: #fff; font-weight: 600; font-size: 14px; text-align: left; padding: 0 10px; }
.ffb-pop button.on { border-color: var(--ffb-acc); }
.ffb-menu { left: 4px; top: 2px; width: 270px; max-height: calc(100% - 8px); overflow-y: auto; }
.ffb-grid { display: flex; align-items: center; gap: 4px; font-size: 13px; color: #c9d6e3; padding-left: 4px; }
.ffb-grid button { flex: 1; text-align: center; padding: 0; }

/* long-press radial menu */
.ffb-radial { position: absolute; inset: 0; z-index: 7; background: rgba(10,16,24,.25); }
.ffb-radial button { position: absolute; width: 50px; height: 50px; border-radius: 50%; border: 2px solid var(--ffb-acc); background: var(--panel); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; box-shadow: 0 6px 18px rgba(0,0,0,.4); }
.ffb-radial button span { font-size: 18px; line-height: 1; } .ffb-radial button small { font-size: 11px; line-height: 1; position: absolute; top: 52px; white-space: nowrap; background: rgba(18,28,40,.85); padding: 2px 5px; border-radius: 5px; }

/* checklist drawer */
.ffb-drawer { position: absolute; top: 0; right: 0; bottom: 0; width: min(320px, 70vw); z-index: 9; background: var(--os-bg); color: var(--os-text); display: flex; flex-direction: column; box-shadow: -10px 0 30px rgba(0,0,0,.35); }
.ffb-dr-h { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 4px 12px; background: var(--os-side); color: #fff; font-family: var(--hd); font-size: 18px; }
.ffb-dr-h .ffb-ib { background: transparent; border-color: rgba(255,255,255,.3); }
.ffb-dr-b { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }
.ffb-dr-b h4 { font-family: var(--hd); margin: 10px 0 4px; font-size: 16px; color: var(--os-side); }
#ffb .ffb-checks { list-style: none; margin: 0; padding: 0; font-size: 13px; }
#ffb .ffb-checks li { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 4px 2px; border-bottom: 1px solid var(--os-line); cursor: pointer; }
#ffb .ffb-checks li.no { color: #a04000; font-weight: 600; }
#ffb .ffb-checks li i { margin-left: auto; font-style: normal; font-size: 18px; color: var(--os-acc); }
.ffb-cartrow { display: flex; align-items: center; gap: 6px; margin: 8px 0; flex-wrap: wrap; }
.ffb-cartrow .ffb-qt { color: var(--os-text); } .ffb-cartrow .ffb-q { background: #fff; color: var(--os-text); border-color: var(--os-line); min-width: 44px; }
.ffb-cartrow small { color: var(--os-muted); font-size: 12px; }
.ffb-btn { height: 42px; border-radius: 9px; border: 1px solid var(--os-line); background: #fff; color: var(--os-text); font-weight: 700; padding: 0 14px; font-size: 14px; }
.ffb-btn.go { background: #2e8b57; color: #fff; border-color: #2e8b57; }
.ffb-dr-b .ffb-btn { width: 100%; margin-top: 6px; }

/* confirm sheet */
.ffb-ask { position: fixed; inset: 0; z-index: 200; background: rgba(8,12,18,.55); display: flex; align-items: center; justify-content: center; padding: 12px; }
.ffb-ask-c { background: var(--os-bg); color: var(--os-text); border-radius: 14px; padding: 14px 16px; max-width: 520px; width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; font-size: 14px; line-height: 1.4; }
.ffb-ask-c p { margin: 0 0 10px; }
.ffb-ask-b { display: flex; justify-content: flex-end; gap: 8px; }

@media (max-width: 820px) {
  #ffb .ffb-body { flex-direction: row; }
  #ffb .ffb-cvw { min-height: 0; }
}
@media (max-height: 400px) {
  .ffb-rail button { height: 44px; }
  .ffb-rail button small { font-size: 11px; }
}
@media (max-width: 700px) { #ffb .ffb-title { display: none; } }
#ffb .ffb-hint { position: static; left: auto; right: auto; bottom: auto; background: none; border-radius: 0; pointer-events: auto; }
#ffb .ffb-body, #ffb .ffb-main, #ffb .ffb-cvw, #ffb { overflow: clip; }
