*{box-sizing:border-box}html{scroll-behavior:smooth}body{margin:0;font-family:Inter,system-ui,sans-serif;background:#f3f4f6;color:#111}
.topbar{display:flex;justify-content:space-between;align-items:center;padding:12px 18px;background:#111;color:#fff;flex-wrap:wrap;gap:12px}
.brand{display:flex;gap:12px;align-items:center}.logo{width:44px;height:44px;border-radius:12px;background:#facc15;display:grid;place-items:center;flex:none}.logo svg{width:30px;height:30px}
.brand h1{margin:0;font-size:20px}.brand p{margin:2px 0 0;opacity:.7;font-size:12px}
.top-actions{display:flex;gap:8px;flex-wrap:wrap}
.btn{border:1px solid #ddd;background:#fff;padding:9px 14px;border-radius:10px;cursor:pointer;font-weight:600;display:inline-flex;align-items:center;justify-content:center;gap:8px;transition:background .15s ease,transform .1s ease}.btn:hover{background:#f9fafb}.btn:active{transform:scale(.98)}.btn.primary{background:#facc15;border-color:#facc15}.btn.dark{background:#111;color:#fff}.btn.small{padding:6px 10px}
.ic{width:18px;height:18px;flex:none}
.layout{display:grid;grid-template-columns:390px minmax(0,1fr);gap:16px;padding:16px;align-items:start}
.panel{background:#fff;border-radius:16px;padding:8px 16px;display:flex;flex-direction:column;box-shadow:0 2px 10px rgba(0,0,0,.06);position:sticky;top:16px;max-height:calc(100vh - 32px);overflow:auto}
/* Accordion: every settings group collapses with a smooth height animation (grid-rows trick — no layout jumps) */
.acc{border-bottom:1px solid #f3f4f6}.acc:last-child{border-bottom:0}
.acc-head{width:100%;display:flex;align-items:center;justify-content:space-between;gap:10px;background:none;border:0;padding:0;cursor:pointer;text-align:left;min-height:48px}
.acc-head:focus-visible{outline:2px solid #facc15;outline-offset:2px;border-radius:6px}
.acc-title{font-size:14px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.acc-chev{width:20px;height:20px;flex:none;transition:transform .28s ease;color:#6b7280}
.acc.closed .acc-chev{transform:rotate(-90deg)}
.acc-body{display:grid;grid-template-rows:1fr;transition:grid-template-rows .3s ease}
.acc.closed .acc-body{grid-template-rows:0fr}
.acc-inner{overflow:hidden;min-height:0;padding:2px 2px 14px}
.panel h2{font-size:14px;margin:0 0 10px;text-transform:uppercase;letter-spacing:.06em}.count{font-size:11px;background:#e0e7ff;padding:2px 8px;border-radius:20px;text-transform:none;letter-spacing:0}
/* Solid letter style: dots/stroke settings don't apply — dim them, keep headers clickable */
.solid-note{display:none}
body.solid-mode .solid-note{display:block}
body.solid-mode .solid-dims{opacity:.45;pointer-events:none;filter:saturate(.5)}
.lbl{display:block;font-size:13px;font-weight:600;margin:10px 0 6px}.hint{font-weight:400;color:#6b7280}.val{float:right;background:#fef3c7;padding:1px 8px;border-radius:20px}
textarea,input[type=text],select{width:100%;padding:10px;border:1.5px solid #e5e7eb;border-radius:10px;font:inherit}textarea{resize:vertical;min-height:76px}textarea:focus{outline:2px solid #facc15;border-color:#facc15}
input[type=number]{width:100%;padding:9px;border:1.5px solid #e5e7eb;border-radius:10px}
input[type=range]{width:100%;accent-color:#111}input[type=color]{width:100%;height:36px;border:none;background:none}
.row{display:flex;align-items:center}.gap{gap:8px;flex-wrap:wrap}.grid2{display:grid;grid-template-columns:1fr 1fr;gap:10px}
.chip{padding:6px 10px;border-radius:20px;border:1px solid #e5e7eb;background:#f9fafb;cursor:pointer;transition:background .15s ease}.chip:hover{background:#fef3c7}
.check{display:flex;gap:8px;align-items:center;font-size:13px;margin-top:10px;cursor:pointer}
.seg{display:flex;border:1.5px solid #e5e7eb;border-radius:10px;overflow:hidden;flex-wrap:wrap}.seg button{flex:1;padding:9px;border:0;background:#fff;cursor:pointer;font-weight:600;white-space:nowrap;display:inline-flex;align-items:center;justify-content:center;gap:6px;transition:background .15s ease}.seg button.active{background:#111;color:#fff}.seg.small-seg button{padding:6px 8px;font-size:12px}
.small{font-size:12px;color:#6b7280;line-height:1.5}.center{text-align:center}
.preview-wrap{background:#fff;border-radius:16px;padding:14px;box-shadow:0 2px 10px rgba(0,0,0,.06);position:sticky;top:16px;min-width:0}
.preview-toolbar{display:flex;justify-content:space-between;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:12px}
.badge{background:#dcfce7;padding:5px 10px;border-radius:20px;font-size:12px;font-weight:700;display:inline-flex;align-items:center;gap:6px}.badge.live{background:#dcfce7}.pulse{width:8px;height:8px;border-radius:50%;background:#16a34a;display:inline-block;animation:pulse 1.6s infinite}.badge.updating{background:#fef3c7}.badge.updating .pulse{background:#d97706}
@keyframes pulse{0%{box-shadow:0 0 0 0 rgba(22,163,74,.5)}70%{box-shadow:0 0 0 7px rgba(22,163,74,0)}100%{box-shadow:0 0 0 0 rgba(22,163,74,0)}}
.paper-scroll{background:#e5e7eb;border-radius:12px;padding:18px;display:flex;justify-content:center;overflow:auto;max-height:82vh}
#previewCanvas{background:#fff;box-shadow:0 8px 30px rgba(0,0,0,.18);max-width:100%;height:auto;display:block;touch-action:pan-y}
.foot{text-align:center;padding:14px;font-size:12px;color:#6b7280}
@media print{body{background:#fff}.topbar,.panel,.preview-toolbar,.foot,.preview-wrap>p{display:none!important}.layout{display:block;padding:0}.preview-wrap{box-shadow:none;padding:0}.paper-scroll{padding:0;background:#fff;max-height:none;overflow:visible}#previewCanvas{box-shadow:none;max-width:100%}}
.img-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:6px;max-height:280px;overflow:auto;margin:10px 0;padding:4px;background:#f9fafb;border-radius:10px}
.img-btn{border:1px solid #e5e7eb;background:#fff;border-radius:10px;padding:6px 2px;cursor:pointer;font-size:22px;display:flex;flex-direction:column;align-items:center;gap:2px;min-height:58px;transition:background .15s ease}.img-btn:hover{background:#fef3c7;border-color:#facc15}.img-btn span{font-size:9px;color:#6b7280;line-height:1.1;text-align:center;word-break:break-word}
.img-btn svg{width:30px;height:30px}
.added-img{display:flex;align-items:center;gap:8px;padding:6px;background:#f9fafb;border-radius:8px;margin:4px 0;font-size:12px}.added-img input{flex:1}
.icon-btn{display:inline-flex;align-items:center;justify-content:center;width:32px;height:32px;border:1px solid #e5e7eb;background:#fff;border-radius:8px;cursor:pointer;flex:none}.icon-btn:hover{background:#fee2e2;border-color:#fca5a5}.icon-btn svg{width:16px;height:16px}
/* ---- Mobile: no horizontal overflow, 44px+ tap targets, 16px inputs (no iOS zoom), stacked layout ---- */
@media(max-width:900px){
  html,body{overflow-x:hidden}
  .layout{grid-template-columns:minmax(0,1fr);padding:12px;gap:12px}
  .panel,.preview-wrap{position:static;max-height:none}
  .panel{padding:6px 12px}
  .topbar{padding:10px 12px}
  .top-actions{width:100%}
  .top-actions .btn{flex:1;padding:10px 8px;font-size:13px}
  .btn,.chip,.seg button,.acc-head{min-height:44px}
  .chip{padding:10px 14px}
  .seg button{white-space:normal;font-size:13px}
  textarea,input[type=text],input[type=number],select{font-size:16px}
  .brand h1{font-size:18px}
  .brand p{display:none}
  .preview-wrap{padding:10px}
  .paper-scroll{padding:10px;max-height:none}
  .preview-toolbar{flex-direction:column;align-items:stretch}
  .preview-toolbar label{display:flex;align-items:center;gap:8px}
  .img-grid{grid-template-columns:repeat(4,1fr)}
  .grid2{grid-template-columns:1fr 1fr}
}
@media(max-width:420px){
  .img-grid{grid-template-columns:repeat(3,1fr)}
  .grid2{grid-template-columns:1fr}
  .top-actions{flex-direction:column}
  .top-actions .btn{width:100%}
}
