#upgrade-bubbles{display:none}
.codex-launch{display:flex;align-items:center;gap:10px;margin-top:18px;border:0;border-bottom:1px solid #746447;border-radius:0;background:transparent;min-height:44px;padding:8px 0;color:#d2bb91;text-align:left;font-size:13px;letter-spacing:.04em}
.codex-launch svg{width:20px;height:20px}.codex-launch small{display:block;margin-top:4px;color:#9dafa9;font-size:11px;letter-spacing:0}
#foundry-codex{width:min(940px,calc(100vw - var(--safe-left) - var(--safe-right) - 24px));height:min(800px,calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px));max-height:calc(100dvh - var(--safe-top) - var(--safe-bottom) - 24px);padding:0;overflow:hidden;background:#121c20;border:1px solid #7b694b;border-radius:12px;color:#e0e8e1}
#foundry-codex[open]{display:flex;flex-direction:column}
#foundry-codex::backdrop{background:#02080cba;backdrop-filter:blur(5px)}
.codex-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:20px 22px 12px;flex-shrink:0}
.codex-heading h2{margin:5px 0 0;font-size:25px}.codex-heading .eyebrow{font-size:9px;color:#c4a774;letter-spacing:.14em}
#codex-close{min-width:48px;min-height:48px;border-radius:50%;font-size:26px;flex-shrink:0}
.codex-search-row{padding:0 22px 14px;display:flex;align-items:center;gap:12px;flex-shrink:0}
.codex-search-row label{flex:1;min-width:0;font-size:11px;color:#a8b8b6}
#codex-search{display:block;width:100%;min-height:46px;margin-top:5px;border:1px solid #465b5e;background:#091318;color:#e0e8e1;border-radius:6px;padding:10px 12px;font:inherit;font-size:16px}
#codex-status{font-size:11px;color:#c1ac86;white-space:nowrap}
.codex-body{display:grid;grid-template-columns:150px minmax(0,1fr);gap:12px;min-height:0;flex:1;border-top:1px solid #354344}
#codex-categories{display:flex;flex-direction:column;gap:4px;padding:14px 0 16px 14px;overflow:auto;overscroll-behavior:contain}
#codex-categories button{flex-shrink:0;min-height:44px;text-align:left;padding:10px 12px;font-size:12px;background:transparent;border-color:transparent;color:#aabebc}
#codex-categories button[aria-pressed=true]{background:#2d362d;border-color:#8f7b4e;color:#ffe0a8}
#codex-entries{min-width:0;min-height:0;overflow:auto;overscroll-behavior:contain;padding:14px 22px 24px 0;scrollbar-color:#6a796e transparent}
.codex-entry{border:1px solid #3e5051;border-radius:7px;background:#172329;margin-bottom:10px;overflow:hidden}
.codex-entry summary{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:15px;min-height:56px;cursor:pointer;list-style:none;color:#e8dfc9}
.codex-entry summary::-webkit-details-marker{display:none}.codex-entry summary small{display:block;font-size:9px;text-transform:uppercase;letter-spacing:.1em;color:#95b6b0;margin-bottom:5px}.codex-entry summary b{font-size:14px;font-weight:600}.codex-entry summary>span:last-child{font-size:22px;color:#c2aa7a}.codex-entry details[open] summary>span:last-child{transform:rotate(45deg)}
.codex-copy{padding:0 15px 16px;font-size:13px;line-height:1.65}.codex-copy p{margin:0 0 12px!important;color:#c2d0cc!important;font-size:13px!important;line-height:1.65!important}
.codex-table{max-width:100%;overflow:auto;overscroll-behavior:contain}.codex-table table{width:100%;border-collapse:collapse;font-size:12px;line-height:1.5;text-align:left}.codex-table caption{text-align:left;color:#a9beb4;padding-bottom:8px}.codex-table th,.codex-table td{padding:9px 8px;border-bottom:1px solid #3a4c4d;vertical-align:top;overflow-wrap:anywhere}.codex-table th{font-weight:500;color:#e6d0a7}.codex-table th:first-child{width:25%}.codex-table td:nth-child(2){width:23%;color:#d7c292}.codex-table td{color:#bfd0cb}.codex-empty{padding:20px;color:#b7c8bf}

@media(max-width:900px),(pointer:coarse){
 #upgrade-bubbles:not([hidden]){display:block;position:absolute;z-index:11;right:calc(8px + var(--safe-right));top:calc(var(--hud-top) + var(--safe-top) + 62px);bottom:calc(var(--dock-height) + var(--safe-bottom) + 12px);width:54px;pointer-events:none}
 [data-tray-groups]{display:flex;flex-direction:column;gap:8px;max-height:100%;overflow:auto;pointer-events:none;scrollbar-width:none}
 [data-tray-group]{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;width:54px;height:54px;min-height:54px;flex-shrink:0;padding:3px;border:1px solid #82948b;border-radius:50%;background:linear-gradient(145deg,#293c40,#132227);box-shadow:0 2px 9px #0006;color:#cbdcd6;pointer-events:auto;font-size:10px;line-height:1.1;touch-action:manipulation}
 [data-tray-group] svg{width:20px;height:20px}
 [data-tray-group][aria-expanded=true]{background:linear-gradient(145deg,#6b542d,#302b22);color:#ffe2a1;border-color:#e4bf76}
 [data-tray-group] i{display:none;position:absolute;top:3px;right:3px;width:7px;height:7px;border-radius:50%;background:#a6d4ad;box-shadow:0 0 0 2px #15282c}
 [data-tray-group].has-upgrade i{display:block}
 #upgrade-tray{position:absolute;top:0;right:62px;bottom:0;width:94px;display:flex;flex-direction:column;max-height:100%;min-height:0;border:1px solid #5b6c60;border-radius:38px 38px 15px 15px;background:#122127ef;box-shadow:0 4px 18px #0006;pointer-events:auto;overflow:hidden;animation:tray-arrive .16s ease-out}
 #upgrade-tray[hidden]{display:none}
 .tray-heading{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;padding:5px 0 0;flex-shrink:0}
 [data-tray-title]{width:100%;text-align:center;font-size:10px;font-weight:500;color:#d4c39e;padding:4px}
 .tray-heading button{min-height:44px;min-width:44px;padding:0;border:0;background:transparent;color:#d8decf;font-size:21px;border-radius:50%;touch-action:manipulation}
 [data-tray-help][aria-expanded=true]{color:#ffe3ae;background:#55432c}
 [data-tray-items]{min-height:0;overflow:auto;overscroll-behavior:contain;touch-action:pan-y;padding:4px 6px 10px;scrollbar-width:thin;scrollbar-color:#658174 transparent;mask-image:linear-gradient(#000 96%,transparent)}
 .tray-upgrade{display:flex;align-items:center;justify-content:center;gap:10px;min-width:0;margin-bottom:8px}
 [data-upgrade-bubble]{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;flex:0 0 68px;width:68px;height:68px;min-height:68px;padding:5px 2px;border-radius:50%;border:1px solid #475c60;background:linear-gradient(145deg,#2e4145,#17282e);color:#bdcbc5;touch-action:manipulation;box-shadow:inset 0 0 0 3px #192b30}
 [data-upgrade-bubble] b{font-size:11px;line-height:1.1;font-weight:600}
 [data-bubble-level]{font-size:10px;line-height:1.1;color:#b4cbbf}
 [data-bubble-price]{font-size:9px;line-height:1.1;max-width:62px;color:#ddc89b;white-space:normal}
 [data-upgrade-bubble]:disabled{opacity:.72;cursor:default}[data-upgrade-bubble].affordable{border-color:#b9d39a;color:#e4eddb;background:linear-gradient(145deg,#3a4f3d,#1d302c)}
 [data-upgrade-bubble].installed{border-color:#9dbdc0}
 .tray-upgrade-info,[data-tray-status]{display:none}
 #upgrade-bubbles[data-details=true] #upgrade-tray{width:min(310px,calc(100vw - var(--safe-left) - var(--safe-right) - 86px));border-radius:16px}
 #upgrade-bubbles[data-details=true] .tray-heading{flex-wrap:nowrap;justify-content:flex-end;padding:4px 6px}
 #upgrade-bubbles[data-details=true] [data-tray-title]{text-align:left;flex:1;padding-left:8px;font-size:12px}
 #upgrade-bubbles[data-details=true] .tray-upgrade{flex-direction:row-reverse;padding-block:6px;justify-content:flex-start;border-top:1px solid #344849}
 #upgrade-bubbles[data-details=true] .tray-upgrade-info{display:block;flex:1;min-width:0;padding-left:6px;overflow-wrap:anywhere}
 .tray-upgrade-info>b{font-size:12px;color:#e5d5ae}.tray-upgrade-info p{font-size:11px;line-height:1.5;color:#c0d1cb;margin:5px 0}.tray-upgrade-info small{display:block;font-size:10px;color:#95ada8;line-height:1.4}.tray-upgrade-info strong{display:block;font-size:10px;color:#e2ba84;margin-top:6px;line-height:1.4;font-weight:500}
 #upgrade-bubbles[data-details=true] [data-tray-status]{display:block;flex-shrink:0;font-size:10px;line-height:1.4;color:#d0c197;padding:8px 12px;margin:0;border-top:1px solid #3b5050}
 #command-dock #mobile-workshop{display:none}
 #command-dock .base-actions{grid-column:1/5}
 #app[data-upgrade-tray]:not([data-upgrade-tray='']) #training-coach{display:none}
 #app #training-coach{width:calc(100% - var(--safe-left) - var(--safe-right) - 86px)}
 #app[data-upgrade-tray]:not([data-upgrade-tray='']) #toast{left:calc(8px + var(--safe-left));right:calc(172px + var(--safe-right));width:auto;transform:none;font-size:11px}
 .codex-heading{padding:16px 14px 10px}.codex-heading h2{font-size:23px}.codex-search-row{padding:0 14px 12px;gap:8px}
 .codex-body{grid-template-columns:minmax(0,1fr);grid-template-rows:auto minmax(0,1fr);gap:0}
 #codex-categories{flex-direction:row;padding:8px 14px;overflow-x:auto;border-bottom:1px solid #354344;scrollbar-width:thin}
 #codex-categories button{white-space:nowrap;min-height:44px;padding:9px 12px}
 #codex-entries{padding:12px 14px 20px}.codex-copy{padding:0 10px 12px}.codex-table th,.codex-table td{padding:8px 5px;font-size:11px}
}
@keyframes tray-arrive{from{opacity:0;transform:translateX(6px)}to{opacity:1;transform:translateX(0)}}
@media(prefers-reduced-motion:reduce){#upgrade-tray{animation:none}}
/* In landscape keep commands left and refits right, with the field between. */
@media(max-height:500px) and (min-width:480px) and (max-width:900px),(max-height:500px) and (min-width:480px) and (pointer:coarse){
 #command-dock{left:calc(8px + var(--safe-left));right:auto;width:250px}
 #upgrade-bubbles:not([hidden]){top:calc(var(--hud-top) + var(--safe-top) + 6px);bottom:calc(var(--safe-bottom) + 8px)}
 #app .camera-tools{right:calc(70px + var(--safe-right))}
 #app .hud-panel,#app[data-training]:not([data-training='']) .hud-panel{left:calc(266px + var(--safe-left));right:calc(8px + var(--safe-right));bottom:calc(8px + var(--safe-bottom))}
 #app #training-coach{left:calc(266px + var(--safe-left));right:calc(74px + var(--safe-right));width:auto}
 #app[data-upgrade-tray]:not([data-upgrade-tray='']) #toast{left:calc(266px + var(--safe-left));right:calc(172px + var(--safe-right))}
 #toast{left:calc(266px + var(--safe-left));right:calc(74px + var(--safe-right));bottom:calc(8px + var(--safe-bottom))}
 #app #network-bar{left:calc(266px + var(--safe-left));right:calc(74px + var(--safe-right));max-width:none}
 #app[data-upgrade-tray]:not([data-upgrade-tray='']) .camera-tools{display:none}
}
