
:root{
  --bg:#F6F8FB;
  --fg:#0f172a;
  --panel:#ffffff;
  --silver:#cbd5e1;
  --blue:#2563eb;
  --blue-hi:#1e40af;
  --accent:#94a3b8;
}
*{box-sizing:border-box}
html,body{height:100%}
body{ margin:0; font:14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; color:var(--fg); background:var(--bg); }
.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 14px; background:linear-gradient(#eef2ff, #e0e7ff);
  border-bottom:2px solid var(--blue);
  box-shadow:0 2px 8px rgba(0,0,0,.06), inset 0 -2px 0 #93c5fd;
}
.topbar h1{margin:0; font-size:16px}
.topbar .status{font-size:12px; color:#334155}
.toolbar{
  display:flex; gap:6px; align-items:center; flex-wrap:wrap;
  padding:8px; background:var(--panel);
  border-bottom:1px solid var(--silver);
  box-shadow:0 4px 8px rgba(0,0,0,.04);
}
.toolbar .sep{width:1px; height:22px; background:var(--silver); margin:0 6px}
.toolbar button{
  padding:6px 10px; border:1px solid #94a3b8; border-radius:8px;
  background:linear-gradient(#fff,#f1f5f9);
  box-shadow:inset 0 1px 0 #fff, 0 1px 2px rgba(0,0,0,.06);
  cursor:pointer;
}
.toolbar button:hover{border-color:var(--blue); box-shadow:0 0 0 2px rgba(37,99,235,.15)}
.toolbar button:active{transform:translateY(1px)}
.toolbar button.active {
  border-color: var(--blue);
  background: linear-gradient(#e0ecff, #cbdcff);
  box-shadow: 0 0 0 2px rgba(37,99,235,.3);
}
/* Font UI */
.fontpicker{ position:relative }
.fontbtn{ padding:6px 10px; border:1px solid #94a3b8; border-radius:8px; background:#fff; }
.fontpanel{
  position:absolute; top:100%; left:0; min-width:240px; max-height:260px; overflow:auto;
  background:#fff; border:1px solid #cbd5e1; border-radius:8px; box-shadow:0 12px 24px rgba(0,0,0,.14);
  z-index:1000; padding:6px;
}
.fontpanel .font-item{
  padding:6px 8px; border-radius:6px; cursor:pointer;
}
.fontpanel .font-item:hover{ background:#eef2ff; }
.size-label select{ padding:6px 8px; border-radius:8px; border:1px solid #94a3b8; background:#fff }
.color-label input[type="color"]{ width:36px; height:32px; padding:0; border:1px solid #94a3b8; border-radius:8px; background:#fff }

.stage{max-width:100%; margin:18px auto; padding:0 12px}
.page{
  background:#fff; min-height:70vh; padding:18px;
  border:1px solid #60a5fa; border-radius:16px;
  box-shadow:0 8px 20px rgba(0,0,0,.06), inset 0 0 0 3px rgba(147,197,253,.55);
}
.editor{min-height:60vh; outline:none;}
.editor table{border-collapse:collapse; width:100%}
.editor th,.editor td{border:1px solid #d0d7e2; padding:8px; vertical-align:top}
.modals-root{position:fixed; inset:0; pointer-events:none}
.modal{ pointer-events:auto; position:fixed; inset:0; display:grid; place-items:center; background:rgba(15,23,42,.35); padding:20px; }
.modal .panel{
  width:min(720px, 96vw); background:#fff; border-radius:14px; padding:16px;
  border:1px solid #cbd5e1; box-shadow:0 12px 28px rgba(0,0,0,.18);
}
.modal .panel header{display:flex; justify-content:space-between; align-items:center; margin-bottom:8px}
.modal .panel header h3{margin:0; font-size:16px}
.modal .panel footer{display:flex; gap:8px; justify-content:flex-end; margin-top:14px}
.modal .panel button{padding:6px 10px; border-radius:8px; border:1px solid #94a3b8; background:#f8fafc}
.modal .panel button.primary{border-color:var(--blue); background:#e0ecff}

/* Resizable with 8 handles + rotate */
.resize-wrap{ position: relative; display:inline-block; max-width:100%; transform-origin:center center; }
.resize-wrap.__resizing{ outline: 2px dashed #2563eb; outline-offset: 2px; }
.handle{
  position:absolute; width:10px; height:10px; background:#e0ecff; border:2px solid #2563eb; border-radius:2px;
  box-shadow:0 1px 2px rgba(0,0,0,.15); z-index:5; user-select:none;
}
.handle.tl{ top:-6px; left:-6px; cursor:nwse-resize; }
.handle.tm{ top:-6px; left:50%; transform:translateX(-50%); cursor:ns-resize; }
.handle.tr{ top:-6px; right:-6px; cursor:nesw-resize; }
.handle.ml{ top:50%; left:-6px; transform:translateY(-50%); cursor:ew-resize; }
.handle.mr{ top:50%; right:-6px; transform:translateY(-50%); cursor:ew-resize; }
.handle.bl{ bottom:-6px; left:-6px; cursor:nesw-resize; }
.handle.bm{ bottom:-6px; left:50%; transform:translateX(-50%); cursor:ns-resize; }
.handle.br{ bottom:-6px; right:-6px; cursor:nwse-resize; }
.rotate-handle{
  position:absolute; top:-30px; left:50%; transform:translateX(-50%);
  width:14px; height:14px; border-radius:50%;
  background:#e0ecff; border:2px solid #2563eb; cursor:grab; box-shadow:0 1px 2px rgba(0,0,0,.15);
}
.editor img{ max-width:100%; height:auto; }
