* { box-sizing: border-box }
:root { color-scheme: light; --ink:#26202a; --muted:#675d69; --border:#ded6dd; --paper:#f7f3f5; --accent:#67405f; --soft:#eee5ec; font: 16px/1.45 'Segoe UI', system-ui, sans-serif; color:var(--ink); background:var(--paper) }
body { margin:0 }
button,input,select,textarea { font:inherit; color:inherit }
button,select,input,textarea { border:1px solid var(--border); border-radius:7px; padding:.56rem .72rem; background:#fff }
button { cursor:pointer; min-height:40px }
button:hover { background:var(--soft) }
button:disabled { opacity:.55; cursor:default }
a { color:var(--accent) }
:focus-visible { outline:3px solid #9d5d93; outline-offset:2px }
.primary { background:var(--accent); color:#fff; border-color:var(--accent) }
.primary:hover { background:#512e4b }
.topbar { min-height:64px; padding:.7rem clamp(1rem,4vw,3rem); background:#251d26; color:#fff; display:flex; justify-content:space-between; align-items:center; gap:1rem }
.brand { color:#fff; text-decoration:none; letter-spacing:.16em; font: 1.55rem Georgia,serif }
#top-actions { display:flex; gap:.4rem; flex-wrap:wrap; justify-content:flex-end }
#top-actions button { color:var(--ink) }
#app { max-width:1240px; margin:0 auto; padding:clamp(1rem,4vw,2.7rem) }
#app.editing { max-width:none; padding: .85rem }
h1,h2,h3 { margin:.2em 0 .65em; line-height:1.15; font-family:Georgia,serif }
h1 { font-size:clamp(1.9rem,4vw,3rem) }
h2 { font-size:1.4rem }
h3 { font-size:1.15rem }
.hero { margin:3rem 0 1.75rem }
.home-grid { display:grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,215px),1fr)); gap:.9rem }
.tile { min-height:106px; padding:1.3rem; text-align:left; font-weight:650; font-size:1.2rem }
.card { border:1px solid var(--border); background:#fff; padding:1rem; border-radius:10px; margin:.75rem 0 }
.narrow { max-width:640px }
.row,.toolbar { display:flex; align-items:center; flex-wrap:wrap; gap:.5rem }
.spread { justify-content:space-between }
.stack { display:grid; gap:.75rem }
label { display:grid; gap:.23rem; min-width:0 }
label.inline { display:flex; gap:.4rem; align-items:center }
input[type=text], input[type=number], select,textarea { width:100%; min-width:0 }
textarea { min-height:6rem; resize:vertical }
.help,small { color:var(--muted) }
.warning { color:#852244 }
.workspace { display:grid; grid-template-columns:minmax(0,1fr) minmax(245px,300px); gap:.8rem; margin-top:.8rem; align-items:start }
.toolbar { margin:.4rem 0 }
.stage { height:min(71vh,900px); overflow:auto; background:#e6dfe6; border:1px solid var(--border); border-radius:8px; position:relative; padding:1rem }
.sheet { position:relative; margin:0 auto; background:white; box-shadow:0 3px 18px #35283738; touch-action:none }
.sheet canvas,.objects,.grid { position:absolute; inset:0; width:100%; height:100% }
.sheet canvas,.grid { pointer-events:none }
.grid { opacity:.38 }
.object { position:absolute; border:1px solid transparent; background:none; padding:0; min-height:0; border-radius:0; touch-action:none; cursor:move }
.object:hover { background:#b091ac1f; border-color:#9d769680 }
.object.selected { border-color:#6b3760; outline:1px solid #fff }
.object.invalid { border-color:#c13b54; outline:1px dashed #c13b54 }
.grip { position:absolute; width:16px; height:16px; border:1px solid #6b3760; background:white; border-radius:50%; transform:translate(-50%,-50%); touch-action:none }
.grip[data-corner=tl] { top:0;left:0;cursor:nwse-resize }
.grip[data-corner=tr] { top:0;left:100%;cursor:nesw-resize }
.grip[data-corner=bl] { top:100%;left:0;cursor:nesw-resize }
.grip[data-corner=br] { top:100%;left:100%;cursor:nwse-resize }
.panel { max-height:74vh; overflow:auto; margin:0 }
.formgrid { display:grid; grid-template-columns:1fr 1fr; gap:.45rem }
.panel fieldset { padding:.65rem; border:1px solid var(--border); border-radius:7px; min-width:0 }
details > summary { cursor:pointer; padding:.25rem 0 }
#status { position:fixed; bottom:1rem; right:1rem; z-index:9; max-width:min(470px,calc(100% - 2rem)); background:#261d28; color:#fff; padding:.65rem .9rem; border-radius:7px; box-shadow:0 4px 20px #24162844 }
#status:empty { display:none }
dialog { border:1px solid var(--border); border-radius:10px; padding:1.1rem; width:min(94vw,690px); max-height:88dvh; overflow:auto }
dialog::backdrop { background:#1b1720a0 }
dialog img { max-width:100%; height:auto; border:1px solid var(--border) }
#print-sheet { display:none }
@media(max-width:760px) {
 .workspace {grid-template-columns:1fr}
 .stage {height:min(59dvh,660px)}
 .panel {max-height:none}
 .hero {margin-top:1.25rem}
}
@media print {
 :root,body { background:white; margin:0; padding:0 }
 body > :not(#print-sheet) { display:none !important }
 #print-sheet { display:block; position:absolute; inset:0; overflow:hidden }
 #print-sheet img { display:block; max-width:none }
}
