:root {
  color-scheme: light;
  --paper: #f8f7f1;
  --ink: #272a24;
  --line: #ddded3;
  --serif: 'Baskervville', 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: 'Inter', 'Helvetica Neue', Arial, sans-serif;
  font: 15px/1.45 var(--sans);
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box }
body { max-width: 1700px; min-height: 100svh; margin: auto; }
button, select, a { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button, select { cursor: pointer }
button { border: 0; background: transparent }
a { text-decoration: none }
a:focus-visible, button:focus-visible, select:focus-visible, canvas:focus-visible { outline: 2px solid #925137; outline-offset: -2px }
.topbar { margin: 0 clamp(18px,3.2vw,58px); height: 77px; border-bottom: 1px solid var(--line); display:flex; align-items:center; justify-content:space-between; }
.brand { display: flex; align-items:center; gap: 12px; font: 600 26px/1 var(--serif); letter-spacing: -1.25px; }
.brand-mark { width: 28px; height: 28px; position:relative; display:block; }
.brand-mark i { position:absolute; inset:0; background:#b1764c; clip-path:polygon(50% 0, 100% 25%, 50% 51%, 0 25%) }
.brand-mark i:nth-child(2) { background:#86543d; clip-path:polygon(0 25%, 50% 51%, 50% 100%,0 74%) }
.brand-mark i:nth-child(3) { background:#d8a47a; clip-path:polygon(50% 51%,100% 25%,100% 74%,50% 100%) }
.file-link, .asset-link { display:inline-flex; align-items:center; gap: 8px; font-size: 12px; font-weight: 600; }
.file-link { border:1px solid #c5c8ba; border-radius: 7px; padding: 8px 14px }
.file-link span, .asset-link span { font-size: 16px; line-height: 1 }
.file-link:hover,.asset-link:hover { background:#fff9 }
.atlas-links { display:flex; align-items:center; gap:8px; }
@media(max-width:520px) {
  .topbar { flex-wrap:wrap; height:auto; min-height:60px; gap:6px; padding:6px 0; }
  .atlas-links { gap:5px; }
  .atlas-links .file-link { padding:5px 7px; font-size:11px; }
}
main { padding: clamp(20px,2.5vw,40px) clamp(18px,3.2vw,58px); display:grid; grid-template-columns: minmax(218px,270px) minmax(0,1fr); gap:clamp(22px,3vw,48px) }
aside { padding: 8px 0 }
.library-heading { display:flex; align-items:baseline; justify-content:space-between; margin-bottom:14px }
.library-heading h2 { font:500 31px/1.1 var(--serif); letter-spacing:-1.4px; margin:0 }
.library-heading span,.hint { color:#62685b; font-size:12px }
#species { display:flex; background:#ebece3; padding:4px; border-radius:9px; gap:2px; margin-bottom:12px }
#species button { flex:1; border-radius:6px; font-size:13px; padding:8px 2px; color:#666b60 }
#species button[aria-pressed=true] { color:var(--ink); background:#fffef9; box-shadow:0 1px 4px #444d371c; font-weight:600 }
#characters { display:grid; gap:4px }
.model { display:grid; grid-template-columns:52px 1fr auto; text-align:left; width:100%; gap:13px; align-items:center; padding:6px; border:1px solid transparent; border-radius:10px; }
.model:hover { background:#eceee4 }
.model[aria-pressed=true] { background:#e7ebdf; border-color:#bfc8b1 }
.portrait { width:52px; height:55px; display:block; background-image:url('./images/portraits.png'); background-position:var(--portrait) center; background-size:1200% 100%; background-color:#e9e5da; border-radius:6px }
.model small { display:block; color:#666a5f; font:10px/1.3 ui-monospace, monospace; letter-spacing:1.15px; margin-bottom:4px }
.model strong { font-weight:600; font-size:14px; }
.mark { width:6px; height:6px; border-radius:50%; margin-right:6px; }
[aria-pressed=true] > .mark { background:#63795a }
#mobile-model { display:none }
.style-picker { border-top:1px solid var(--line); margin-top:clamp(16px, 2.4vh, 30px); padding-top:clamp(13px, 2vh, 22px) }
.style-picker h2 { margin:0 0 13px; font:500 25px/1.1 var(--serif); letter-spacing:-1px }
#styles { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; }
#styles button {
  position:relative; display:grid; grid-template-columns:1fr; justify-items:center;
  width:100%; padding:2px 5px 6px; overflow:hidden;
  background:var(--matte); color:#2b302a; border:1px solid #34392d22; border-radius:9px;
  font-size:12px; line-height:1.3; font-weight:600;
}
[data-style="studio"] { --matte:#dde5d6; --light:#edf0e5; --edge:#bccab3; --stage-ink:#495541 }
[data-style="porcelain"] { --matte:#d8e5e8; --light:#f1f7f5; --edge:#b3cbd2; --stage-ink:#3b5360 }
[data-style="toon"] { --matte:#f0e4c8; --light:#fff4d9; --edge:#dbc49c; --stage-ink:#5c503c }
[data-style="clay"] { --matte:#ead2c5; --light:#f9e8d8; --edge:#d4b4a6; --stage-ink:#624a40 }
#styles img { width:100%; height:clamp(46px, 6.5vh, 68px); object-fit:contain; display:block; }
#styles button:hover { border-color:#6e786b }
#styles button[aria-pressed="true"] { border-color:#384936; box-shadow:inset 0 0 0 1px #384936; }
#styles button[aria-pressed="true"]::after {
  content:''; position:absolute; top:6px; right:6px; width:14px; height:14px;
  border-radius:50%; background:#384936;
}
#styles button[aria-pressed="true"]::before {
  content:''; position:absolute; z-index:1; top:9px; right:11px; width:3px; height:6px;
  border:solid white; border-width:0 1.5px 1.5px 0; transform:rotate(42deg);
}
#styles button:disabled { opacity:.55; cursor:default }
.viewer { position:relative; height:calc(100svh - 77px - clamp(40px,5vw,80px)); min-height:520px; max-height:1000px; display:flex; flex-direction:column; overflow:hidden; border-radius:16px; background:radial-gradient(ellipse at 44% 34%,var(--light) 0%,var(--matte) 55%,var(--edge) 115%); border:1px solid var(--edge); }
.stage-heading { padding:clamp(20px,2.5vw,40px) clamp(20px,2.8vw,42px) 0; display:flex; align-items:flex-start; justify-content:space-between; gap:12px }
.caption { min-width:0 }
.eyebrow { text-transform:uppercase; font:600 10px/1.3 var(--sans); letter-spacing:1.9px; color:var(--stage-ink); }
h1 { margin:5px 0; font:500 clamp(34px,3.3vw,58px)/1.05 var(--serif); letter-spacing:-.055em; }
#note { margin:7px 0 0; font-size:13px; color:var(--stage-ink); }
.asset-link { flex:none; padding:7px 10px; border-radius:6px; border:1px solid #41483c38; color:var(--stage-ink) }
#stage { flex:1 1 auto; min-height:0; margin:0 6px; position:relative }
canvas { display:block; width:100%; height:100%; cursor:grab; touch-action:none }
canvas:active { cursor:grabbing }
#status { position:absolute; top:50%; align-self:center; pointer-events:none; color:#484e43; background:#eff1e6; padding:6px 10px; border-radius:5px; font-size:13px }
#status:empty { display:none }
.stage-footer { flex:none; display:flex; flex-wrap:wrap; align-items:end; gap:8px clamp(12px,2vw,32px); padding:4px clamp(16px,2.5vw,40px) 18px; }
.tool-group { display:grid; gap:4px }
#wardrobe { display:flex; align-items:stretch; min-width:0; padding:3px; margin:0; gap:3px; border:1px solid #39433840; border-radius:8px; background:#fffcf275; font-size:12px; }
.shirt-option[hidden] { display:none }
.shirt-option { display:flex; gap:6px; align-items:center; padding:5px 6px; cursor:pointer; }
#shirt { margin:0; accent-color:#394836; cursor:inherit; }
#shirt:focus-visible { outline:2px solid #925137; outline-offset:2px; }
#tops, #bottoms, #headwear { min-width:0; padding:5px 3px 5px 7px; border:0; border-left:1px solid #39433840; border-radius:0; background:transparent; }
#wardrobe:disabled { opacity:.5; }
#wardrobe:disabled :is(.shirt-option, select) { cursor:default; }
.tool-label { color:var(--stage-ink); font-size:11px; font-weight:600; }
.segmented { display:inline-flex; align-items:stretch; border:1px solid #39433840; border-radius:8px; padding:3px; gap:1px; background:#fffcf275; }
.segmented button { min-width:38px; border-radius:5px; padding:6px 9px; font-size:12px }
.segmented button:enabled:hover:not([aria-pressed=true]) { background:#f5f6ee }
.segmented button[aria-pressed=true] { background:#394836; color:#f6f8ef }
.segmented button:disabled { opacity:.45; cursor:default }
.segmented select { border:0; border-radius:5px; padding:6px 8px; font:inherit; font-size:12px; background:transparent; color:inherit; cursor:pointer; max-width:9.5em }
.segmented select:enabled:hover { background:#f5f6ee }
.segmented select:disabled { opacity:.45; cursor:default }
#playback { border-left:1px solid #b8c2ad; border-radius:0 5px 5px 0; min-width:34px; margin-left:2px; display:grid; place-items:center }
#playback span { display:block; width:10px; height:12px; background:currentColor; clip-path:polygon(14% 0, 100% 50%, 14% 100%) }
#playback[data-playing=true] span { clip-path:none; background:linear-gradient(to right,currentColor 36%,transparent 36% 64%,currentColor 64%); height:10px }
.hint { margin:auto 0 10px auto; color:var(--stage-ink) }
.hint b { padding:0 4px; font-weight:normal }
@media(max-width:920px) {
  main { grid-template-columns:205px minmax(0,1fr); gap:18px }
  .model { gap:9px; padding:6px; grid-template-columns:52px 1fr auto }
  .portrait {width:52px;height:55px}
}
@media(max-width:1100px) { .hint { display:none } }
@media(max-width:740px) {
  .topbar { height:60px }
  .brand { font-size:23px }
  main { display:flex; flex-direction:column; gap:14px; padding:14px 12px }
  aside { padding:0 2px }
  .collection { display:flex; align-items:center; gap:14px; }
  .library-heading { margin:0; }
  .library-heading h2 { font:600 13px var(--sans); letter-spacing:0 }
  .library-heading span,#species,#characters { display:none }
  #mobile-model { display:block; flex:1; border:1px solid #c8cdbf; border-radius:6px; background:#eeefe6; padding:8px; font-size:14px; min-width:0 }
  .style-picker { margin-top:11px; padding:0; border:0 }
  .style-picker h2 { margin:0 0 6px; font:600 13px/1.25 var(--sans); letter-spacing:0 }
  #styles { grid-template-columns:repeat(4, minmax(0,1fr)); gap:6px }
  #styles button { padding-bottom:5px; }
  #styles img { height:36px }
  .viewer { height:auto; min-height:calc(100svh - 232px); border-radius:12px }
  #stage { flex:1 0 225px }
  #stage canvas { position:absolute; inset:0 }
  .stage-heading { padding:15px 15px 0 }
  #note { margin-top:4px }
  .asset-link { padding:6px 8px }
  .stage-footer { padding:2px 12px 10px; justify-content:center; gap:8px 16px }
}
@media(max-width:450px) {
  .stage-footer { display:grid; grid-template-columns:max-content minmax(0, 200px); align-items:center; gap:5px 10px; padding:5px 12px 12px }
  .tool-group { display:contents }
  .segmented { gap:1px; padding:2px }
  .segmented button { flex:1; min-width:34px; padding:7px 4px }
  .wardrobe-group { display:grid; grid-column:1/-1; grid-template-columns:subgrid; align-items:center }
  #wardrobe { flex-wrap:wrap; }
  #headwear { flex:1 1 100%; border-left:0; border-top:1px solid #39433840; }
  #bottoms { flex:1 }
}
