/* PDF 填寫工具 — 依 super-individual 視覺規範 v1（色彩/字體/元件皆用規範 token） */
:root{
  --blue:#3D5062; --blue-deep:#2C3B49; --mist:#AABBC2; --paper:#EFF0EC;
  --card:#FFFFFF; --tint:#E4EAEE; --line:#DCE1E0; --ink:#2F3E4C;
  --sub:#59717B; --faint:#7C8B95; --danger:#B23A2F; --bubble:#DCE6EC;
}
*{margin:0;padding:0;box-sizing:border-box}
html,body{height:100%}
body{
  font-family:"Noto Sans TC","Microsoft JhengHei",system-ui,sans-serif;
  background:var(--paper); color:var(--ink); font-size:14.5px; line-height:1.7;
}
#app{display:flex; flex-direction:column; height:100vh}
[hidden]{display:none!important}
[data-icon] svg{display:block}

/* ── 頂欄 ── */
.topbar{
  display:flex; align-items:center; gap:20px; padding:12px 22px;
  background:var(--card); border-bottom:1px solid var(--line);
}
.topbar-title{display:flex; align-items:center; gap:10px; min-width:0}
.topbar-title [data-icon]{width:21px;height:21px;color:var(--blue)}
.topbar-title h1{font-size:19px; font-weight:700; color:var(--blue); white-space:nowrap}
.doc-name{
  font-size:12.5px; color:var(--sub); background:var(--tint); padding:3px 10px;
  border-radius:20px; max-width:260px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.steps{display:flex; gap:4px; list-style:none; margin-left:auto}
.steps li{
  font-size:12.5px; color:var(--faint); padding:4px 12px; border-radius:20px;
  position:relative; font-weight:500;
}
.steps li:not(:first-child)::before{
  content:""; position:absolute; left:-5px; top:50%; width:6px; height:1px; background:var(--line);
}
.steps li.on{background:var(--blue); color:#fff; font-weight:700}
.steps li.done{color:var(--blue)}
.topbar-actions{display:flex; gap:8px}

/* ── 舞台共通 ── */
.stage{flex:1; min-height:0; overflow:auto}

/* ── 上傳 ── */
#stage-upload{display:flex; align-items:center; justify-content:center; padding:30px}
.dropzone{
  width:min(620px,100%); background:var(--card); border:2px dashed var(--mist);
  border-radius:12px; padding:52px 40px; text-align:center; cursor:pointer;
  transition:border-color .18s, background .18s;
}
.dropzone.hover{border-color:var(--blue); background:#F7F9F8}
.dz-icon{display:inline-flex; width:34px; height:34px; color:var(--mist); margin-bottom:14px}
.dropzone h2{font-size:20px; color:var(--blue); margin-bottom:10px}
.dropzone p{color:var(--sub); font-size:13.5px; margin-bottom:20px}
.dz-hint{font-size:12px; color:var(--faint); margin-top:14px; margin-bottom:0!important}

/* ── 解析中 ── */
#stage-parse{display:flex; align-items:center; justify-content:center}
.parse-card{text-align:center; padding:40px}
.spinner{
  width:38px; height:38px; margin:0 auto 18px; border-radius:50%;
  border:3px solid var(--tint); border-top-color:var(--blue);
  animation:spin .9s linear infinite;
}
@keyframes spin{to{transform:rotate(360deg)}}
.parse-card h2{font-size:19px; color:var(--blue)}
.sub{font-size:13px; color:var(--sub)}

/* ── 工作區 ── */
.workspace{display:flex; gap:0}
.canvas-col{flex:1; min-width:0; display:flex; flex-direction:column; border-right:1px solid var(--line)}
.canvas-toolbar{
  display:flex; align-items:center; gap:8px; padding:8px 14px;
  background:var(--card); border-bottom:1px solid var(--line);
}
.icon-btn{
  display:inline-flex; align-items:center; justify-content:center;
  width:30px; height:30px; border:1px solid var(--line); border-radius:9px;
  background:var(--card); color:var(--ink); cursor:pointer;
}
.icon-btn:hover{background:var(--tint)}
.icon-btn [data-icon]{width:17px;height:17px}
.icon-btn:disabled{opacity:.35; cursor:not-allowed}
#pg-next [data-icon]{transform:scaleX(-1)}
.pg-ind{font-size:13px; color:var(--sub); min-width:52px; text-align:center}
.ct-gap{flex:1}
.ct-note{font-size:12px; color:var(--faint)}
.canvas-wrap{
  position:relative; flex:1; min-height:0; overflow:auto; padding:18px;
  display:flex; justify-content:center; align-items:flex-start;
}
#pdf-canvas{
  max-width:100%; height:auto; background:#fff;
  border:1px solid var(--line); border-radius:4px;
}
.marker-layer{position:absolute; inset:18px; pointer-events:none}
.marker{
  position:absolute; transform:translate(-3px,-100%);
  border:1.5px solid var(--mist); background:rgba(170,187,194,.14);
  border-radius:3px; min-width:14px; min-height:14px;
  transition:border-color .15s, background .15s;
}
.marker.sel{border-color:var(--blue); background:rgba(61,80,98,.14); border-width:2px}
.marker.has-val{border-style:solid}
.marker .tag{
  position:absolute; top:-19px; left:-2px; font-size:10.5px; line-height:1.3;
  background:var(--blue); color:#fff; padding:1px 7px; border-radius:4px;
  white-space:nowrap; opacity:0; transition:opacity .15s;
}
.marker.sel .tag{opacity:1}

/* ── 右欄表單 ── */
.form-col{
  width:390px; flex-shrink:0; display:flex; flex-direction:column;
  background:var(--card);
}
.form-head{padding:16px 18px 8px}
.form-head h2{font-size:16.5px; color:var(--blue)}
.field-list{flex:1; min-height:0; overflow-y:auto; padding:6px 14px 14px}
.field-row{
  border:1px solid var(--line); border-radius:9px; padding:9px 11px;
  margin-bottom:8px; cursor:pointer; background:var(--card);
  transition:border-color .15s, background .15s;
}
.field-row.sel{border-color:var(--blue); background:#F7F9F8; border-left:3px solid var(--blue); padding-left:9px}
.fr-top{display:flex; align-items:center; gap:8px; margin-bottom:5px}
.fr-label{
  font-size:12.5px; font-weight:700; color:var(--sub); border:none; background:transparent;
  flex:1; min-width:0; font-family:inherit; padding:1px 2px; border-radius:4px;
}
.fr-label:focus{outline:1.5px solid var(--mist); background:#fff}
.fr-page{font-size:11px; color:var(--faint); white-space:nowrap}
.fr-del{
  display:inline-flex; width:22px; height:22px; align-items:center; justify-content:center;
  border:none; background:transparent; color:var(--faint); cursor:pointer; border-radius:5px;
}
.fr-del:hover{color:var(--danger); background:#F8EFEE}
.fr-del [data-icon]{width:14px;height:14px}
.fr-input{
  width:100%; border:1px solid var(--line); border-radius:9px; padding:8px 10px;
  font-size:14px; font-family:inherit; color:var(--ink); background:#fff;
}
.fr-input:focus{outline:none; border-color:var(--blue)}
.fr-input::placeholder{color:var(--faint)}
.fr-check{display:flex; align-items:center; gap:9px; font-size:13.5px; color:var(--ink); padding:2px 0}
.fr-check input{width:17px; height:17px; accent-color:var(--blue)}
.fr-size{display:flex; align-items:center; gap:6px; margin-top:6px; font-size:11.5px; color:var(--faint)}
.fr-size input{width:52px; border:1px solid var(--line); border-radius:5px; padding:2px 6px; font-size:12px}
.form-foot{
  display:flex; gap:9px; padding:12px 16px; border-top:1px solid var(--line);
}
.form-foot .btn{flex:1}

/* ── 按鈕 ── */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:7px;
  background:var(--blue); color:#fff; border:none; border-radius:9px;
  font-size:14px; font-weight:700; padding:10px 18px; cursor:pointer;
  font-family:inherit; transition:background .15s;
}
.btn:hover{background:var(--blue-deep)}
.btn:disabled{opacity:.35; cursor:not-allowed}
.btn [data-icon]{width:16px;height:16px}
.btn.ghost{background:var(--card); color:var(--ink); border:1px solid var(--line); font-weight:500}
.btn.ghost:hover{background:var(--tint)}

/* ── 預覽 ── */
.previewer{display:flex; flex-direction:column; align-items:center; padding:26px 20px}
.preview-head{text-align:center; margin-bottom:18px}
.preview-head h2{font-size:20px; color:var(--blue)}
.preview-pages{display:flex; flex-direction:column; gap:20px; align-items:center; width:100%}
.preview-pages canvas{
  max-width:min(860px,100%); height:auto; background:#fff;
  border:1px solid var(--line); border-radius:4px;
}
.preview-actions{
  position:sticky; bottom:0; display:flex; gap:12px; padding:16px;
  margin-top:8px; background:linear-gradient(transparent, var(--paper) 40%);
  width:100%; justify-content:center;
}

/* ── 完成 ── */
#stage-done{display:flex; align-items:center; justify-content:center}
.done-card{text-align:center; background:var(--card); border:1px solid var(--line); border-radius:12px; padding:44px 56px}
.done-icon{display:inline-flex; width:34px; height:34px; color:var(--blue); margin-bottom:12px}
.done-card h2{font-size:20px; color:var(--blue); margin-bottom:6px}
.done-actions{display:flex; gap:10px; margin-top:22px; justify-content:center}

/* ── Toast ── */
.toast{
  position:fixed; left:50%; bottom:26px; transform:translateX(-50%);
  background:var(--blue-deep); color:#fff; font-size:13.5px;
  padding:10px 20px; border-radius:9px; box-shadow:0 6px 22px rgba(20,30,38,.28);
  z-index:60; max-width:min(560px,92vw);
}
.toast.err{background:var(--danger)}

/* ── 響應式 ── */
@media (max-width:900px){
  .workspace{flex-direction:column}
  .canvas-col{border-right:none; border-bottom:1px solid var(--line); max-height:52vh}
  .form-col{width:100%; flex:1}
  .steps{display:none}
}
