:root{
  --bg:#0f1115; --fg:#e8e8e8; --muted:#a6a6a6; --panel:#13161c; --line:#262a33;
  --accent:#5aa9ff; --guide:#78d1ff; --hud:#ffe16b; --magenta:#ff2bbf;
}

*{box-sizing:border-box}
html,body{height:100%;margin:0;background:var(--bg);color:var(--fg);font:14px/1.35 system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif}
.preview{ position:fixed; inset:0; background:#0c0e12; overflow:hidden; touch-action:none; }
#stage{ position:absolute; left:0; top:0; transform-origin:0 0; will-change:transform; }
svg [data-role]{ touch-action:none }
.guide{stroke:var(--guide);stroke-width:1.5;stroke-dasharray:6 4;fill:none}
.handle{fill:#0c1829;stroke:var(--guide);stroke-width:1.5}
.hud{position:absolute;z-index:10;background:var(--hud);color:#000;padding:2px 6px;border-radius:.35rem;font-size:12px;border:1px solid #b89c2a;pointer-events:none}

/* Rulers */
.ruler{position:absolute; z-index:6; pointer-events:none;}
.ruler-top{left:28px; top:0; height:28px;}
.ruler-left{left:0; top:28px; width:28px}
.ruler-corner{position:absolute; left:0; top:0; width:28px; height:28px; background:#0a0c10; z-index:7; border-right:1px solid #343a46; border-bottom:1px solid #343a46}

/* Settings */
.settings-wrap{ position:fixed; inset:0; pointer-events:none; z-index:30; }
.settings-btn{
  position:fixed; right:16px; bottom:16px;
  padding:.5rem .85rem; border-radius:.65rem;
  font-size:15px; font-weight:600; background:#1f2a44; color:#fff;
  border:1px solid #2f416a; box-shadow:0 6px 18px rgba(0,0,0,.35);
  touch-action:none; user-select:none; pointer-events:auto;
}
.settings-btn.dragging{ right:auto; bottom:auto; }

.sheet{ position:fixed; inset:0; display:block; pointer-events:none; }
.sheet[data-open="false"] .sheet-card{ display:none; }
.sheet-card{
  position:fixed; left:40px; top:40px;
  width: min(560px, 92vw); height: min(640px, 88vh);
  min-width: 320px; min-height: 320px;
  background:rgba(19,22,28,.96); border:1px solid var(--line);
  display:flex; flex-direction:column; border-radius:12px; overflow:hidden;
  font-size:13px; box-shadow:0 12px 40px rgba(0,0,0,.55);
  pointer-events:auto;
}

.sheet-header{
  display:flex;justify-content:space-between;align-items:center;
  padding:8px 10px; border-bottom:1px solid var(--line); user-select:none;
  touch-action:none;
}
.sheet-header h1{font-size:15px;margin:0; cursor:pointer;}
.sheet-actions{display:flex; gap:6px; align-items:center}
.chk-inline{ display:inline-flex; gap:6px; align-items:center; font-size:12px; color:var(--muted); }
.icon-btn{background:#172133;color:var(--fg);border:1px solid #2a3652;border-radius:.5rem;padding:.3rem .55rem}
.sheet-body{ padding:8px 10px; overflow:auto; overscroll-behavior:contain; }

h2{ font-size:12px; color:var(--muted); margin:10px 0 6px; text-transform:uppercase; letter-spacing:.06em }
.row{display:flex;gap:6px;align-items:center;margin-bottom:5px;flex-wrap:wrap}
label{min-width:96px;color:var(--muted);font-size:11px}
.grid2{display:grid;grid-template-columns:1fr 1fr;gap:6px}
input[type="number"],input[type="text"],select,textarea{
  background:#161a20;color:var(--fg);border:1px solid #2a2f39;border-radius:.45rem;
  padding:.24rem .38rem; min-width:0; font-size:13px; height:30px;
}
textarea{height:auto; font:13px/1.3 system-ui; }
input[type="number"]{ width:92px }
input[type="text"]{ width:100% }
select{appearance:auto; max-width:220px}
input[type="checkbox"]{transform:translateY(1px)}
.btns{display:flex;gap:8px;flex-wrap:wrap;margin:10px 0}
button{background:#172133;color:var(--fg);border:1px solid #2a3652;border-radius:.55rem;padding:.38rem .65rem;cursor:pointer;font-size:13px}
button:active{transform:translateY(1px)}
.hidden{display:none}

/* section separators */
.sheet-body section + section{ border-top:1px dashed #2a2f39; padding-top:10px; margin-top:8px; }

/* window resize handles */
.win-handle{ position:absolute; width:16px; height:16px; background:transparent; z-index:2; touch-action:none; }
.handle-nw{left:-2px; top:-2px; cursor:nwse-resize}
.handle-ne{right:-2px; top:-2px; cursor:nesw-resize}
.handle-sw{left:-2px; bottom:-2px; cursor:nesw-resize}
.handle-se{right:-2px; bottom:-2px; cursor:nwse-resize}
.handle-n{left:50%; top:-2px; transform:translateX(-50%); cursor:ns-resize}
.handle-s{left:50%; bottom:-2px; transform:translateX(-50%); cursor:ns-resize}
.handle-w{left:-2px; top:50%; transform:translateY(-50%); cursor:ew-resize}
.handle-e{right:-2px; top:50%; transform:translateY(-50%); cursor:ew-resize}

/* tiny status line */
.status{ font-size:12px; color:#9ad07a; margin-top:2px; white-space:pre-wrap; }
