/* Floor Plan & Interior Designer — mobile-first 2D/3D studio */
:root{
  --fp-bg:#f4f5f2;--fp-surface:#ffffff;--fp-surface-2:#eef0ec;--fp-canvas:#fafaf7;
  --fp-grid-minor:#ebede8;--fp-grid-major:#d7dcd2;--fp-text:#1c2529;--fp-muted:#5c6b70;
  --fp-line:#d4dad3;--fp-line-strong:#b4bfb7;--fp-accent:#1d6f63;--fp-accent-2:#15564d;
  --fp-accent-soft:#dff1ed;--fp-on-accent:#ffffff;--fp-wall:#27343a;--fp-dim:#0f766e;
  --fp-danger:#dc2626;--fp-danger-soft:#fef2f2;
  --fp-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
  --fp-mono:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
}
@media (prefers-color-scheme:dark){
  :root:not([data-theme=light]){
    --fp-bg:#11171a;--fp-surface:#172126;--fp-surface-2:#1f2d33;--fp-canvas:#10191d;
    --fp-grid-minor:#1a282e;--fp-grid-major:#243840;--fp-text:#edf3f4;--fp-muted:#9eb3ba;
    --fp-line:#283b42;--fp-line-strong:#3c5761;--fp-accent:#2dd4bf;--fp-accent-2:#5eead4;
    --fp-accent-soft:#153835;--fp-on-accent:#06231f;--fp-wall:#dbe4e8;--fp-dim:#5eead4;
    --fp-danger:#f87171;--fp-danger-soft:#3d1b1b;
  }
}
:root[data-theme=dark]{
  --fp-bg:#11171a;--fp-surface:#172126;--fp-surface-2:#1f2d33;--fp-canvas:#10191d;
  --fp-grid-minor:#1a282e;--fp-grid-major:#243840;--fp-text:#edf3f4;--fp-muted:#9eb3ba;
  --fp-line:#283b42;--fp-line-strong:#3c5761;--fp-accent:#2dd4bf;--fp-accent-2:#5eead4;
  --fp-accent-soft:#153835;--fp-on-accent:#06231f;--fp-wall:#dbe4e8;--fp-dim:#5eead4;
  --fp-danger:#f87171;--fp-danger-soft:#3d1b1b;
}

.fp-app{display:flex;flex-direction:column;height:calc(100dvh - 110px);min-height:540px;max-height:960px;background:var(--fp-bg);color:var(--fp-text);font:14px/1.4 var(--fp-font);border:1px solid var(--fp-line);border-radius:14px;overflow:hidden;box-shadow:0 8px 28px rgba(10,24,30,.08)}
.fp-app *,.fp-app *::before,.fp-app *::after{box-sizing:border-box}
.fp-app button,.fp-app input,.fp-app select{font:inherit;color:inherit}
.fp-app :focus-visible{outline:2px solid var(--fp-accent);outline-offset:2px}

.fp-topbar{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;background:var(--fp-surface);border-bottom:1px solid var(--fp-line);flex:none}
.fp-brand{display:flex;align-items:center;gap:8px;min-width:0;flex:1 1 180px}
.fp-title{font-weight:700;font-size:15px;white-space:nowrap}
.fp-select{min-height:36px;max-width:230px;flex:1;padding:0 10px;border:1px solid var(--fp-line-strong);border-radius:9px;background:var(--fp-surface-2);font-size:13px}
.fp-view-switch{display:inline-flex;padding:3px;border-radius:10px;background:var(--fp-surface-2);border:1px solid var(--fp-line);gap:2px}
.fp-app .fp-seg{min-height:32px;padding:0 10px;border:0;border-radius:7px;background:transparent;cursor:pointer;font-size:12px;font-weight:700;color:var(--fp-muted)}
.fp-app .fp-seg.active{background:var(--fp-accent);color:var(--fp-on-accent)}
.fp-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}

.fp-app .fp-btn{display:inline-flex;align-items:center;justify-content:center;gap:5px;min-height:36px;min-width:36px;padding:0 10px;border:1px solid var(--fp-line-strong);border-radius:9px;background:var(--fp-surface);cursor:pointer;font-size:13px;font-weight:600;touch-action:manipulation}
.fp-app .fp-btn:hover{background:var(--fp-surface-2)}
.fp-app .fp-btn:disabled{opacity:.45;cursor:not-allowed}
.fp-app .fp-btn-primary{background:var(--fp-accent);border-color:var(--fp-accent);color:var(--fp-on-accent)}
.fp-app .fp-btn-primary:hover{background:var(--fp-accent-2)}
.fp-app .fp-btn-danger{color:var(--fp-danger);border-color:var(--fp-danger);background:var(--fp-danger-soft)}
.fp-app .fp-btn-sm{min-height:32px;min-width:32px;padding:0 9px;font-size:12px}

.fp-main{display:flex;flex-direction:column;flex:1;min-height:0;overflow:hidden}
.fp-stage{position:relative;flex:1 1 58%;min-height:260px;display:flex;flex-direction:column;overflow:hidden}
.fp-pane-2d,.fp-pane-3d{position:relative;flex:1 1 0;min-height:0;min-width:0;overflow:hidden;background:var(--fp-canvas)}
.fp-pane-2d[hidden],.fp-pane-3d[hidden]{display:none!important}
.fp-app[data-view=split] .fp-stage{flex-direction:row}
.fp-app[data-view=split] .fp-pane-3d{border-left:1px solid var(--fp-line)}

.fp-svg{display:block;width:100%;height:100%;touch-action:none;user-select:none;-webkit-user-select:none}
.fp-app[data-tool=wall] .fp-svg,.fp-app[data-tool=room] .fp-svg{cursor:crosshair}
.fp-app[data-tool=place] .fp-svg{cursor:copy}
.fp-app[data-tool=erase] .fp-svg{cursor:not-allowed}
.fp-grid-minor{stroke:var(--fp-grid-minor);stroke-width:.8}
.fp-grid-major{stroke:var(--fp-grid-major);stroke-width:1.1}

.fp-tool-rail{position:absolute;top:10px;left:10px;z-index:4;display:flex;flex-wrap:wrap;gap:3px;padding:4px;background:var(--fp-surface);border:1px solid var(--fp-line);border-radius:11px;box-shadow:0 4px 14px rgba(0,0,0,.1)}
.fp-app .fp-tool{min-height:34px;padding:0 9px;border:0;border-radius:8px;background:transparent;cursor:pointer;font-size:12px;font-weight:600;color:var(--fp-muted)}
.fp-app .fp-tool.active{background:var(--fp-accent-soft);color:var(--fp-accent)}

.fp-hud-bottom{position:absolute;left:10px;right:10px;bottom:10px;z-index:4;display:flex;align-items:center;justify-content:space-between;gap:8px;pointer-events:none}
.fp-status{pointer-events:auto;padding:6px 10px;border-radius:9px;background:var(--fp-surface);border:1px solid var(--fp-line);font:12px/1.3 var(--fp-mono);box-shadow:0 2px 8px rgba(0,0,0,.08)}
.fp-zoom-pill{pointer-events:auto;display:inline-flex;align-items:center;gap:2px;padding:2px;border-radius:9px;background:var(--fp-surface);border:1px solid var(--fp-line);box-shadow:0 2px 8px rgba(0,0,0,.08)}
.fp-zoom-pill button{width:30px;height:30px;border:0;border-radius:7px;background:transparent;cursor:pointer;font-weight:700}
.fp-zoom-pill button:hover{background:var(--fp-surface-2)}
.fp-zoom-pill span{min-width:44px;text-align:center;font:12px var(--fp-mono)}

.fp-sel-bar{position:absolute;top:10px;right:10px;z-index:5;display:flex;align-items:center;gap:5px;padding:5px 7px;border-radius:10px;background:var(--fp-surface);border:1px solid var(--fp-line);box-shadow:0 4px 16px rgba(0,0,0,.12)}
.fp-sel-name{font:600 12px var(--fp-mono);padding:0 4px;color:var(--fp-accent)}

/* 3D viewport */
.fp-3d-host{width:100%;height:100%;background:linear-gradient(180deg,#d8e8f0,#f2f0ea)}
.fp-3d-bar{position:absolute;top:10px;left:10px;z-index:4;display:flex;flex-wrap:wrap;gap:5px;padding:4px;border-radius:11px;background:var(--fp-surface);border:1px solid var(--fp-line);box-shadow:0 4px 14px rgba(0,0,0,.12)}
.fp-walk-pad{position:absolute;right:14px;bottom:14px;z-index:5;display:flex;flex-direction:column;align-items:center;gap:4px;padding:6px;border-radius:12px;background:var(--fp-surface);border:1px solid var(--fp-line);box-shadow:0 4px 14px rgba(0,0,0,.16)}
.fp-walk-mid{display:flex;gap:4px}
.fp-walk-pad button{width:36px;height:36px;border:1px solid var(--fp-line-strong);border-radius:8px;background:var(--fp-surface-2);cursor:pointer;font-weight:700}

/* Side / Bottom Inspector */
.fp-panel{flex:0 0 42%;min-height:220px;display:flex;flex-direction:column;background:var(--fp-surface);border-top:1px solid var(--fp-line);overflow:hidden}
.fp-tabs{display:grid;grid-template-columns:repeat(4,1fr);border-bottom:1px solid var(--fp-line);background:var(--fp-surface-2);flex:none}
.fp-app .fp-tab{min-height:40px;border:0;border-bottom:2px solid transparent;background:transparent;cursor:pointer;font-size:13px;font-weight:600;color:var(--fp-muted)}
.fp-app .fp-tab.active{color:var(--fp-accent);border-bottom-color:var(--fp-accent);background:var(--fp-surface)}
.fp-panel-body{flex:1;min-height:0;overflow-y:auto;-webkit-overflow-scrolling:touch;padding:10px}
.fp-pane{display:flex;flex-direction:column;gap:10px}
.fp-pane[hidden]{display:none!important}
.fp-search{width:100%;min-height:36px;padding:0 10px;border:1px solid var(--fp-line-strong);border-radius:9px;background:var(--fp-surface-2)}

.fp-cat-title{margin:6px 0 5px;font-size:11px;text-transform:uppercase;letter-spacing:.06em;color:var(--fp-muted)}
.fp-cat-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(88px,1fr));gap:6px}
.fp-app .fp-item-btn{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;min-height:58px;padding:6px 4px;border:1px solid var(--fp-line);border-radius:10px;background:var(--fp-surface-2);cursor:pointer;font-size:11px;font-weight:600;text-align:center}
.fp-app .fp-item-btn:hover,.fp-app .fp-item-btn.active{border-color:var(--fp-accent);background:var(--fp-accent-soft);color:var(--fp-accent)}
.fp-item-btn svg{width:30px;height:22px;stroke:currentColor;fill:none;stroke-width:1.6}

.fp-inspect-body{display:flex;flex-direction:column;gap:10px}
.fp-prop-head{display:flex;align-items:center;justify-content:space-between;padding-bottom:6px;border-bottom:1px solid var(--fp-line)}
.fp-prop-title{font-weight:700;font-size:15px}
.fp-field{display:flex;flex-direction:column;gap:4px}
.fp-field label{font-size:12px;font-weight:600;color:var(--fp-muted)}
.fp-field input,.fp-field select{min-height:36px;padding:0 10px;border:1px solid var(--fp-line-strong);border-radius:8px;background:var(--fp-surface-2)}
.fp-field-row{display:grid;grid-template-columns:1fr 1fr;gap:8px}
.fp-swatches{display:flex;flex-wrap:wrap;gap:6px}
.fp-swatch{width:28px;height:28px;border-radius:7px;border:2px solid var(--fp-line);cursor:pointer}
.fp-swatch.active{border-color:var(--fp-accent);transform:scale(1.08)}
.fp-empty{margin:10px 4px;color:var(--fp-muted);font-size:13px}

.fp-rooms-summary{display:grid;grid-template-columns:1fr 1fr;gap:6px}
.fp-stat{padding:8px;border-radius:9px;background:var(--fp-surface-2);border:1px solid var(--fp-line)}
.fp-stat span{display:block;font-size:11px;color:var(--fp-muted)}
.fp-stat strong{font:700 14px var(--fp-mono)}
.fp-room-card,.fp-level-card{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:8px 10px;border-radius:9px;background:var(--fp-surface-2);border:1px solid var(--fp-line);cursor:pointer}
.fp-room-card.active,.fp-level-card.active{border-color:var(--fp-accent);background:var(--fp-accent-soft)}
.fp-level-actions{display:flex;gap:6px;flex-wrap:wrap}

/* SVG architectural elements */
.fp-wall{stroke:var(--fp-wall);stroke-linecap:square;cursor:pointer}
.fp-wall.selected{stroke:var(--fp-accent)}
.fp-wall-hit{stroke:transparent;stroke-width:18;cursor:pointer}
.fp-dim-line{stroke:var(--fp-dim);stroke-width:1;opacity:.8}
.fp-dim-text{font:600 10px var(--fp-mono);fill:var(--fp-dim);pointer-events:none}
.fp-room-label{font:700 12px var(--fp-font);fill:var(--fp-text);pointer-events:none}
.fp-room-area{font:600 11px var(--fp-mono);fill:var(--fp-muted);pointer-events:none}
.fp-furn{cursor:grab}
.fp-furn.selected .fp-furn-box{stroke:var(--fp-accent);stroke-width:2;stroke-dasharray:4 2}
.fp-draft{stroke:var(--fp-accent);stroke-width:4;stroke-dasharray:6 4;fill:none;pointer-events:none}

/* Modal */
.fp-dialog{width:min(480px,94vw);padding:0;border:1px solid var(--fp-line);border-radius:14px;background:var(--fp-surface);color:var(--fp-text);box-shadow:0 20px 60px rgba(0,0,0,.35)}
.fp-dialog::backdrop{background:rgba(8,14,18,.55);backdrop-filter:blur(3px)}
.fp-dialog-head{display:flex;align-items:center;justify-content:space-between;padding:12px 14px;border-bottom:1px solid var(--fp-line)}
.fp-dialog-head h2{margin:0;font-size:16px}
.fp-dialog-body{padding:14px;display:flex;flex-direction:column;gap:14px}
.fp-file-sec h3{margin:0 0 8px;font-size:12px;text-transform:uppercase;letter-spacing:.05em;color:var(--fp-muted)}
.fp-btn-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:8px}

@media (min-width:900px){
  .fp-main{flex-direction:row}
  .fp-stage{flex:1 1 auto;min-height:0}
  .fp-panel{flex:0 0 340px;border-top:0;border-left:1px solid var(--fp-line)}
}
@media (max-width:600px){
  .fp-app{height:calc(100dvh - 82px);border-radius:10px}
  .fp-title{display:none}
  .fp-topbar{padding:6px 8px;gap:6px}
  .fp-app .fp-btn{min-height:32px;min-width:32px;padding:0 8px;font-size:12px}
  .fp-app[data-view=split] .fp-stage{flex-direction:column}
  .fp-app[data-view=split] .fp-pane-3d{border-left:0;border-top:1px solid var(--fp-line)}
  .fp-sel-bar{top:auto;bottom:50px;left:10px;right:10px;justify-content:space-between}
}
