.furniture-layer{position:absolute;inset:0;z-index:8;pointer-events:none}.furniture-item{position:absolute;pointer-events:auto;user-select:none;touch-action:none;transform-origin:center bottom;cursor:grab;filter:drop-shadow(0 10px 10px rgba(50,38,28,.18));transition:filter .15s,outline .15s}.furniture-item:active{cursor:grabbing}.furniture-item.selected{outline:3px solid #8b7ac4;outline-offset:8px;border-radius:18px;filter:drop-shadow(0 12px 12px rgba(68,52,110,.28))}.furniture-image{display:block;width:clamp(110px,12vw,190px);height:auto;object-fit:contain;pointer-events:none}.furniture-sofa .furniture-image{width:clamp(180px,19vw,320px)}.furniture-bed .furniture-image{width:clamp(300px,24vw,390px)}.furniture-rug .furniture-image{width:clamp(220px,30vw,500px);opacity:.92}.furniture-emoji{display:block;font-size:clamp(48px,6vw,90px);line-height:1}.furniture-toggle{position:fixed;left:14px;top:14px;z-index:80;border:0;border-radius:24px;padding:12px 20px;background:#5d5879;color:#fff;font:700 16px system-ui;box-shadow:0 5px 16px #302b4760;cursor:pointer}.furniture-panel{position:fixed;left:14px;top:68px;z-index:79;width:300px;padding:16px;border-radius:18px;background:#fffaf5f2;box-shadow:0 12px 32px #4c3f3428;display:none;font:14px system-ui;color:#4e465d}.furniture-panel.open{display:block}.furniture-panel h3{margin:0 0 8px;font-size:16px}.furniture-panel .furniture-hint{margin-bottom:11px;color:#887c8c}.furniture-catalog{display:grid;grid-template-columns:repeat(3,1fr);gap:7px}.furniture-catalog button,.furniture-actions button{border:0;border-radius:10px;padding:9px 6px;background:#eee9f5;color:#514a68;font-weight:700;cursor:pointer}.furniture-catalog button:hover,.furniture-actions button:hover{background:#dcd3ed}.furniture-actions{display:grid;grid-template-columns:repeat(3,1fr);gap:7px;margin-top:10px}.furniture-actions button.danger{background:#f3dddd;color:#8e4d4d}.furniture-selected{margin-top:10px;min-height:18px;color:#6e6276;font-size:12px}

/* Keep the existing selector outside portrait camera motion; reserve its top-left slot. */
.character-selector{position:fixed}
.furniture-toggle{left:calc(max(12px,env(safe-area-inset-left)) + 112px);top:max(12px,env(safe-area-inset-top))}
.furniture-panel{top:calc(max(12px,env(safe-area-inset-top)) + 54px);max-width:calc(100vw - 28px);max-height:calc(100dvh - 90px);overflow-y:auto}

/* Editing is a draft until the user explicitly saves it. */
.furniture-layer{z-index:auto}
.furniture-item{cursor:default}
.is-furniture-editing .furniture-item{cursor:grab}
.is-furniture-editing .furniture-item:active{cursor:grabbing}
.furniture-panel h4{margin:14px 0 7px;font-size:13px}
.furniture-edit-status{min-height:20px;margin:12px 0 8px;line-height:1.4}
.furniture-session-actions{display:flex;gap:8px;margin-bottom:9px}
.furniture-session-actions button{flex:1;border:0;border-radius:10px;padding:11px;background:#e8e1ef;color:#514a68;font:700 14px system-ui;cursor:pointer}
.furniture-session-actions [data-session=save]{background:#625780;color:#fff}
.furniture-panel button:disabled{opacity:.4;cursor:default}
.furniture-panel small{color:#74697e}

@media(max-width:700px){.furniture-panel{max-height:45dvh}}

/* premium render-force v3: visual sizing only; layout coordinates/contracts unchanged */
.furniture-item.furniture-sofa .furniture-image{width:300px;max-width:34vw;height:auto}
.furniture-item.furniture-chair .furniture-image{width:170px;max-width:20vw;height:auto}
.furniture-item.furniture-table .furniture-image{width:190px;max-width:22vw;height:auto}
.furniture-item.furniture-plant .furniture-image{width:130px;max-width:15vw;height:auto}
.furniture-item.furniture-lamp .furniture-image{width:115px;max-width:13vw;height:auto}
.furniture-item.furniture-rug .furniture-image{width:330px;max-width:38vw;height:auto}
@media(max-width:768px){
 .furniture-item.furniture-sofa .furniture-image{width:230px;max-width:46vw}
 .furniture-item.furniture-chair .furniture-image{width:135px;max-width:28vw}
 .furniture-item.furniture-table .furniture-image{width:150px;max-width:31vw}
 .furniture-item.furniture-plant .furniture-image{width:105px;max-width:22vw}
 .furniture-item.furniture-lamp .furniture-image{width:90px;max-width:19vw}
 .furniture-item.furniture-rug .furniture-image{width:270px;max-width:55vw}
}

/* =========================================================
   MEECHU PREMIUM VISUAL POLISH V4
   Render-layer enforcement only.
   No DB/layout/SIT/LIE contract changes.
   ========================================================= */

.furniture-item{
  transform-origin:50% 100%;
  filter:drop-shadow(0 10px 12px rgba(46,30,18,.18));
}

.furniture-item .furniture-image{
  display:block;
  object-fit:contain;
  user-select:none;
  -webkit-user-drag:none;
  image-rendering:auto;
}

/* Force premium asset at the final visual layer.
   This wins even if an old saved <img src> survives in DOM. */
.furniture-item.furniture-sofa .furniture-image{
  content:url('/assets/furniture/premium-v2/sofa-premium-v2.png');
  width:320px;
  max-width:33vw;
}
.furniture-item.furniture-chair .furniture-image{
  content:url('/assets/furniture/premium-v2/chair-premium-v2.png');
  width:178px;
  max-width:18vw;
}
.furniture-item.furniture-table .furniture-image{
  content:url('/assets/furniture/premium-v2/table-premium-v2.png');
  width:205px;
  max-width:21vw;
}
.furniture-item.furniture-plant .furniture-image{
  content:url('/assets/furniture/premium-v2/plant-premium-v2.png');
  width:138px;
  max-width:14vw;
}
.furniture-item.furniture-lamp .furniture-image{
  content:url('/assets/furniture/premium-v2/stand-premium-v2.png');
  width:120px;
  max-width:12vw;
}
.furniture-item.furniture-rug .furniture-image{
  content:url('/assets/furniture/premium-v2/rug-premium-v2.png');
  width:350px;
  max-width:36vw;
  filter:drop-shadow(0 7px 8px rgba(55,37,24,.12));
}

/* Bed remains on the proven LIE visual until bed-contact QA closes. */
.furniture-item.furniture-bed .furniture-image{
  filter:drop-shadow(0 10px 10px rgba(55,37,24,.14));
}

/* Better selection treatment without obscuring art. */
body.is-furniture-editing .furniture-item.selected{
  outline:2px solid rgba(142,205,255,.92);
  outline-offset:5px;
  border-radius:18px;
}
body.is-furniture-editing .furniture-item:hover{
  filter:drop-shadow(0 12px 16px rgba(38,75,105,.22));
}

/* Ground contact: subtle visual-only grounding. */
.furniture-item::after{
  content:'';
  position:absolute;
  left:50%;
  bottom:-2px;
  width:62%;
  height:10px;
  transform:translateX(-50%);
  border-radius:50%;
  background:rgba(70,45,24,.10);
  filter:blur(5px);
  pointer-events:none;
  z-index:-1;
}
.furniture-item.furniture-rug::after{display:none}
.furniture-item.furniture-lamp::after,
.furniture-item.furniture-plant::after{width:48%}

/* Keep catalog buttons visually readable while preserving existing behavior. */
.furniture-catalog button{
  min-height:42px;
  border-radius:14px;
  font-weight:700;
}

/* Mobile / fold-safe tuning */
@media(max-width:768px){
  .furniture-item.furniture-sofa .furniture-image{width:245px;max-width:46vw}
  .furniture-item.furniture-chair .furniture-image{width:142px;max-width:27vw}
  .furniture-item.furniture-table .furniture-image{width:160px;max-width:30vw}
  .furniture-item.furniture-plant .furniture-image{width:108px;max-width:21vw}
  .furniture-item.furniture-lamp .furniture-image{width:94px;max-width:18vw}
  .furniture-item.furniture-rug .furniture-image{width:280px;max-width:54vw}
}

/* MEECHU V6 premium bed + directional rotation */
.furniture-item.furniture-bed .furniture-image{
  content:url('/assets/furniture/premium-v2/bed-premium-v2.png');
  width:330px;
  max-width:34vw;
  height:auto;
  filter:drop-shadow(0 10px 12px rgba(55,37,24,.16));
}
@media(max-width:768px){
  .furniture-item.furniture-bed .furniture-image{
    width:255px;
    max-width:48vw;
  }
}


/* MEECHU 4DIR FURNITURE V8 */
.furniture-item.furniture-sofa .furniture-image,
.furniture-item.furniture-chair .furniture-image,
.furniture-item.furniture-table .furniture-image,
.furniture-item.furniture-bed .furniture-image{content:normal !important;}
.furniture-item.furniture-sofa .furniture-image{width:320px;max-width:33vw;height:auto}
.furniture-item.furniture-chair .furniture-image{width:178px;max-width:18vw;height:auto}
.furniture-item.furniture-table .furniture-image{width:205px;max-width:21vw;height:auto}
.furniture-item.furniture-bed .furniture-image{width:330px;max-width:34vw;height:auto;filter:drop-shadow(0 10px 12px rgba(55,37,24,.16))}
@media(max-width:768px){
 .furniture-item.furniture-sofa .furniture-image{width:245px;max-width:46vw}
 .furniture-item.furniture-chair .furniture-image{width:142px;max-width:27vw}
 .furniture-item.furniture-table .furniture-image{width:160px;max-width:30vw}
 .furniture-item.furniture-bed .furniture-image{width:255px;max-width:48vw}
}

/* MEECHU TOP NAV + CHAT UI V18 INLINE */
.space-top-nav-v18{position:fixed;left:12px;top:12px;z-index:90;display:flex;align-items:center;gap:10px;flex-wrap:wrap;max-width:calc(100vw - 24px)}
.space-top-nav-v18 .character-selector-button,.space-top-nav-v18 .furniture-toggle,.space-top-nav-v18 .space-top-nav-btn-v18{position:static!important;inset:auto!important;margin:0!important;min-width:112px!important;height:52px!important;padding:0 18px!important;border-radius:26px!important;border:1px solid rgba(255,255,255,.16)!important;background:rgba(74,68,104,.92)!important;color:#fff!important;box-shadow:0 8px 20px rgba(22,16,38,.16)!important;display:flex!important;align-items:center!important;justify-content:center!important;gap:8px!important;font-size:17px!important;font-weight:800!important;line-height:1!important;white-space:nowrap!important}
.space-top-nav-v18 .space-top-nav-btn-v18.is-active{background:rgba(99,86,146,.96)!important}
.space-top-nav-v18 .character-selector-button img{width:30px!important;height:30px!important;object-fit:cover!important;border-radius:50%!important}
#chatHistoryToggle.space-chat-legacy-toggle-hidden-v18,.space-chat-duplicate-control-hidden-v18{display:none!important}
#chatHistoryShell{left:12px!important;top:76px!important;width:min(360px,calc(100vw - 24px))!important}
#chatHistoryPanel{padding:16px!important;border-radius:22px!important}
#chatHistoryPanel .chat-history-head{min-height:auto!important;margin:0 0 10px!important}
#chatHistoryPanel .chat-history-head strong{font-size:18px!important;line-height:1.2!important;letter-spacing:0!important;white-space:nowrap!important}
#chatHistoryPanel .chat-history-head strong small,#chatHistoryPanel .chat-history-head small{margin-top:3px!important;font-size:12px!important;line-height:1.3!important;font-weight:500!important}
#chatHistoryPanel .space-chat-filter{margin:6px 0 12px!important;gap:8px!important}
#chatHistoryPanel .space-chat-filter span{min-width:64px!important;padding:7px 12px!important;font-size:13px!important;line-height:1!important;text-align:center!important}
@media(max-width:760px){.space-top-nav-v18{left:8px;top:8px;gap:7px;max-width:calc(100vw - 16px)}.space-top-nav-v18 .character-selector-button,.space-top-nav-v18 .furniture-toggle,.space-top-nav-v18 .space-top-nav-btn-v18{min-width:88px!important;height:44px!important;padding:0 12px!important;border-radius:22px!important;font-size:14px!important}.space-top-nav-v18 .character-selector-button img{width:26px!important;height:26px!important}#chatHistoryShell{left:8px!important;top:60px!important;width:min(340px,calc(100vw - 16px))!important}}


/* MEECHU ANDROID MOBILE NAV FIX V19 */
@media(max-width:599px){
  .space-top-nav-v18,.space-top-nav-v17{
    left:8px!important;
    right:8px!important;
    top:8px!important;
    width:calc(100vw - 16px)!important;
    max-width:none!important;
    display:grid!important;
    grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:6px!important;
  }
  .space-top-nav-v18 .character-selector-button,
  .space-top-nav-v18 .furniture-toggle,
  .space-top-nav-v18 .space-top-nav-btn-v18,
  .space-top-nav-v17 .character-selector-button,
  .space-top-nav-v17 .furniture-toggle,
  .space-top-nav-v17 .space-top-nav-btn-v17{
    width:100%!important;
    min-width:0!important;
    height:46px!important;
    padding:0 6px!important;
    border-radius:23px!important;
    font-size:13px!important;
    gap:4px!important;
  }
  .space-top-nav-v18 .character-selector-button img,
  .space-top-nav-v17 .character-selector-button img{
    width:23px!important;
    height:23px!important;
    flex:0 0 23px!important;
  }
  #roomStatus,.room-status{
    top:61px!important;
    right:8px!important;
    left:auto!important;
    min-width:auto!important;
    padding:7px 10px!important;
    font-size:11px!important;
    border-radius:999px!important;
    z-index:2200!important;
  }
  #chatHistoryShell{
    top:61px!important;
    left:8px!important;
    width:min(340px,calc(100vw - 16px))!important;
  }
}

/* MAPLELIKE CANDIDATE V1: shared room geometry, existing assets retained. */
#room[data-world-contract] .furniture-layer{z-index:auto}
#room[data-world-contract] .furniture-item.furniture-sofa .furniture-image{width:calc(320 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] .furniture-item.furniture-chair .furniture-image{width:calc(178 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] .furniture-item.furniture-table .furniture-image{width:calc(205 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] .furniture-item.furniture-bed .furniture-image{width:calc(330 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] .furniture-item.furniture-plant .furniture-image{width:calc(138 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] .furniture-item.furniture-lamp .furniture-image{width:calc(120 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] .furniture-item.furniture-rug .furniture-image{width:calc(350 * var(--world-unit));max-width:none;height:auto}
#room[data-world-contract] #avatar[src*="assets/sprites/master01/"]{height:calc(150 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translate(-50%,-100%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master01/"]{height:calc(150 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translateY(0%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] #avatar[src*="assets/sprites/master02/"]{height:calc(150 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translate(-50%,-100%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master02/"]{height:calc(150 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translateY(0%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] #avatar[src*="assets/sprites/master03/"]{height:calc(171.435 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translate(-50%,-92.1875%);transform-origin:50% 100%;clip-path:inset(0 0 7.8125% 0)}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master03/"]{height:calc(171.435 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translateY(7.8125%);transform-origin:50% 100%;clip-path:inset(0 0 7.8125% 0)}
#room[data-world-contract] #avatar[src*="assets/sprites/master04/"]{height:calc(162.285 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translate(-50%,-100%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master04/"]{height:calc(162.285 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translateY(0%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] #avatar[src*="assets/sprites/master05/"]{height:calc(150 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translate(-50%,-100%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master05/"]{height:calc(150 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translateY(0%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] #avatar[src*="assets/sprites/youngjoong/"]{height:calc(156.75 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translate(-50%,-92.1875%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] .remote-player img[src*="assets/sprites/youngjoong/"]{height:calc(156.75 * var(--world-unit));width:auto;scale:1;translate:0 0;transform:translateY(7.8125%);transform-origin:50% 100%;clip-path:none}
#room[data-world-contract] #avatar[src*="assets/sprites/master03/left/walk_"]{height:calc(201 * var(--world-unit));transform:translate(-50%,-81.25%);clip-path:inset(0 0 12.5% 0)}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master03/left/walk_"]{height:calc(201 * var(--world-unit));transform:translateY(18.75%);clip-path:inset(0 0 12.5% 0)}
#room[data-world-contract] #avatar[src*="assets/sprites/master03/right/walk_"]{height:calc(215 * var(--world-unit));transform:translate(-50%,-77.5%);clip-path:inset(0 0 12.5% 0)}
#room[data-world-contract] .remote-player img[src*="assets/sprites/master03/right/walk_"]{height:calc(215 * var(--world-unit));transform:translateY(22.5%);clip-path:inset(0 0 12.5% 0)}
#room[data-world-contract] .space-head-nickname{z-index:1800}
#room[data-world-contract] .bubble{z-index:1700}
#room[data-world-contract] .room-status{position:fixed;z-index:2200}
html body .space-top-nav-v18,html body .space-top-nav-v17{z-index:2200}
html body .character-selector,html body .furniture-toggle,html body .furniture-panel{z-index:2200}
html body #chatHistoryShell,html body .chat-composer,html body #virtualJoystick,html body .space-seat-controls{z-index:2200}
#room[data-world-contract] .meechu-contact-shadow{width:calc(37 * var(--world-unit));height:calc(10 * var(--world-unit))}
#room[data-world-contract] .meechu-contact-shadow[data-state="walk"]{width:calc(39 * var(--world-unit));height:calc(9 * var(--world-unit))}

#room[data-world-contract] .furniture-item.actor-occluder,#room[data-world-contract] .remote-interaction-furniture.actor-occluder{opacity:1}

/* Action controls belong to the HUD, independent of world/camera scaling. */
html body .space-seat-controls{transform:none;max-width:min(190px,45vw);align-items:flex-end}
html body .space-seat-controls button{min-width:64px;min-height:44px;padding:10px 18px;font-size:14px}
html body .space-seat-controls span:empty{display:none}

html body #chatHistoryShell.chat-panel-v2{position:fixed!important;z-index:2200!important;top:82px!important;left:12px!important}

/* FURNITURE_DEPTH_AUTHORITY_V40: JS depth values are the single source of truth. */
#room[data-world-contract] .furniture-layer .furniture-item{z-index:var(--furniture-depth,8)!important}
#room[data-world-contract] #avatar{z-index:var(--avatar-depth,40)!important}

/* BUBBLE_NICKNAME_STACK_V41: speech must stay above the account nickname badge. */
#room[data-world-contract] .bubble,#room[data-world-contract] .chat-bubble,#room[data-world-contract] .remote-bubble{z-index:1900!important}
#room[data-world-contract] .space-head-nickname{z-index:1800!important}

/* SPACE_PANEL_TOUCH_TARGET_V42: keep edit actions reliably tappable. */
html body .furniture-panel button{min-height:44px}
