/* The default 3D desk keeps the illustrated fallback and dialog layouts intact. */
body[data-scene="3d"] .desk-bottom-tools :is(.feedback-entry,.desk-settings-button){color:var(--ink-soft);font-size:12px;text-shadow:none}
body[data-scene="3d"] .desk-bottom-tools .feedback-entry:hover{color:var(--vermilion)}
body.ritual-desk[data-scene="3d"]{
  --bg:#e9dec8;--xuan:#e9dec8;--paper:#fbf3e3;--paper-shade:#eee0c6;
  --ink:#342e27;--ink-soft:#564a3e;--muted:#6f6252;--line:#d4c3a5;
  --bronze:#a18b5d;--bronze-soft:#c6b18a;--green:#564a3e;--green-soft:#eee1c9;--accent:#963f32;
  --world-brocade:#963f32;--world-gold:#a18b5d;--world-gold-deep:#806b43;
  --vermilion:#963f32;--vermilion-deep:#7f332a;
  background:var(--bg);color:var(--ink);overflow-x:hidden;
}
body[data-scene="3d"] #desk3d-canvas{position:fixed;inset:0;z-index:0;width:100%;height:100svh;overflow:hidden;background:var(--bg);pointer-events:auto}
body[data-scene="3d"] #desk3d-canvas canvas{display:block;width:100%;height:100%;cursor:default;touch-action:pan-y;outline:none}
body[data-scene="3d"] #desk3d-canvas canvas:focus-visible{outline:2px solid var(--vermilion);outline-offset:-5px}
body[data-scene="3d"] .desk-world{position:relative;z-index:1;display:block;width:100%;height:100svh;min-height:0;padding:0;overflow:visible;pointer-events:none;background:none}
body[data-scene="3d"] .desk-world::before,
body[data-scene="3d"] .desk-backdrop,
body[data-scene="3d"] .world-picker,
body[data-scene="3d"] .desk-quest,
body[data-scene="3d"] .desk-invitation,
body[data-scene="3d"] .desk-casting .ritual-stage{display:none!important}
body[data-scene="3d"] .desk-scene{position:absolute;inset:0;display:block;width:100%;height:100%;min-height:0;margin:0;padding:0;pointer-events:none;background:none}
body[data-scene="3d"] .desk-table{position:absolute;inset:0;display:block;width:100%;max-width:none;height:100%;margin:0;padding:0;pointer-events:none;background:none}
body[data-scene="3d"] .desk-casting{position:absolute;inset:0;display:block;width:100%;height:100%;min-height:0;padding:0;background:none;pointer-events:none}
body[data-scene="3d"] #ritual-area{position:absolute;inset:0;width:100%;height:100%;max-height:none;pointer-events:none}
body[data-scene="3d"] #ritual-area:not([hidden]){display:block}

/* Quiet edge controls leave the fixed front view clear. */
body[data-scene="3d"] .desk-header{position:fixed;top:max(17px,env(safe-area-inset-top));left:clamp(24px,4vw,58px);right:clamp(24px,4vw,58px);height:53px;z-index:10;pointer-events:none}
body[data-scene="3d"] .desk-header>a,
body[data-scene="3d"] .desk-header button{pointer-events:auto}
body[data-scene="3d"] .desk-header .brand{color:var(--ink);text-shadow:none;font-size:24px}
body[data-scene="3d"] .desk-header .brand small{color:var(--muted);font-size:9px;letter-spacing:1.2px}
body[data-scene="3d"] .desk-header .brand-seal{font-family:var(--calligraphy);color:var(--paper);background:var(--vermilion);box-shadow:inset 0 0 0 1px #f1e6c899,0 3px 8px #47352312}
body[data-scene="3d"] .desk-header .desk-tool{color:var(--ink-soft);text-shadow:none;font:12px/1.5 var(--sans)}
body[data-scene="3d"] .desk-header .desk-tool small{color:var(--vermilion)}
body[data-scene="3d"] .desk-header .tool-book{border-color:var(--world-gold);background:linear-gradient(90deg,#b7a06a 0 4px,#963f32 5px);box-shadow:1px 2px 3px #4735231c}
body[data-scene="3d"] .desk-header .tool-fold{border-color:var(--world-gold);background:linear-gradient(90deg,#c7b08b 0 31%,#e3cda5 32% 34%,#a45e48 35% 65%,#e3cda5 66% 68%,#c7b08b 69%);box-shadow:1px 2px 3px #4735231c}
body[data-scene="3d"] :is(.desk-header .language-toggle,.sheet-toolbar .language-toggle,.detail-language){color:var(--ink-soft);background:#fbf3e3e0;border-color:var(--bronze-soft);box-shadow:0 2px 6px #47352308}
body[data-scene="3d"] #desk3d-intro{position:fixed;z-index:4;top:100px;left:50%;width:min(440px,calc(100vw - 650px));min-width:230px;transform:translateX(-50%);text-align:center;color:var(--ink-soft);pointer-events:none}
body[data-scene="3d"] #desk3d-intro [data-desk3d-copy="eyebrow"]{font:11px/1.5 var(--sans);letter-spacing:.18em;color:var(--muted);margin:0 0 6px}
body[data-scene="3d"] #desk3d-intro h2{font:29px/1.25 var(--serif);letter-spacing:-.025em;color:var(--ink);margin:0;text-wrap:balance}
body[data-scene="3d"] #desk3d-intro [data-desk3d-copy="hint"]{font:12px/1.7 var(--sans);color:var(--muted);margin:9px 0 0}
body[data-scene="3d"] #desk3d-intro .desk3d-loading{font:12px/1.7 var(--sans);color:var(--muted);margin:7px 0 0;min-height:18px}
body[data-scene="3d"] .desk3d-coin-key{display:flex;justify-content:center;align-items:center;gap:22px;width:max-content;max-width:100%;margin:12px auto 0;padding:4px 14px;border:1px solid #c6b18a55;border-radius:22px;background:#fbf3e3ed;font:12px/1.5 var(--sans);color:var(--ink-soft)}
body[data-scene="3d"] .desk3d-coin-key[hidden]{display:none}
body[data-scene="3d"] .desk3d-coin-key>span{display:inline-flex;align-items:center;gap:7px}
body[data-scene="3d"] .desk3d-coin-face{display:inline-flex;position:relative;flex:0 0 auto;align-items:center;justify-content:center;gap:2px;width:31px;height:31px;border:2px solid #ad7e34;border-radius:50%;color:#2d210e;background:#e5bd63;box-shadow:inset 0 0 0 2px #f7df9e;vertical-align:middle}
body[data-scene="3d"] .desk3d-coin-face.jade{color:#f4ffe4;border-color:#295d50;background:#397b69;box-shadow:inset 0 0 0 2px #86b29a}
body[data-scene="3d"] .desk3d-coin-face i{position:absolute;top:6px;left:6px;right:6px;height:3px;background:currentColor}
body[data-scene="3d"] .desk3d-coin-face.jade i{background:linear-gradient(to right,currentColor 0 37%,transparent 37% 63%,currentColor 63%)}
body[data-scene="3d"] .desk3d-coin-face b{padding-top:9px;font:600 12px/1.1 var(--sans)}
body[data-scene="3d"] .desk3d-coin-key .desk3d-coin-face{width:26px;height:26px}
body[data-scene="3d"] .desk3d-coin-key .desk3d-coin-face i{left:5px;right:5px;top:5px;height:2px}
body[data-scene="3d"] .desk3d-coin-key .desk3d-coin-face b{font-size:10px;padding-top:7px}
body[data-scene="3d"] .desk3d-toss-faces{display:flex;justify-content:center;align-items:center;gap:7px;color:var(--muted);font:13px/1.3 var(--sans)}
body[data-scene="3d"] .desk3d-toss-total{font-size:19px;color:var(--ink);white-space:nowrap;flex-shrink:0}
body[data-scene="3d"] .desk3d-toss-caption{display:block;margin-top:5px;font:12px/1.5 var(--sans);color:var(--ink-soft)}
body[data-scene="3d"] .desk3d-view-tools{display:flex;justify-content:center;align-items:center;gap:8px;width:max-content;max-width:100%;margin:12px auto 0}
body[data-scene="3d"] .desk3d-view-tools .desk3d-coin-key{margin:0;gap:16px;padding:4px 11px}
body[data-scene="3d"] #desk3d-reset-view{min-height:36px;padding:6px 10px;border:1px solid var(--bronze-soft);border-radius:20px;background:#fbf3e3ed;color:var(--ink-soft);font:12px/1.4 var(--sans);white-space:nowrap;cursor:pointer;pointer-events:auto}
body[data-scene="3d"] #desk3d-reset-view:disabled{opacity:.55;cursor:default}
body[data-scene="3d"] #desk3d-reset-view:focus-visible{outline:2px solid var(--vermilion);outline-offset:3px}

/* The question and growing figure are small paper objects beside the simulation. */
body[data-scene="3d"] .desk-question{position:fixed;top:137px;left:clamp(28px,4vw,58px);z-index:6;width:228px;max-width:228px;height:164px;min-height:164px;padding:22px 21px 15px;transform:rotate(-.6deg);background:var(--paper-fibers),linear-gradient(115deg,#fbf3e3,#f3e5cb);border-bottom-color:#bda87755;box-shadow:1px 5px 13px #47352312;pointer-events:auto}
body[data-scene="3d"] .desk-question::before{left:11px;top:17px;bottom:17px;background:#bdab832e}
body[data-scene="3d"] .desk-question::after{width:11px;height:11px}
body[data-scene="3d"] .slip-mark{top:9px;right:13px;font-size:13px;color:var(--vermilion)}
body[data-scene="3d"] .desk-question #question{height:86px;min-height:86px;max-height:86px;font:16px/26px var(--sans);font-style:normal;background:repeating-linear-gradient(to bottom,transparent 0 25px,#b5a58044 25px 26px)}
body[data-scene="3d"] .desk-question #question::placeholder{font-style:normal;color:var(--muted);-webkit-text-fill-color:var(--muted)}
body[data-scene="3d"] .desk-question-options{font:12px/1.5 var(--sans);margin-top:12px}
body[data-scene="3d"] .question-options-paper{left:-7px;top:calc(100% + 10px);width:300px;max-width:calc(100vw - 48px);max-height:min(380px,50svh);transform:none;box-shadow:0 8px 25px #47352321}
body[data-scene="3d"] .question-options-paper :is(.question-examples button,.chip,.topic-field legend){font-size:12px}
body[data-scene="3d"] .slip-footnote{display:none}
body[data-scene="3d"] .desk-lines{position:fixed;top:139px;right:clamp(34px,4vw,64px);z-index:5;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;width:124px;height:auto;min-height:0;pointer-events:none}
body[data-scene="3d"] .desk-scroll{display:flex;flex-direction:column;align-items:center;justify-content:center;width:118px;min-width:0;min-height:232px;height:232px;padding:22px 15px 20px;transform:none;border-color:#a18b5d66;box-shadow:2px 6px 13px #4735231a;pointer-events:auto}
body[data-scene="3d"] .scroll-rod{left:-7px;right:-7px;height:9px;box-shadow:0 2px 2px #4735231a}
body[data-scene="3d"] .scroll-heading{font:22px/1.2 "Songti SC","Noto Serif CJK SC",STSong,serif;margin:0 0 17px}
body[data-scene="3d"] .desk-scroll .line-ladder{width:76px;height:98px;min-height:98px;gap:8px;margin:0 auto}
body[data-scene="3d"] .desk-scroll .ladder-row{height:7px;min-height:7px;flex:0 0 7px;font-size:7px;gap:6px}
body[data-scene="3d"] .desk-scroll .yao-line{width:53px;height:4px;gap:9px}
body[data-scene="3d"] .scroll-footer{font:12px/1.5 var(--sans);margin:14px 0 0;text-align:center;text-wrap:balance}
body[data-scene="3d"] .desk-milestones{gap:5px;height:14px;margin-top:13px}
body[data-scene="3d"] .desk-milestones>span{width:13px;height:13px;color:var(--muted);border-color:var(--bronze);background:#fbf3e399;box-shadow:none}
body[data-scene="3d"] .desk-milestones>span>i{display:none}
body[data-scene="3d"] .desk-milestones>span.active{color:var(--vermilion);border-color:var(--vermilion);background:#fbf3e3}
body[data-scene="3d"] .desk-milestones>span.filled{color:var(--paper);border-color:var(--ink-soft);background:var(--ink-soft);box-shadow:none}
body[data-scene="3d"] .scroll-hint{display:none}

/* A small action dock is independent of the view, so feet remain visible. */
body[data-scene="3d"] #ritual-message{position:fixed;bottom:158px;left:50%;z-index:4;transform:translateX(-50%);align-self:auto;width:max-content;max-width:min(430px,calc(100vw - 40px));min-height:0;margin:0;padding:4px 12px;border-radius:16px;background:#fbf3e3e8;box-shadow:none;color:var(--ink-soft);text-shadow:none;font:12px/1.6 var(--sans);text-align:center;pointer-events:none}
body[data-scene="3d"] .desk-actions{position:fixed;left:50%;bottom:max(63px,calc(env(safe-area-inset-bottom) + 48px));z-index:7;transform:translateX(-50%);display:grid;grid-template-columns:1fr auto 1fr;grid-template-rows:54px auto;align-items:center;align-content:center;gap:10px 17px;width:min(540px,calc(100vw - 28px));margin:0;padding:0;pointer-events:none}
body[data-scene="3d"] .desk-actions #cast-button{width:154px;min-width:154px;height:54px;min-height:54px;padding:4px 19px;gap:0;border:1px solid #7f332a;border-radius:28px;outline:0;outline-offset:0;transform:none;background:var(--vermilion);box-shadow:inset 0 1px 0 #e1ab8299,0 4px 0 #753e3066,0 8px 17px #6a4c3824;pointer-events:auto;transition:transform .15s ease,background-color .15s ease,box-shadow .15s ease}
body[data-scene="3d"] .desk-actions #cast-button:hover{transform:translateY(-1px);background:var(--vermilion-deep);box-shadow:inset 0 1px 0 #e1ab8299,0 5px 0 #753e3066,0 9px 19px #6a4c3824}
body[data-scene="3d"] .desk-actions #cast-button:active{transform:translateY(2px);box-shadow:inset 0 1px 0 #e1ab8299,0 1px 0 #753e3066,0 3px 9px #6a4c3824}
body[data-scene="3d"] .desk-actions #cast-button:disabled{transform:none;opacity:.76}
body[data-scene="3d"] .desk-actions #cast-button:focus-visible{outline:2px solid var(--ink);outline-offset:6px}
body[data-scene="3d"] .desk-actions #cast-button .seal-character{font:29px/1.05 var(--calligraphy);letter-spacing:.04em;max-width:100%;color:#fff8e4}
body[data-scene="3d"] .desk-actions #cast-button .seal-character[lang="en"]{font:600 23px/1.05 Georgia,"Times New Roman",serif;letter-spacing:.09em}
body[data-scene="3d"] .desk-actions #cast-button .seal-character[lang="en"][data-cast-word="reveal"]{font-size:21px}
body[data-scene="3d"] .desk-actions #cast-button .seal-label{font:11px/1.35 var(--sans);max-width:130px;letter-spacing:.03em;margin-top:2px;color:#f7e5cb}
body[data-scene="3d"] .desk-actions #reset-button{max-width:110px;padding:4px 8px;border-radius:12px;background:#fbf3e3ed;font:12px/1.5 var(--sans);color:var(--ink-soft);text-shadow:none;text-decoration-color:var(--bronze);pointer-events:auto}
body[data-scene="3d"] .desk-actions .under-button{font:12px/1.5 var(--sans);color:var(--ink-soft);max-width:360px;padding:2px 10px;border-radius:12px;background:#fbf3e3ed;text-shadow:none}
body[data-scene="3d"] .desk-bottom{position:fixed;left:clamp(24px,4vw,58px);right:clamp(24px,4vw,58px);bottom:max(13px,env(safe-area-inset-bottom));z-index:7;display:flex;justify-content:space-between;align-items:center;gap:20px;font-size:12px;color:var(--muted);text-shadow:none;pointer-events:none}
body[data-scene="3d"] .desk-bottom button{pointer-events:auto}
body[data-scene="3d"] .desk-settings-button{font:12px/1.6 var(--sans);color:var(--ink-soft);text-shadow:none}
body[data-scene="3d"] .desk-settings-button>span{color:var(--bronze)}
body[data-scene="3d"] .feedback-entry{color:var(--ink-soft);text-shadow:none}
body[data-scene="3d"] .desk-whisper{font:12px/1.5 var(--sans);color:var(--muted);text-shadow:none}

/* Manual entry remains an accessible paper panel in front of the same table. */
body[data-scene="3d"] #manual-area{position:fixed;z-index:8;top:46%;left:50%;transform:translate(-50%,-50%);width:min(380px,calc(100vw - 42px));min-height:0;max-width:none;max-height:58svh;overflow:auto;padding:22px 27px;border:1px solid var(--bronze-soft);border-radius:5px;background:var(--paper-fibers),var(--paper);box-shadow:0 12px 35px #4735232b;pointer-events:auto}
body[data-scene="3d"] #manual-area .manual-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:11px 12px;margin:16px 0}
body[data-scene="3d"] #manual-area .manual-grid label{font:12px/1.5 var(--sans)}
body[data-scene="3d"] #manual-area .manual-grid select{min-height:38px;font-size:13px;line-height:1.4}
body[data-scene="3d"] #manual-area .manual-caption{font-size:15px;line-height:1.6}
body[data-scene="3d"] #manual-area .manual-key{font:12px/1.6 var(--sans)}
body[data-scene="3d"] .yaojian-feedback-dialog{--feedback-ink:var(--ink);--feedback-muted:var(--muted);--feedback-paper:var(--paper);--feedback-line:var(--line);box-shadow:0 24px 90px #47352340}
body[data-scene="3d"] .yaojian-feedback-dialog::backdrop{background:#342e2780}
body[data-scene="3d"] .yaojian-feedback-dialog .feedback-header{background:linear-gradient(120deg,#f0e1c6,#fbf3e3)}
body[data-scene="3d"] .yaojian-feedback-dialog :is(.feedback-eyebrow,.feedback-fallback){color:var(--ink-soft)}
@supports selector(:has(*)){
  body[data-scene="3d"]:has(#manual-area:not([hidden])) .desk-world{height:100svh;min-height:100svh;overflow:visible}
  body[data-scene="3d"]:has(#manual-area:not([hidden])) #ritual-message{display:none}
}

@media(max-width:1000px) and (min-width:761px){
  body[data-scene="3d"] .desk-question{left:25px;width:205px;max-width:205px;padding-left:19px;padding-right:18px}
  body[data-scene="3d"] .desk-lines{right:27px;width:108px}
  body[data-scene="3d"] .desk-scroll{width:104px;padding-left:12px;padding-right:12px}
  body[data-scene="3d"] #desk3d-intro{width:min(360px,calc(100vw - 420px));min-width:220px;top:106px}
  body[data-scene="3d"] #desk3d-intro h2{font-size:26px}
}
@media(max-width:760px){
  body[data-scene="3d"] .desk-world{height:100svh;min-height:0;padding:0;overflow:visible}
  body[data-scene="3d"] .desk-header{top:max(10px,env(safe-area-inset-top));left:15px;right:15px;height:45px;gap:12px}
  body[data-scene="3d"] .desk-header .brand{font-size:21px;gap:7px;letter-spacing:0}
  body[data-scene="3d"] .desk-header .brand-seal{width:29px;height:33px;font-size:22px}
  body[data-scene="3d"] .desk-header .brand small{display:none}
  body[data-scene="3d"] .desk-header .desk-tools{gap:10px}
  body[data-scene="3d"] .desk-header .desk-tool{font-size:12px;gap:5px;min-height:44px}
  body[data-scene="3d"] .desk-header .desk-tool small{font-size:8px}
  body[data-scene="3d"] .desk-header .tool-book,
  body[data-scene="3d"] .desk-header .tool-fold{display:none}
  body[data-scene="3d"] .desk-header .language-toggle{padding:5px 7px;min-width:44px;min-height:38px;font-size:12px}
  body[data-scene="3d"] #desk3d-intro{top:73px;width:calc(100vw - 32px);max-width:440px;min-width:0}
  body[data-scene="3d"] #desk3d-intro [data-desk3d-copy="eyebrow"]{display:none}
  body[data-scene="3d"] #desk3d-intro h2{font-size:24px;line-height:1.25;letter-spacing:-.01em}
  body[data-scene="3d"] #desk3d-intro [data-desk3d-copy="hint"]{display:none}
  body[data-scene="3d"] #desk3d-intro .desk3d-loading{position:absolute;top:calc(100% + 4px);left:0;right:0;margin:0;font-size:12px}
  body[data-scene="3d"] .desk3d-coin-key{margin-top:8px;gap:20px;font-size:12px}
  body[data-scene="3d"] .desk-question{top:164px;left:16px;width:calc(100vw - 119px);max-width:none;height:96px;min-height:96px;padding:15px 17px 9px;transform:none}
  body[data-scene="3d"] .desk-question::before{left:9px;top:14px;bottom:13px}
  body[data-scene="3d"] .desk-question #question{height:44px;min-height:44px;max-height:44px;font:16px/22px var(--sans);background:repeating-linear-gradient(to bottom,transparent 0 21px,#b5a58044 21px 22px)}
  body[data-scene="3d"] .slip-mark{top:6px;right:10px;font-size:10px}
  body[data-scene="3d"] .desk-question-options{font-size:12px;line-height:1.4;margin-top:7px}
  body[data-scene="3d"] .question-options-paper{left:-1px;max-width:calc(100vw - 34px);width:300px;max-height:min(310px,44svh);padding:17px}
  body[data-scene="3d"] .desk-lines{top:166px;right:18px;width:73px;height:auto}
  body[data-scene="3d"] .desk-scroll{display:flex;flex-direction:column;width:71px;height:175px;min-height:175px;padding:15px 6px 13px;transform:none;background:var(--paper-fibers),linear-gradient(90deg,var(--world-brocade) 0 5px,#c6b18a 5px 6px,var(--paper) 6px calc(100% - 6px),#c6b18a calc(100% - 6px) calc(100% - 5px),var(--world-brocade) calc(100% - 5px));box-shadow:1px 5px 10px #47352314}
  body[data-scene="3d"] .scroll-rod{left:-5px;right:-5px;height:7px}
  body[data-scene="3d"] .scroll-heading{font-size:18px;margin:0 0 12px}
  body[data-scene="3d"] .desk-scroll .line-ladder{width:54px;height:71px;min-height:71px;gap:6px;margin:0 auto}
  body[data-scene="3d"] .desk-scroll .ladder-row{width:54px;height:5px;min-height:5px;flex:0 0 5px;font-size:6px;gap:4px}
  body[data-scene="3d"] .desk-scroll .yao-line{width:37px;height:3px;gap:6px}
  body[data-scene="3d"] .desk-scroll .move-dot{font-size:8px;right:-7px;top:-4px}
  body[data-scene="3d"] .scroll-footer{font-size:11px;line-height:1.4;margin:10px 0 0;max-width:59px;text-align:center}
  body[data-scene="3d"] .desk-milestones{gap:3px;height:10px;margin-top:10px}
  body[data-scene="3d"] .desk-milestones>span{width:9px;height:9px}
  body[data-scene="3d"] #ritual-message{bottom:max(143px,calc(env(safe-area-inset-bottom) + 130px));font-size:12px;line-height:1.5;max-width:calc(100vw - 36px);padding:4px 10px}
  body[data-scene="3d"] .desk-actions{bottom:max(60px,calc(env(safe-area-inset-bottom) + 48px));width:calc(100vw - 24px);grid-template-rows:54px auto;gap:9px 10px}
  body[data-scene="3d"] .desk-actions #cast-button{width:150px;min-width:150px;height:54px;min-height:54px}
  body[data-scene="3d"] .desk-actions #cast-button .seal-character[lang="en"]{font-size:22px}
  body[data-scene="3d"] .desk-actions #cast-button .seal-character[lang="en"][data-cast-word="reveal"]{font-size:20px}
  body[data-scene="3d"] .desk-actions #reset-button{font-size:12px;line-height:1.4;max-width:79px;min-height:44px;padding:4px 6px}
  body[data-scene="3d"] .desk-actions .under-button{font-size:12px;line-height:1.5;max-width:calc(100vw - 44px)}
  body[data-scene="3d"] .desk-bottom{left:16px;right:16px;bottom:max(10px,env(safe-area-inset-bottom));gap:10px}
  body[data-scene="3d"] .desk-bottom-tools{gap:15px}
  body[data-scene="3d"] .desk-settings-button,
  body[data-scene="3d"] .feedback-entry{font-size:12px;min-height:44px}
  body[data-scene="3d"] .desk-whisper{display:none}
  body[data-scene="3d"] #manual-area{top:278px;left:16px;transform:none;width:calc(100vw - 119px);max-height:calc(100svh - 427px);padding:17px 15px;min-height:0;border-radius:3px}
  body[data-scene="3d"] #manual-area .manual-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px 9px;margin:12px 0}
  body[data-scene="3d"] #manual-area .manual-grid label{font-size:12px;line-height:1.35}
  body[data-scene="3d"] #manual-area .manual-grid select{font-size:16px;min-height:36px}
  body[data-scene="3d"] #manual-area .manual-caption{font-size:13px;line-height:1.45}
  body[data-scene="3d"] #manual-area .manual-key{font-size:12px;line-height:1.55}
}
@media(max-width:760px) and (max-height:700px){
  body[data-scene="3d"] .desk-header{top:max(6px,env(safe-area-inset-top));height:42px}
  body[data-scene="3d"] #desk3d-intro{top:60px}
  body[data-scene="3d"] #desk3d-intro h2{font-size:24px}
  body[data-scene="3d"] .desk3d-coin-key{margin-top:6px;gap:18px}
  body[data-scene="3d"] .desk-question{top:144px;height:88px;min-height:88px;padding-top:12px;padding-bottom:7px}
  body[data-scene="3d"] .desk-question #question{height:42px;min-height:42px;max-height:42px;font-size:16px;line-height:21px;background:repeating-linear-gradient(to bottom,transparent 0 20px,#b5a58044 20px 21px)}
  body[data-scene="3d"] .desk-question-options{margin-top:5px}
  body[data-scene="3d"] .desk-lines{top:146px}
  body[data-scene="3d"] .desk-scroll{height:162px;min-height:162px;padding-top:13px;padding-bottom:11px}
  body[data-scene="3d"] .scroll-heading{margin-bottom:9px}
  body[data-scene="3d"] .desk-scroll .line-ladder{height:66px;min-height:66px;gap:5px}
  body[data-scene="3d"] .scroll-footer{margin-top:8px}
  body[data-scene="3d"] #ritual-message{bottom:max(130px,calc(env(safe-area-inset-bottom) + 119px))}
  body[data-scene="3d"] .desk-actions{bottom:max(48px,calc(env(safe-area-inset-bottom) + 39px));gap:7px 9px}
  body[data-scene="3d"] .desk-bottom{bottom:max(4px,env(safe-area-inset-bottom))}
  body[data-scene="3d"] #manual-area{top:245px;max-height:calc(100svh - 382px);padding:13px 14px}
}
@media(min-width:761px) and (max-height:700px){
  body[data-scene="3d"] .desk-header{top:10px;height:45px}
  body[data-scene="3d"] #desk3d-intro{top:77px}
  body[data-scene="3d"] #desk3d-intro h2{font-size:27px}
  body[data-scene="3d"] #desk3d-intro [data-desk3d-copy="hint"]{margin-top:5px;font-size:12px}
  body[data-scene="3d"] .desk3d-coin-key{margin-top:8px}
  body[data-scene="3d"] .desk-question{top:107px;height:155px;min-height:155px;padding-top:17px;padding-bottom:13px}
  body[data-scene="3d"] .desk-lines{top:108px}
  body[data-scene="3d"] .desk-scroll{height:209px;min-height:209px;padding-top:17px;padding-bottom:17px}
  body[data-scene="3d"] .scroll-heading{font-size:20px;margin-bottom:14px}
  body[data-scene="3d"] .desk-scroll .line-ladder{height:89px;min-height:89px;gap:7px}
  body[data-scene="3d"] .scroll-footer{margin-top:13px}
  body[data-scene="3d"] .desk-actions{bottom:48px}
  body[data-scene="3d"] #ritual-message{bottom:139px}
  body[data-scene="3d"] .desk-bottom{bottom:8px}
}
@media(max-width:350px){
  body[data-scene="3d"] .desk-header{left:11px;right:11px;gap:6px}
  body[data-scene="3d"] .desk-header .brand{font-size:18px;gap:6px}
  body[data-scene="3d"] .desk-header .brand-seal{width:26px;height:30px;font-size:21px}
  body[data-scene="3d"] .desk-header .brand small{display:none}
  body[data-scene="3d"] .desk-header .desk-tools{gap:7px}
  body[data-scene="3d"] .desk-header .desk-tool{font-size:12px}
  body[data-scene="3d"] .desk-header .language-toggle{font-size:12px;padding:5px 6px}
  body[data-scene="3d"] .desk-question{left:12px;width:calc(100vw - 108px);padding-left:14px;padding-right:13px}
  body[data-scene="3d"] .desk-lines{right:13px;width:70px}
  body[data-scene="3d"] #manual-area{left:12px;width:calc(100vw - 108px);padding-left:12px;padding-right:12px}
  body[data-scene="3d"] .desk-actions{grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);column-gap:7px}
  body[data-scene="3d"] .desk-actions #cast-button{width:140px;min-width:140px}
  body[data-scene="3d"] .desk-actions #reset-button{font-size:12px}
}
@media(prefers-reduced-motion:reduce){
  body[data-scene="3d"] .desk-actions #cast-button{transition:none!important}
}

/* Opt-in preview calibration, separate from the casting experience. */
body[data-scene="3d"] #desk3d-camera-panel{
  position:fixed;left:24px;bottom:65px;z-index:12;width:300px;
  max-height:max(44px,calc(100svh - 350px));overflow:auto;overscroll-behavior:contain;
  margin:0;border:1px solid var(--bronze-soft);border-radius:10px;background:#fbf3e3fa;
  color:var(--ink);box-shadow:0 7px 25px #47352329;font:12px/1.5 var(--sans);
  pointer-events:auto;text-shadow:none;
}
#desk3d-camera-panel>summary{position:sticky;top:0;z-index:1;display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:44px;padding:10px 13px;list-style:none;background:#f3e5cb;cursor:pointer;font-weight:600}
#desk3d-camera-panel>summary::-webkit-details-marker{display:none}
#desk3d-camera-panel>summary::after{content:'+';font-size:19px;font-weight:400}
#desk3d-camera-panel[open]>summary::after{content:'−'}
#desk3d-camera-panel [data-camera-mode]{margin-left:auto;font:10px/1.4 var(--sans);color:var(--muted)}
#desk3d-camera-panel .camera-panel-body{padding:10px 13px 12px}
#desk3d-camera-panel .camera-panel-help{margin:0 0 9px;font:11px/1.6 var(--sans);color:var(--muted)}
#desk3d-camera-panel .camera-axis-row{display:grid;grid-template-columns:16px minmax(0,1fr) 85px;gap:8px;align-items:center;margin:7px 0}
#desk3d-camera-panel .camera-axis-row>label{font:600 13px/1.4 ui-monospace,monospace}
#desk3d-camera-panel .camera-distance-field{display:grid;grid-template-columns:minmax(0,1fr) 85px;gap:5px 8px;align-items:center;margin:0 0 10px;padding-bottom:9px;border-bottom:1px solid var(--line)}
#desk3d-camera-panel .camera-distance-field>span{grid-column:1/-1;font:12px/1.5 var(--sans);color:var(--ink-soft)}
#desk3d-camera-panel input{min-width:0;width:100%;margin:0;box-shadow:none}
#desk3d-camera-panel input[type="number"]{height:36px;padding:5px 6px;border:1px solid var(--bronze-soft);border-radius:5px;background:#fdf7ec;color:var(--ink);font:13px/1.4 ui-monospace,monospace}
#desk3d-camera-panel input[type="range"]{height:32px;padding:0;border:0;outline-offset:3px;background:transparent;accent-color:var(--vermilion);cursor:ew-resize}
#desk3d-camera-panel input[aria-invalid="true"]{border-color:#ac4a39}
#desk3d-camera-panel .camera-advanced{margin:9px 0 0;border-top:1px solid var(--line)}
#desk3d-camera-panel .camera-advanced>summary,
#desk3d-camera-panel .camera-output>summary{display:list-item;min-height:34px;padding:8px 0;cursor:pointer;font:12px/1.5 var(--sans);color:var(--ink-soft)}
#desk3d-camera-panel .camera-target-fields{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;margin:4px 0 10px}
#desk3d-camera-panel .camera-target-fields label{display:grid;gap:4px;font:11px/1.5 var(--sans)}
#desk3d-camera-panel .camera-fov-field{display:grid;grid-template-columns:minmax(0,1fr) 72px;gap:5px 9px;align-items:center}
#desk3d-camera-panel .camera-fov-field>span{grid-column:1/-1;font-size:11px}
#desk3d-camera-panel .camera-panel-actions{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:7px;margin-top:11px}
#desk3d-camera-panel .camera-panel-actions button{min-width:0;min-height:36px;padding:6px 3px;border:1px solid var(--bronze-soft);border-radius:6px;background:#f3e5cb;color:var(--ink-soft);font:11px/1.4 var(--sans);cursor:pointer}
#desk3d-camera-panel .camera-panel-actions [data-camera-copy]{color:#fffaf0;background:var(--vermilion);border-color:var(--vermilion)}
#desk3d-camera-panel .camera-panel-actions button:disabled{opacity:.55;cursor:default}
#desk3d-camera-panel :is(input,button,summary):focus-visible{outline:2px solid var(--vermilion);outline-offset:2px}
#desk3d-camera-panel .camera-panel-status{margin:7px 0 0;font:11px/1.5 var(--sans);color:var(--ink-soft)}
#desk3d-camera-panel .camera-panel-status:empty{display:none}
#desk3d-camera-panel .camera-output{margin-top:5px}
#desk3d-camera-panel textarea{display:block;width:100%;min-height:130px;margin:0;padding:9px;border:1px solid var(--bronze-soft);border-radius:5px;background:#fdf7ec;color:var(--ink);font:12px/1.5 ui-monospace,monospace;resize:vertical}
@media(min-width:761px) and (max-height:600px){
  body[data-scene="3d"] #desk3d-camera-panel{bottom:35px;max-height:60svh}
}
@media(max-width:760px){
  body[data-scene="3d"] #desk3d-camera-panel{left:12px;right:12px;bottom:max(12px,env(safe-area-inset-bottom));width:auto;max-height:34svh}
  #desk3d-camera-panel .camera-panel-body{padding:9px 12px 12px}
  #desk3d-camera-panel .camera-panel-help{display:none}
  #desk3d-camera-panel .camera-axis-row{grid-template-columns:16px minmax(0,1fr) 94px;gap:7px}
  #desk3d-camera-panel input[type="number"]{height:39px;font-size:16px}
  #desk3d-camera-panel .camera-panel-actions button{min-height:44px;font-size:12px}
  #desk3d-camera-panel .camera-advanced>summary,
  #desk3d-camera-panel .camera-output>summary{min-height:44px;padding:11px 0}
}

/* During a mobile cast, the captured question folds away and progress stays
   in a compact strip, outside the camera's reserved landing area. */
@media(max-width:760px){
  body[data-scene="3d"] #desk3d-intro [data-desk3d-copy="hint"]{display:block;margin-top:5px;font-size:12px;line-height:1.5}
  body[data-scene="3d"] .desk3d-view-tools{margin-top:7px;gap:6px}
  body[data-scene="3d"] #desk3d-reset-view{min-height:44px;padding:5px 9px}
  body[data-scene="3d"] .desk3d-view-tools .desk3d-coin-key{gap:8px;padding:4px 7px;font-size:12px}
  body[data-scene="3d"] .desk3d-coin-key>span{gap:5px;white-space:nowrap}
  body[data-scene="3d"] .desk-question{top:198px}
  body[data-scene="3d"] .desk-lines{top:200px}
  body[data-scene="3d"] #manual-area{top:310px;max-height:calc(100svh - 459px)}
  body[data-scene="3d"]:has(#desk3d-canvas[data-dragging="true"]) .desk-question,
  body[data-scene="3d"]:has(#desk3d-canvas[data-dragging="true"]) .desk-lines{visibility:hidden;pointer-events:none}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-question{visibility:hidden;pointer-events:none}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) #desk3d-intro{top:65px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) #desk3d-intro :is([data-desk3d-copy="eyebrow"],h2,[data-desk3d-copy="hint"]){display:none}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk3d-view-tools{margin-top:0}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-lines{top:119px;left:16px;right:16px;width:auto;flex-direction:row;justify-content:center;align-items:center;gap:12px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-scroll{display:grid;grid-template-columns:20px 46px minmax(0,1fr);gap:9px;width:calc(100% - 92px);height:60px;min-height:60px;padding:8px 10px;background:var(--paper-fibers),var(--paper)}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .scroll-rod{display:none}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .scroll-heading{margin:0;font-size:16px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-scroll .line-ladder{width:46px;height:42px;min-height:42px;gap:3px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-scroll .ladder-row{width:46px;height:4px;min-height:4px;flex:0 0 4px;font-size:5px;gap:4px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-scroll .yao-line{width:31px;height:3px;gap:5px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .scroll-footer{max-width:none;margin:0;font-size:11px}
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-milestones{margin:0;gap:3px;height:10px;flex:0 0 69px}
}
@media(max-width:760px) and (max-height:700px){
  body[data-scene="3d"] .desk-question{top:184px}
  body[data-scene="3d"] .desk-lines{top:186px}
  body[data-scene="3d"] #manual-area{top:284px;max-height:calc(100svh - 421px)}
}
@media(max-height:450px){
  body[data-scene="3d"] .desk-header{top:5px;left:14px;right:14px;height:38px}
  body[data-scene="3d"] #desk3d-intro,
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) #desk3d-intro{top:47px;width:min(380px,calc(100vw - 300px));min-width:280px}
  body[data-scene="3d"] #desk3d-intro :is([data-desk3d-copy="eyebrow"],h2,[data-desk3d-copy="hint"]){display:none}
  body[data-scene="3d"] .desk3d-view-tools{margin-top:0}
  body[data-scene="3d"] .desk-question{top:97px;left:14px;width:150px;max-width:150px;height:82px;min-height:82px;padding:10px 12px}
  body[data-scene="3d"] .desk-question #question{height:40px;min-height:40px;max-height:40px;font-size:16px;line-height:20px}
  body[data-scene="3d"] .desk-question-options{font-size:12px;margin-top:3px}
  body[data-scene="3d"] .desk-lines,
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-lines{top:97px;left:auto;right:14px;width:82px;flex-direction:column;gap:0}
  body[data-scene="3d"] .desk-scroll,
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-scroll{display:flex;flex-direction:column;gap:0;width:80px;height:130px;min-height:130px;padding:10px 8px;background:var(--paper-fibers),var(--paper)}
  body[data-scene="3d"] .scroll-heading{font-size:16px;margin:0 0 5px}
  body[data-scene="3d"] .desk-scroll .line-ladder{width:46px;height:42px;min-height:42px;gap:3px}
  body[data-scene="3d"] .desk-scroll .ladder-row{width:46px;height:4px;min-height:4px;flex:0 0 4px;font-size:5px;gap:4px}
  body[data-scene="3d"] .desk-scroll .yao-line{width:31px;height:3px;gap:5px}
  body[data-scene="3d"] .scroll-footer{font-size:11px;margin:8px 0 0}
  body[data-scene="3d"] .desk-milestones,
  body[data-scene="3d"]:is([data-stage="tossing"],[data-stage="casting"],[data-stage="complete"]) .desk-milestones{width:69px;flex:0 0 auto;gap:3px;height:10px;margin:8px 0 0}
  body[data-scene="3d"] .desk-actions{bottom:10px;grid-template-rows:54px;row-gap:0}
  body[data-scene="3d"] .desk-actions .under-button,
  body[data-scene="3d"] .desk-whisper{display:none}
  body[data-scene="3d"] #ritual-message{left:auto;right:16px;bottom:17px;transform:none;max-width:190px}
  body[data-scene="3d"] .desk3d-toss-faces{gap:5px}
  body[data-scene="3d"] #manual-area{top:97px;left:14px;transform:none;width:200px;max-height:calc(100svh - 165px);padding:12px}
}
