@font-face{font-family:'Fraunces';font-style:italic;font-weight:500;font-display:swap;src:url('fonts/fraunces-italic.woff2') format('woff2');}
@font-face{font-family:'Fraunces';font-style:normal;font-weight:500;font-display:swap;src:url('fonts/fraunces-normal.woff2') format('woff2');}
@font-face{font-family:'Fraunces';font-style:normal;font-weight:600;font-display:swap;src:url('fonts/fraunces-normal.woff2') format('woff2');}
@font-face{font-family:'Fraunces';font-style:normal;font-weight:700;font-display:swap;src:url('fonts/fraunces-normal.woff2') format('woff2');}
@font-face{font-family:'Work Sans';font-style:normal;font-weight:400;font-display:swap;src:url('fonts/work-sans.woff2') format('woff2');}
@font-face{font-family:'Work Sans';font-style:normal;font-weight:500;font-display:swap;src:url('fonts/work-sans.woff2') format('woff2');}
@font-face{font-family:'Work Sans';font-style:normal;font-weight:600;font-display:swap;src:url('fonts/work-sans.woff2') format('woff2');}
@font-face{font-family:'Work Sans';font-style:normal;font-weight:700;font-display:swap;src:url('fonts/work-sans.woff2') format('woff2');}

:root{
  --bg:#EEF0F2; --surface:#FFFFFF; --surface-2:#E2E5EA; --surface-3:#D6DAE0;
  --text:#15171A; --text-dim:#5B6168; --accent:#5B3DF5; --accent-ink:#FFFFFF;
  --danger:#E03131; --success:#2F9E44; --border:#D6DAE0;
  --font-display:'Fraunces', Georgia, serif; --font-body:'Work Sans', system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){
    --bg:#15161A; --surface:#1E2026; --surface-2:#272A31; --surface-3:#343843;
    --text:#EDEEF0; --text-dim:#9AA0A8; --accent:#8C7CFB; --accent-ink:#15161A;
    --danger:#FF6B6B; --success:#51CF66; --border:#343843; color-scheme: dark;
  }
}
:root[data-theme="dark"]{
  --bg:#15161A; --surface:#1E2026; --surface-2:#272A31; --surface-3:#343843;
  --text:#EDEEF0; --text-dim:#9AA0A8; --accent:#8C7CFB; --accent-ink:#15161A;
  --danger:#FF6B6B; --success:#51CF66; --border:#343843; color-scheme: dark;
}
*{box-sizing:border-box;}
html,body{height:100%;}
body{margin:0;background:var(--bg);color:var(--text);font-family:var(--font-body);font-size:15px;line-height:1.4;-webkit-tap-highlight-color:transparent;}
button{font-family:inherit;cursor:pointer;}
h1,h2,h3{font-family:var(--font-display);margin:0;line-height:1.25;}
svg.i{width:1.15em;height:1.15em;stroke:currentColor;stroke-width:2;fill:none;stroke-linecap:round;stroke-linejoin:round;vertical-align:-0.2em;flex:none;}
[hidden]{display:none!important;}

body::before{content:"";position:fixed;inset:0 0 auto;height:env(safe-area-inset-top,0px);z-index:30;background:var(--surface);}

header{background:var(--surface);border-bottom:1px solid var(--border);box-shadow:0 2px 6px rgba(0,0,0,.06);position:sticky;top:env(safe-area-inset-top,0px);z-index:31;}
.header-inner{padding:12px max(16px,env(safe-area-inset-left,0px)) 10px max(16px,env(safe-area-inset-right,0px));}
.brand{display:flex;align-items:baseline;gap:8px;margin-bottom:10px;}
.brand h1{font-size:1.25rem;font-weight:700;letter-spacing:-0.01em;}
.album-row{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none;}
.album-row::-webkit-scrollbar{display:none;}
.chip{flex:none;display:flex;align-items:center;gap:8px;padding:5px 14px 5px 5px;border-radius:999px;border:1px solid var(--border);background:var(--surface-2);color:var(--text-dim);font-size:.85rem;font-weight:500;white-space:nowrap;max-width:180px;}
.chip.active{background:var(--accent);color:var(--accent-ink);border-color:var(--accent);}
.chip-thumb{flex:none;width:34px;height:34px;border-radius:9px;overflow:hidden;background:var(--surface-3);display:flex;align-items:center;justify-content:center;color:var(--text-dim);}
.chip-thumb canvas{width:100%;height:100%;display:block;}
.chip-thumb.empty svg{width:16px;height:16px;}
.chip.active .chip-thumb.empty{background:rgba(255,255,255,.22);color:var(--accent-ink);}
.chip-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;}
.chip-add{flex:none;width:44px;height:44px;border-radius:50%;border:1px dashed var(--border);background:transparent;color:var(--text-dim);display:flex;align-items:center;justify-content:center;}

main{padding:48px max(16px,env(safe-area-inset-left,0px)) calc(100px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-right,0px));max-width:1100px;margin:0 auto;}
.toolbar{display:flex;align-items:center;gap:10px;margin-bottom:12px;min-width:0;}
.album-current{font-family:var(--font-display);font-size:1.15rem;font-weight:600;line-height:1.25;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.count-pill{font-size:.72rem;color:var(--text-dim);background:var(--surface-2);border-radius:999px;padding:2px 9px;flex:none;}
.spacer{flex:1;}
.icon-btn{width:36px;height:36px;border-radius:50%;border:1px solid var(--border);background:var(--surface);color:var(--text-dim);display:flex;align-items:center;justify-content:center;flex:none;}
.btn{display:inline-flex;align-items:center;gap:7px;border:none;border-radius:10px;padding:9px 16px;font-size:.88rem;font-weight:600;flex:none;}
.btn-accent{background:var(--accent);color:var(--accent-ink);}
.btn-ghost{background:var(--surface-2);color:var(--text);}
.btn-danger{background:var(--danger);color:#fff;}
.btn[disabled]{background:var(--surface-2)!important;color:var(--text-dim)!important;opacity:1;pointer-events:none;}

.gallery{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:12px;}
.thumb{position:relative;aspect-ratio:1;border-radius:12px;overflow:hidden;background:var(--surface-2);border:1px solid var(--border);}
.thumb canvas{width:100%;height:100%;display:block;}
.thumb-actions{position:absolute;top:6px;right:6px;display:flex;gap:6px;}
.thumb-actions button{width:28px;height:28px;border-radius:50%;background:rgba(10,10,12,.6);color:#fff;border:none;display:flex;align-items:center;justify-content:center;}
.thumb-num{position:absolute;bottom:6px;left:7px;font-size:.68rem;font-weight:700;color:#fff;background:rgba(10,10,12,.55);border-radius:6px;padding:1px 6px;}

.empty-state{text-align:center;padding:48px 20px;color:var(--text-dim);}
.empty-state h2{font-size:1.1rem;color:var(--text);margin-bottom:6px;}
.empty-state p{max-width:320px;margin:0 auto;font-size:.88rem;}

.fab{position:fixed;right:calc(20px + env(safe-area-inset-right,0px));bottom:calc(20px + env(safe-area-inset-bottom,0px));width:62px;height:62px;border-radius:50%;background:var(--accent);color:var(--accent-ink);border:none;box-shadow:0 8px 20px rgba(0,0,0,.28);display:flex;align-items:center;justify-content:center;z-index:40;}
.fab svg{width:1.6em;height:1.6em;}

.overlay{position:fixed;inset:0;background:var(--bg);z-index:50;display:flex;flex-direction:column;}
.ov-bar{flex:none;display:flex;align-items:center;gap:10px;padding:calc(12px + env(safe-area-inset-top,0px)) max(16px,env(safe-area-inset-right,0px)) 12px max(16px,env(safe-area-inset-left,0px));background:var(--surface);border-bottom:1px solid var(--border);}
.ov-bar h2{font-size:1.02rem;flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.ov-body{flex:1;min-height:0;display:flex;flex-direction:column;align-items:center;justify-content:center;overflow:auto;padding:20px max(16px,env(safe-area-inset-right,0px)) 20px max(16px,env(safe-area-inset-left,0px));}
.ov-foot{flex:none;display:flex;gap:10px;padding:14px max(16px,env(safe-area-inset-right,0px)) calc(14px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px));background:var(--surface);border-top:1px solid var(--border);}
.ov-foot .btn{flex:1;justify-content:center;}

#reviewImgWrap{max-width:100%;max-height:100%;}
#reviewImgWrap img{max-width:100%;max-height:calc(100vh - 220px);display:block;border-radius:10px;}

.stage-wrap{display:flex;align-items:center;justify-content:center;width:100%;flex:1;min-height:0;}
.stage{position:relative;max-width:min(94vw,640px);max-height:58vh;width:auto;height:auto;overflow:hidden;border-radius:6px;background:#000;}
.stage img{width:100%;height:100%;display:block;user-select:none;-webkit-user-drag:none;}
.cropbox{position:absolute;border:2px solid #fff;box-shadow:0 0 0 9999px rgba(0,0,0,.55);touch-action:none;}
.handle{position:absolute;width:26px;height:26px;background:#fff;border-radius:50%;border:2px solid var(--accent);transform:translate(-50%,-50%);touch-action:none;}
.handle.nw{top:0;left:0;} .handle.ne{top:0;left:100%;} .handle.sw{top:100%;left:0;} .handle.se{top:100%;left:100%;}
.edit-controls{flex:none;display:flex;gap:8px;padding:14px max(16px,env(safe-area-inset-right,0px)) calc(14px + env(safe-area-inset-bottom,0px)) max(16px,env(safe-area-inset-left,0px));background:var(--surface);border-top:1px solid var(--border);flex-wrap:wrap;}

#displayOverlay{background:#0b0c0e;}
#displayOverlay .ov-bar{background:#15161a;border-color:#2a2c33;color:#fff;}
#displayOverlay .ov-bar h2{color:#fff;}
#displayOverlay .icon-btn{background:#2a2c33;border-color:#3a3d45;color:#fff;}
#tileGrid{flex:1;min-height:0;display:grid;gap:3px;background:#000;touch-action:none;}
#tileGrid .tile{position:relative;overflow:hidden;background:#111;}
#tileGrid canvas{width:100%;height:100%;display:block;}
.dots{flex:none;display:flex;gap:6px;justify-content:center;align-items:center;padding:8px 0;background:#15161a;}
.dots .dot{width:7px;height:7px;border-radius:50%;background:#444750;border:none;padding:0;}
.dots .dot.active{background:var(--accent);width:9px;height:9px;}

.modal-backdrop{position:fixed;inset:0;background:rgba(10,10,12,.45);z-index:60;display:flex;align-items:center;justify-content:center;padding:20px;}
.modal-card{background:var(--surface);border-radius:14px;padding:18px;width:100%;max-width:340px;box-shadow:0 20px 50px rgba(0,0,0,.3);}
.modal-card h3{font-size:1rem;margin-bottom:10px;}
.modal-card input{width:100%;padding:10px 12px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--text);font-size:.95rem;margin-bottom:14px;}
.modal-card .row{display:flex;gap:8px;}
.modal-card .row .btn{flex:1;justify-content:center;}

.toast{position:fixed;left:50%;bottom:calc(96px + env(safe-area-inset-bottom,0px));transform:translateX(-50%);background:var(--text);color:var(--bg);padding:9px 16px;border-radius:999px;font-size:.82rem;font-weight:500;z-index:80;opacity:0;transition:opacity .25s,transform .25s;pointer-events:none;}
.toast.show{opacity:1;transform:translateX(-50%) translateY(-4px);}
