:root { --bg: #1e1f24; --bg2: #26282e; --bg3: #2f3239; --line: #3a3d45; --tx: #e6e8ec; --mu: #9aa0ab; --ac: #c026d3; --ac2: #7c3aed; font-family: "Segoe UI", system-ui, Arial, sans-serif; font-size: 13px; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--tx); user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
body { display: flex; flex-direction: column; }

#menubar { display: flex; align-items: center; height: 34px; background: #17181c; border-bottom: 1px solid var(--line); padding: 0 8px; gap: 6px; flex: none; }
.logo { display: flex; align-items: center; gap: 7px; margin-right: 8px; }
.logo img { width: 22px; height: 22px; }
.logo b { font-size: 13px; letter-spacing: .3px; }
#menus { display: flex; }
.menu { position: relative; }
.menu > button { background: none; border: 0; padding: 6px 10px; border-radius: 5px; cursor: pointer; }
.menu > button:hover, .menu.open > button { background: var(--bg3); }
.menu .dd { position: absolute; top: 100%; left: 0; min-width: 250px; background: #2a2c32; border: 1px solid var(--line); border-radius: 8px; padding: 5px; z-index: 100; box-shadow: 0 12px 30px rgba(0,0,0,.45); display: none; max-height: 80vh; overflow-y: auto; }
.menu.open .dd { display: block; }
.dd button { display: flex; width: 100%; background: none; border: 0; text-align: left; padding: 6px 10px; border-radius: 5px; cursor: pointer; gap: 10px; }
.dd button:hover { background: var(--ac2); }
.dd button span.k { margin-left: auto; color: var(--mu); font-size: 11.5px; }
.dd button:hover span.k { color: #eee; }
.dd hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.dd .sub { color: var(--mu); font-size: 11px; padding: 6px 10px 2px; text-transform: uppercase; letter-spacing: .6px; }
#docname { margin-left: auto; color: var(--mu); font-size: 12px; }

#optbar { height: 38px; flex: none; background: var(--bg2); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 12px; overflow-x: auto; white-space: nowrap; }
#optbar label { display: flex; align-items: center; gap: 6px; color: var(--mu); }
#optbar input[type=range] { width: 100px; accent-color: var(--ac); }
#optbar input[type=number] { width: 58px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; }
#optbar select { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; }
#optbar .tname { font-weight: 600; color: var(--tx); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg button { background: var(--bg); border: 0; padding: 4px 9px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--ac2); color: #fff; }
.btn { background: var(--bg3); border: 1px solid var(--line); border-radius: 6px; padding: 5px 11px; cursor: pointer; }
.btn:hover { border-color: #5a5e68; }
.btn.pri { background: linear-gradient(90deg, var(--ac2), var(--ac)); border: 0; color: #fff; font-weight: 600; }

#workspace { flex: 1; display: flex; min-height: 0; }
#toolbar { width: 46px; flex: none; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; padding: 6px 0; gap: 2px; overflow-y: auto; }
#toolbar button { width: 36px; height: 34px; border: 0; background: none; border-radius: 6px; cursor: pointer; font-size: 17px; display: grid; place-items: center; }
#toolbar button:hover { background: var(--bg3); }
#toolbar button.on { background: var(--ac2); box-shadow: inset 0 0 0 1px #a78bfa; }
#toolbar hr { width: 28px; border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
#stage { flex: 1; position: relative; overflow: hidden; background: #131417; }
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#panels { width: 270px; flex: none; background: var(--bg2); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.panel { border-bottom: 1px solid var(--line); padding: 8px 10px; }
.panel.grow { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.panel h3 { margin: 0 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--mu); }
#colors .sw { display: flex; gap: 10px; align-items: center; }
.swatch2 { position: relative; width: 52px; height: 46px; flex: none; }
.swatch2 div { position: absolute; width: 32px; height: 32px; border: 2px solid #fff; border-radius: 4px; cursor: pointer; box-shadow: 0 0 0 1px #000; }
.swatch2 .fg { left: 0; top: 0; z-index: 2; } .swatch2 .bg { left: 18px; top: 14px; }
.palette { display: grid; grid-template-columns: repeat(12, 1fr); gap: 2px; margin-top: 8px; }
.palette div { aspect-ratio: 1; border-radius: 2px; cursor: pointer; border: 1px solid rgba(0,0,0,.4); }
#colors input[type=text] { width: 80px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; font-family: Consolas, monospace; }
#layerprops { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
#layerprops select { flex: 1; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px; }
#layerprops input[type=range] { width: 80px; accent-color: var(--ac); }
#layers { flex: 1; overflow-y: auto; min-height: 60px; }
.lrow { display: flex; align-items: center; gap: 7px; padding: 4px; border-radius: 6px; cursor: pointer; border: 1px solid transparent; }
.lrow:hover { background: var(--bg3); }
.lrow.on { background: #3b2a5c; border-color: #6d4fb3; }
.lrow canvas { width: 40px; height: 30px; flex: none; border: 1px solid var(--line); background: repeating-conic-gradient(#666 0 25%, #999 0 50%) 0 0/8px 8px; object-fit: contain; }
.lrow .eye { width: 22px; text-align: center; opacity: .9; }
.lrow .eye.off { opacity: .25; }
.lrow .ln { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .lt { font-size: 10px; color: var(--mu); }
#layerbtns { display: flex; gap: 3px; margin-top: 6px; flex-wrap: wrap; }
#layerbtns button { flex: 1; background: var(--bg3); border: 1px solid var(--line); border-radius: 5px; padding: 4px 0; cursor: pointer; font-size: 13px; }
#history { max-height: 150px; overflow-y: auto; }
#history div { padding: 3px 6px; border-radius: 4px; cursor: pointer; font-size: 12px; }
#history div:hover { background: var(--bg3); }
#history div.cur { background: var(--ac2); }
#history div.fut { opacity: .4; }

#status { height: 26px; flex: none; background: #17181c; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 16px; padding: 0 10px; color: var(--mu); font-size: 12px; }
#status .sp { flex: 1; }
#status button { background: var(--bg3); border: 1px solid var(--line); border-radius: 4px; padding: 0 8px; cursor: pointer; height: 20px; }

#modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 200; }
#dialog { background: #2a2c32; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; min-width: 340px; max-width: min(760px, 94vw); max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
#dialog h2 { margin: 0 0 12px; font-size: 16px; }
#dialog .row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
#dialog .row > label:first-child { width: 120px; color: var(--mu); flex: none; }
#dialog input[type=range] { flex: 1; accent-color: var(--ac); }
#dialog input[type=number], #dialog input[type=text], #dialog select, #dialog textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 7px; }
#dialog input[type=number] { width: 80px; }
#dialog textarea { width: 100%; min-height: 90px; resize: vertical; }
#dialog .acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#dialog .note { color: var(--mu); font-size: 12px; margin: 6px 0; }
#dialog .presets { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 10px; }
#dialog .presets button { text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; cursor: pointer; }
#dialog .presets button:hover { border-color: var(--ac); }
#dialog .presets small { display: block; color: var(--mu); }
.welcome { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.welcome button { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px 10px; cursor: pointer; text-align: center; }
.welcome button:hover { border-color: var(--ac); background: #2d2440; }
.welcome b { display: block; font-size: 22px; margin-bottom: 6px; }
.anchor { display: grid; grid-template-columns: repeat(3, 26px); gap: 3px; }
.anchor button { width: 26px; height: 26px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; cursor: pointer; }
.anchor button.on { background: var(--ac2); }
#busy { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 300; cursor: wait; }
#busy > div { background: #2a2c32; padding: 16px 22px; border-radius: 10px; display: flex; gap: 12px; align-items: center; }
.spin { width: 20px; height: 20px; border: 3px solid #555; border-top-color: var(--ac); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
#toast { position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); background: #3b2a5c; border: 1px solid #6d4fb3; padding: 8px 16px; border-radius: 8px; z-index: 400; }
canvas.curve { background: #1a1b1f; border: 1px solid var(--line); border-radius: 6px; cursor: crosshair; display: block; }
canvas.hist { background: #1a1b1f; border: 1px solid var(--line); border-radius: 6px; display: block; width: 100%; height: 80px; }
#status #z-out,#status #z-in,#status #z-fit{min-width:28px;min-height:24px}
