.npc-host{--npc-accent:#b6c59b;display:grid;grid-template-columns:clamp(104px,33vw,150px) minmax(0,1fr);align-items:center;position:relative;isolation:isolate;min-height:112px;flex-shrink:0;gap:4px;overflow:visible}
.npc-host:before{content:"";position:absolute;z-index:-1;inset:30% 0 0 5%;background:linear-gradient(110deg,#122a2cd9,#17232977);border-radius:36px 9px 20px 6px;box-shadow:0 9px 16px #08171936}
.npc-host .npc-portrait{width:100%;aspect-ratio:1;min-height:0!important;padding:0!important;position:relative;display:block;background:transparent!important;border:0!important;border-radius:0!important;box-shadow:none!important;filter:none!important;touch-action:manipulation;overflow:visible;transform:none!important;cursor:pointer}
.npc-sprite{display:block;position:absolute;inset:0;background-repeat:no-repeat;background-size:300% 200%;background-position:0 0;transform-origin:50% 85%;filter:drop-shadow(3px 7px 3px #07131d66);pointer-events:none;will-change:auto}
.npc-host[data-npc-role=secretary] .npc-sprite{background-image:url('../../art/ui/npcs/secretary.webp?v=bust3')}
.npc-host[data-npc-role=alchemist] .npc-sprite{background-image:url('../../art/ui/npcs/alchemist.webp?v=bust3')}
.npc-host[data-npc-role=blacksmith] .npc-sprite{background-image:url('../../art/ui/npcs/blacksmith.webp?v=bust3')}
.npc-host[data-npc-role=mage] .npc-sprite{background-image:url('../../art/ui/npcs/mage.webp?v=bust3')}
.npc-host[data-npc-emotion=happy] .npc-sprite{background-position:50% 0}
.npc-host[data-npc-emotion=focus] .npc-sprite{background-position:100% 0}
.npc-host[data-npc-emotion=surprise] .npc-sprite{background-position:0 100%}
.npc-host[data-npc-emotion=sad] .npc-sprite{background-position:50% 100%}
.npc-host[data-npc-emotion=proud] .npc-sprite{background-position:100% 100%}
.npc-copy{min-width:0;padding:16px 12px 8px 0;color:#f4ecdb}
.npc-copy>small{display:flex;flex-wrap:wrap;align-items:center;gap:6px;color:var(--npc-accent);font-size:10px;letter-spacing:.02em}
.npc-copy>small>b{font-size:13px;color:#fff7e5}
.npc-copy .npc-line{font-size:12px;line-height:1.5;margin:7px 0 0;word-break:keep-all;overflow-wrap:anywhere;min-height:3em;max-width:26em}
.npc-compact{grid-template-columns:88px minmax(0,1fr);min-height:84px}
.npc-compact .npc-copy{padding-top:12px}
.npc-compact .npc-line{font-size:11px;margin-top:4px}
.work-theatre{--work-color:#b8a4db;display:flex;flex:1;min-height:260px;flex-direction:column;align-items:center;justify-content:center;gap:10px;position:relative;isolation:isolate;padding:12px 4px;overflow:hidden}
.work-theatre>h3{margin:0;color:#e8dbbd;font-size:19px;letter-spacing:.08em}
.work-theatre>.npc-host{width:100%;max-width:360px;grid-template-columns:clamp(140px,40vw,190px) minmax(0,1fr);z-index:2}
.work-theatre .npc-copy .npc-line{font-size:13px;min-height:4.5em}
.work-seal{position:relative;width:112px;height:84px;margin-top:-24px;flex-shrink:0;filter:drop-shadow(0 7px 9px #050b1855);color:var(--work-color)}
.work-seal>i{position:absolute;inset:18px 4px;border:2px solid currentColor;border-radius:50%;transform:rotateX(55deg);opacity:.45;box-shadow:0 0 16px currentColor,inset 0 0 8px currentColor}
.work-seal>i+i{inset:7px 16px;transform:rotate(42deg) skew(-8deg,-8deg);border-radius:4px;opacity:.7}
.work-seal>b{position:absolute;left:0;right:0;top:5px;font-size:44px;line-height:1;text-align:center;text-shadow:0 0 18px currentColor}
.work-seal>span:not(.work-target){position:absolute;inset:-40px;background:radial-gradient(ellipse,#fffce3c9,transparent 65%);opacity:0;pointer-events:none}
.work-theatre[data-work-stage=windup] .work-seal{animation:npc-work-gather .55s ease-in both}
.work-theatre[data-work-stage=impact] .work-seal>span:not(.work-target){animation:npc-work-flash .6s ease-out both}
.work-status{font-size:13px;color:#e9dfc9;margin:0;min-height:20px}
.work-theatre .work-skip{min-height:36px;padding:6px 20px;border-radius:8px;background:#293b45;color:#e8e8dd;border:1px solid #6c7c7b}
[data-work-presentation=playing] [data-work-result]{display:none!important}
@keyframes npc-work-gather{0%{transform:scale(1)}70%{transform:scale(.72) translateY(5px);filter:drop-shadow(0 0 16px var(--work-color))}100%{transform:scale(.85)}}
@keyframes npc-work-flash{0%{opacity:.95;transform:scale(.5)}35%{opacity:.8;transform:scale(1.25)}100%{opacity:0;transform:scale(1.6)}}
@media(max-height:680px){.npc-host:not(.work-theatre .npc-host){grid-template-columns:90px minmax(0,1fr);min-height:86px}.npc-copy .npc-line{font-size:11px}.work-theatre{min-height:220px;gap:5px}.work-theatre>.npc-host{grid-template-columns:136px minmax(0,1fr)}}
@media(prefers-reduced-motion:reduce){.npc-host *,.work-theatre *{animation:none!important;transition:none!important}}

.work-seal .work-target{position:absolute!important;left:50%;top:5px;transform:translateX(-50%)!important;width:54px!important;height:70px!important;min-height:0!important;pointer-events:none;--slot-edge:50px;--slot-row:70px;z-index:1}.work-seal .work-target .item-copy,.work-seal .work-target strong,.work-seal .work-target small{display:none}.work-seal:has(.work-target)>b{opacity:.3}.work-seal>.ui-icon.work-target{height:54px!important;background:#e8e2cb;color:#3d695b;border-radius:8px;padding:8px;box-shadow:0 5px 12px #0006}

/* Facility stage. Original waist-up art, table plane, then dialogue on its fascia.
   Only this active role's atlas loads; the smaller dialogue crops stay unchanged. */
.npc-host.npc-counter{--counter-top:#8c8261;--counter-edge:#c5b58b;--counter-face:#293c39;--room:url('../../art/ui/guild-common-room.webp');display:block;position:relative;height:clamp(202px,30dvh,266px);min-height:0;overflow:hidden;border-radius:7px 25px 6px 6px;background-image:linear-gradient(90deg,#10272c66,#14282b33),var(--room);background-size:cover;background-position:50% 40%;box-shadow:inset 0 1px #fff3,0 5px #0b19286e,0 10px 18px #07132366;isolation:isolate}
.npc-counter[data-npc-role=alchemist]{--room:url('../../art/ui/crafting-workshop.webp');--counter-top:#739582;--counter-edge:#adc6a4;--counter-face:#183d3b}
.npc-counter[data-npc-role=mage]{--room:url('../../art/ui/cubing-workshop.webp');--counter-top:#80728f;--counter-edge:#c9afd2;--counter-face:#33263f}
.npc-counter[data-npc-role=blacksmith]{--room:url('../../art/ui/cubing-workshop.webp');--counter-top:#97775c;--counter-edge:#e1b57e;--counter-face:#46312d;background-position:30% 60%}
.npc-host.npc-counter:before{inset:0;z-index:-1;border-radius:0;background:radial-gradient(ellipse at 50% 35%,#dfe4ae26,transparent 58%),linear-gradient(0deg,#091e28a6,transparent 70%);box-shadow:inset 0 15px 40px #0d172c44}
.npc-host.npc-counter .npc-portrait{position:absolute;left:50%;bottom:-20px;width:calc(clamp(202px,30dvh,266px) + 12px);height:auto;aspect-ratio:1;translate:-50% 0;z-index:1}
.npc-counter .npc-sprite{filter:drop-shadow(5px 8px 2px #09152280);transform-origin:50% 90%}
.npc-counter[data-npc-role=secretary] .npc-sprite{background-image:url('../../art/ui/npcs/secretary-counter.webp')}
.npc-counter[data-npc-role=alchemist] .npc-sprite{background-image:url('../../art/ui/npcs/alchemist-counter.webp')}
.npc-counter[data-npc-role=blacksmith] .npc-sprite{background-image:url('../../art/ui/npcs/blacksmith-counter.webp')}
.npc-counter[data-npc-role=mage] .npc-sprite{background-image:url('../../art/ui/npcs/mage-counter.webp')}
.npc-countertop{position:absolute;z-index:2;left:-4%;right:-4%;bottom:0;height:79px;background:linear-gradient(180deg,var(--counter-edge) 0 3px,var(--counter-face) 3px 100%);box-shadow:0 -7px 16px #11182777;pointer-events:none}
.npc-countertop:before{content:'';position:absolute;left:2%;right:2%;top:-17px;height:18px;background:linear-gradient(170deg,var(--counter-edge),var(--counter-top) 50%);clip-path:polygon(3% 0,96% 0,100% 100%,0 100%)}
.npc-countertop:after{content:'';position:absolute;inset:10px 7% 8px;border:1px solid #e2d7b52b;border-radius:3px 10px 3px 3px;box-shadow:inset 0 2px 4px #06152244}
.npc-countertop>i{position:absolute;top:-18px;left:9%;width:45px;height:9px;background:#4a4c3e;border:2px solid #b3aa7b;box-shadow:0 3px #182d2e;transform:skewX(-24deg);border-radius:2px}
.npc-countertop>i+i{left:auto;right:10%;width:24px;height:13px;top:-24px;background:var(--npc-accent);border-color:#d3d5b6;transform:skewX(10deg);box-shadow:3px 4px #152c3266}
.npc-counter .npc-copy{position:absolute;z-index:3;left:0;right:0;bottom:0;height:76px;padding:10px 16px;pointer-events:none}
.npc-counter .npc-copy>small{font-size:10px;gap:8px}.npc-counter .npc-copy>small>b{font-size:15px}
.npc-counter .npc-copy .npc-line{font-size:12px;line-height:1.4;min-height:0;max-width:none;margin:4px 0 0}
.workshop-vista:has(>.npc-counter){height:auto;min-height:0;background:none;box-shadow:none;overflow:visible;border:0}
#modal:is([data-kind=npc-office],[data-kind=recruit]):has(.npc-counter){width:min(94vw,460px);min-width:0;padding:16px;overflow:hidden}
#modal:is([data-kind=npc-office],[data-kind=recruit]):has(.npc-counter) #modal-content{display:flex;flex-direction:column;gap:11px;max-height:calc(100dvh - 80px);overflow:hidden}
#modal:has(.npc-counter) #modal-content>h2{margin:0;font-size:19px;flex:none}
#modal:has(.npc-counter) #modal-content>p{margin:0;font-size:12px;line-height:1.5;flex:none}
#modal:has(.npc-counter) .npc-counter{width:100%;flex:none}
#modal[data-kind=recruit] details{flex:0 1 auto;min-height:30px;overflow-y:auto;overscroll-behavior:contain;margin:0;font-size:11px}
#modal:has(.npc-counter) .button-row{margin-top:3px;flex:none}
@media(max-height:700px){
 .npc-host.npc-counter{height:184px;min-height:0;grid-template-columns:none}
 .npc-host.npc-counter .npc-portrait{width:200px;bottom:-20px}
 .npc-countertop{height:66px}.npc-counter .npc-copy{height:64px;padding:7px 13px}
 .npc-counter .npc-copy>small>b{font-size:13px}.npc-counter .npc-copy .npc-line{font-size:11px;margin-top:3px}
 #modal:is([data-kind=npc-office],[data-kind=recruit]):has(.npc-counter) #modal-content{gap:8px}
 main[data-page=forge]:has(.forge-work) .npc-counter{height:160px}
 main[data-page=forge]:has(.forge-work) .npc-counter .npc-portrait{width:176px}
}

/* Lower the desk face to expose the chest, arms and tools above it. */
.npc-countertop{height:53px}.npc-countertop:before{top:-12px;height:13px}
.npc-countertop>i{top:-12px}.npc-countertop>i+i{top:-18px}
.npc-counter .npc-copy{height:51px;padding:5px 13px}
.npc-counter .npc-copy>small{font-size:9px;line-height:14px}.npc-counter .npc-copy>small>b{font-size:12px}
.npc-counter .npc-copy .npc-line{font-size:11px;line-height:14px;margin:2px 0 0;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.npc-work-canvas{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}
.npc-sprite[data-mesh=active]{background-image:none!important}
.work-theatre{width:100%;gap:12px;min-height:0;padding:8px 0;overflow:hidden}
.work-theatre>.npc-host.npc-counter{width:100%;max-width:none;height:318px;min-height:0;flex:none}
.work-theatre>.npc-counter .npc-portrait{width:330px;bottom:-20px}
.work-theatre .npc-copy .npc-line{min-height:0;font-size:11px}
.work-theatre .work-seal{position:absolute;left:42%;bottom:64px;width:88px;height:65px;margin:0;z-index:4;pointer-events:none}
.work-theatre[data-operation=enhance] .work-seal{left:25%}
.work-theatre[data-operation=craft] .work-seal{left:38%}
.work-theatre .work-seal .work-target{width:42px!important;height:50px!important;top:12px}
.work-theatre .work-seal>i{opacity:.3}.work-theatre .work-seal>b{font-size:30px}
.work-theatre .work-status{font-size:12px}.work-theatre .work-skip{min-height:38px}
#modal:is([data-kind=cube-result],[data-kind=craft-result]):has(.work-theatre){height:fit-content;max-height:90dvh}
#modal[data-kind=cube-result]:has(.work-theatre) #modal-content{height:auto;flex:0 1 auto}
@media(max-height:700px){
 .npc-countertop{height:45px}.npc-counter .npc-copy{height:43px;padding:3px 11px}
 .npc-counter .npc-copy>small>b{font-size:11px}.npc-counter .npc-copy .npc-line{font-size:10px;line-height:12px;margin:1px 0 0}
 .work-theatre>.npc-host.npc-counter{height:264px}.work-theatre>.npc-counter .npc-portrait{width:276px}
 .work-theatre .work-seal{bottom:56px}.work-theatre{gap:8px}
}
