:root {
  --paper: #fdf6ec; --paper-2: #f6eadb; --latte: #c8a27a; --latte-2: #e2c9a6; --espresso: #4a3626; --mocha: #6f4e37;
  --blush: #f5c6c6; --sage: #b7cdb0; --neon: #b44cff; --neon-glow: 0 0 24px #b44cff88, 0 0 48px #b44cff44;
  --ink: #2a1f16; --muted: #8a6f5a; --card: #fffaf3; --shadow: 0 8px 24px rgba(74, 54, 38, .12), 0 2px 6px rgba(74, 54, 38, .08);
  --radius: 20px; --font: 'Fredoka', 'SF Pro Rounded', ui-rounded, 'Nunito', system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font); overscroll-behavior: none; }
body { -webkit-font-smoothing: antialiased; }
button { user-select: none; -webkit-user-select: none; font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
button:active { transform: scale(.96); }
h1, h2, h3 { margin: 0; font-weight: 600; }
#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.screen-enter { animation: fadeUp .28s ease-out both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.error { padding: 24px; color: #b3261e; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 999px; font-weight: 600; font-size: 16px; transition: transform .12s, box-shadow .2s, background .2s; }
.btn.primary { background: var(--espresso); color: var(--paper); box-shadow: var(--shadow); }
.btn.ghost { background: var(--paper-2); color: var(--espresso); }
.btn.danger { background: #e25c5c; color: #fff; }
.btn.neon { background: linear-gradient(135deg, #c56bff, var(--neon)); color: #fff; box-shadow: var(--neon-glow); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; display: inline-flex; align-items: center; justify-content: center; font-size: 20px; color: var(--espresso); background: var(--paper-2); transition: background .15s; }
.icon-btn:disabled { opacity: .35; }
.icon-btn.active { background: var(--espresso); color: var(--paper); }
.icon-btn[data-glitter].active { background: linear-gradient(135deg, #ffd166, #ff8fab); box-shadow: 0 0 16px #ffb3c688; }

/* ---------- splash ---------- */
.splash { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; text-align: center; background: radial-gradient(circle at 50% 30%, #fff5e6, var(--paper) 60%); cursor: pointer; }
.splash .logo { width: 160px; height: 160px; filter: drop-shadow(0 10px 20px rgba(74,54,38,.18)); }
.splash h1 { font-size: 36px; color: var(--espresso); letter-spacing: .5px; }
.splash .tag { color: var(--muted); font-size: 18px; margin-top: -8px; }
.splash .bar { width: 180px; height: 8px; border-radius: 8px; background: var(--paper-2); overflow: hidden; margin-top: 22px; }
.splash .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--latte), var(--neon)); border-radius: 8px; animation: fill 2.1s ease-in-out forwards; }
@keyframes fill { to { width: 100%; } }
.steam { animation: steam 2.6s ease-in-out infinite; transform-origin: 50% 100%; opacity: .8; }
.steam:nth-child(2) { animation-delay: .6s; } .steam:nth-child(3) { animation-delay: 1.2s; }
@keyframes steam { 0% { transform: translateY(4px) scaleX(1); opacity: 0; } 40% { opacity: .9; } 100% { transform: translateY(-16px) scaleX(1.15); opacity: 0; } }

/* ---------- home ---------- */
.home { display: flex; flex-direction: column; padding: calc(var(--safe-top) + 18px) 18px calc(var(--safe-bottom) + 110px); overflow-y: auto; gap: 18px; }
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.home-head .greet { color: var(--muted); font-size: 15px; }
.home-head h1 { font-size: 28px; color: var(--espresso); line-height: 1.1; }
.coin-badge { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border-radius: 999px; background: #fff3c4; color: #8a6508; font-weight: 600; box-shadow: inset 0 0 0 1.5px #f4d35e; white-space: nowrap; }
.home-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; color: var(--espresso); font-size: 18px; }
.section-title small { color: var(--muted); font-weight: 400; font-size: 13px; }
.wip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.wip-card { position: relative; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; text-align: left; display: flex; flex-direction: column; transition: transform .15s; }
.wip-card:active { transform: scale(.97); }
.wip-card .thumb { aspect-ratio: 4 / 5; background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.wip-card .thumb img, .wip-card .thumb svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.wip-card .meta { padding: 10px 12px 12px; }
.wip-card .name { font-weight: 600; color: var(--espresso); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wip-card .time { color: var(--muted); font-size: 12px; }
.wip-card .more { position: absolute; top: 8px; right: 8px; width: 34px; height: 34px; border-radius: 12px; background: rgba(255,250,243,.92); color: var(--espresso); font-size: 18px; font-weight: 700; box-shadow: var(--shadow); display: flex; align-items: center; justify-content: center; }
.empty { text-align: center; padding: 36px 20px; color: var(--muted); background: var(--paper-2); border-radius: var(--radius); }
.empty .art { font-size: 54px; margin-bottom: 8px; }
.fab { position: fixed; right: 22px; bottom: calc(var(--safe-bottom) + 22px); width: 66px; height: 66px; border-radius: 50%; background: linear-gradient(135deg, #d08bff, var(--neon)); color: #fff; font-size: 40px; line-height: 1; display: flex; align-items: center; justify-content: center; box-shadow: var(--neon-glow), 0 10px 24px rgba(180,76,255,.35); animation: pulse 2.4s ease-in-out infinite; z-index: 5; }
.fab span { margin-top: -4px; }
@keyframes pulse { 0%, 100% { box-shadow: var(--neon-glow), 0 10px 24px rgba(180,76,255,.35); } 50% { box-shadow: 0 0 34px #b44cffaa, 0 0 70px #b44cff55, 0 10px 24px rgba(180,76,255,.35); } }

/* ---------- gallery / shop ---------- */
.page-head { display: flex; align-items: center; gap: 12px; padding: calc(var(--safe-top) + 12px) 14px 10px; }
.page-head h1 { font-size: 22px; color: var(--espresso); flex: 1; }
.gallery { padding: 0 18px calc(var(--safe-bottom) + 24px); overflow-y: auto; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.shop { padding: 0 18px calc(var(--safe-bottom) + 24px); overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.shop-intro { color: var(--muted); font-size: 14px; margin: 0 0 4px; }
.shop-item { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.shop-item .icon { font-size: 34px; width: 52px; text-align: center; }
.shop-item .info { flex: 1; min-width: 0; }
.shop-item .info strong { display: block; color: var(--espresso); }
.shop-item .info small { color: var(--muted); display: block; font-size: 13px; }
.shop-item .swatches { display: flex; gap: 4px; margin-top: 6px; }
.shop-item .swatches i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
.shop-item .buy { padding: 10px 14px; font-size: 14px; min-width: 92px; }
.shop-item .buy.owned { background: var(--sage); color: #2f4a31; }

/* ---------- studio ---------- */
.studio { background: var(--paper-2); }
.topbar { display: flex; align-items: center; gap: 6px; padding: calc(var(--safe-top) + 8px) 10px 8px; background: var(--paper); box-shadow: 0 1px 0 rgba(74,54,38,.08); z-index: 2; }
.topbar .spacer { flex: 1; }
.topbar .title { font-weight: 600; color: var(--espresso); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 30vw; }
.topbar .done { padding: 10px 16px; font-size: 15px; }
.meter { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 64px; }
.meter .coins { font-size: 13px; font-weight: 600; color: #8a6508; }
.meter .bar { width: 56px; height: 6px; border-radius: 6px; background: rgba(74,54,38,.12); overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #f4d35e, #ffb347); transition: width .3s; }
.studio-stage { flex: 1; min-height: 0; position: relative; }
.painter-host { position: absolute; inset: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--paper-2); cursor: crosshair; }
.painter-viewport { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fdf6ec; box-shadow: 0 10px 40px rgba(74,54,38,.25); }
.painter-viewport canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.painter-viewport .lines { mix-blend-mode: multiply; pointer-events: none; }
.painter-viewport .overlay, .painter-viewport .sparkle { pointer-events: none; }
.painter-host.lights-off { background: #120d24; }
.painter-host.lights-off .painter-viewport { background: #1b1433; }
.painter-host.lights-off .lines { mix-blend-mode: screen; filter: invert(1) opacity(.7); }
.painter-host.lights-off .overlay { filter: drop-shadow(0 0 8px #b44cff); }
.hint { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: rgba(74,54,38,.85); color: var(--paper); font-size: 13px; padding: 7px 12px; border-radius: 999px; pointer-events: none; white-space: nowrap; opacity: 0; transition: opacity .2s; }
.hint.show { opacity: 1; }

/* ---------- toolbar ---------- */
.toolbar { background: var(--paper); border-radius: 22px 22px 0 0; box-shadow: 0 -6px 24px rgba(74,54,38,.12); padding: 8px 12px calc(var(--safe-bottom) + 10px); display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.tb-handle { width: 44px; height: 5px; border-radius: 5px; background: rgba(74,54,38,.2); margin: 0 auto 2px; }
.tb-row { display: flex; align-items: center; gap: 8px; }
.tools { overflow-x: auto; scrollbar-width: none; }
.tools::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 10px; border-radius: 14px; background: var(--paper-2); color: var(--mocha); font-size: 11px; font-weight: 500; min-width: 58px; transition: background .15s, color .15s, transform .12s; }
.chip .ico { font-size: 20px; line-height: 1; }
.chip.active { background: var(--espresso); color: var(--paper); }
.chip.glow.active { background: linear-gradient(135deg, #c56bff, var(--neon)); box-shadow: var(--neon-glow); }
.size-wrap { display: flex; align-items: center; gap: 6px; margin-left: auto; padding-left: 6px; color: var(--muted); font-size: 12px; }
input[type=range].size { width: 90px; accent-color: var(--espresso); }
.seg { display: flex; background: var(--paper-2); border-radius: 14px; padding: 3px; gap: 2px; }
.seg button { padding: 8px 14px; border-radius: 11px; font-size: 13px; font-weight: 600; color: var(--mocha); transition: background .15s, color .15s; }
.seg button.active { background: var(--espresso); color: var(--paper); }
.seg button.guide.active { background: var(--neon); }
.mode-hint { color: var(--muted); font-size: 12px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.colors { gap: 10px; }
.cur-swatch { width: 44px; height: 44px; border-radius: 14px; box-shadow: inset 0 0 0 3px #fff, 0 2px 8px rgba(0,0,0,.18); flex-shrink: 0; position: relative; }
.cur-swatch::after { content: '▾'; position: absolute; right: -2px; bottom: -4px; font-size: 12px; background: var(--paper); color: var(--espresso); border-radius: 50%; width: 16px; height: 16px; line-height: 16px; text-align: center; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.cur-swatch.open::after { content: '▴'; }
.swatch-row { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 3px 2px; }
.swatch-row::-webkit-scrollbar { display: none; }
.swatch { width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .12s; }
.swatch.active { box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 5px var(--espresso); transform: scale(1.05); }
.swatch.glow-on.active { box-shadow: 0 0 0 2.5px var(--paper), 0 0 0 5px var(--neon), var(--neon-glow); }
.picker-wrap { display: none; flex-direction: column; gap: 6px; padding-top: 4px; max-height: 44vh; overflow-y: auto; }
.picker-wrap.open { display: flex; }
.picker-head { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 13px; }
.picker-head .btn { padding: 8px 14px; font-size: 13px; }
.picker { display: none; flex-direction: column; gap: 10px; }
.picker.open { display: flex; }
.hue, .sv { position: relative; border-radius: 12px; overflow: hidden; touch-action: none; }
.hue { height: 26px; }
.sv { height: 120px; }
.hue canvas, .sv canvas { width: 100%; height: 100%; display: block; }
.pk-marker { position: absolute; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.3), 0 2px 6px rgba(0,0,0,.25); transform: translate(-50%, -50%); pointer-events: none; }
.pal { display: flex; align-items: center; gap: 8px; }
.pal .pal-name { width: 78px; font-size: 12px; color: var(--muted); flex-shrink: 0; }
.pal .swatch-row { flex: 1; }
.hex { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- dialogs ---------- */
.backdrop { position: fixed; inset: 0; background: rgba(42,31,22,.35); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .18s; z-index: 50; }
.backdrop.show { opacity: 1; }
.backdrop.bottom { align-items: flex-end; padding: 0; }
.backdrop.clear { background: transparent; }
.dialog { background: var(--card); border-radius: 24px; padding: 24px 22px 18px; width: min(360px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); transform: scale(.95); transition: transform .18s; }
.backdrop.show .dialog { transform: none; }
.dialog h2 { font-size: 20px; color: var(--espresso); margin-bottom: 6px; }
.dialog p { color: var(--muted); margin: 0 0 18px; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; }
.input { width: 100%; font: inherit; font-size: 17px; padding: 12px 14px; border-radius: 14px; border: 2px solid var(--latte-2); background: var(--paper); color: var(--ink); margin-bottom: 16px; outline: none; }
.input:focus { border-color: var(--neon); }
.sheet { width: 100%; background: var(--card); border-radius: 26px 26px 0 0; padding: 10px 18px calc(var(--safe-bottom) + 22px); transform: translateY(30px); transition: transform .2s; box-shadow: 0 -10px 40px rgba(0,0,0,.2); }
.backdrop.show .sheet { transform: none; }
.sheet-handle { width: 44px; height: 5px; border-radius: 5px; background: rgba(74,54,38,.2); margin: 0 auto 14px; }
.sheet h2 { font-size: 20px; color: var(--espresso); margin-bottom: 14px; }
.sheet-options { display: flex; flex-direction: column; gap: 10px; }
.sheet-option { display: flex; align-items: center; gap: 14px; text-align: left; background: var(--paper-2); border-radius: 18px; padding: 14px 16px; transition: background .15s; }
.sheet-option:hover { background: var(--latte-2); }
.sheet-option .sheet-icon { font-size: 30px; width: 44px; text-align: center; }
.sheet-option strong { display: block; color: var(--espresso); font-size: 17px; }
.sheet-option small { color: var(--muted); }
.menu { position: fixed; background: var(--card); border-radius: 16px; box-shadow: 0 12px 36px rgba(0,0,0,.22); padding: 6px; width: 190px; display: flex; flex-direction: column; }
.menu-item { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 11px; text-align: left; font-weight: 500; color: var(--espresso); }
.menu-item:hover { background: var(--paper-2); }
.menu-item.danger { color: #c43f3f; }
#toast { position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 96px); transform: translate(-50%, 20px); background: var(--espresso); color: var(--paper); padding: 12px 18px; border-radius: 999px; font-weight: 500; box-shadow: var(--shadow); opacity: 0; transition: opacity .2s, transform .2s; z-index: 60; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .home { padding-left: 32px; padding-right: 32px; max-width: 1000px; width: 100%; margin: 0 auto; }
  .toolbar { padding-left: 20px; padding-right: 20px; }
}

/* ---------- v3: themes ---------- */
:root[data-theme="lavender"] { --paper: #f6f0fb; --paper-2: #ece2f7; --latte: #b79ad9; --latte-2: #d7c4ef; --espresso: #4b2e6f; --mocha: #6e4c96; --blush: #f2c9e6; --sage: #cfd9b6; --card: #fcf8ff; --muted: #8b6fa8; --ink: #2a1b3d; }
:root[data-theme="matcha"] { --paper: #f3f7ec; --paper-2: #e4ecd6; --latte: #9fbd7a; --latte-2: #c6d9ad; --espresso: #3e5a2f; --mocha: #5e7c4a; --blush: #f2d9c9; --sage: #b7cdb0; --card: #fbfdf6; --muted: #6f8a5d; --ink: #203019; }
:root[data-theme="midnight"] { --paper: #1d1828; --paper-2: #2a2238; --latte: #8d6ab8; --latte-2: #4a3c62; --espresso: #f1e6ff; --mocha: #cdb7ea; --blush: #5a3950; --sage: #3c5a45; --card: #2b2340; --muted: #a28ec4; --ink: #f3ecff; --shadow: 0 8px 24px rgba(0,0,0,.45), 0 2px 6px rgba(0,0,0,.3); }
:root[data-theme="midnight"] .btn.primary { background: #b44cff; color: #fff; }
:root[data-theme="midnight"] .studio, :root[data-theme="midnight"] .painter-host { background: #141021; }
:root[data-theme="midnight"] .wip-card .thumb { background: #3a3050; }
:root[data-theme="midnight"] .coin-badge { background: #4a3a12; color: #ffd97a; box-shadow: inset 0 0 0 1.5px #a8862a; }
:root[data-theme="midnight"] .hint, :root[data-theme="midnight"] #toast { background: #f1e6ff; color: #2a1b3d; }
:root[data-theme="midnight"] .dialog h2, :root[data-theme="midnight"] .sheet h2, :root[data-theme="midnight"] .home-head h1 { color: #f1e6ff; }

/* ---------- v3: fx row, stickers, patterns, shop sections, confetti ---------- */
.fx-row { gap: 6px; overflow-x: auto; scrollbar-width: none; }
.fx-row::-webkit-scrollbar { display: none; }
.fx { display: inline-flex; align-items: center; gap: 5px; padding: 7px 11px; border-radius: 999px; background: var(--paper-2); color: var(--mocha); font-size: 12px; font-weight: 600; white-space: nowrap; }
.fx.active { background: var(--espresso); color: var(--paper); }
.fx.glitter.active { background: linear-gradient(135deg, #ffd166, #ff8fab); color: #3a1d2a; }
.fx.lights.active { background: #1b1433; color: #ffe9a8; }
.sub-row { gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sub-row::-webkit-scrollbar { display: none; }
.sub-row .label { color: var(--muted); font-size: 12px; flex-shrink: 0; }
.mini { padding: 6px 10px; border-radius: 12px; background: var(--paper-2); color: var(--mocha); font-size: 12px; font-weight: 600; white-space: nowrap; }
.mini.active { background: var(--espresso); color: var(--paper); }
.mini .big { font-size: 18px; }
.shop-section { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.shop-section h2 { font-size: 17px; color: var(--espresso); }
.shop-section h2 small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.shop-item .buy.active { background: var(--latte-2); color: var(--espresso); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 80; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 10px; height: 14px; border-radius: 2px; animation: confettiFall 1.6s ease-in forwards; }
@keyframes confettiFall { 0% { transform: translateY(0) rotate(0); opacity: 1; } 100% { transform: translateY(105vh) rotate(720deg); opacity: .8; } }
.paper-swatches { display: flex; gap: 10px; flex-wrap: wrap; padding: 4px 0 10px; }
.paper-swatch { width: 52px; height: 52px; border-radius: 14px; box-shadow: inset 0 0 0 2px rgba(0,0,0,.08); display: flex; align-items: flex-end; justify-content: center; font-size: 10px; color: #4a3626; padding-bottom: 4px; }
.paper-swatch.active { box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--neon); }
.theme-btn { margin-left: 6px; }

/* ---------- v5: gallery categories, shop filters ---------- */
.page-head h1 small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.cat-tabs { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 0 18px 12px; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab { flex-shrink: 0; padding: 9px 14px; border-radius: 999px; background: var(--paper-2); color: var(--mocha); font-weight: 600; font-size: 14px; white-space: nowrap; }
.cat-tab i { font-style: normal; opacity: .6; font-size: 12px; margin-left: 2px; }
.cat-tab.active { background: var(--espresso); color: var(--paper); }
.shop-filters { display: flex; gap: 8px; padding: 0 0 6px; }
.shop-filters .cat-tab { font-size: 13px; padding: 8px 12px; }
.shop-empty { text-align: center; color: var(--muted); padding: 30px 10px; background: var(--paper-2); border-radius: var(--radius); }

.gallery .wip-card .thumb { background: #fdf6ec; }

/* ---------- v6: my gallery ---------- */
.gallery-strip { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; text-align: left; width: 100%; }
.strip-thumbs { display: flex; }
.strip-thumbs img { width: 44px; height: 54px; object-fit: cover; border-radius: 6px; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); margin-right: -14px; background: #fdf6ec; }
.strip-thumbs img:last-child { margin-right: 0; }
.strip-empty { font-size: 30px; }
.strip-text { flex: 1; display: flex; flex-direction: column; }
.strip-text strong { color: var(--espresso); } .strip-text small { color: var(--muted); }
.strip-arrow { font-size: 26px; color: var(--muted); }
.btn.small { padding: 9px 14px; font-size: 13px; }
.gallery-wall { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; padding: 14px 22px calc(var(--safe-bottom) + 30px); background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.35), transparent 50%), var(--paper-2); align-content: start; }
.gallery-wall .empty { grid-column: 1 / -1; }
.art-empty { font-size: 54px; margin-bottom: 8px; }
.art { position: relative; display: flex; flex-direction: column; align-items: center; transform: rotate(var(--tilt, 0deg)); transition: transform .2s; text-align: center; padding-top: 14px; }
.art:hover { transform: rotate(0deg) scale(1.03); }
.art .hook { position: absolute; top: 0; left: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--latte); transform: translateX(-50%); box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.art .hook::after { content: ''; position: absolute; left: 3px; top: 6px; width: 2px; height: 10px; background: var(--latte); }
.art .frame { background: #fff; padding: 8px; border: 8px solid var(--mocha); border-radius: 3px; box-shadow: 0 12px 26px rgba(74,54,38,.28), inset 0 0 0 1px rgba(0,0,0,.08); width: 100%; }
.art .frame img { display: block; width: 100%; aspect-ratio: 4 / 5; object-fit: cover; background: #fdf6ec; }
.plaque { margin-top: 8px; background: var(--latte-2); color: var(--espresso); border-radius: 6px; padding: 5px 10px; font-size: 12px; display: flex; flex-direction: column; max-width: 100%; }
.plaque strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plaque span { color: var(--mocha); font-size: 11px; }
.backdrop.lightbox { background: rgba(20, 12, 30, .8); }
.lb { position: relative; width: min(560px, 100%); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.lb-frame { background: #fff; padding: 10px; border: 10px solid var(--mocha); border-radius: 3px; box-shadow: 0 20px 60px rgba(0,0,0,.5); max-height: 62vh; }
.lb-frame img { display: block; max-height: calc(62vh - 40px); max-width: 100%; width: auto; height: auto; }
.lb-meta { color: #fff; display: flex; gap: 12px; align-items: baseline; } .lb-meta span { opacity: .7; font-size: 13px; }
.lb-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.lb-actions .btn { padding: 10px 14px; font-size: 14px; }
.lb-actions .btn.ghost { background: rgba(255,255,255,.15); color: #fff; }
.lb-close { position: absolute; top: -8px; right: -4px; background: rgba(255,255,255,.15); color: #fff; }

/* ---------- v11: account ---------- */
.account { padding: 0 18px calc(var(--safe-bottom) + 24px); display: flex; flex-direction: column; gap: 12px; overflow-y: auto; }
.account .btn.wide { width: 100%; padding: 15px 20px; }
.account-note { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 2px 0 6px; }
.acct-card { display: flex; align-items: center; gap: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.acct-avatar { font-size: 38px; }
.acct-card strong { display: block; color: var(--espresso); font-size: 17px; }
.acct-card small { color: var(--muted); }
.turnstile-host { display: flex; justify-content: center; min-height: 0; }

/* ---------- v12: handshake return ---------- */
.signin-wait { align-items: center; text-align: center; padding-top: 22vh; gap: 6px; }
.signin-wait h1 { font-size: 22px; color: var(--espresso); }
.signin-wait .acct-avatar { font-size: 56px; animation: pulse 2.4s ease-in-out infinite; }

/* ============================================================
   v13 — phones and tablets
   ============================================================ */

/* iOS inflates text in landscape unless told not to, and double-tap-to-zoom
   adds a 300ms delay to every tap. The painter sets `touch-action: none` on
   itself, which is stricter and still wins there. */
html { -webkit-text-size-adjust: 100%; }
body { touch-action: manipulation; -webkit-touch-callout: none; }

/* Landscape on a phone: the bottom toolbar used to eat 45% of the height and
   left the page at 12% scale — unusable. Move it to a side rail so the canvas
   keeps the full height, which is the only dimension that matters here. */
@media (orientation: landscape) and (max-height: 600px) {
  .studio.screen {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 210px;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .topbar { grid-column: 1 / -1; padding-top: calc(var(--safe-top) + 4px); padding-bottom: 4px; }
  .topbar .title { max-width: 22vw; }
  .studio-stage { grid-column: 1; grid-row: 2; min-height: 0; }
  .toolbar-host { grid-column: 2; grid-row: 2; min-height: 0; display: flex; }
  .toolbar {
    width: 100%; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 22px 0 0 0;
    box-shadow: -6px 0 24px rgba(74, 54, 38, .12);
    padding: 8px 10px calc(var(--safe-bottom) + 10px);
    padding-right: calc(env(safe-area-inset-right, 0px) + 10px);
  }
  .tb-handle { display: none; }
  .tb-row { flex-wrap: wrap; }
  .tools { overflow: visible; }
  .toolbar .chip { flex: 1 1 44%; min-width: 0; padding: 5px 4px; font-size: 10px; }
  .chip .ico { font-size: 17px; }
  .size-wrap { width: 100%; margin-left: 0; padding-left: 0; }
  input[type=range].size { width: 100%; }
  .modes .seg { width: 100%; flex-wrap: wrap; }
  .toolbar .seg button { flex: 1 1 auto; padding: 7px 6px; font-size: 12px; }
  .mode-hint, .hex { display: none; }
  .swatch-row.quick { overflow: visible; flex-wrap: wrap; }
  .toolbar .swatch { width: 34px; height: 34px; }
  .toolbar .fx { flex: 1 1 auto; font-size: 11px; padding: 6px 8px; }
  .picker-wrap { max-height: none; }
  .sub-row { overflow: visible; }
  /* A bottom sheet in a 390px-tall window has to stay reachable. */
  .sheet { max-height: 86vh; overflow-y: auto; }
  .dialog { max-height: 86vh; overflow-y: auto; }
  .lb-frame { max-height: 52vh; }
  .lb-frame img { max-height: calc(52vh - 40px); }
}

/* Tablets and up: stop lines running to 100+ characters, and let cards breathe
   rather than multiplying into a contact sheet. */
@media (min-width: 720px) {
  .account, .shop, .shop-filters { max-width: 720px; margin-inline: auto; width: 100%; }
  .page-head { max-width: 1000px; margin-inline: auto; width: 100%; }
  .gallery, .cat-tabs { max-width: 1000px; margin-inline: auto; width: 100%; }
  .wip-grid, .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
  .gallery-wall { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); max-width: 1000px; margin-inline: auto; width: 100%; }
  .account-note { font-size: 15px; }
}

/* Wide screens: the toolbar controls were stranded at either end of a very
   wide bar with dead space between them. Cap the run and centre it. The
   min-height guard keeps this away from the landscape side rail above. */
@media (min-width: 900px) and (min-height: 601px) {
  .toolbar { padding-left: max(20px, calc((100vw - 880px) / 2)); padding-right: max(20px, calc((100vw - 880px) / 2)); }
}

/* Little fingers: Apple asks for 44pt targets and the toolbar was shipping
   32px mode buttons and 30px swatches. Portrait/tablet gets the bigger hits;
   the landscape side rail above deliberately stays compact, because there the
   scarce resource is height and the canvas needs it more. */
.seg button { padding: 14px 14px; }
.swatch { width: 36px; height: 36px; }
.mini { padding: 9px 12px; }
.fx { padding: 9px 12px; }
.pk-marker { width: 22px; height: 22px; }
.hue { height: 32px; }
