/* Graphican PDF editor — top bar, page thumbnails left, pages centre, properties right, tool dock bottom. */
@font-face { font-family:"iBrand"; src:url("/assets/fonts/ibrand.otf") format("opentype"); font-display:swap; }

:root {
  --bg:#ffffff; --bg2:#f5f5f5; --bg3:#ebebeb; --canvas:#e9e9ee;
  --text:#1e1e1e; --muted:#6b6b6b; --dim:#a0a0a0; --line:#e6e6e6; --line2:#d6d6d6;
  --acc:#6d56fa; --acc-soft:rgba(109,86,250,.12);
  --shadow:0 2px 6px rgba(0,0,0,.08), 0 10px 30px -8px rgba(0,0,0,.18);
  --page-shadow:0 1px 3px rgba(0,0,0,.12), 0 8px 24px -10px rgba(0,0,0,.25);
  --sw:208px; --pw:236px; --th:52px;
}
[data-theme="dark"] {
  --bg:#2c2c2c; --bg2:#383838; --bg3:#444; --canvas:#1b1b1d;
  --text:#f2f2f2; --muted:#b3b3b3; --dim:#7a7a7a; --line:#3d3d3d; --line2:#4d4d4d;
  --acc-soft:rgba(129,109,251,.22);
  --shadow:0 2px 6px rgba(0,0,0,.35), 0 10px 30px -8px rgba(0,0,0,.6);
  --page-shadow:0 1px 3px rgba(0,0,0,.5), 0 10px 30px -10px rgba(0,0,0,.8);
}

* { box-sizing:border-box; margin:0; padding:0; }
html, body { height:100%; overflow:hidden; background:var(--canvas); color:var(--text); font:400 12px/1.4 "Inter", system-ui, sans-serif; -webkit-font-smoothing:antialiased; }
button, input, select { font:inherit; color:inherit; }
button { background:none; border:0; cursor:pointer; }
button:disabled { opacity:.35; cursor:default; }
[hidden] { display:none !important; }
:focus-visible { outline:2px solid var(--acc); outline-offset:1px; }
a { color:inherit; }
svg.i { width:18px; height:18px; display:block; fill:none; stroke:currentColor; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round; flex:none; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; }
.grow { flex:1; }

.ib { width:30px; height:30px; display:grid; place-items:center; border-radius:6px; flex:none; color:var(--text); font-size:16px; }
.ib:hover:not(:disabled) { background:var(--bg2); }
.btn { display:inline-flex; align-items:center; justify-content:center; gap:6px; height:30px; padding:0 12px; border-radius:6px; border:1px solid var(--line2); font-weight:500; white-space:nowrap; text-decoration:none; }
.btn:hover { background:var(--bg2); }
.btn.sm { height:26px; padding:0 8px; font-size:11.5px; }
.btn.danger:hover { color:#e5484d; border-color:#e5484d; }
.btn-primary { height:32px; padding:0 16px; border-radius:7px; background:var(--acc); color:#fff; font-weight:600; }
.btn-primary:hover:not(:disabled) { filter:brightness(1.08); }

/* ---------- layout ---------- */
.pe { display:flex; flex-direction:column; height:100%; }
.top { height:var(--th); flex:none; display:flex; align-items:center; gap:6px; padding:0 10px; background:var(--bg); border-bottom:1px solid var(--line); z-index:30; }
.logo { display:flex; align-items:center; gap:8px; padding:6px 8px 6px 6px; border-radius:6px; text-decoration:none; font:400 16px/1 "iBrand", "Inter", sans-serif; }
.logo:hover { background:var(--bg2); }
.orb { width:13px; height:13px; border-radius:50%; background:radial-gradient(circle at 35% 30%, #fff, #a497ff 40%, #34229e 85%); box-shadow:0 0 8px #816dfb; flex:none; }
.tag { font-size:10px; font-weight:700; letter-spacing:.06em; padding:3px 6px; border-radius:4px; background:var(--acc-soft); color:var(--acc); }
.fname { width:min(280px, 30vw); height:30px; padding:0 8px; border-radius:6px; border:1px solid transparent; background:transparent; font-weight:600; font-size:13px; }
.fname:hover { border-color:var(--line2); }
.fname:focus { outline:none; border-color:var(--acc); }
.zoomg { display:flex; align-items:center; border:1px solid var(--line); border-radius:7px; margin:0 4px; }
.zoomg .ib { width:28px; height:28px; }
.zl { min-width:52px; height:28px; font-variant-numeric:tabular-nums; font-weight:500; }
.zl:hover { background:var(--bg2); }

.body { flex:1; display:flex; min-height:0; position:relative; }

/* ---------- thumbnails ---------- */
.side { width:var(--sw); flex:none; display:flex; flex-direction:column; background:var(--bg); border-right:1px solid var(--line); min-height:0; z-index:20; }
.side-head { display:flex; align-items:center; gap:6px; padding:12px 12px 6px; font-size:12.5px; }
.side-head .cnt { color:var(--muted); flex:1; }
.pgtools { display:flex; flex-wrap:wrap; gap:2px; padding:0 8px 8px; border-bottom:1px solid var(--line); }
.pgtools .ib { width:30px; height:30px; }
.pgtools .ib svg.i { width:17px; height:17px; }
.thumbs { flex:1; overflow-y:auto; padding:12px 10px 90px; display:flex; flex-direction:column; gap:14px; align-items:center; }
.th { position:relative; width:130px; cursor:pointer; user-select:none; -webkit-user-select:none; }
.th .tb { position:relative; background:#fff; box-shadow:0 0 0 1px var(--line2); border-radius:3px; overflow:hidden; display:grid; place-items:center; }
.th canvas { display:block; width:100%; height:100%; }
.th .tn { display:block; text-align:center; margin-top:5px; font-size:11px; color:var(--muted); font-variant-numeric:tabular-nums; }
.th.cur .tb { box-shadow:0 0 0 2px var(--acc); }
.th.sel .tb { box-shadow:0 0 0 2px var(--acc), 0 0 0 5px var(--acc-soft); }
.th.sel .tn { color:var(--acc); font-weight:600; }
.th.drag { opacity:.4; }
.th.over-b::after, .th.over-a::after { content:""; position:absolute; left:-6px; right:-6px; height:3px; border-radius:2px; background:var(--acc); }
.th.over-b::after { top:-9px; }
.th.over-a::after { bottom:-9px; }

/* ---------- pages ---------- */
.view { flex:1; position:relative; overflow:auto; min-width:0; overscroll-behavior:contain; }
.pages { display:flex; flex-direction:column; align-items:center; gap:22px; padding:28px 24px 120px; min-width:min-content; }
.pg { position:relative; background:#fff; box-shadow:var(--page-shadow); flex:none; }
.pg > canvas.pc { position:absolute; inset:0; width:100%; height:100%; display:block; }
.pg .canvas-container { position:absolute !important; inset:0; }
.pg .pn { position:absolute; left:0; top:-19px; font-size:11px; color:var(--muted); font-variant-numeric:tabular-nums; }
.pg.cur .pn { color:var(--acc); font-weight:600; }
.pg.drawing .canvas-container, .pg.drawing .upper-canvas { touch-action:none; }

/* existing-text edit layer */
.tl { position:absolute; inset:0; pointer-events:none; z-index:5; }
.tl span { position:absolute; pointer-events:auto; cursor:text; border-radius:2px; outline:1px dashed rgba(109,86,250,.45); background:rgba(109,86,250,.05); }
.tl span:hover { outline:2px solid var(--acc); background:rgba(109,86,250,.14); }

/* ---------- empty state ---------- */
.empty { position:absolute; inset:0; overflow:auto; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:18px; padding:28px 20px 100px; }
.drop { width:min(560px, 100%); display:flex; flex-direction:column; align-items:center; gap:8px; padding:40px 24px; border:1.5px dashed var(--line2); border-radius:16px; background:var(--bg); text-align:center; cursor:pointer; transition:border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color:var(--acc); background:var(--acc-soft); }
.drop-ic { width:56px; height:56px; display:grid; place-items:center; border-radius:14px; background:var(--acc); color:#fff; font-weight:700; letter-spacing:.04em; margin-bottom:6px; box-shadow:0 8px 24px -8px var(--acc); }
.drop b { font-size:15px; }
.drop-s { color:var(--muted); }
.drop-s u { color:var(--acc); text-decoration:none; font-weight:600; }
.types { display:flex; flex-wrap:wrap; justify-content:center; gap:4px; margin-top:10px; max-width:460px; }
.types span { font-size:10.5px; padding:2px 7px; border-radius:20px; background:var(--bg2); color:var(--muted); }
.empty-row { display:flex; flex-wrap:wrap; gap:8px; justify-content:center; }
.feats { list-style:none; display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px 22px; width:min(560px, 100%); color:var(--muted); }
.feats b { display:block; color:var(--text); font-weight:600; }
.seo-static { width:min(560px, 100%); color:var(--dim); font-size:11px; }
.seo-static h1 { font-size:12px; color:var(--muted); font-weight:600; }
.seo-static a { color:var(--muted); }
.pe.has-doc .empty { display:none; }
.pe:not(.has-doc) .side, .pe:not(.has-doc) .props, .pe:not(.has-doc) .dock, .pe:not(.has-doc) .zoomg { display:none; }

.dropzone { position:absolute; inset:10px; z-index:40; border:2px dashed var(--acc); border-radius:14px; background:rgba(109,86,250,.1); display:grid; place-items:center; pointer-events:none; }
.dropzone span { padding:10px 16px; border-radius:8px; background:var(--acc); color:#fff; font-weight:600; }
.busy { position:absolute; inset:0; z-index:45; display:flex; align-items:center; justify-content:center; gap:10px; background:color-mix(in srgb, var(--canvas) 70%, transparent); font-weight:500; }
.spin { width:18px; height:18px; border-radius:50%; border:2px solid var(--acc-soft); border-top-color:var(--acc); animation:spin .8s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ---------- properties ---------- */
.props { width:var(--pw); flex:none; background:var(--bg); border-left:1px solid var(--line); overflow-y:auto; padding-bottom:90px; z-index:20; }
.sec { padding:12px 14px; border-bottom:1px solid var(--line); display:flex; flex-direction:column; gap:9px; }
.sec-t { font-weight:600; font-size:11.5px; display:flex; align-items:center; justify-content:space-between; }
.sec-t small { font-weight:400; color:var(--muted); }
.note { color:var(--muted); font-size:11.5px; line-height:1.5; }
.row { display:flex; align-items:center; gap:6px; }
.row > label { width:62px; flex:none; color:var(--muted); }
.row select, .row input[type=number] { flex:1; min-width:0; height:28px; border-radius:6px; border:1px solid var(--line2); background:var(--bg); padding:0 6px; }
input[type=range] { flex:1; accent-color:var(--acc); min-width:0; }
.sws { display:flex; flex-wrap:wrap; gap:6px; }
.sw { width:22px; height:22px; border-radius:50%; box-shadow:inset 0 0 0 1px rgba(0,0,0,.15); position:relative; }
.sw.on::after { content:""; position:absolute; inset:-4px; border-radius:50%; border:2px solid var(--acc); }
.sw.custom { background:conic-gradient(#f44, #fd4, #4d4, #4df, #44f, #f4f, #f44); overflow:hidden; }
.sw.custom input { position:absolute; inset:0; opacity:0; cursor:pointer; }
.sw.none { background:linear-gradient(135deg, transparent 45%, #e5484d 45%, #e5484d 55%, transparent 55%), var(--bg); }
.seg { display:flex; gap:2px; padding:2px; border-radius:7px; background:var(--bg2); }
.seg button { flex:1; height:26px; display:grid; place-items:center; border-radius:5px; color:var(--muted); font-weight:600; }
.seg button.on { background:var(--bg); color:var(--text); box-shadow:0 1px 2px rgba(0,0,0,.12); }
.btns { display:flex; flex-wrap:wrap; gap:6px; }
.kbd { font-size:10.5px; color:var(--dim); }

/* ---------- tool dock ---------- */
.dock { position:absolute; left:calc(50% + (var(--sw) - var(--pw)) / 2); bottom:18px; transform:translateX(-50%); z-index:25; display:flex; align-items:center; gap:2px; padding:5px; border-radius:14px; background:var(--bg); box-shadow:var(--shadow); border:1px solid var(--line); max-width:calc(100% - var(--sw) - var(--pw) - 24px); overflow-x:auto; scrollbar-width:none; }
.dock::-webkit-scrollbar { display:none; }
.tool { min-width:42px; height:44px; padding:0 5px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; border-radius:9px; color:var(--text); flex:none; font-size:10px; }
.tool span { color:var(--muted); white-space:nowrap; }
.tool:hover { background:var(--bg2); }
.tool.on { background:var(--acc); color:#fff; }
.tool.on span { color:#fff; }
.dock .sep { width:1px; height:26px; background:var(--line2); margin:0 3px; flex:none; }

/* save menu */
.top { position:relative; }
.smenu { position:absolute; right:10px; top:calc(var(--th) - 4px); z-index:60; width:290px; padding:6px; border-radius:10px; background:var(--bg); border:1px solid var(--line); box-shadow:var(--shadow); display:flex; flex-direction:column; }
.smenu button { text-align:left; padding:9px 10px; border-radius:7px; display:flex; flex-direction:column; gap:2px; }
.smenu button:hover { background:var(--acc-soft); }
.smenu b { font-weight:600; font-size:12.5px; }
.smenu small { color:var(--muted); font-size:11px; line-height:1.35; }

/* ---------- modal (signature) ---------- */
.modal { position:fixed; inset:0; z-index:90; display:grid; place-items:center; padding:16px; background:rgba(0,0,0,.5); }
.mbox { width:min(640px, 100%); background:var(--bg); border-radius:14px; box-shadow:var(--shadow); padding:16px; display:flex; flex-direction:column; gap:12px; }
.mbox h2 { font-size:15px; }
.sigpad { width:100%; aspect-ratio:3 / 1; background:#fff; border:1px solid var(--line2); border-radius:10px; touch-action:none; cursor:crosshair; display:block; }
.mrow { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.sig-type { flex:1; min-width:160px; height:34px; border-radius:7px; border:1px solid var(--line2); background:var(--bg); padding:0 10px; font-size:14px; }

.toast { position:fixed; left:50%; top:62px; transform:translate(-50%, -16px); z-index:100; padding:9px 14px; border-radius:8px; background:#1e1e1e; color:#fff; font-weight:500; opacity:0; pointer-events:none; transition:opacity .2s, transform .2s; box-shadow:var(--shadow); max-width:calc(100% - 24px); text-align:center; }
.toast.show { opacity:1; transform:translate(-50%, 0); }

.mob-only { display:none !important; }
.side-btn { position:absolute; left:10px; bottom:84px; z-index:26; height:34px; padding:0 12px; border-radius:18px; background:var(--bg); box-shadow:var(--shadow); border:1px solid var(--line); font-weight:600; }

/* ---------- small screens ---------- */
@media (max-width:1380px) { .tool span { font-size:9.5px; } }
@media (max-width:980px) {
  :root { --pw:212px; --sw:168px; }
  .th { width:108px; }
}
@media (max-width:760px) {
  :root { --th:50px; }
  .mob-only { display:grid !important; }
  .side-btn.mob-only { display:block !important; }
  .pe:not(.has-doc) .side-btn { display:none !important; }
  .lt, .tag, #pe-theme { display:none; }
  .fname { width:auto; flex:1; min-width:0; }
  .top .grow { display:none; }
  .zoomg .ib { display:none; }
  .zoomg { margin:0; }
  #pe-open { display:none; }
  .side { position:absolute; left:0; top:0; bottom:0; width:min(250px, 80vw); transform:translateX(-102%); transition:transform .22s; box-shadow:var(--shadow); }
  .side.open { transform:none; }
  .props { position:absolute; left:0; right:0; bottom:66px; width:auto; max-height:44vh; border:0; border-top:1px solid var(--line); border-radius:14px 14px 0 0; box-shadow:0 -10px 30px -12px rgba(0,0,0,.3); padding-bottom:6px; }
  .props:empty, .props.idle { display:none; }
  .props .sec { padding:10px 14px; }
  .dock { left:8px; right:8px; bottom:8px; transform:none; max-width:none; border-radius:14px; }
  .pages { padding:24px 8px 150px; gap:18px; }
  .feats { grid-template-columns:1fr; }
  .drop { padding:30px 18px; }
}
