:root {
  --ink: #e9f5ef;
  --muted: #9fb7b3;
  --teal-950: #061315;
  --teal-900: #091d20;
  --teal-850: #0d2729;
  --teal-800: #123235;
  --teal-700: #1a4547;
  --cyan: #4ce5dc;
  --cyan-soft: #a5fff7;
  --gold: #f2c96d;
  --coral: #ec785c;
  --line: rgba(140, 215, 207, .17);
  --panel: rgba(7, 24, 26, .94);
  --scale: 1;
}

* {
  box-sizing: border-box;
  scrollbar-width: thin;
  scrollbar-color: var(--teal-700) rgba(6, 19, 21, .72);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: rgba(6, 19, 21, .72); }
*::-webkit-scrollbar-thumb { border: 2px solid rgba(6, 19, 21, .72); border-radius: 99px; background: var(--teal-700); }
*::-webkit-scrollbar-thumb:hover { background: #286164; }
*::-webkit-scrollbar-corner { background: rgba(6, 19, 21, .72); }
html { background: var(--teal-950); color: var(--ink); font-family: "Trebuchet MS", "Gill Sans", sans-serif; font-size: calc(16px * var(--scale)); }
body { margin: 0; min-width: 320px; min-height: 100vh; overflow: hidden; background:
  radial-gradient(circle at 50% 35%, rgba(46, 140, 137, .22), transparent 38%),
  linear-gradient(135deg, #061315 0%, #0b2526 48%, #061719 100%); }
button, input, select, textarea { font: inherit; }
button { color: inherit; }

.app-shell { height: 100vh; min-height: 100vh; display: grid; grid-template-rows: auto minmax(0, 1fr); position: relative; }
.app-shell::before { content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .18; background-image:
  linear-gradient(30deg, transparent 47%, rgba(115, 232, 222, .14) 48%, transparent 49%),
  linear-gradient(150deg, transparent 47%, rgba(115, 232, 222, .10) 48%, transparent 49%); background-size: 46px 80px; }

.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 12px 24px; border-bottom: 1px solid var(--line); background: rgba(4, 17, 19, .9); backdrop-filter: blur(18px); position: relative; z-index: 3; }
.brand-lockup { display: flex; align-items: center; gap: 13px; }
.brand-mark { width: 43px; height: 43px; border: 1px solid rgba(76,229,220,.5); border-radius: 50%; position: relative; box-shadow: inset 0 0 20px rgba(76,229,220,.13), 0 0 24px rgba(76,229,220,.1); }
.brand-mark::before, .brand-mark::after, .brand-mark span { content: ""; position: absolute; inset: 50% auto auto 50%; transform: translate(-50%,-50%); }
.brand-mark::before { width: 100%; height: 1px; background: var(--cyan); }
.brand-mark::after { width: 12px; height: 12px; border: 3px solid var(--teal-950); border-radius: 50%; background: var(--cyan); }
.brand-mark span { width: 29px; height: 29px; border: 1px solid rgba(76,229,220,.5); border-radius: 50%; }
.eyebrow, .section-kicker { margin: 0 0 2px; color: var(--cyan); font-size: .64rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; }
h1 { margin: 0; font-size: 1.65rem; line-height: 1; letter-spacing: .04em; text-transform: uppercase; }
h1 em { color: var(--gold); font-style: italic; font-weight: 400; text-transform: none; }
h2 { margin: 0; font-size: 1.25rem; font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.scale-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .78rem; }
.scale-control input { width: 110px; accent-color: var(--cyan); }
.scale-control output { min-width: 38px; color: var(--ink); }

.button, .icon-button, .text-button, .quick-views button, .category, .item-card { border: 0; cursor: pointer; }
.button { min-height: 38px; padding: 0 16px; border: 1px solid var(--line); border-radius: 5px; background: var(--teal-800); font-weight: 700; font-size: .82rem; transition: .18s ease; }
.button:hover { transform: translateY(-1px); border-color: rgba(76,229,220,.55); }
.button.primary { color: #062022; background: var(--cyan); border-color: transparent; }
.button.ghost { background: rgba(16,54,57,.55); }
.text-button { padding: 0; background: none; color: var(--cyan); font-size: .72rem; }

.workspace { min-height: 0; display: grid; grid-template-columns: minmax(230px, 280px) minmax(420px, 1fr) minmax(330px, 410px); gap: 12px; padding: 12px; position: relative; z-index: 1; }
.panel { min-height: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); box-shadow: 0 20px 50px rgba(0,0,0,.18); }
.control-rail { overflow-y: auto; }
.control-rail section { padding: 18px; border-bottom: 1px solid var(--line); }
.section-heading, .inventory-heading, .modal-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; }

.switch-row { margin-top: 12px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .8rem; cursor: pointer; }
.switch-row input { position: absolute; opacity: 0; }
.switch-row i { width: 38px; height: 20px; border-radius: 99px; background: #173538; position: relative; transition: .2s; }
.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #829a97; transition: .2s; }
.switch-row input:checked + i { background: rgba(76,229,220,.35); }
.switch-row input:checked + i::after { transform: translateX(18px); background: var(--cyan); }

.equipped-list { margin-top: 12px; display: grid; gap: 6px; }
.equipped-item { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 7px; padding: 8px 9px; border: 1px solid transparent; border-radius: 5px; background: rgba(19,51,53,.6); }
.equipped-item span { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .75rem; }
.equipped-item button { width: 24px; height: 24px; border: 0; border-radius: 4px; color: var(--muted); background: rgba(255,255,255,.06); cursor: pointer; }
.dye-dot { width: 13px; height: 13px; border: 1px solid rgba(255,255,255,.5); border-radius: 50%; }
.muted { color: var(--muted); font-size: .76rem; }
.appearance-controls { display: grid; gap: 9px; margin-top: 12px; }
.appearance-controls label { display: grid; gap: 4px; color: var(--muted); font-size: .7rem; }
.appearance-controls select { width: 100%; padding: 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--teal-850); }
.appearance-palette { min-width: 0; margin: -2px 0 2px; padding: 0; border: 0; }
.appearance-palette legend { margin-bottom: 6px; padding: 0; color: var(--muted); font-size: .7rem; }
.appearance-swatches { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.appearance-swatches button { min-width: 0; aspect-ratio: 1.45; border: 2px solid rgba(255,255,255,.16); border-radius: 5px; background: var(--swatch); box-shadow: inset 0 0 0 1px rgba(0,0,0,.18); cursor: pointer; transition: transform .15s, border-color .15s, box-shadow .15s; }
.appearance-swatches button:hover { transform: translateY(-1px); border-color: rgba(255,255,255,.58); }
.appearance-swatches button[aria-pressed="true"] { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(242,201,109,.2), inset 0 0 0 1px rgba(0,0,0,.22); }

.stage-panel { display: grid; grid-template-rows: auto minmax(260px,1fr) auto; overflow: hidden; position: relative; }
.stage-copy { padding: 18px 20px 4px; z-index: 2; }
.stage-copy h2 { font-size: 1.5rem; }
.stage-copy p:last-child { margin: 5px 0 0; color: var(--muted); font-size: .75rem; }
.stage { min-height: 0; display: grid; place-items: center; position: relative; overflow: hidden; }
.stage.grid { background-image: linear-gradient(rgba(108,196,189,.065) 1px, transparent 1px), linear-gradient(90deg, rgba(108,196,189,.065) 1px, transparent 1px); background-size: 32px 32px; background-position: center; }
.stage::after { content: ""; position: absolute; width: min(68%, 520px); aspect-ratio: 1; border: 1px solid rgba(76,229,220,.12); border-radius: 50%; }
.stage-glow { position: absolute; width: 50%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(76,229,220,.16), transparent 68%); filter: blur(10px); }
#outfitPreview { width: min(76%, 650px); height: min(76%, 650px); image-rendering: pixelated; position: relative; z-index: 2; }
.ground-shadow { position: absolute; bottom: 14%; width: 180px; height: 28px; border-radius: 50%; background: rgba(0,0,0,.34); filter: blur(10px); }
.quick-views { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; border-top: 1px solid var(--line); background: var(--line); }
.quick-views button { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: 5px; padding: 6px 10px; color: var(--muted); background: var(--teal-900); text-align: left; }
.quick-views button.active { color: var(--cyan-soft); background: var(--teal-850); }
.quick-views canvas { width: 48px; height: 48px; image-rendering: pixelated; }
.quick-views span { font-size: .72rem; font-weight: 700; }

.inventory-panel { display: grid; grid-template-rows: auto auto auto 1fr; overflow: hidden; }
.inventory-heading { padding: 18px 18px 10px; }
.count-pill { min-width: 38px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 99px; color: var(--cyan-soft); font-size: .7rem; text-align: center; }
.search-wrap { margin: 0 16px 12px; display: grid; grid-template-columns: 30px 1fr; align-items: center; border: 1px solid var(--line); border-radius: 5px; background: rgba(5,17,19,.8); }
.search-wrap span { color: var(--cyan); font-size: 1.2rem; text-align: center; }
.search-wrap input { min-width: 0; padding: 10px 10px 10px 0; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: .78rem; }
.search-wrap input::placeholder { color: #66817e; }
.categories { display: flex; gap: 5px; padding: 0 16px 12px; overflow-x: auto; }
.category { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: transparent; font-size: .67rem; text-transform: capitalize; }
.category.active { color: var(--teal-950); background: var(--gold); border-color: var(--gold); }
.inventory-grid { min-height: 0; display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); align-content: start; gap: 7px; padding: 0 14px 16px; overflow-y: auto; }
.inventory-spacer { grid-column: 1 / -1; min-height: 0; pointer-events: none; }
.item-card { min-width: 0; height: 9.5rem; contain: layout paint style; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 5px; padding: 8px; border: 1px solid rgba(140,215,207,.1); border-radius: 6px; color: var(--ink); background: rgba(17,44,46,.62); position: relative; text-align: left; transition: border-color .16s, transform .16s, background .16s; }
.item-card:hover { transform: translateY(-2px); border-color: rgba(76,229,220,.52); background: rgba(20,58,60,.8); }
.item-card.equipped { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(242,201,109,.24); }
.item-card canvas { width: 100%; height: 100%; min-height: 0; object-fit: contain; image-rendering: pixelated; }
.item-copy { min-width: 0; display: grid; grid-template-rows: 1.7rem 1.5rem; gap: .25rem; }
.item-card strong { overflow: hidden; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; font-size: .67rem; line-height: 1.25; }
.item-card small { display: block; color: var(--muted); font-size: .58rem; line-height: 1.25; text-transform: uppercase; letter-spacing: .04em; }
.availability-badge { position: absolute; z-index: 2; top: 6px; left: 6px; max-width: calc(100% - 12px); overflow: hidden; padding: 3px 5px; border: 1px solid rgba(242,201,109,.5); border-radius: 3px; color: #ffefbd; background: rgba(63,45,13,.92); font-size: .48rem; font-weight: 800; letter-spacing: .04em; line-height: 1; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.availability-badge.confirmed { border-color: rgba(236,120,92,.7); color: #ffd4c8; background: rgba(75,27,20,.94); }

.modal { width: min(760px, calc(100vw - 28px)); max-height: calc(100vh - 28px); padding: 0; border: 1px solid rgba(76,229,220,.35); border-radius: 9px; color: var(--ink); background: #081719; box-shadow: 0 30px 100px rgba(0,0,0,.65); }
.modal::backdrop { background: rgba(0,9,10,.72); backdrop-filter: blur(5px); }
.modal form { padding: 22px; }
.modal-heading { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--teal-850); font-size: 1.25rem; }
.dye-modal { width: min(480px, calc(100vw - 28px)); }
.dye-preview { margin: 18px 0; display: grid; place-items: center; height: 260px; border-radius: 7px; background: radial-gradient(circle, rgba(76,229,220,.12), transparent 65%), #061214; }
.dye-preview canvas { width: 240px; height: 240px; image-rendering: pixelated; }
.color-row { display: grid; grid-template-columns: 1fr 70px 80px; align-items: center; gap: 12px; color: var(--muted); }
.color-row input { width: 70px; height: 36px; border: 0; background: transparent; }
.color-row output { color: var(--ink); font-family: Consolas, monospace; font-size: .8rem; }
.swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 7px; margin-top: 14px; }
.swatches button { aspect-ratio: 1; border: 2px solid rgba(255,255,255,.16); border-radius: 50%; cursor: pointer; }
.modal-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 18px; }
.modal-intro { color: var(--muted); font-size: .78rem; }
.preset-modal form { max-height: calc(100vh - 28px); overflow-y: auto; }
.preset-slots { display: grid; gap: 6px; margin-top: 15px; }
.preset-row { display: grid; grid-template-columns: 32px minmax(100px,1fr) repeat(4,auto); gap: 6px; align-items: center; padding: 7px; background: rgba(19,51,53,.55); }
.preset-row input { min-width: 0; padding: 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: #071416; }
.preset-row button { padding: 7px 9px; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--teal-800); cursor: pointer; font-size: .7rem; }
.preset-row button:disabled { opacity: .35; cursor: default; }
.import-box { display: grid; gap: 7px; margin-top: 18px; color: var(--muted); font-size: .75rem; }
.import-box textarea { min-height: 90px; resize: vertical; padding: 10px; border: 1px solid var(--line); border-radius: 5px; color: var(--ink); background: #061214; }
.modal-status { margin-right: auto; color: var(--cyan-soft); font-size: .72rem; }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 24px; transform: translate(-50%,20px); padding: 11px 16px; border: 1px solid rgba(76,229,220,.4); border-radius: 5px; color: var(--ink); background: #0b2b2d; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { transform: translate(-50%,0); opacity: 1; }
.loading-screen { position: fixed; z-index: 99; inset: 0; display: grid; place-content: center; justify-items: center; background: #061315; transition: opacity .35s, visibility .35s; }
.loading-screen.hidden { opacity: 0; visibility: hidden; }
.loading-screen p { margin: 18px 0 3px; font-family: Georgia, serif; font-size: 1.2rem; }
.loading-screen small { color: var(--muted); }
.loader-orbit { width: 54px; height: 54px; border: 1px solid rgba(76,229,220,.2); border-radius: 50%; position: relative; animation: spin 1.2s linear infinite; }
.loader-orbit::before { content: ""; position: absolute; left: -3px; top: 22px; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 18px var(--cyan); }
.loader-orbit span { position: absolute; inset: 12px; border: 1px solid rgba(242,201,109,.4); border-radius: 50%; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 1120px) {
  body { overflow: auto; }
  .app-shell { height: auto; }
  .workspace { grid-template-columns: 220px minmax(420px,1fr); grid-template-rows: minmax(620px, calc(100vh - 100px)) 620px; }
  .inventory-panel { grid-column: 1 / -1; }
  .inventory-grid { grid-template-columns: repeat(6,minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .topbar { align-items: flex-start; padding: 12px 14px; }
  .scale-control { display: none; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .workspace { display: flex; flex-direction: column; padding: 8px; }
  .stage-panel { order: 1; min-height: 560px; }
  .control-rail { order: 2; max-height: none; overflow: visible; }
  .inventory-panel { order: 3; height: 620px; min-height: 620px; flex: 0 0 620px; }
  .inventory-grid { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .quick-views span { display: none; }
  .quick-views button { grid-template-columns: 1fr; justify-items: center; }
  .preset-row { grid-template-columns: 24px 1fr 1fr; }
  .preset-row button { min-width: 0; }
}
