/* PHOJ Spellbook Atelier — scoped game-panel presentation.
   Explicit opt-in only: the native shell, learning/editor/admin views are untouched.
   Existing responsive grids, links, forms and all asset/account logic stay native. */

/* 1. Theme tokens. Dark mode is ink/charcoal + antique gold, not muddy brown. */
:root.ph8660-spellbook .ph8662-book-panel {
  --book-paper:#fbf5e8; --book-raised:#fffdf5; --book-soft:#f1e7d2;
  --book-deep:#ecdcc1; --book-ink:#3e3227; --book-muted:#756348;
  --book-heading:#594027; --book-gold:#94703b; --book-link:#805a2c;
  --book-line:#d9c9a9; --book-trim:#bba278; --book-leather:#262128;
  --book-focus:#936a33; --book-hover:#eadeca; --book-rank-mix:32%;
  --book-success:#24664f; --book-warning:#815a23;
  --book-shadow:0 3px 8px #4f392508,0 12px 30px #4f392510;
  --book-frame:inset 0 1px 0 #ffffffb3,0 3px 8px #4f392508,0 12px 30px #4f392510;
  --book-texture:url('/ph-book-8660/parchment-512.webp');
  --book-wash:linear-gradient(#fffaf0ed,#fffaf0ed);
  --book-hero-wash:radial-gradient(ellipse at 9% 24%,#fffdf4c2,transparent 65%),linear-gradient(115deg,#f2e4c7d9,#faf1dfed);
  --book-action-top:#745533; --book-action-bottom:#503c29; --book-action-ink:#fff6e4;
  --book-action-edge:#9e7a45; --book-glint:#ffffff70; --book-slot-line:#cdbb99;
  --book-slot-inset:inset 0 1px 5px #73512d0c,inset 0 0 0 3px #fffcf42b;
  color:var(--book-ink);
}
:root.ph8660-spellbook.theme--dark .ph8662-book-panel {
  --book-paper:var(--ph8670-surface,#1a202a); --book-raised:var(--ph8670-soft,#222b36); --book-soft:var(--ph8670-soft,#222b36);
  --book-deep:#28313c; --book-ink:var(--ph8670-ink,#e3e8ef); --book-muted:var(--ph8670-muted,#b2bdcc);
  --book-heading:var(--ph8670-heading,#e5c78f); --book-gold:var(--ph8670-gold,#e5c78f); --book-link:var(--ph8670-link,#a9cdfb);
  --book-line:var(--ph8670-edge,#3c4a5b); --book-trim:#82715a; --book-leather:#141923;
  --book-focus:#e5c27e; --book-hover:#353039; --book-rank-mix:75%;
  --book-success:var(--ph8670-success,#9ad9ba); --book-warning:var(--ph8670-warning,#edcc8a);
  --book-shadow:0 3px 8px #08070b26,0 16px 36px #08070b38;
  --book-frame:inset 0 1px 0 #f0d8ad14,0 3px 8px #08070b26,0 16px 36px #08070b38;
  --book-wash:linear-gradient(#1a202afa,#1a202afa);
  --book-hero-wash:radial-gradient(ellipse at 9% 24%,#b1905220,transparent 65%),linear-gradient(115deg,#242b35f7,#1a202afa);
  --book-action-top:#e0c68f; --book-action-bottom:#c4a16a; --book-action-ink:#28231e;
  --book-action-edge:#e3c58d; --book-glint:#fff3cf38; --book-slot-line:#49424b;
  --book-slot-inset:inset 0 1px 7px #08070b45,inset 0 0 0 3px #ffffff02;
}
/* 2. Private adapters. Tokens never leak into navbar wallet/popovers. */
:root.ph8660-spellbook .ph8662-book-panel.ph8600-inventory {
  --bag-bg:var(--book-paper); --bag-panel:var(--book-soft);
  --bag-line:var(--book-line); --bag-text:var(--book-ink);
  --bag-muted:var(--book-muted); --bag-gold:var(--book-heading);
  --ph8570-bg:var(--book-paper); --ph8570-soft:var(--book-soft);
  --ph8570-line:var(--book-line); --ph8570-text:var(--book-ink);
  --ph8570-muted:var(--book-muted); --ph8570-blue:var(--book-link);
  --ph8570-gold:var(--book-gold);
}
:root.ph8660-spellbook .ph8662-book-panel.ph8640-page {
  --mail-bg:var(--book-paper); --mail-panel:var(--book-soft);
  --mail-ink:var(--book-ink); --mail-muted:var(--book-muted);
  --mail-line:var(--book-line); --mail-gold:var(--book-gold);
  --mail-accent:var(--book-link);
}
:root.ph8660-spellbook .ph8662-book-panel.ph8620-page {
  --relic-bg:var(--book-paper); --relic-panel:var(--book-soft);
  --relic-ink:var(--book-ink); --relic-muted:var(--book-muted);
  --relic-gold:var(--book-heading); --relic-line:var(--book-line);
}
:root.ph8660-spellbook .ph8662-book-panel .ph8570-shop-wallet {
  --ph8570-bg:var(--book-paper); --ph8570-soft:var(--book-soft);
  --ph8570-line:var(--book-line); --ph8570-text:var(--book-ink);
  --ph8570-muted:var(--book-muted); --ph8570-blue:var(--book-link);
  --ph8570-gold:var(--book-gold);
}
/* 3. Hairline frames, soft paper, restrained illumination. */
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-inv-hero,.ph8640-hero,.ph8620-shop-hero) {
  position:relative; isolation:isolate; overflow:hidden;
  background-color:var(--book-deep)!important;
  background-image:var(--book-hero-wash),var(--book-texture)!important;
  background-size:auto,auto,512px 512px!important;
  border-width:1px!important; border-color:var(--book-trim)!important; border-radius:18px;
  color:var(--book-ink)!important; box-shadow:var(--book-frame)!important;
}
:root.ph8660-spellbook .ph8662-book-panel :is(h1,h2,h3) { color:var(--book-heading)!important; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-inv-hero,.ph8640-hero,.ph8620-shop-hero) :is(p,.ph8600-eyebrow,.ph8640-kicker,.ph8620-kicker) { color:var(--book-muted)!important; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-inv-hero,.ph8640-hero,.ph8620-shop-hero) p { font-size:13px; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-inv-hero,.ph8640-hero,.ph8620-shop-hero)::before {
  content:""; position:absolute; inset:8px; border:1px solid color-mix(in srgb,var(--book-trim) 25%,transparent);
  border-radius:11px; pointer-events:none; opacity:.65;
  background:linear-gradient(var(--book-trim),var(--book-trim)) left top/22px 1px no-repeat,
    linear-gradient(var(--book-trim),var(--book-trim)) left top/1px 22px no-repeat,
    linear-gradient(var(--book-trim),var(--book-trim)) right bottom/22px 1px no-repeat,
    linear-gradient(var(--book-trim),var(--book-trim)) right bottom/1px 22px no-repeat;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-inv-hero,.ph8640-hero,.ph8620-shop-hero)::after {
  content:""; position:absolute; inset:0; pointer-events:none; z-index:-1;
  background:linear-gradient(110deg,transparent 30%,var(--book-glint) 48%,transparent 66%);
  transform:translateX(-110%);
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-bag,.ph8600-item-detail,.ph8600-bag-empty,.ph8640-letter,.ph8640-panel,.ph8640-empty,.ph8650-compose-aside,.ph8620-purchase-layout) {
  background-color:var(--book-paper)!important;
  background-image:var(--book-wash),var(--book-texture)!important;
  background-size:auto,512px 512px!important;
  border-width:1px!important; border-color:var(--book-line)!important; border-radius:16px;
  box-shadow:var(--book-frame)!important; color:var(--book-ink)!important;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-bag-heading,.ph8600-owner,.ph8640-letter-head) {
  background:linear-gradient(120deg,var(--book-soft),var(--book-paper))!important;
  border-color:var(--book-line)!important; color:var(--book-ink)!important;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8640-emblem,.ph8650-postmark,.ph8640-letter-icon) {
  background:radial-gradient(ellipse at top,color-mix(in srgb,var(--book-gold) 10%,transparent),transparent),var(--book-soft)!important;
  border-color:color-mix(in srgb,var(--book-gold) 35%,var(--book-line))!important;
  color:var(--book-gold)!important; box-shadow:inset 0 1px 0 #ffffff12;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-owner a,.ph8600-detail-empty>svg,.ph8620-fineprint,.ph8620-price,.ph8620-shop-item footer>small,.ph8630-catalog-heading,.ph8630-rarity-legend) { color:var(--book-muted)!important; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8620-back,.ph8640-back) { color:var(--book-link)!important; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-bag-area {
  background:radial-gradient(ellipse at 50% 0%,color-mix(in srgb,var(--book-gold) 5%,transparent),transparent 70%),var(--book-paper)!important;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8600-inv-wallet {
  background:linear-gradient(120deg,var(--book-raised),var(--book-paper))!important;
  border-color:var(--book-line); box-shadow:var(--book-shadow);
}
:root.ph8660-spellbook .ph8662-book-panel .ph8600-inv-wallet small { font-size:10px; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-inv-wallet b { font-size:16px; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-inv-wallet>div { align-items:stretch; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-inv-wallet>div>.ph8570-currency-icon { align-self:center; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-inv-wallet>div>span {
  display:flex; flex-direction:column; justify-content:space-between; gap:3px; min-width:0;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-inv-filters label,.ph8600-bag-heading>span,.ph8600-inv-pagination,.ph8600-owner a) { font-size:11px; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-detail-empty p,.ph8600-detail-content p) { font-size:12px; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-detail-content dl>div { font-size:11px; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-bag-heading>span {
  border-color:var(--book-line); background:var(--book-raised); box-shadow:inset 0 1px 0 #ffffff15;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8600-owner>span { border-color:var(--book-line); background:var(--book-raised); }
:root.ph8660-spellbook .ph8662-book-panel .ph8610-vault-seal { color:var(--book-gold); opacity:.65; }
/* 4. Commerce cards and jewel slots. Rarity hues remain shared and intact. */
:root.ph8660-spellbook .ph8662-book-panel .ph8620-relic-showcase {
  background:radial-gradient(ellipse at center,color-mix(in srgb,var(--rank) 8%,transparent),transparent 65%),var(--book-paper)!important;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8620-shop-item {
  border-color:color-mix(in srgb,var(--rank) 38%,var(--book-line));
  border-radius:14px;
  background:radial-gradient(ellipse at 50% 8%,color-mix(in srgb,var(--rank) 9%,transparent),transparent 70%),linear-gradient(155deg,var(--book-raised),var(--book-paper))!important;
  box-shadow:var(--book-frame)!important;
  transition:transform .22s ease,box-shadow .22s ease,border-color .22s ease;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8620-shop-item h2 { font-size:14px!important; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8620-shop-item footer,.ph8620-checkout dl>div) { border-color:var(--book-line)!important; }
:root.ph8660-spellbook .ph8662-book-panel .ph8620-checkout .ph8620-notice { color:var(--book-heading)!important; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8620-rank,.ph8600-rarity) {
  color:color-mix(in srgb,var(--rank,var(--rarity)) var(--book-rank-mix),var(--book-ink))!important; font-size:10px;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8630-item-frame:not([data-ph8700-grade]) {
  background:radial-gradient(ellipse at 40% 15%,color-mix(in srgb,var(--rank) 23%,var(--book-leather)),var(--book-leather) 85%)!important;
  transition:transform .22s ease,box-shadow .22s ease;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8630-item-frame>img,.ph8600-slot-icon) { transition:transform .3s ease; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-item-slot.is-empty {
  background:linear-gradient(145deg,var(--book-soft),var(--book-paper))!important;
  border-width:1px; border-color:var(--book-slot-line)!important;
  border-radius:9px; box-shadow:var(--book-slot-inset)!important;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8600-item-slot.is-empty>i { border-color:var(--book-trim); opacity:.3; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-bag-empty {
  border-color:var(--book-trim)!important; box-shadow:var(--book-frame),0 16px 40px #17101924!important;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8600-slot-name { color:#f2e9d9!important; }
:root.ph8660-spellbook .ph8662-book-panel .ph8600-item-slot.is-selected {
  outline-color:var(--rank); box-shadow:inset 0 0 0 2px #101019,0 0 0 4px color-mix(in srgb,var(--rank) 15%,transparent),0 5px 18px color-mix(in srgb,var(--rank) 22%,transparent)!important;
}
/* 5. Forms, segmented navigation and polished controls. Source editors opt out. */
:root.ph8660-spellbook .ph8662-book-panel :is(input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=hidden]),textarea,select):not(:is(.monaco-editor *,.CodeMirror *,.cm-editor *,.ace_editor *,[name=code],[name=source],[data-ph84933-input],[data-ph-no-theme],[data-ph-no-theme] *)) {
  background-color:var(--book-raised)!important; border-color:var(--book-line)!important;
  color:var(--book-ink)!important; accent-color:var(--book-gold); border-radius:8px;
  box-shadow:inset 0 1px 2px #17101905; transition:border-color .18s ease,box-shadow .18s ease;
}
:root.ph8660-spellbook .ph8662-book-panel :is(input,textarea)::placeholder { color:var(--book-muted); opacity:.8; }
:root.ph8660-spellbook .ph8662-book-panel .ph8650-navigation {
  background:var(--book-soft)!important; border-color:var(--book-line)!important; box-shadow:inset 0 1px 3px #17101908;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8650-navigation>a { transition:background .18s ease,box-shadow .18s ease,color .18s ease; }
:root.ph8660-spellbook .ph8662-book-panel .ph8650-navigation>a.is-active {
  background:var(--book-raised); color:var(--book-heading)!important;
  box-shadow:inset 0 -2px var(--book-gold),0 2px 7px #1710190c;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8640-status {
  color:var(--book-gold); background:color-mix(in srgb,var(--book-gold) 10%,transparent);
  border-color:color-mix(in srgb,var(--book-gold) 30%,transparent);
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8640-recipient>span,.ph8640-recipient>b,.ph8640-notice.is-success,.ph8640-claim-success strong,.ph8640-delivery[data-state=delivered]) { color:var(--book-success); }
:root.ph8660-spellbook .ph8662-book-panel .ph8640-status:is([data-state=claimed],[data-state=returned]) {
  color:var(--book-success); background:color-mix(in srgb,var(--book-success) 10%,transparent);
  border-color:color-mix(in srgb,var(--book-success) 30%,transparent);
}
:root.ph8660-spellbook .ph8662-book-panel .ph8640-status[data-state=claiming] { color:var(--book-link); }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8640-status:is([data-state=blocked],[data-state=failed],[data-state=return_pending],[data-state=refunding]),.ph8640-delivery[data-state=blocked]) { color:var(--book-warning); }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button) {
  position:relative; isolation:isolate; overflow:hidden; border-radius:9px;
  background:linear-gradient(var(--book-raised),var(--book-soft))!important;
  border-color:var(--book-trim)!important; color:var(--book-heading)!important;
  box-shadow:inset 0 1px #ffffff55,0 2px 4px #1710190a!important;
  transition:transform .18s ease,box-shadow .22s ease,border-color .22s ease;
}
:root.ph8660-spellbook .ph8662-book-panel .ph8600-button { font-size:12px; }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button).is-primary {
  background:linear-gradient(135deg,var(--book-action-top),var(--book-action-bottom))!important;
  border-color:var(--book-action-edge)!important; color:var(--book-action-ink)!important;
  box-shadow:inset 0 1px #fff0c54d,0 3px 8px #1710191a!important;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button)::after {
  content:""; position:absolute; inset:0; pointer-events:none;
  background:linear-gradient(105deg,transparent 25%,var(--book-glint) 50%,transparent 75%);
  transform:translateX(-130%); transition:transform .65s ease;
}
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button):active:not(:disabled):not([aria-disabled=true]) { transform:translateY(1px); }
:root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button):disabled { box-shadow:none!important; }
:root.ph8660-spellbook .ph8662-book-panel :is(a,button,input,textarea,select,summary):focus-visible:not(:is(.monaco-editor *,.CodeMirror *,.cm-editor *,.ace_editor *)) { outline-color:var(--book-focus)!important; }
:root.ph8660-spellbook .ph8662-book-panel .ph8620-shop-item:focus-within {
  border-color:var(--rank); box-shadow:var(--book-frame),0 0 0 2px color-mix(in srgb,var(--rank) 20%,transparent)!important;
}
@media(hover:hover) and (pointer:fine) {
  :root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button):hover:not(:active):not(:disabled):not([aria-disabled=true]) {
    transform:translateY(-1px); box-shadow:inset 0 1px #ffffff55,0 0 0 2px color-mix(in srgb,var(--book-gold) 10%,transparent),0 5px 14px #1710191a!important;
  }
  :root.ph8660-spellbook .ph8662-book-panel :is(.ph8600-button,.ph8640-button,.ph8620-button):hover:not(:disabled):not([aria-disabled=true])::after { transform:translateX(130%); }
  :root.ph8660-spellbook .ph8662-book-panel .ph8620-shop-item:hover {
    transform:translateY(-3px); border-color:var(--rank);
    box-shadow:var(--book-frame),0 0 18px color-mix(in srgb,var(--rank) 13%,transparent)!important;
  }
  :root.ph8660-spellbook .ph8662-book-panel .ph8600-item-slot:not(.is-empty):hover {
    transform:translateY(-2px); box-shadow:inset 0 0 0 2px #101019,0 5px 18px color-mix(in srgb,var(--rank) 28%,transparent)!important;
  }
  :root.ph8660-spellbook .ph8662-book-panel :is(.ph8630-item-frame:hover>img,.ph8600-item-slot:hover .ph8600-slot-icon) { transform:translateY(-2px) scale(1.06); }
  :root.ph8660-spellbook .ph8662-book-panel .ph8640-mail-row:hover {
    border-color:var(--book-trim)!important; box-shadow:var(--book-shadow),0 0 0 1px color-mix(in srgb,var(--book-gold) 12%,transparent)!important;
  }
  :root.ph8660-spellbook .ph8662-book-panel .ph8650-navigation>a:hover { background:var(--book-hover); }
}
/* 6. Visible-only finite ambient motion; the existing rarity budget is reused.
   No cursor listeners, particles, timers, blur or content hidden until JS. */
:root.ph8660-spellbook .ph8662-book-panel .ph8660-lit::before { animation:ph8660-illumination 4.8s ease-in-out 3; }
:root.ph8660-spellbook .ph8662-book-panel .ph8660-lit::after { animation:ph8663-chapter-glint 8s ease-in-out 2; }
:root.ph8660-spellbook .ph8662-book-panel .ph8660-lit :is(.ph8600-vault-emblem,.ph8620-shop-crest) { animation:ph8663-relic-drift 5.2s ease-in-out 2; }
:root.ph8660-spellbook .ph8662-book-panel .ph8660-awakened { animation:ph8660-leaf-open .38s ease-out backwards; }
@keyframes ph8660-illumination { 0%,100%{opacity:.4}50%{opacity:.9} }
@keyframes ph8660-leaf-open { from{opacity:.93;transform:translateY(3px)}to{opacity:1;transform:translateY(0)} }
@keyframes ph8663-chapter-glint { 0%,55%{transform:translateX(-110%)}90%,100%{transform:translateX(110%)} }
@keyframes ph8663-relic-drift { 0%,100%{transform:translateY(0)}50%{transform:translateY(-4px)} }
:root.ph8660-spellbook[data-ph-book-motion=paused] .ph8662-book-panel :is(.ph8660-lit::before,.ph8660-lit::after,.ph8660-awakened,.ph8600-vault-emblem,.ph8620-shop-crest) { animation-play-state:paused!important; }
@media(prefers-reduced-motion:reduce) {
  :root.ph8660-spellbook .ph8662-book-panel *,
  :root.ph8660-spellbook .ph8662-book-panel *::before,
  :root.ph8660-spellbook .ph8662-book-panel *::after { animation:none!important; transition:none!important; }
}
@media print {
  :root.ph8660-spellbook .ph8662-book-panel {
    --book-paper:#fff; --book-soft:#fff; --book-raised:#fff; --book-ink:#111; --book-heading:#111;
    --book-muted:#333; --book-line:#aaa; --book-texture:none; --book-wash:none; --book-hero-wash:none;
  }
  :root.ph8660-spellbook .ph8662-book-panel :is(.ph8640-panel,.ph8600-bag,.ph8640-hero,.ph8600-inv-hero,.ph8620-shop-hero) { background:#fff!important; box-shadow:none!important; color:#111!important; }
  :root.ph8660-spellbook .ph8662-book-panel *,
  :root.ph8660-spellbook .ph8662-book-panel *::before,
  :root.ph8660-spellbook .ph8662-book-panel *::after { animation:none!important; transition:none!important; }
}
