:root{
  --burg:#6B2738; --burg-2:#5a2030; --cream:#F5EFE5; --paper:#faf6f0;
  --taupe:#8A7968; --wine:#3E2230;
  --ink:#2a1f24; --line:#e6ddd1; --line-2:#d8cdbd;
  --panel:#fffdfa; --rail:#f1e9dd; --muted:#8c8073;
  --shadow:0 1px 3px rgba(60,34,48,0.08);
  --font-ui:'Jost', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
*{box-sizing:border-box;}
html,body{margin:0;height:100%;}
body{
  font-family:var(--font-ui); color:var(--ink); background:var(--cream);
  -webkit-font-smoothing:antialiased; overflow:hidden;
}
button{font-family:var(--font-ui); cursor:pointer;}
#root,.app{height:100vh; display:flex; flex-direction:column;}

/* ---------------- top bar ---------------- */
.topbar{
  height:60px; flex:0 0 60px; display:flex; align-items:center; justify-content:space-between;
  padding:0 20px; background:var(--burg); color:var(--cream);
  border-bottom:1px solid rgba(0,0,0,0.15);
}
.brand-lock{display:flex; align-items:baseline; gap:2px; font-family:'EB Garamond', Georgia, serif;}
.bl-a{font-size:26px; font-weight:700;}
.bl-b{font-size:26px; font-weight:700; font-style:italic; margin-right:12px;}
.bl-sub{font-family:var(--font-ui); font-size:12px; letter-spacing:3px; text-transform:uppercase; opacity:.7;}
.top-actions{display:flex; align-items:center; gap:8px;}
.top-actions .divider{width:1px; height:24px; background:rgba(255,255,255,0.2); margin:0 4px;}

.btn{
  border:1px solid transparent; border-radius:8px; padding:8px 14px; font-size:13px; font-weight:500;
  background:var(--cream); color:var(--burg); transition:all .15s;
}
.btn:hover{filter:brightness(0.97);}
.btn.primary{background:var(--cream); color:var(--burg); font-weight:600;}
.btn.ghost{background:rgba(255,255,255,0.08); color:var(--cream); border-color:rgba(255,255,255,0.22);}
.btn.ghost:hover{background:rgba(255,255,255,0.16);}
.btn.ghost.active{background:var(--cream); color:var(--burg); border-color:var(--cream);}
.btn.block{width:100%;}
.btn.sm{padding:6px 11px; font-size:12px;}
.btn.danger{color:#9b3b3b;}
.btn:disabled{opacity:.35; cursor:default;}

.export-wrap{position:relative;}
.menu{
  position:absolute; right:0; top:42px; background:#fff; border:1px solid var(--line);
  border-radius:10px; box-shadow:0 12px 32px rgba(40,20,28,0.18); padding:6px; z-index:50; min-width:190px;
}
.menu button{display:block; width:100%; text-align:left; border:none; background:none; padding:10px 12px;
  border-radius:7px; font-size:13px; color:var(--ink);}
.menu button:hover{background:var(--rail);}

/* ---------------- workspace ---------------- */
.workspace{flex:1; display:flex; min-height:0;}

/* rail */
.rail{
  width:212px; flex:0 0 212px; background:var(--rail); border-right:1px solid var(--line-2);
  display:flex; flex-direction:column; min-height:0;
}
.rail-head{padding:14px 18px 8px; font-size:11px; letter-spacing:2.5px; text-transform:uppercase; color:var(--muted); font-weight:600;}
.rail-list{flex:1; overflow-y:auto; padding:6px 10px 10px;}
.rail-item{position:relative; display:flex; gap:8px; align-items:flex-start; padding:8px; border-radius:10px; margin-bottom:6px; cursor:pointer; border:1px solid transparent;}
.rail-item:hover{background:rgba(255,255,255,0.55);}
.rail-item.active{background:#fff; border-color:var(--burg); box-shadow:var(--shadow);}
.rail-num{font-size:12px; color:var(--muted); width:14px; text-align:right; padding-top:2px; font-weight:600;}
.thumb-clip{overflow:hidden; border-radius:5px; box-shadow:0 1px 4px rgba(40,20,28,.18); flex:0 0 auto; background:#000;}
.rail-tools{position:absolute; right:6px; top:6px; display:none; gap:3px; background:rgba(255,255,255,.92); border-radius:7px; padding:3px; box-shadow:var(--shadow);}
.rail-item:hover .rail-tools{display:flex;}
.rail-tools button{width:22px; height:22px; border:none; background:none; border-radius:5px; font-size:12px; color:var(--ink);}
.rail-tools button:hover{background:var(--rail);}
.rail-tools button:disabled{opacity:.3;}
.rail-add{padding:10px; border-top:1px solid var(--line-2); position:relative;}
.add-menu{position:absolute; bottom:54px; left:10px; right:10px; background:#fff; border:1px solid var(--line); border-radius:10px; box-shadow:0 12px 32px rgba(40,20,28,0.18); padding:6px; z-index:40;}
.add-menu button{display:flex; flex-direction:column; gap:1px; width:100%; text-align:left; border:none; background:none; padding:9px 11px; border-radius:7px;}
.add-menu button:hover{background:var(--rail);}
.add-menu strong{font-size:13px; color:var(--burg);}
.add-menu span{font-size:11px; color:var(--muted);}

/* stage */
.stage{flex:1; min-width:0; position:relative; display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 50% 36%, #efe7da 0%, #e7dccb 100%);
  overflow:hidden;}
.stage-canvas{position:relative;}
.stage-hint{position:absolute; bottom:16px; left:50%; transform:translateX(-50%); font-size:12px; color:var(--muted);
  background:rgba(255,255,255,0.7); padding:6px 14px; border-radius:20px; white-space:nowrap; pointer-events:none;}

/* inspector */
.inspector{width:300px; flex:0 0 300px; background:var(--panel); border-left:1px solid var(--line-2); display:flex; flex-direction:column; min-height:0;}
.ins-tabs{display:flex; border-bottom:1px solid var(--line);}
.ins-tab{flex:1; border:none; background:none; padding:14px 0; font-size:12px; letter-spacing:1.5px; text-transform:uppercase; color:var(--muted); font-weight:600; border-bottom:2px solid transparent;}
.ins-tab.on{color:var(--burg); border-bottom-color:var(--burg);}
.ins-scroll{flex:1; overflow-y:auto; padding:4px 0 40px;}
.ins-section{padding:16px 18px; border-bottom:1px solid var(--line);}
.ins-title{font-size:11px; letter-spacing:2px; text-transform:uppercase; color:var(--muted); font-weight:700; margin-bottom:12px; display:flex; justify-content:space-between; align-items:center;}
.ins-title .mini{font-size:11px; letter-spacing:0; text-transform:none;}
.hint{font-size:12px; color:var(--muted); line-height:1.5; margin-bottom:10px;}
.layer-name{font-family:'EB Garamond', serif; font-size:18px; color:var(--burg); margin-bottom:10px;}

.ins-row{display:flex; align-items:center; gap:10px; margin-bottom:11px;}
.ins-label{width:74px; flex:0 0 74px; font-size:12px; color:var(--muted);}
.ins-control{flex:1; min-width:0;}

.seg{display:flex; background:var(--rail); border-radius:8px; padding:2px; gap:2px;}
.seg-btn{flex:1; border:none; background:none; padding:6px 4px; border-radius:6px; font-size:12px; color:var(--muted); font-weight:500;}
.seg-btn.on{background:#fff; color:var(--burg); box-shadow:var(--shadow);}

.slider-wrap{display:flex; align-items:center; gap:8px;}
.slider-wrap input[type=range]{flex:1; accent-color:var(--burg);}
.slider-val{font-size:11px; color:var(--muted); width:40px; text-align:right; font-variant-numeric:tabular-nums;}

.swatches{display:flex; gap:6px; flex-wrap:wrap;}
.sw{width:26px; height:26px; border-radius:7px; border:2px solid #fff; box-shadow:0 0 0 1px var(--line-2); cursor:pointer;}
.sw.on{box-shadow:0 0 0 2px var(--burg);}
.sw.auto{background:linear-gradient(135deg,#fff 50%,#3E2230 50%); color:var(--burg); font-size:11px; font-weight:700; display:flex; align-items:center; justify-content:center;}

.fmt-row{display:flex; gap:6px;}
.fmt{width:34px; height:32px; border:1px solid var(--line-2); background:#fff; border-radius:7px; font-size:15px; color:var(--ink);}
.fmt:hover{background:var(--rail);}
.fmt.b{font-weight:800; font-family:'EB Garamond',serif;}
.fmt.i{font-style:italic; font-family:'EB Garamond',serif;}
.fmt.u{text-decoration:underline;}

.btn-row{display:flex; gap:6px;}
.sel,.txt,.hex{width:100%; border:1px solid var(--line-2); border-radius:7px; padding:7px 9px; font-size:13px; font-family:var(--font-ui); color:var(--ink); background:#fff;}
.txt.em{font-style:italic;}
.wm-edit{display:flex; gap:6px;}
.color-edit{display:flex; align-items:center; gap:8px; margin-bottom:8px;}
.color-edit input[type=color]{width:34px; height:34px; border:1px solid var(--line-2); border-radius:8px; padding:2px; background:#fff;}
.hex{flex:1; font-family:ui-monospace, monospace; text-transform:uppercase;}
.mini{border:1px solid var(--line-2); background:#fff; border-radius:6px; padding:3px 8px; font-size:12px; color:var(--burg);}
.mini.x{border:none; color:var(--muted); padding:3px 6px;}

/* modal */
.modal-bg{position:fixed; inset:0; background:rgba(40,22,30,0.5); display:flex; align-items:center; justify-content:center; z-index:100;}
.modal{background:#fff; border-radius:16px; padding:26px; width:520px; max-width:92vw; box-shadow:0 30px 80px rgba(40,20,28,0.35);}
.modal h3{margin:0 0 6px; font-family:'EB Garamond',serif; font-size:24px; color:var(--burg);}
.modal p{margin:0 0 14px; font-size:13px; color:var(--muted); line-height:1.5;}
.modal textarea{width:100%; border:1px solid var(--line-2); border-radius:10px; padding:12px; font-size:14px; font-family:var(--font-ui); resize:vertical; line-height:1.5;}
.modal-actions{display:flex; justify-content:flex-end; gap:10px; margin-top:16px;}

/* toast */
.toast{position:fixed; bottom:24px; left:50%; transform:translateX(-50%); background:var(--wine); color:var(--cream);
  padding:12px 22px; border-radius:30px; font-size:13px; box-shadow:0 12px 32px rgba(40,20,28,0.3); z-index:200;}

::-webkit-scrollbar{width:10px; height:10px;}
::-webkit-scrollbar-thumb{background:var(--line-2); border-radius:6px; border:3px solid transparent; background-clip:content-box;}
