@font-face{font-family:"Everflow Termes";src:url("../assets/vendor/typst/fonts/TeXGyreTermesX-Regular.otf") format("opentype");font-style:normal;font-weight:400;font-display:swap}
@font-face{font-family:"Everflow Termes";src:url("../assets/vendor/typst/fonts/TeXGyreTermesX-Bold.otf") format("opentype");font-style:normal;font-weight:700;font-display:swap}
@font-face{font-family:"Everflow Kai";src:url("../assets/vendor/typst/fonts/FandolKai-Regular.otf") format("opentype");font-style:normal;font-weight:400;font-display:swap}

html,body{min-height:100%}
body.editor-page{overflow-x:hidden;background:#f1f2f4}
body.editor-page.dark{background:#090a0c}

.editor-topbar{
  position:sticky;top:0;z-index:90;height:64px;padding:0 18px;
  display:flex;align-items:center;justify-content:space-between;gap:18px;
  border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--card) 96%,transparent);
  backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);
}
.editor-brand-wrap,.editor-top-actions,.editor-toolbar-actions{display:flex;align-items:center;gap:9px}
.editor-top-actions{justify-content:flex-end}
.editor-shell{
  width:100%;min-height:calc(100dvh - 64px);display:grid;
  grid-template-columns:310px minmax(0,1fr);align-items:start;
}
.editor-sidebar{
  position:sticky;top:64px;height:calc(100dvh - 64px);display:flex;flex-direction:column;
  border-right:1px solid var(--line);background:var(--card);z-index:30;
}
.sidebar-head{
  padding:18px 16px 13px;display:flex;align-items:flex-start;justify-content:space-between;gap:12px;
  border-bottom:1px solid var(--line);
}
.sidebar-head span,.editor-toolbar span{display:block;color:var(--red);font-size:9px;font-weight:900;letter-spacing:.15em}
.sidebar-head strong{display:block;max-width:215px;margin-top:3px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:15px}
.sidebar-head>b{
  min-width:31px;height:31px;padding:0 8px;display:grid;place-items:center;border-radius:9px;background:var(--soft);
  font-size:11px;
}
.sidebar-note{padding:10px 16px;color:var(--muted);font-size:9px;border-bottom:1px solid var(--line);line-height:1.6}
.editor-sidebar .order-list{padding:8px;flex:1;min-height:0;overflow:auto}
.sidebar-foot{
  min-height:54px;padding:10px 15px;display:flex;align-items:center;justify-content:space-between;gap:10px;
  border-top:1px solid var(--line);
}
.sidebar-foot a{display:inline-flex;align-items:center}

.editor-main{min-width:0;padding-bottom:42px}
.editor-toolbar{
  position:sticky;top:64px;z-index:25;min-height:66px;padding:11px 18px;
  display:flex;align-items:center;justify-content:space-between;gap:18px;
  border-bottom:1px solid var(--line);background:color-mix(in srgb,var(--card) 94%,transparent);
  backdrop-filter:blur(16px);-webkit-backdrop-filter:blur(16px);
}
.editor-toolbar strong,.editor-toolbar small{display:block}
.editor-toolbar strong{font-size:13px}
.editor-toolbar small{margin-top:2px;color:var(--muted);font-size:9px}
.preview-chip{
  min-height:30px;padding:0 10px!important;display:inline-flex!important;align-items:center!important;gap:6px;
  border:1px solid var(--line);border-radius:999px;background:var(--soft);color:var(--muted)!important;
  font-size:9px!important;font-weight:800!important;letter-spacing:0!important;
}
.preview-chip i{width:6px;height:6px;border-radius:50%;background:var(--green)}

.editor-main .paper-stage{min-height:calc(100dvh - 130px);padding:30px 34px 70px;background:#e7e8eb}
body.dark .editor-main .paper-stage{background:#090a0c}
.editor-main .paper-sheet{margin:0 auto}

.editor-main .compile-bar{
  position:sticky;top:130px;z-index:40;margin:12px 16px 0;border-radius:16px;
}
@media(max-width:900px){
  .editor-shell{grid-template-columns:250px minmax(0,1fr)}
  .editor-top-actions .ghost-btn:first-child{display:none}
}
@media(max-width:760px){
  .editor-topbar{height:58px;padding:0 10px}
  .editor-topbar .brand small{display:none}
  .editor-topbar .local-pill{display:none}
  .editor-top-actions .ghost-btn{display:none}
  .editor-top-actions .primary-btn{min-height:38px;padding:0 10px;font-size:10px}
  .editor-shell{display:block}
  .editor-sidebar{position:relative;top:auto;height:auto;max-height:43dvh;border-right:0;border-bottom:1px solid var(--line)}
  .editor-sidebar .order-list{max-height:260px}
  .editor-toolbar{top:0;min-height:58px;padding:9px 11px}
  .editor-toolbar>div:first-child small{display:none}
  .editor-toolbar-actions .preview-chip{display:none!important}
  .editor-main .paper-stage{padding:12px 0 34px;overflow:hidden}
  body.editor-page.compile-mode .paper-stage{padding:10px 0}
}
@media print{
  .editor-topbar,.editor-sidebar,.editor-toolbar,.compile-bar,.question-move-tools{display:none!important}
  .editor-shell,.editor-main,.paper-stage{display:block!important;width:auto!important;margin:0!important;padding:0!important;background:#fff!important}
}

.mode-switch{display:flex;padding:3px;background:var(--soft);border:1px solid var(--line);border-radius:10px;flex-shrink:0}
.mode-switch button{border:0;border-radius:7px;padding:8px 14px;background:transparent;color:var(--muted);cursor:pointer;font:inherit}
.mode-switch button[aria-pressed="true"]{background:var(--card);color:var(--red);box-shadow:0 1px 5px #0001}
.paper-settings,.question-editor{padding:12px 16px;border-bottom:1px solid var(--line)}
.paper-settings label,.question-editor label{display:block;font-size:12px;margin-bottom:10px;color:var(--muted)}
.paper-settings input,.question-editor input,.question-editor textarea,.question-editor select{display:block;box-sizing:border-box;width:100%;margin-top:5px;padding:8px;border:1px solid var(--line);border-radius:7px;background:var(--card);color:var(--text);font:inherit}
.question-editor textarea{min-height:85px;resize:vertical;line-height:1.6}
.question-editor{overflow:auto;max-height:48dvh;border-top:1px solid var(--line)}
.question-editor h3{font-size:13px;margin:0 0 12px}.question-editor .option-editor{display:flex;align-items:center;gap:5px}.option-editor input{flex:1;min-width:0}
.order-item.is-selected{outline:1px solid var(--red);background:var(--soft)}.order-copy{cursor:pointer}
body.preview-mode .editor-sidebar{display:none}body.preview-mode .editor-shell{grid-template-columns:minmax(0,1fr)}
.pdf-status{padding:8px 18px;font-size:12px;color:var(--muted)}.pdf-status:empty{display:none}
#pdfPreview{width:100%;height:calc(100dvh - 172px);border:0;background:#e7e8eb}
#pdfPreview[hidden]{display:none}.paper-running-head.book-head{display:flex;justify-content:space-between;gap:12px}.paper-running-head.book-head span{max-width:45%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
@media(max-width:760px){.editor-topbar{height:auto;min-height:58px;flex-wrap:wrap;padding:8px 10px;gap:6px}.editor-top-actions{flex-wrap:wrap}.editor-top-actions .ghost-btn{display:inline-flex;padding:6px;font-size:10px}.editor-sidebar{max-height:none}.editor-sidebar .order-list{max-height:180px;flex:auto}.question-editor{max-height:45dvh}.editor-toolbar{position:relative;top:auto;flex-wrap:wrap;gap:8px}.editor-toolbar-actions{flex-wrap:wrap}.mode-switch button{padding:7px 10px}}

.paper-sheet,.paper-running-head,.paper-footer{font-family:"Times New Roman","Everflow Song",serif;font-synthesis:none}.paper-header h1{font-family:"Everflow Hei",sans-serif}

@media(max-width:760px){#templateButton{display:inline-flex}.editor-main .paper-sheet{width:210mm;min-width:210mm;max-width:none;transform:none;zoom:var(--preview-scale,0.45)}.editor-main .paper-stage{min-height:0}}


/* 2026-09-21 local editor: Chinese template selector + locked cover controls */
.history-actions{display:flex;gap:4px}
.icon-text-btn{
  width:34px;height:34px;display:grid;place-items:center;border:1px solid var(--line);border-radius:10px;
  background:var(--card);cursor:pointer;font-size:17px;font-weight:800
}
.icon-text-btn:disabled{opacity:.32;cursor:default}
.save-state{
  min-height:32px;padding:0 9px;display:inline-flex;align-items:center;gap:6px;border-radius:999px;
  color:var(--muted);font-size:9px;font-weight:800;white-space:nowrap
}
.save-state i{width:6px;height:6px;border-radius:50%;background:var(--green)}
.template-control{position:relative}
.template-trigger{display:flex!important;align-items:center;gap:8px;white-space:nowrap}
.template-trigger b{font-size:11px;color:var(--muted)}
.template-popover{
  position:absolute;z-index:140;top:calc(100% + 8px);right:0;width:330px;max-height:min(72vh,590px);overflow:auto;
  padding:9px;border:1px solid var(--line);border-radius:16px;background:var(--card);box-shadow:0 22px 70px rgba(0,0,0,.16)
}
.template-popover-head{padding:7px 8px 10px;border-bottom:1px solid var(--line)}
.template-popover-head strong,.template-popover-head small{display:block}
.template-popover-head strong{font-size:13px}
.template-popover-head small{margin-top:2px;color:var(--muted);font-size:9px}
.template-popover section{padding:9px 0 3px}
.template-popover h4{margin:0 8px 6px;color:var(--muted);font-size:9px;letter-spacing:.12em}
.template-option{
  width:100%;padding:9px 10px;display:flex;align-items:center;justify-content:space-between;gap:12px;
  border:0;border-radius:10px;background:transparent;color:var(--text);text-align:left;cursor:pointer
}
.template-option:hover{background:var(--soft)}
.template-option.is-active{background:color-mix(in srgb,var(--red) 8%,var(--soft));color:var(--red)}
.template-option strong{font-size:12px}
.template-option small{color:var(--muted);font-size:9px;white-space:nowrap}
.locked-row{
  display:grid;grid-template-columns:1fr auto auto;align-items:center;gap:8px;padding:8px 0;color:var(--muted);font-size:10px
}
.locked-row b{font-size:10px;color:var(--text);font-weight:700}
.locked-row em{padding:2px 6px;border-radius:999px;background:var(--soft);font-size:8px;font-style:normal}
.order-toolbar{padding:10px 16px 5px;display:flex;align-items:center;justify-content:space-between;color:var(--muted)}
.order-toolbar strong{font-size:10px;color:var(--text)}
.order-toolbar span{font-size:9px}
.question-editor-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:10px}
.question-editor-head h3{margin:0}
.question-editor-head>div{display:flex;gap:6px}
.question-editor .check-row{display:flex;align-items:center;gap:5px}
.question-editor .check-row input{width:auto;margin:0}
.option-editor b{width:18px;text-align:center}
.add-option{margin-top:6px}

/* Fixed white cover preview. Only title and export date are dynamic. */
.cover-sheet{
  position:relative!important;width:210mm!important;min-width:210mm!important;height:297mm!important;min-height:297mm!important;
  margin:0 auto 28px!important;overflow:hidden;background:#fff;color:#111;box-shadow:var(--page-shadow);
  transform-origin:top center
}
.cover-main-title{
  position:absolute;left:18mm;right:18mm;top:calc(297mm - 171mm - 9mm);
  text-align:center;font-family:"Everflow Hei","Noto Sans SC",sans-serif;font-size:24pt;font-weight:700;line-height:1.18
}
.cover-signature{
  position:absolute;left:18mm;right:18mm;top:calc(297mm - 146mm - 5mm);
  text-align:center;font-family:"Everflow Song",serif;font-size:11pt
}
.cover-bottom-line{position:absolute;left:18mm;top:266mm;width:50mm;border-top:.45pt solid #111}
.cover-brand{position:absolute;left:18mm;top:271.5mm;font-family:"Everflow Song",serif;font-size:9pt}
.cover-date{position:absolute;left:18mm;top:278mm;font-family:"Everflow Song",serif;font-size:8pt}

/* Preview sheet follows the selected fixed template dimensions. */
.editor-main #paperSheet{
  width:var(--paper-w,210mm);min-width:var(--paper-w,210mm);
  min-height:var(--paper-h,297mm);height:auto;transform-origin:top center
}
body[data-template="exam"][data-layout="a3"] #paperSheet,
body[data-template="exam"][data-layout="mixed"] #paperSheet{padding-left:18mm;padding-right:18mm}
body[data-template="exam"][data-layout="a3"] .paper-questions,
body[data-template="exam"][data-layout="mixed"] .paper-questions{
  columns:2;column-gap:24mm;column-rule:0 solid transparent
}
body[data-template="book"] #paperSheet{padding-left:18mm;padding-right:18mm}
body[data-template="book"][data-layout="padl"] #paperSheet{padding:10mm 12mm 12mm}
body[data-template="book"][data-layout="padp"] #paperSheet{padding:14mm 14mm 12mm}
body[data-template="book"][data-layout="single"] .question,
body[data-template="book"][data-layout="padl"] .question,
body[data-template="book"][data-layout="padp"] .question{break-after:page}
.paper-section-heading{break-after:avoid-column;break-inside:avoid;margin-top:.7em}
.question{break-inside:avoid-column;cursor:pointer}
.question:hover{outline:1px dashed rgba(243,18,36,.18);outline-offset:2mm}
.force-break-before{break-before:page}
.paper-running-head[hidden]{display:none!important}

@media(max-width:1060px){
  .save-state{display:none}
  .editor-shell{grid-template-columns:280px minmax(0,1fr)}
}
@media(max-width:760px){
  .history-actions{display:none}
  .template-control{order:1}
  .template-popover{position:fixed;left:10px;right:10px;top:64px;width:auto;max-height:70dvh}
  .save-state{display:none}
  #saveProjectButton{display:none!important}
  .editor-main .paper-stage{overflow:auto}
  .editor-main #paperSheet,.cover-sheet{zoom:var(--preview-scale,.45);transform:none}
  .cover-sheet{margin-bottom:20px!important}
}


/* 2026-09-21 XeLaTeX parity calibration: measured against original PDFs */
.editor-main #paperSheet{box-sizing:border-box}
.editor-main #paperSheet .paper-header{display:none!important}
.editor-main #paperSheet .paper-questions{padding:0 0 14mm!important}
.editor-main #paperSheet .question{
  font-weight:400!important;
  line-height:1.56!important;
}
.editor-main #paperSheet .question-number{font-weight:400!important}
.editor-main #paperSheet .question-body p{margin:0!important}
.editor-main #paperSheet .options{margin-left:calc(2.25em + .55em)!important}
.editor-main #paperSheet .options.cols-4{grid-template-columns:repeat(4,minmax(0,1fr));column-gap:.55em!important}
.editor-main #paperSheet .options.cols-3{grid-template-columns:repeat(3,minmax(0,1fr));column-gap:.8em!important}
.editor-main #paperSheet .options.cols-2{grid-template-columns:repeat(2,minmax(0,1fr));column-gap:1.2em!important}
.editor-main #paperSheet .options.cols-1{grid-template-columns:1fr}
.editor-main #paperSheet .paper-footer{border:0!important;padding-top:0!important;justify-content:center!important;color:#24272b!important}

/* 试卷：原 Exam A4 / A3 geometry */
body[data-template="exam"] .editor-main #paperSheet{
  font-size:10.5pt!important;line-height:1.56!important;
}
body[data-template="exam"][data-layout="a4"] .editor-main #paperSheet{
  padding:16mm 20mm 12mm!important;
}
body[data-template="exam"][data-layout="a3"] .editor-main #paperSheet,
body[data-template="exam"][data-layout="mixed"] .editor-main #paperSheet{
  padding:14mm 18mm 11mm!important;
}
body[data-template="exam"] .editor-main #paperSheet .question{margin-bottom:2.93mm!important}
body[data-template="exam"] .editor-main #paperSheet .options{margin-top:2.60mm!important}
body[data-template="exam"] .editor-main #paperSheet .paper-running-head{display:none!important}
body[data-template="exam"] .editor-main #paperSheet .paper-footer{
  left:20mm!important;right:20mm!important;bottom:5.3mm!important;
  font-size:9pt!important;font-family:"Everflow Song","FandolKai","KaiTi",serif!important;
}
body[data-template="exam"][data-layout="a3"] .editor-main #paperSheet .paper-footer,
body[data-template="exam"][data-layout="mixed"] .editor-main #paperSheet .paper-footer{
  left:18mm!important;right:18mm!important;
}

/* 做题本：原 ExBook geometry / typography */
body[data-template="book"] .editor-main #paperSheet{
  font-size:12pt!important;line-height:1.56!important;
  padding:14mm 18mm 14mm!important;
}
body[data-template="book"][data-layout="compact"] .editor-main #paperSheet .question{margin-bottom:1.69mm!important}
body[data-template="book"][data-layout="standard"] .editor-main #paperSheet .question{margin-bottom:25mm!important}
body[data-template="book"][data-layout="loose"] .editor-main #paperSheet .question{margin-bottom:75mm!important}
body[data-template="book"][data-layout="single"] .editor-main #paperSheet .question,
body[data-template="book"][data-layout="padl"] .editor-main #paperSheet .question,
body[data-template="book"][data-layout="padp"] .editor-main #paperSheet .question{margin-bottom:0!important}
body[data-template="book"] .editor-main #paperSheet .options{margin-top:2.97mm!important}
body[data-template="book"] .editor-main #paperSheet .paper-running-head{
  left:18mm!important;right:18mm!important;top:5.7mm!important;height:6mm!important;
  font-size:10pt!important;line-height:12pt!important;font-weight:700!important;
  border-bottom:.4pt solid #24272b!important;padding-bottom:1.5mm!important;
}
body[data-template="book"] .editor-main #paperSheet .paper-footer{
  left:18mm!important;right:18mm!important;bottom:4.0mm!important;
  font-size:9pt!important;line-height:11pt!important;
  font-family:"Everflow Song","FandolSong","Songti SC",serif!important;
}
body[data-template="book"][data-layout="padl"] .editor-main #paperSheet{
  padding:10mm 12mm 12mm!important;
}
body[data-template="book"][data-layout="padp"] .editor-main #paperSheet{
  padding:14mm 14mm 12mm!important;
}
body[data-template="book"][data-layout="padl"] .editor-main #paperSheet .paper-running-head,
body[data-template="book"][data-layout="padp"] .editor-main #paperSheet .paper-running-head{
  left:12mm!important;right:12mm!important;
}
body[data-template="book"][data-layout="padp"] .editor-main #paperSheet .paper-running-head{
  left:14mm!important;right:14mm!important;
}

/* 原 white 正封面：按参考 PDF 实测字号/坐标校准 */
.cover-main-title{
  top:121.3mm!important;
  font-family:"Everflow Song","FandolSong","Songti SC",serif!important;
  font-size:24.787pt!important;line-height:30pt!important;font-weight:700!important;
}
.cover-signature{
  top:147.0mm!important;
  font-family:"Everflow Song","FandolSong","Songti SC",serif!important;
  font-size:14.346pt!important;line-height:18pt!important;font-weight:700!important;
}
.cover-bottom-line{left:18mm!important;top:266mm!important;width:50mm!important;border-top:.4pt solid #111!important}
.cover-brand{
  left:19.3mm!important;top:270.6mm!important;
  font-family:"Everflow Song","FandolSong","Songti SC",serif!important;
  font-size:9.465pt!important;line-height:12pt!important;font-weight:700!important;
}
.cover-date{
  left:19.3mm!important;top:277.2mm!important;
  font-family:"Everflow Song","FandolSong","Songti SC",serif!important;
  font-size:8.966pt!important;line-height:11pt!important;font-weight:700!important;
}
body[data-template="exam"] .cover-date{color:#f00!important}
body[data-template="book"] .cover-date{color:#24272b!important}


/* Current fixed master parity correction - source recompiled 2026-09-21 */
body[data-template="exam"] .editor-main #paperSheet{
  font-size:9pt!important;
  line-height:1.56!important;
}
body[data-template="book"] .editor-main #paperSheet{
  font-size:10.5pt!important;
  line-height:1.56!important;
}
body[data-template="book"][data-layout="compact"] .editor-main #paperSheet .question{
  margin-bottom:2.0225mm!important;
}
body[data-template="exam"] .paper-section-heading{
  font-size:9pt!important;line-height:1.56!important;font-weight:700!important;
}
body[data-template="book"] .paper-section-heading{
  font-size:12pt!important;
}
.paper-running-head.book-head{
  display:grid!important;grid-template-columns:1fr 1fr 1fr!important;align-items:start!important;
}
.paper-running-head.book-head span{max-width:none!important;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.paper-running-head.book-head span:nth-child(1){text-align:left}
.paper-running-head.book-head span:nth-child(2){text-align:center}
.paper-running-head.book-head span:nth-child(3){text-align:right}
body[data-template="exam"] .cover-main-title{font-size:24.7871pt!important;line-height:30pt!important}
body[data-template="book"] .cover-main-title{font-size:21.9178pt!important;line-height:30pt!important}
.cover-signature{font-size:18.3313pt!important;line-height:18pt!important;top:147.0mm!important}

.editor-main #paperSheet .option{
  display:grid!important;grid-template-columns:2.25em minmax(0,1fr)!important;align-items:start!important;
}
.editor-main #paperSheet .option-label{display:block;white-space:nowrap}
.editor-main #paperSheet .option-body{display:block;min-width:0}


/* Single-source master variables: preview must follow template-modes.js */
.editor-main #paperSheet{
  box-sizing:border-box!important;
  padding:var(--master-top) var(--master-right) var(--master-bottom) var(--master-left)!important;
  font-size:var(--master-font)!important;
  line-height:var(--master-leading)!important;
}
.editor-main #paperSheet .question{
  margin-bottom:var(--question-gap,var(--master-question-gap))!important;
  font-size:inherit!important;
  line-height:inherit!important;
}
.editor-main #paperSheet .question[style*="margin-bottom"]{
  /* inline per-question override intentionally wins through style attribute */
}
.editor-main #paperSheet .options{
  margin-top:var(--master-choice-before)!important;
}
body[data-template="book"][data-layout="single"] .editor-main #paperSheet .question,
body[data-template="book"][data-layout="padl"] .editor-main #paperSheet .question,
body[data-template="book"][data-layout="padp"] .editor-main #paperSheet .question{
  margin-bottom:0!important;
}
body[data-template="exam"][data-layout="a3"] .editor-main #paperSheet .paper-questions,
body[data-template="exam"][data-layout="mixed"] .editor-main #paperSheet .paper-questions{
  column-gap:var(--master-column-gap)!important;
}


/* Batch selection + major-section manager */
.order-toolbar-actions{display:flex;align-items:center;gap:6px}
.order-toolbar-actions .text-btn{font-size:9px}
.order-check{width:14px;height:14px;margin:0 2px 0 0;accent-color:var(--red);flex:0 0 auto}
.order-item.is-multi-selected{background:color-mix(in srgb,var(--red) 7%,var(--soft));box-shadow:inset 3px 0 0 var(--red)}
.batch-bar{
  margin:6px 8px 2px;padding:8px;display:flex;align-items:center;gap:6px;flex-wrap:wrap;
  border:1px solid var(--line);border-radius:11px;background:var(--soft);font-size:9px
}
.batch-bar[hidden]{display:none}
.batch-bar span{font-weight:800}
.batch-bar label{display:flex;align-items:center;gap:4px;color:var(--muted)}
.batch-bar input{width:58px;padding:5px 6px;border:1px solid var(--line);border-radius:7px;background:var(--card);color:var(--text)}
.batch-bar select{min-width:112px;padding:5px 7px;border:1px solid var(--line);border-radius:7px;background:var(--card);color:var(--text);font:inherit}
.section-panel{
  margin:6px 8px;padding:8px;border:1px solid var(--line);border-radius:12px;background:var(--soft)
}
.section-panel[hidden]{display:none}
.section-panel-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:5px}
.section-panel-head strong{font-size:10px}
.section-manage-row{
  display:grid;grid-template-columns:minmax(0,1fr) auto auto auto auto;align-items:center;gap:4px;
  padding:6px 2px;border-top:1px solid var(--line)
}
.section-manage-row strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:10px}
.section-manage-row>span{color:var(--muted);font-size:8px;white-space:nowrap}
.section-manage-row .text-btn{padding:4px;font-size:8px}
.section-empty{margin:8px 2px;color:var(--muted);font-size:9px}
@media(max-width:760px){
  .batch-bar{position:sticky;top:0;z-index:5}
  .section-manage-row{grid-template-columns:minmax(0,1fr) auto auto auto}
  .section-manage-row>span{display:none}
}


/* 2026-09-21 final mother-template calibration + Typst exact preview */
body[data-template="exam"] .editor-main #paperSheet{
  font-size:9.03374pt!important;
  line-height:1.56006!important;
}
body[data-template="book"] .editor-main #paperSheet{
  font-size:10.53937pt!important;
  line-height:1.56000!important;
}
body[data-template="exam"] .paper-section-heading{
  margin:2ex 0 1ex!important;
  padding:0!important;
  font-family:"Everflow Hei","FandolHei","SimHei",sans-serif!important;
  font-size:9.03374pt!important;
  line-height:1.56006!important;
  font-weight:700!important;
  text-align:left!important;
}
body[data-template="book"] .paper-section-heading{
  margin:2pt 0 4pt!important;
  padding:0!important;
  font-family:"Everflow Hei","FandolHei","SimHei",sans-serif!important;
  font-size:12.045pt!important;
  line-height:1.56000!important;
  font-weight:400!important;
  text-align:center!important;
}
.cover-signature{
  font-size:18.4pt!important;
  line-height:18pt!important;
  top:147mm!important;
}
.cover-date{color:#f00!important}

.question-body .semantic-row{
  display:grid;
  align-items:start;
  margin:0;
}
.question-body .semantic-row.circled{
  grid-template-columns:2.2em minmax(0,1fr);
  column-gap:.38em;
}
.question-body .semantic-row.roman{
  grid-template-columns:2.15em minmax(0,1fr);
  column-gap:.35em;
}
.question-body .semantic-row.subq{
  grid-template-columns:1.9em minmax(0,1fr);
  column-gap:.6em;
}
.question-body .semantic-row.is-group-start.circled,
.question-body .semantic-row.is-group-start.roman{margin-top:.3em!important}
.question-body .semantic-row.is-group-start.subq{margin-top:.35em!important}
.question-body .semantic-row.circled,
.question-body .semantic-row.roman{margin-bottom:.15em!important}
.question-body .semantic-row.subq{margin-bottom:.2em!important}
.question-body .semantic-label{text-align:right;white-space:nowrap}
.question-body .semantic-content{min-width:0}

.typst-preview{
  min-height:calc(100dvh - 112px);
  overflow:auto;
  padding:24px max(18px,calc((100% - 1080px)/2));
  background:var(--soft);
}
.typst-preview[hidden]{display:none!important}
.typst-preview svg{
  display:block;
  width:min(100%,1080px);
  height:auto;
  margin:0 auto;
  background:#fff;
  box-shadow:0 16px 54px rgba(27,31,42,.14);
}
body.preview-mode .typst-preview{display:block}
body.preview-mode .paper-stage{display:none!important}
@media(max-width:760px){
  .typst-preview{padding:12px 8px;min-height:calc(100dvh - 104px)}
  .typst-preview svg{width:100%}
}


/* 2026-09-21 three-surface responsive pass: desktop / tablet / phone */
.editor-main .paper-sheet{
  zoom:var(--preview-scale,1)!important;
  transform:none!important;
}
.editor-main .paper-stage{
  overflow:auto;
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}
.typst-preview{
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  touch-action:pan-x pan-y pinch-zoom;
}
.typst-preview svg{max-width:100%}

@media(min-width:1181px){
  .editor-shell{grid-template-columns:310px minmax(0,1fr)}
  .editor-main .paper-stage{padding-inline:max(28px,calc((100vw - 1420px)/2))}
}

@media(min-width:761px) and (max-width:1180px){
  .editor-topbar{padding-inline:12px;gap:10px}
  .editor-brand-wrap,.editor-top-actions{gap:7px;min-width:0}
  .editor-top-actions{flex:0 1 auto}
  .editor-shell{grid-template-columns:clamp(252px,28vw,286px) minmax(0,1fr)}
  .editor-sidebar{min-width:0}
  .sidebar-head{padding:15px 13px 11px}
  .sidebar-head strong{max-width:185px}
  .paper-settings,.question-editor{padding-inline:13px}
  .editor-toolbar{padding:10px 12px;gap:10px}
  .editor-toolbar-actions{gap:7px}
  .editor-main .paper-stage{padding:20px 16px 48px}
  .typst-preview{padding:18px 14px 36px}
  .question-editor{max-height:43dvh}
}
@media(min-width:761px) and (max-width:980px){
  .editor-topbar .local-pill,.save-state,#saveProjectButton{display:none!important}
  .editor-topbar .brand small{display:none}
  .mode-switch button{padding-inline:11px}
  .template-trigger{max-width:190px;overflow:hidden}
  .template-trigger span{overflow:hidden;text-overflow:ellipsis}
  .editor-toolbar-actions .preview-chip:last-of-type{display:none!important}
}

@media(max-width:760px){
  html,body{max-width:100%;overflow-x:hidden}
  body.editor-page{
    padding-left:env(safe-area-inset-left);
    padding-right:env(safe-area-inset-right);
  }

  .editor-topbar{
    position:sticky;top:0;height:auto;min-height:0;
    display:grid;grid-template-columns:minmax(0,1fr);align-items:center;
    padding:
      calc(7px + env(safe-area-inset-top))
      max(10px,env(safe-area-inset-right))
      7px
      max(10px,env(safe-area-inset-left));
    gap:7px;
  }
  .editor-brand-wrap{
    width:100%;min-width:0;justify-content:space-between;
  }
  .editor-topbar .brand{min-width:0}
  .editor-topbar .brand>span:last-child{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .editor-topbar .brand small,.editor-topbar .local-pill,.save-state,.history-actions,#saveProjectButton{display:none!important}
  .editor-top-actions{
    width:100%;min-width:0;display:grid;
    grid-template-columns:minmax(0,1fr) auto;gap:7px;
  }
  .template-control{min-width:0;order:0}
  .template-trigger{
    width:100%;max-width:none;min-width:0;justify-content:space-between;
    min-height:40px;padding:0 11px!important;
  }
  .template-trigger span{min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
  .mode-switch{min-width:132px}
  .mode-switch button{min-height:34px;min-width:62px;padding:7px 9px}
  .template-popover{
    position:fixed;z-index:160;
    left:max(8px,env(safe-area-inset-left));
    right:max(8px,env(safe-area-inset-right));
    top:calc(92px + env(safe-area-inset-top));
    width:auto;max-height:calc(100dvh - 112px - env(safe-area-inset-top));
    border-radius:14px;
  }
  .template-option{min-height:46px;padding:10px}
  .template-option small{white-space:normal;text-align:right;line-height:1.3}

  .editor-shell{display:flex;flex-direction:column;min-height:0}
  .editor-sidebar{
    position:relative;top:auto;height:auto;max-height:none;width:100%;
    border-right:0;border-bottom:1px solid var(--line);
  }
  .sidebar-head{padding:12px 12px 9px;align-items:center}
  .sidebar-head strong{max-width:calc(100vw - 80px);font-size:14px}
  .sidebar-note{display:none}

  .paper-settings{
    display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    gap:8px 10px;padding:10px 12px 8px;
  }
  .paper-settings label{margin:0;min-width:0}
  .paper-settings #bookHeaderLabel,.paper-settings .locked-row{grid-column:1/-1}
  .locked-row{padding:3px 0 2px}

  .order-toolbar{padding:9px 12px 5px}
  .order-toolbar-actions{gap:4px}
  .order-toolbar-actions .text-btn{padding:6px 7px;min-height:34px}
  .editor-sidebar .order-list{
    display:flex;gap:8px;max-height:none;overflow-x:auto;overflow-y:hidden;
    padding:7px 10px 10px;scroll-snap-type:x proximity;
    scrollbar-width:thin;
  }
  .editor-sidebar .order-item{
    flex:0 0 min(82vw,300px);min-width:220px;
    scroll-snap-align:start;
  }

  .batch-bar{
    position:relative;top:auto;margin:6px 10px 2px;padding:8px;
    overflow-x:auto;flex-wrap:nowrap;
  }
  .batch-bar>*{flex:0 0 auto}
  .section-panel{margin-inline:10px}
  .section-manage-row{grid-template-columns:minmax(0,1fr) auto auto auto}
  .section-manage-row>span{display:none}

  .question-editor{
    max-height:none;overflow:visible;padding:12px;
    border-top:1px solid var(--line);
  }
  .question-editor textarea{min-height:112px}
  .question-editor-head{align-items:flex-start}
  .question-editor-head>div{flex-wrap:wrap;justify-content:flex-end}
  .option-editor{min-height:44px}
  .sidebar-foot{
    padding:9px 12px calc(10px + env(safe-area-inset-bottom));
    gap:6px;flex-wrap:wrap;
  }

  /* 16px prevents unwanted iOS focus zoom. */
  .paper-settings input,
  .question-editor input,
  .question-editor textarea,
  .question-editor select,
  .batch-bar input,
  .batch-bar select{font-size:16px!important}
  .paper-settings input,.question-editor input,.question-editor select{min-height:42px}
  .question-editor button,.sidebar-foot button,.sidebar-foot a{min-height:38px}

  .editor-main{width:100%;padding-bottom:0}
  .editor-toolbar{
    position:relative;top:auto;min-height:58px;
    display:grid;grid-template-columns:minmax(0,1fr) auto;
    padding:9px 10px;gap:8px;
  }
  .editor-toolbar>div:first-child{min-width:0}
  .editor-toolbar>div:first-child strong{
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
  }
  .editor-toolbar>div:first-child small{display:none}
  .editor-toolbar-actions{gap:6px;flex-wrap:nowrap}
  .editor-toolbar-actions .preview-chip{display:none!important}
  #printButton{
    min-height:40px;padding:0 13px;white-space:nowrap;
    font-size:11px;
  }
  .pdf-status{
    padding:7px 10px;font-size:10px;line-height:1.45;
    overflow-wrap:anywhere;
  }

  .editor-main .paper-stage{
    min-height:0;padding:12px 8px 34px;overflow:hidden;
  }
  .editor-main #paperSheet,.editor-main .cover-sheet{
    width:var(--paper-w,210mm);
    max-width:none;
    transform:none!important;
  }
  .editor-main .cover-sheet{
    width:210mm!important;min-width:210mm!important;
    zoom:var(--preview-scale,var(--cover-preview-scale,.44))!important;
    margin-bottom:18px!important;
  }
  .editor-main #paperSheet{
    zoom:var(--preview-scale,var(--paper-preview-scale,.44))!important;
  }

  .typst-preview{
    min-height:calc(100dvh - 154px - env(safe-area-inset-top));
    padding:10px 6px calc(22px + env(safe-area-inset-bottom));
  }
  .typst-preview svg{
    width:100%!important;max-width:100%!important;height:auto!important;
    margin:0 auto;border-radius:0;
    box-shadow:0 8px 28px rgba(27,31,42,.12);
  }

  body.preview-mode .editor-main{min-height:calc(100dvh - 92px)}
  body.preview-mode .editor-toolbar{position:sticky;top:0;z-index:35}
}

@media(max-width:430px){
  .paper-settings{grid-template-columns:1fr}
  .paper-settings #bookHeaderLabel,.paper-settings .locked-row{grid-column:auto}
  .locked-row{grid-template-columns:1fr auto}
  .locked-row em{display:none}
  .editor-topbar .brand-mark{width:28px;height:28px}
  .editor-topbar .brand>span:last-child{font-size:13px}
  .template-popover{top:calc(90px + env(safe-area-inset-top))}
  .question-editor-head{display:block}
  .question-editor-head>div{margin-top:7px;justify-content:flex-start}
  .sidebar-foot{justify-content:flex-start}
}

@media(pointer:coarse){
  .editor-topbar button,.editor-toolbar button,.text-btn,.icon-text-btn{
    touch-action:manipulation;
  }
}


/* Mobile stacking correction: topbar owns the sticky layer. */
@media(max-width:760px){
  body.preview-mode .editor-toolbar{position:relative!important;top:auto!important;z-index:25}
}


/* 2026-09-21 three-device editor layout
   Desktop >= 1200, Tablet 768-1199, Phone <= 767 */

/* Desktop */
@media (min-width:1200px){
  .editor-shell{grid-template-columns:320px minmax(0,1fr)!important}
  .editor-sidebar{top:64px;height:calc(100dvh - 64px)}
  .editor-topbar{min-width:0}
  .editor-top-actions{min-width:0}
  .editor-toolbar{top:64px}
  .typst-preview{padding-inline:max(28px,calc((100% - 1120px)/2))}
}

/* Tablet */
@media (min-width:768px) and (max-width:1199px){
  .editor-topbar{
    height:68px;padding:0 12px;gap:10px;
  }
  .editor-brand-wrap{min-width:150px}
  .editor-topbar .brand small{display:none}
  .editor-topbar .local-pill{display:none}
  .editor-top-actions{gap:6px;min-width:0}
  .editor-top-actions .ghost-btn{padding-inline:9px}
  .save-state{display:none}
  .history-actions .icon-text-btn{width:32px;height:32px}
  .mode-switch button{padding:7px 10px}
  .editor-shell{
    grid-template-columns:292px minmax(0,1fr)!important;
    min-height:calc(100dvh - 68px);
  }
  .editor-sidebar{
    top:68px;height:calc(100dvh - 68px);
  }
  .sidebar-head{padding:14px 12px 10px}
  .paper-settings,.question-editor{padding:10px 12px}
  .order-toolbar{padding-inline:12px}
  .editor-toolbar{
    top:68px;min-height:60px;padding:9px 12px;
  }
  .editor-toolbar-actions{gap:6px}
  .preview-chip{padding-inline:8px!important}
  .typst-preview{
    min-height:calc(100dvh - 128px);
    padding:18px 14px 34px;
  }
  .typst-preview svg{
    width:min(100%,920px);
  }
  .template-popover{width:310px}
  .batch-bar{margin-inline:6px}
}

/* Phone */
@media (max-width:767px){
  html,body{max-width:100%;overflow-x:hidden}
  body.editor-page{padding-bottom:max(0px,env(safe-area-inset-bottom))}

  .editor-topbar{
    position:sticky;top:0;z-index:100;
    height:auto!important;min-height:54px;
    padding:7px 8px!important;
    display:grid!important;
    grid-template-columns:auto minmax(0,1fr);
    gap:6px!important;
  }
  .editor-brand-wrap{min-width:0}
  .editor-topbar .brand{min-width:0}
  .editor-topbar .brand>span:last-child{
    min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap
  }
  .editor-topbar .brand small,.local-pill,.save-state,.history-actions,#saveProjectButton{
    display:none!important;
  }
  .editor-top-actions{
    min-width:0;width:100%;
    justify-content:flex-end!important;
    gap:5px!important;
    overflow-x:auto;
    scrollbar-width:none;
    -webkit-overflow-scrolling:touch;
  }
  .editor-top-actions::-webkit-scrollbar{display:none}
  .template-control{flex:0 1 auto;min-width:0;order:0!important}
  #templateButton{
    display:flex!important;max-width:148px;
    min-height:38px;padding:0 8px!important;
    overflow:hidden;
  }
  #templateButtonLabel{
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
    font-size:10px;
  }
  .mode-switch{
    flex:0 0 auto;padding:2px;border-radius:9px;
  }
  .mode-switch button{
    min-height:34px;padding:0 9px!important;font-size:10px;
  }
  .template-popover{
    position:fixed!important;
    left:8px!important;right:8px!important;top:56px!important;
    width:auto!important;max-height:calc(100dvh - 68px)!important;
    border-radius:14px;
    overscroll-behavior:contain;
  }
  .template-option{min-height:46px}
  .template-option strong{font-size:12px}
  .template-option small{font-size:8px}

  .editor-shell{
    display:block!important;width:100%;min-height:0;
  }
  .editor-sidebar{
    position:relative!important;top:auto!important;
    width:100%;height:auto!important;max-height:none!important;
    border:0!important;background:var(--card);
  }
  body.preview-mode .editor-sidebar{display:none!important}

  .sidebar-head{padding:12px 12px 9px}
  .sidebar-head strong{max-width:calc(100vw - 90px);font-size:14px}
  .sidebar-note{padding:8px 12px;font-size:9px}
  .paper-settings,.question-editor{padding:10px 12px}
  .paper-settings label,.question-editor label{font-size:11px}
  .paper-settings input,.question-editor input,.question-editor textarea,.question-editor select{
    min-height:42px;font-size:16px; /* prevents iOS focus zoom */
    padding:9px 10px;
  }
  .question-editor textarea{min-height:120px;line-height:1.55}
  .question-editor{
    max-height:none!important;overflow:visible!important;
  }
  .question-editor-head{
    position:sticky;top:54px;z-index:12;
    padding:7px 0;background:var(--card);
  }
  .question-editor-head>div{gap:4px;flex-wrap:wrap;justify-content:flex-end}
  .question-editor-head .text-btn{min-height:34px;padding-inline:7px}

  .order-toolbar{
    position:sticky;top:54px;z-index:14;
    padding:8px 12px;background:var(--card);border-bottom:1px solid var(--line)
  }
  .order-toolbar-actions{gap:4px}
  .order-toolbar-actions .text-btn{min-height:34px;padding:0 7px}
  .editor-sidebar .order-list{
    max-height:32dvh!important;min-height:96px;
    padding:6px 8px!important;
    overflow:auto!important;
    overscroll-behavior:contain;
  }
  .order-item{min-height:46px}
  .order-controls button{min-width:32px;min-height:32px}
  .order-check{width:18px;height:18px}
  .batch-bar{
    position:sticky!important;top:96px!important;z-index:13;
    margin:5px 8px;padding:7px;
  }
  .batch-bar input,.batch-bar select{min-height:36px;font-size:12px}
  .section-panel{margin:5px 8px;padding:7px}
  .section-manage-row{
    grid-template-columns:minmax(0,1fr) auto auto auto!important;
    min-height:42px;
  }
  .section-manage-row>span{display:none!important}
  .sidebar-foot{
    position:sticky;bottom:0;z-index:20;
    padding:8px 12px max(8px,env(safe-area-inset-bottom));
    background:color-mix(in srgb,var(--card) 97%,transparent);
    backdrop-filter:blur(14px);-webkit-backdrop-filter:blur(14px);
  }
  .sidebar-foot .text-btn{min-height:36px}

  .editor-main{width:100%;padding:0}
  .editor-toolbar{
    position:sticky!important;top:54px!important;z-index:80;
    min-height:50px!important;padding:7px 8px!important;
    gap:6px!important;background:color-mix(in srgb,var(--card) 97%,transparent);
  }
  .editor-toolbar>div:first-child{min-width:0}
  .editor-toolbar>div:first-child>span,.editor-toolbar>div:first-child small{display:none!important}
  .editor-toolbar strong{
    max-width:42vw;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
    font-size:10px!important;
  }
  .editor-toolbar-actions{margin-left:auto;gap:5px!important;flex-wrap:nowrap!important}
  .editor-toolbar-actions .preview-chip{display:none!important}
  #printButton{
    min-height:38px;padding:0 11px!important;font-size:10px!important;white-space:nowrap;
  }
  .pdf-status{
    padding:7px 10px;font-size:10px;line-height:1.45;
    position:sticky;top:104px;z-index:70;
    background:color-mix(in srgb,var(--card) 96%,transparent);
  }

  /* Phone editing is editor-first. Exact pages are shown by the Preview tab. */
  body:not(.preview-mode) .editor-main .paper-stage{display:none!important}
  body:not(.preview-mode) .editor-main .typst-preview{display:none!important}
  body:not(.preview-mode) .editor-main .editor-toolbar{display:none!important}
  body:not(.preview-mode) .editor-main .pdf-status{display:none!important}

  body.preview-mode .editor-main{display:block!important}
  body.preview-mode .editor-toolbar{top:54px!important}
  body.preview-mode .typst-preview{
    display:block!important;
    min-height:calc(100dvh - 104px);
    padding:10px 6px calc(20px + env(safe-area-inset-bottom))!important;
    overflow:auto;
    overscroll-behavior:contain;
  }
  .typst-preview svg{
    width:100%!important;max-width:100%!important;height:auto!important;
    margin:0 auto 10px!important;
    box-shadow:0 8px 28px rgba(27,31,42,.13)!important;
  }

  .toast{
    left:10px!important;right:10px!important;bottom:calc(14px + env(safe-area-inset-bottom))!important;
    max-width:none!important;
  }
}

.mobile-pdf-btn{display:none!important}
@media(max-width:767px){
  .mobile-pdf-btn{
    display:inline-flex!important;flex:0 0 auto;
    min-height:34px!important;padding:0 9px!important;
    border-radius:9px!important;font-size:10px!important;
  }
}


/* Legacy Typst SVG card rules retained for compatibility with older saved previews. */
.typst-preview{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:22px;
}
.typst-preview > section.typst-page{
  display:block;
  width:min(100%,1080px);
  margin:0 auto;
  background:#fff;
  box-shadow:0 16px 54px rgba(27,31,42,.14);
  overflow:hidden;
  flex:0 0 auto;
}
.typst-preview > section.typst-page > svg{
  display:block;
  width:100%!important;
  max-width:100%!important;
  height:auto!important;
  margin:0!important;
  box-shadow:none!important;
}
@media(min-width:768px) and (max-width:1199px){
  .typst-preview > section.typst-page{width:min(100%,920px)}
}
@media(max-width:767px){
  .typst-preview{gap:10px!important}
  .typst-preview > section.typst-page{
    width:100%!important;
    margin:0 auto!important;
    box-shadow:0 8px 28px rgba(27,31,42,.13)!important;
  }
}


/* ==========================================================================
   TeXPage-style workbench (PaperForge MIT interaction pattern, Everflow UI)
   ========================================================================== */
:root{
  --tex-chrome:#1c2533;
  --tex-chrome-2:#263244;
  --tex-chrome-3:#303d50;
  --tex-border:#d8dde5;
  --tex-muted:#758092;
  --navigator-w:238px;
  --editor-w:470px;
  --preview-page-width:820px;
}
body.editor-page{
  height:100dvh;
  overflow:hidden;
  background:#eef0f3;
}
.texpage-topbar{
  position:relative!important;
  top:auto!important;
  height:48px!important;
  min-height:48px!important;
  padding:0 10px!important;
  background:var(--tex-chrome)!important;
  border-bottom:1px solid #111927!important;
  color:#f7f9fc;
  backdrop-filter:none!important;
  -webkit-backdrop-filter:none!important;
}
.texpage-topbar .brand{color:#fff}
.texpage-topbar .brand small{color:#aeb8c7}
.texpage-topbar .brand-mark{
  width:28px;height:28px;border-radius:7px;
  box-shadow:none;
}
.texpage-topbar .local-pill,
.texpage-topbar .save-state{color:#b7c1cf}
.texpage-topbar .ghost-btn,
.texpage-topbar .icon-text-btn{
  border-color:#3b4759!important;
  background:#222e3f!important;
  color:#eef3f8!important;
}
.texpage-topbar .ghost-btn:hover,
.texpage-topbar .icon-text-btn:hover{background:#303d50!important}
.texpage-topbar .mode-switch{
  background:#111927;
  border-color:#384457;
}
.texpage-topbar .mode-switch button{color:#aeb8c7}
.texpage-topbar .mode-switch button[aria-pressed="true"]{
  background:#344258;color:#fff;box-shadow:none
}
.navigator-toggle{font-size:14px!important}

/* Main workbench: project tree | editor | exact preview */
.texpage-workbench{
  height:calc(100dvh - 48px);
  width:100%;
  display:grid;
  grid-template-columns:
    var(--navigator-w) 5px
    minmax(360px,var(--editor-w)) 5px
    minmax(420px,1fr);
  overflow:hidden;
  background:#f4f5f7;
}
.texpage-navigator,
.texpage-editor-pane,
.texpage-preview-pane{
  min-width:0;
  min-height:0;
  overflow:hidden;
  background:#fff;
}
.texpage-navigator{
  display:flex;
  flex-direction:column;
  border-right:1px solid var(--tex-border);
}
.navigator-head{
  height:54px;
  padding:9px 10px 8px 12px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  background:#f8f9fb;
  border-bottom:1px solid var(--tex-border);
}
.navigator-title{min-width:0}
.navigator-title span{
  display:block;
  color:#8b95a4;
  font-size:8px;
  font-weight:800;
  letter-spacing:.14em;
}
.navigator-title strong{
  display:block;
  margin-top:2px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:12px;
  color:#1d2735;
}
.navigator-head>b{
  min-width:26px;height:24px;padding:0 6px;
  display:grid;place-items:center;
  border-radius:6px;
  background:#e9edf3;
  color:#526074;
  font-size:10px;
}
.navigator-tabs{
  display:grid;
  grid-template-columns:1fr 1fr;
  padding:5px;
  gap:4px;
  background:#f8f9fb;
  border-bottom:1px solid var(--tex-border);
}
.navigator-tabs button{
  height:30px;
  border:0;
  border-radius:6px;
  background:transparent;
  color:#758092;
  font:inherit;
  font-size:10px;
  font-weight:700;
  cursor:pointer;
}
.navigator-tabs button[aria-selected="true"]{
  background:#fff;
  color:#1f2b3a;
  box-shadow:0 1px 4px #0d1a2b14;
}
.navigator-panel{
  min-height:0;
  flex:1;
  display:flex;
  flex-direction:column;
  overflow:hidden;
}
.navigator-panel[hidden]{display:none!important}
#outlinePanel .order-list{
  flex:1;
  min-height:0;
  overflow:auto;
  padding:5px 6px 12px;
}
#settingsPanel{
  overflow:auto;
}
#settingsPanel .paper-settings{
  border:0;
  padding:12px;
}
.navigator-actions{
  margin-top:auto;
  padding:10px 12px 12px;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  border-top:1px solid var(--tex-border);
}
.navigator-actions .text-btn{font-size:9px}

/* Tree rows become compact like a source-file tree. */
.texpage-navigator .order-toolbar{
  min-height:38px;
  padding:6px 8px 5px 10px;
  border-bottom:1px solid #edf0f4;
}
.texpage-navigator .order-toolbar strong{
  font-size:9px;
  color:#5f6b7c;
  letter-spacing:.03em;
}
.texpage-navigator .order-toolbar-actions .text-btn{
  min-height:28px;padding:0 5px;font-size:8px
}
.texpage-navigator .order-item{
  min-height:38px;
  border:0!important;
  border-radius:5px!important;
  padding:4px 5px!important;
  background:transparent!important;
  outline:0!important;
}
.texpage-navigator .order-item:hover{background:#f0f3f7!important}
.texpage-navigator .order-item.is-selected{
  background:#e7eef9!important;
  box-shadow:inset 2px 0 0 #507ac5!important;
}
.texpage-navigator .order-item.is-multi-selected{
  background:#f7ecee!important;
  box-shadow:inset 2px 0 0 var(--red)!important;
}
.texpage-navigator .order-copy b{font-size:10px}
.texpage-navigator .order-copy small{font-size:8px;color:#8993a2}
.texpage-navigator .order-num{
  min-width:20px;
  color:#6f7a89;
  font-size:9px;
}
.texpage-navigator .drag-handle{opacity:.38}
.texpage-navigator .order-controls{opacity:0;transition:opacity .12s ease}
.texpage-navigator .order-item:hover .order-controls,
.texpage-navigator .order-item.is-selected .order-controls{opacity:1}

/* Resizable gutters. */
.pane-resizer{
  position:relative;
  z-index:25;
  cursor:col-resize;
  touch-action:none;
  background:#e3e6eb;
}
.pane-resizer::after{
  content:"";
  position:absolute;
  inset:0 -3px;
}
.pane-resizer:hover,
.pane-resizer.is-dragging{background:#6c8fc7}
.navigator-resizer{border-right:1px solid #d5dae2}
.preview-resizer{border-left:1px solid #d5dae2}

/* Main editor pane. */
.texpage-editor-pane{
  display:flex;
  flex-direction:column;
  border-right:1px solid var(--tex-border);
}
.pane-tabbar{
  height:37px;
  flex:0 0 37px;
  display:flex;
  align-items:end;
  justify-content:space-between;
  background:var(--tex-chrome-2);
  border-bottom:1px solid #1b2533;
  color:#dfe6ef;
}
.editor-tab{
  height:33px;
  min-width:160px;
  max-width:72%;
  padding:0 12px;
  display:flex;
  align-items:center;
  gap:7px;
  background:#fff;
  color:#293547;
  border-radius:5px 5px 0 0;
  margin-left:5px;
}
.editor-tab strong{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:11px;
}
.tab-dot{
  width:6px;height:6px;border-radius:50%;background:#e94b5b;flex:0 0 auto
}
.pane-tab-actions{
  height:100%;
  padding:0 9px;
  display:flex;
  align-items:center;
}
.local-state{
  display:flex;
  align-items:center;
  gap:5px;
  color:#aeb8c7;
  font-size:8px;
}
.local-state i{
  width:5px;height:5px;border-radius:50%;background:#4fc184
}
.editor-commandbar{
  min-height:44px;
  padding:6px 10px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  border-bottom:1px solid var(--tex-border);
  background:#fafbfc;
}
.editor-commandbar>div:first-child{min-width:0}
.editor-commandbar strong{
  display:block;
  color:#273344;
  font-size:11px
}
.editor-commandbar span{
  display:block;
  margin-top:1px;
  max-width:220px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#8a94a2;
  font-size:8px
}
.editor-command-actions{display:flex;gap:4px}
.editor-command-actions .text-btn{
  min-height:28px;padding:0 7px;font-size:8px
}
.texpage-question-editor{
  flex:1;
  min-height:0;
  max-height:none!important;
  overflow:auto!important;
  padding:18px 20px 40px!important;
  border:0!important;
  background:#fff;
}
.texpage-question-editor .question-editor-head{
  position:sticky;
  top:-18px;
  z-index:8;
  margin:0 -20px 16px;
  padding:10px 20px;
  background:rgba(255,255,255,.96);
  border-bottom:1px solid #eef1f4;
  backdrop-filter:blur(10px);
}
.texpage-question-editor .question-editor-head h3{
  font-size:13px;
  color:#202b3a;
}
.texpage-question-editor label{
  margin-bottom:15px;
  color:#667284;
  font-size:10px;
  font-weight:700;
}
.texpage-question-editor input,
.texpage-question-editor select,
.texpage-question-editor textarea{
  border-radius:6px!important;
  border-color:#d5dbe4!important;
  background:#fbfcfd!important;
  color:#202a38!important;
  box-shadow:inset 0 1px 1px #18202e08;
}
.texpage-question-editor textarea{
  min-height:210px;
  resize:vertical;
  font-family:"SFMono-Regular","Cascadia Code","JetBrains Mono","Consolas","Everflow Song",monospace;
  font-size:12px;
  line-height:1.75;
  tab-size:2;
}
.texpage-question-editor textarea:focus,
.texpage-question-editor input:focus,
.texpage-question-editor select:focus{
  outline:2px solid #6f91ca33;
  border-color:#7191c5!important;
}
.texpage-question-editor .option-editor{
  padding:3px 0;
  align-items:center
}
.texpage-question-editor .option-editor b{
  width:24px;
  color:#526174;
  font-size:10px
}

/* Exact preview pane, styled like a PDF editor panel. */
.texpage-preview-pane{
  display:flex;
  flex-direction:column;
  background:#d9dde3;
}
.preview-toolbar{
  height:37px;
  flex:0 0 37px;
  display:grid;
  grid-template-columns:minmax(0,1fr) auto minmax(0,1fr);
  align-items:center;
  gap:6px;
  padding:0 7px;
  color:#dfe6ef;
  background:var(--tex-chrome-2);
  border-bottom:1px solid #1a2432;
}
.preview-toolbar-left,
.preview-toolbar-center,
.preview-toolbar-right{
  display:flex;
  align-items:center;
  min-width:0;
  gap:4px;
}
.preview-toolbar-right{justify-content:flex-end}
.preview-toolbar-left strong{
  max-width:180px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:9px;
  font-weight:700;
}
.preview-status-dot{
  width:6px;height:6px;border-radius:50%;background:#52bd83;flex:0 0 auto
}
.preview-toolbar .preview-chip{
  min-height:22px!important;
  height:22px!important;
  padding:0 6px!important;
  border-color:#46546a;
  background:#1c2635;
  color:#aeb9c7!important;
  font-size:7px!important;
}
.viewer-btn,
.zoom-indicator{
  height:25px;
  min-width:25px;
  padding:0 6px;
  border:0;
  border-radius:4px;
  background:transparent;
  color:#d5deea;
  font:inherit;
  font-size:11px;
  cursor:pointer;
}
.viewer-btn:hover,.zoom-indicator:hover{background:#35445a;color:#fff}
.viewer-btn:disabled{opacity:.35;cursor:default}
.zoom-indicator{min-width:44px;font-size:8px}
.fit-btn{font-size:8px;min-width:36px}
.page-indicator{
  min-width:48px;
  text-align:center;
  font-size:8px;
  font-variant-numeric:tabular-nums;
  color:#bac4d1;
}
.toolbar-divider{
  width:1px;height:15px;margin:0 2px;background:#46546a
}
.preview-toolbar #printButton{
  min-height:27px!important;
  height:27px!important;
  padding:0 9px!important;
  border-radius:5px!important;
  font-size:8px!important;
}
.texpage-preview-pane .pdf-status{
  flex:0 0 auto;
  min-height:26px;
  padding:6px 10px;
  background:#f7f8fa;
  border-bottom:1px solid #d8dde5;
  color:#758092;
  font-size:9px;
  line-height:1.4;
}
.texpage-preview-pane .pdf-status:empty{display:none}
.texpage-preview-pane .typst-preview{
  flex:1;
  min-height:0!important;
  overflow:auto;
  padding:20px 20px 56px!important;
  background:#d9dde3!important;
  gap:18px!important;
}
.texpage-preview-pane .typst-preview > section.typst-page{
  width:var(--preview-page-width)!important;
  max-width:none!important;
  transition:width .12s ease;
  box-shadow:0 5px 18px #24314622!important;
}
.texpage-preview-pane .typst-preview > section.typst-page > svg{width:100%!important;height:auto!important}

/* Drawer backdrop for tablet/phone navigator. */
.workbench-backdrop{
  position:fixed;
  inset:48px 0 0;
  z-index:74;
  background:#07101d70;
  backdrop-filter:blur(1px);
}
.workbench-backdrop[hidden]{display:none!important}

/* Desktop: true TeXPage-style simultaneous editor + preview. */
@media(min-width:1101px){
  .mobile-mode-switch{display:none!important}
  .mobile-pdf-btn{display:none!important}
  body.preview-mode .texpage-editor-pane{display:flex!important}
  body.preview-mode .texpage-preview-pane{display:flex!important}
  .navigator-toggle{display:grid!important}
}

/* Tablet: navigator becomes an overlay drawer, editor + preview stay split. */
@media(min-width:768px) and (max-width:1100px){
  :root{--editor-w:42vw;--preview-page-width:680px}
  .texpage-workbench{
    grid-template-columns:minmax(330px,var(--editor-w)) 5px minmax(350px,1fr);
  }
  .navigator-resizer{display:none}
  .texpage-navigator{
    position:fixed;
    z-index:80;
    left:0;
    top:48px;
    bottom:0;
    width:min(290px,76vw);
    transform:translateX(-102%);
    box-shadow:12px 0 40px #111b2a30;
    transition:transform .18s ease;
  }
  body.navigator-open .texpage-navigator{transform:translateX(0)}
  body.navigator-open .workbench-backdrop{display:block!important}
  .texpage-workbench>.texpage-editor-pane{grid-column:1}
  .texpage-workbench>.preview-resizer{grid-column:2}
  .texpage-workbench>.texpage-preview-pane{grid-column:3}
  .preview-toolbar-left .preview-chip{display:none!important}
  .preview-toolbar{grid-template-columns:minmax(0,1fr) auto auto}
  .texpage-question-editor{padding-inline:15px!important}
  .texpage-question-editor .question-editor-head{margin-inline:-15px;padding-inline:15px}
  .mobile-mode-switch{display:none!important}
  .mobile-pdf-btn{display:none!important}
}

/* Phone: one work surface at a time; navigator is a drawer. */
@media(max-width:767px){
  body.editor-page{height:100dvh;overflow:hidden}
  .texpage-topbar{
    height:auto!important;
    min-height:48px!important;
    display:grid!important;
    grid-template-columns:auto minmax(0,1fr)!important;
    padding:6px 7px!important;
    gap:5px!important;
  }
  .texpage-topbar .editor-brand-wrap{min-width:0}
  .texpage-topbar .brand small,
  .texpage-topbar .local-pill,
  .texpage-topbar .save-state,
  .texpage-topbar .history-actions,
  #saveProjectButton{display:none!important}
  .texpage-topbar .editor-top-actions{
    min-width:0;
    overflow-x:auto;
    justify-content:flex-end;
    gap:4px;
    scrollbar-width:none;
  }
  .texpage-topbar .editor-top-actions::-webkit-scrollbar{display:none}
  .navigator-toggle{display:grid!important;flex:0 0 34px}
  .template-control{min-width:0;flex:0 1 138px}
  #templateButton{
    max-width:138px;
    min-height:34px;
    padding:0 7px!important;
  }
  #templateButtonLabel{
    overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:9px
  }
  .mobile-mode-switch{display:flex!important}
  .mobile-mode-switch button{min-height:30px!important;padding:0 8px!important;font-size:9px}
  .mobile-pdf-btn{display:inline-flex!important;min-height:30px!important;height:30px!important}

  .texpage-workbench{
    height:calc(100dvh - 48px);
    display:block;
    overflow:hidden;
  }
  .navigator-resizer,.preview-resizer{display:none!important}
  .texpage-navigator{
    position:fixed;
    z-index:80;
    left:0;top:48px;bottom:0;
    width:min(310px,88vw);
    transform:translateX(-103%);
    transition:transform .18s ease;
    box-shadow:12px 0 40px #111b2a35;
  }
  body.navigator-open .texpage-navigator{transform:translateX(0)}
  body.navigator-open .workbench-backdrop{display:block!important}
  .workbench-backdrop{inset:48px 0 0}

  .texpage-editor-pane,
  .texpage-preview-pane{
    width:100%;
    height:100%;
  }
  body:not(.preview-mode) .texpage-editor-pane{display:flex}
  body:not(.preview-mode) .texpage-preview-pane{display:none}
  body.preview-mode .texpage-editor-pane{display:none!important}
  body.preview-mode .texpage-preview-pane{display:flex!important}

  .pane-tabbar{height:35px;flex-basis:35px}
  .editor-commandbar{min-height:42px;padding:5px 8px}
  .editor-commandbar span{max-width:55vw}
  .texpage-question-editor{
    padding:12px 12px 70px!important;
  }
  .texpage-question-editor .question-editor-head{
    top:-12px;margin:0 -12px 12px;padding:8px 12px;
  }
  .texpage-question-editor textarea{
    min-height:170px;
    font-size:16px!important;
  }
  .texpage-question-editor input,
  .texpage-question-editor select{font-size:16px!important;min-height:42px}
  .question-editor-head>div{flex-wrap:wrap;justify-content:flex-end}

  .preview-toolbar{
    height:39px;
    flex-basis:39px;
    grid-template-columns:minmax(0,1fr) auto;
    padding:0 5px;
  }
  .preview-toolbar-left .preview-chip{display:none!important}
  .preview-toolbar-left strong{max-width:34vw}
  .preview-toolbar-center{
    order:3;
    grid-column:1/-1;
    position:fixed;
    left:50%;
    bottom:max(9px,env(safe-area-inset-bottom));
    z-index:95;
    transform:translateX(-50%);
    padding:4px 6px;
    border:1px solid #435168;
    border-radius:9px;
    background:#202c3d;
    box-shadow:0 8px 24px #0c142240;
  }
  .preview-toolbar-right{justify-self:end}
  .texpage-preview-pane .pdf-status{
    min-height:24px;padding:5px 8px;font-size:8px;
  }
  .texpage-preview-pane .typst-preview{
    padding:8px 6px calc(58px + env(safe-area-inset-bottom))!important;
    gap:8px!important;
  }
  .texpage-preview-pane .typst-preview > section.typst-page{
    width:100%!important;
    max-width:100%!important;
  }

  .template-popover{
    position:fixed!important;
    left:7px!important;right:7px!important;top:48px!important;
    width:auto!important;
    max-height:calc(100dvh - 58px)!important;
    z-index:180!important;
  }
}

/* Very narrow phones: reduce chrome, keep content usable. */
@media(max-width:430px){
  .texpage-topbar .brand>span:last-child{display:none}
  .texpage-topbar{grid-template-columns:32px minmax(0,1fr)!important}
  .template-control{flex-basis:118px}
  #templateButton{max-width:118px}
  .editor-command-actions .text-btn{padding-inline:5px}
  .preview-toolbar-left strong{max-width:29vw}
}


/* Workbench collapse / resize states */
body.is-resizing-panes,
body.is-resizing-panes *{
  cursor:col-resize!important;
  user-select:none!important;
  -webkit-user-select:none!important;
}
@media(min-width:1101px){
  body.navigator-collapsed .texpage-workbench{
    grid-template-columns:minmax(360px,var(--editor-w)) 5px minmax(420px,1fr)!important;
  }
  body.navigator-collapsed .texpage-navigator,
  body.navigator-collapsed .navigator-resizer{display:none!important}
  body.navigator-collapsed .texpage-editor-pane{grid-column:1}
  body.navigator-collapsed .preview-resizer{grid-column:2}
  body.navigator-collapsed .texpage-preview-pane{grid-column:3}
}


/* Neutralize legacy single-pane rules inside the new preview workbench. */
.texpage-preview-pane.editor-main{
  padding:0!important;
  min-width:0!important;
  min-height:0!important;
}
.texpage-preview-pane .typst-preview[hidden]{display:none!important}


/* TeXPage desktop/tablet are simultaneous edit + preview; mode switch is phone-only. */
@media(min-width:768px){
  .mobile-mode-switch{display:none!important}
  body.preview-mode .texpage-editor-pane,
  body:not(.preview-mode) .texpage-editor-pane{display:flex!important}
  body.preview-mode .texpage-preview-pane,
  body:not(.preview-mode) .texpage-preview-pane{display:flex!important}
}


/* 2026-09-21 canonical 3-device workbench layout.
   Desktop >=1180: navigator + editor + preview
   Tablet 768-1179: navigator drawer + editor + preview
   Phone <=767: navigator drawer + edit/preview single surface */
@media(min-width:1180px){
  .texpage-workbench{
    grid-template-columns:var(--navigator-w,260px) 5px minmax(360px,var(--editor-w,460px)) 5px minmax(460px,1fr)!important;
  }
  .texpage-navigator{position:relative!important;inset:auto!important;transform:none!important;width:auto!important;box-shadow:none!important}
  .navigator-resizer,.preview-resizer{display:block!important}
  .texpage-editor-pane,.texpage-preview-pane{display:flex!important;min-width:0}
  .mobile-mode-switch,.mobile-pdf-btn{display:none!important}
  .navigator-toggle{display:grid!important}
  .preview-toolbar{grid-template-columns:minmax(0,1fr) auto auto!important}
  .texpage-preview-pane .typst-preview{padding:20px 20px 56px!important}
}
@media(min-width:768px) and (max-width:1179px){
  body.editor-page{overflow:hidden}
  .texpage-topbar{min-height:48px}
  .texpage-workbench{
    height:calc(100dvh - 48px)!important;
    grid-template-columns:minmax(320px,var(--editor-w,42vw)) 5px minmax(360px,1fr)!important;
    overflow:hidden!important;
  }
  .texpage-navigator{
    position:fixed!important;z-index:80!important;
    left:0!important;top:48px!important;bottom:0!important;
    width:min(310px,78vw)!important;
    transform:translateX(-103%)!important;
    transition:transform .18s ease!important;
    box-shadow:12px 0 40px #111b2a30!important;
  }
  body.navigator-open .texpage-navigator{transform:translateX(0)!important}
  body.navigator-open .workbench-backdrop{display:block!important}
  .workbench-backdrop{inset:48px 0 0!important}
  .navigator-resizer{display:none!important}
  .preview-resizer{display:block!important}
  .texpage-workbench>.texpage-editor-pane{grid-column:1!important}
  .texpage-workbench>.preview-resizer{grid-column:2!important}
  .texpage-workbench>.texpage-preview-pane{grid-column:3!important}
  .texpage-editor-pane,.texpage-preview-pane{display:flex!important;min-width:0}
  .mobile-mode-switch,.mobile-pdf-btn{display:none!important}
  .preview-toolbar{
    grid-template-columns:minmax(0,1fr) auto auto!important;
    padding-inline:7px!important;
  }
  .preview-toolbar-left .preview-chip{display:none!important}
  .preview-toolbar-left strong{max-width:23vw!important}
  .texpage-question-editor{padding-inline:14px!important}
  .texpage-question-editor .question-editor-head{margin-inline:-14px!important;padding-inline:14px!important}
  .texpage-preview-pane .typst-preview{padding:14px 12px 54px!important}
}
@media(max-width:767px){
  body.editor-page{height:100dvh!important;overflow:hidden!important}
  .texpage-topbar{
    min-height:52px!important;
    padding:max(6px,env(safe-area-inset-top)) 7px 6px!important;
    display:grid!important;
    grid-template-columns:auto minmax(0,1fr)!important;
    gap:5px!important;
  }
  .texpage-topbar .editor-brand-wrap{min-width:0!important}
  .texpage-topbar .brand small,.texpage-topbar .local-pill,.texpage-topbar .save-state,
  .texpage-topbar .history-actions,#saveProjectButton{display:none!important}
  .texpage-topbar .editor-top-actions{
    min-width:0!important;overflow-x:auto!important;justify-content:flex-end!important;
    gap:4px!important;scrollbar-width:none;
  }
  .texpage-topbar .editor-top-actions::-webkit-scrollbar{display:none}
  .navigator-toggle{display:grid!important;flex:0 0 34px!important;width:34px!important;height:34px!important}
  .template-control{min-width:0!important;flex:0 1 132px!important}
  #templateButton{max-width:132px!important;min-height:34px!important;height:34px!important;padding:0 7px!important}
  #templateButtonLabel{overflow:hidden!important;text-overflow:ellipsis!important;white-space:nowrap!important;font-size:9px!important}
  .mobile-mode-switch{display:flex!important}
  .mobile-mode-switch button{min-height:34px!important;height:34px!important;padding:0 9px!important;font-size:10px!important}
  .mobile-pdf-btn{display:inline-flex!important;min-height:34px!important;height:34px!important;padding-inline:9px!important}

  .texpage-workbench{height:calc(100dvh - 52px)!important;display:block!important;overflow:hidden!important}
  .navigator-resizer,.preview-resizer{display:none!important}
  .texpage-navigator{
    position:fixed!important;z-index:80!important;
    left:0!important;top:52px!important;bottom:0!important;
    width:min(320px,88vw)!important;
    transform:translateX(-103%)!important;
    transition:transform .18s ease!important;
    box-shadow:12px 0 40px #111b2a35!important;
  }
  body.navigator-open .texpage-navigator{transform:translateX(0)!important}
  body.navigator-open .workbench-backdrop{display:block!important}
  .workbench-backdrop{inset:52px 0 0!important}

  .texpage-editor-pane,.texpage-preview-pane{width:100%!important;height:100%!important;min-width:0!important}
  body:not(.preview-mode) .texpage-editor-pane{display:flex!important}
  body:not(.preview-mode) .texpage-preview-pane{display:none!important}
  body.preview-mode .texpage-editor-pane{display:none!important}
  body.preview-mode .texpage-preview-pane{display:flex!important}

  .pane-tabbar{height:36px!important;flex-basis:36px!important;padding-inline:8px!important}
  .editor-commandbar{min-height:44px!important;padding:6px 9px!important}
  .editor-commandbar span{max-width:52vw!important}
  .texpage-question-editor{padding:12px 12px calc(72px + env(safe-area-inset-bottom))!important}
  .texpage-question-editor .question-editor-head{top:-12px!important;margin:0 -12px 12px!important;padding:8px 12px!important}
  .texpage-question-editor textarea{min-height:178px!important;font-size:16px!important}
  .texpage-question-editor input,.texpage-question-editor select{font-size:16px!important;min-height:42px!important}
  .option-editor{align-items:flex-start!important}
  .question-editor-head>div{flex-wrap:wrap!important;justify-content:flex-end!important}

  .preview-toolbar{
    height:42px!important;flex-basis:42px!important;
    grid-template-columns:minmax(0,1fr) auto!important;padding:0 6px!important;
  }
  .preview-toolbar-left .preview-chip{display:none!important}
  .preview-toolbar-left strong{max-width:38vw!important}
  .preview-toolbar-center{
    position:fixed!important;left:50%!important;bottom:max(10px,env(safe-area-inset-bottom))!important;
    z-index:95!important;transform:translateX(-50%)!important;
    padding:5px 7px!important;border:1px solid #435168!important;border-radius:10px!important;
    background:#202c3d!important;box-shadow:0 8px 24px #0c142240!important;
  }
  .preview-toolbar-right{justify-self:end!important}
  .texpage-preview-pane .pdf-status{min-height:24px!important;padding:5px 8px!important;font-size:8px!important}
  .texpage-preview-pane .typst-preview{
    padding:8px 6px calc(62px + env(safe-area-inset-bottom))!important;
    gap:8px!important;
  }
  .texpage-preview-pane .typst-preview > section.typst-page{width:100%!important;max-width:100%!important}
  .template-popover{
    position:fixed!important;left:7px!important;right:7px!important;top:52px!important;
    width:auto!important;max-height:calc(100dvh - 62px)!important;z-index:180!important
  }
}
@media(max-width:430px){
  .texpage-topbar .brand>span:last-child{display:none!important}
  .texpage-topbar{grid-template-columns:32px minmax(0,1fr)!important}
  .template-control{flex-basis:112px!important}
  #templateButton{max-width:112px!important}
  .editor-command-actions .text-btn{padding-inline:5px!important}
  .preview-toolbar-left strong{max-width:31vw!important}
}


/* Mobile topbar final correction: prevent generic primary button flex growth. */
@media(max-width:767px){
  .texpage-topbar{
    display:grid!important;
    grid-template-columns:34px minmax(0,1fr)!important;
    align-items:center!important;
  }
  .texpage-topbar .editor-brand-wrap{
    width:34px!important;min-width:34px!important;overflow:hidden!important;
  }
  .texpage-topbar .brand{
    width:34px!important;min-width:34px!important;padding:0!important;gap:0!important;
  }
  .texpage-topbar .brand-mark{margin:0!important;flex:0 0 28px!important}
  .texpage-topbar .editor-top-actions{
    display:grid!important;
    grid-template-columns:34px minmax(98px,132px) 42px minmax(92px,auto)!important;
    align-items:center!important;
    justify-content:end!important;
    overflow:visible!important;
    gap:4px!important;
  }
  .texpage-topbar .navigator-toggle{grid-column:1!important;width:34px!important;min-width:34px!important}
  .texpage-topbar .template-control{grid-column:2!important;width:100%!important;min-width:0!important;max-width:none!important}
  .texpage-topbar #templateButton{width:100%!important;max-width:none!important}
  .texpage-topbar .mobile-pdf-btn{
    grid-column:3!important;
    width:42px!important;min-width:42px!important;max-width:42px!important;
    flex:none!important;padding:0!important;justify-content:center!important;
    border-radius:8px!important;font-size:9px!important;
  }
  .texpage-topbar .mobile-mode-switch{
    grid-column:4!important;
    width:auto!important;min-width:92px!important;justify-self:end!important;
  }
  .texpage-topbar .mobile-mode-switch button{
    min-width:44px!important;padding-inline:7px!important;
  }
}
@media(max-width:430px){
  .texpage-topbar .editor-top-actions{
    grid-template-columns:32px minmax(82px,108px) 38px minmax(88px,auto)!important;
  }
  .texpage-topbar .mobile-pdf-btn{width:38px!important;min-width:38px!important;max-width:38px!important}
  .texpage-topbar .mobile-mode-switch{min-width:88px!important}
}

/* 2026-10-12 browser pagination engine: ExamA4 / Book share one physical DOM. */
.paper-measurement-layer{
  position:fixed;left:-30000px;top:0;z-index:-1;box-sizing:border-box;
  visibility:hidden;pointer-events:none;background:#fff;color:#111;
  contain:layout style;font-family:"Everflow Termes","Everflow Song",serif;
}
.browser-paper-preview{
  display:flex!important;flex-direction:column;align-items:center;gap:22px;
  overflow:auto;min-height:calc(100dvh - 112px);padding:30px 22px 64px;
  background:#e9ece7;
}
.browser-paper-preview[hidden]{display:none!important}
.browser-paper-page{
  position:relative;display:block;flex:0 0 auto;box-sizing:border-box;
  width:var(--paper-width,210mm)!important;max-width:none!important;
  height:var(--paper-height,297mm)!important;min-height:var(--paper-height,297mm)!important;
  margin:0!important;overflow:hidden;background:#fff;color:#111;border:1px solid #d7ded8;border-radius:2px;
  box-shadow:0 12px 35px #25372a20;zoom:var(--browser-preview-scale,1);
  font-family:"Everflow Termes","Everflow Song",serif;font-size:var(--paper-font,9.03374pt);line-height:var(--paper-leading,1.56);
  font-synthesis:none;print-color-adjust:exact;-webkit-print-color-adjust:exact;
  page:everflow-content;
}
/* Override legacy SVG card sizing before applying visual zoom. Physical page
   width must remain unchanged or measurement and validation use different widths. */
.texpage-preview-pane .typst-preview.browser-paper-preview > section.typst-page.browser-paper-page{
  width:var(--paper-width,210mm)!important;max-width:none!important;transition:none;
}
.browser-paper-columns{
  position:absolute;top:var(--paper-top);right:var(--paper-right);
  bottom:var(--paper-bottom);left:var(--paper-left);
  display:grid;gap:var(--paper-column-gap);align-items:stretch;
}
.browser-paper-column{position:relative;min-width:0;overflow:hidden}
.paper-layout-item{position:relative;display:flow-root;box-sizing:border-box;min-width:0;overflow:visible;cursor:pointer}
.paper-layout-item .question{margin:0!important;padding:0!important;break-inside:avoid;outline:0!important}
.paper-layout-item .question-line{display:grid;grid-template-columns:2.25em minmax(0,1fr);column-gap:.55em;align-items:start}
.paper-layout-item .question-number{font-weight:400;text-align:right;white-space:nowrap}
.paper-layout-item .question-body{min-width:0;white-space:normal;overflow-wrap:break-word;word-break:normal}
.paper-layout-item .question-body p{margin:0}
.paper-layout-item .question-body .semantic-row{display:grid;grid-template-columns:2.2em minmax(0,1fr);column-gap:.38em}
.paper-layout-item .question-body .semantic-row.roman{grid-template-columns:2.15em minmax(0,1fr);column-gap:.35em}
.paper-layout-item .question-body .semantic-row.subq{grid-template-columns:1.9em minmax(0,1fr);column-gap:.6em}
.paper-layout-item .question-body .semantic-label{text-align:right;white-space:nowrap}
.paper-layout-item .options{
  display:grid;margin:var(--master-choice-before,2.25mm) 0 0 calc(2.25em + .55em);
  row-gap:.22em;column-gap:1.2em;break-inside:avoid;
}
.paper-layout-item .options.cols-4{grid-template-columns:repeat(4,minmax(0,1fr));column-gap:.55em}
.paper-layout-item .options.cols-3{grid-template-columns:repeat(3,minmax(0,1fr));column-gap:.8em}
.paper-layout-item .options.cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}
.paper-layout-item .options.cols-1{grid-template-columns:minmax(0,1fr)}
.paper-layout-item .option{display:grid;grid-template-columns:2.25em minmax(0,1fr);min-width:0}
.paper-layout-item .option-label{white-space:nowrap}.paper-layout-item .option-body{min-width:0;overflow-wrap:break-word}
.paper-layout-item math[display="block"]{display:block;margin:3pt 0;max-width:100%}
.paper-layout-item .paper-section-heading{
  margin:2ex 0 1ex;font-family:"Everflow Hei",sans-serif;font-size:inherit;font-weight:700;line-height:inherit;text-align:left;
}
body[data-template="book"] .paper-layout-item .paper-section-heading{
  margin:2pt 0 4pt;text-align:center;font-size:12.045pt;font-weight:400;line-height:1.56;
}
.question-answer-space{position:relative;box-sizing:border-box;min-height:0}
.browser-gap-handle{
  position:absolute;z-index:8;left:2.8em;right:0;bottom:0;height:7px;padding:0;border:0;border-top:1px dashed transparent;
  background:transparent;color:#315d4d;cursor:ns-resize;opacity:0;transition:opacity .15s,border-color .15s;
}
.paper-layout-item:hover .browser-gap-handle,.browser-gap-handle:focus-visible,.is-adjusting-paper-gap .browser-gap-handle{opacity:1;border-color:#78a38d}
.browser-gap-handle:before{position:absolute;left:50%;top:-4px;width:26px;height:7px;border-radius:99px;background:#78a38d;content:"";transform:translateX(-50%)}
.browser-gap-handle span{position:absolute;right:0;top:-17px;padding:1px 5px;border-radius:4px;background:#edf4ef;font:8px/1.4 system-ui,sans-serif;white-space:nowrap}
.paper-question-fragment-window{position:relative;overflow:hidden}
.paper-question-fragment-body{position:relative;min-height:0;will-change:transform}
.browser-running-header{
  position:absolute;top:calc(var(--paper-top) - 5.3mm - var(--paper-head-sep,3mm));right:var(--paper-right);left:var(--paper-left);height:5.3mm;
  display:grid;grid-template-columns:1fr minmax(0,1.4fr) 1fr;align-items:start;border-bottom:.4pt solid #777;
  font-family:"Everflow Song",serif;font-size:10pt;font-weight:700;line-height:1.2;
}
.browser-running-header span:nth-child(2){text-align:center}.browser-running-header span:last-child{text-align:right}
.browser-paper-footer{
  position:absolute;right:var(--paper-right);bottom:var(--paper-footer);left:var(--paper-left);height:4.5mm;
  display:flex;align-items:start;justify-content:center;border:0;color:#222;
  font-family:"Everflow Kai","Everflow Song",serif;font-size:9pt;line-height:1.2;
}
.browser-paper-footer.is-column-footer{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:var(--paper-column-gap)}
.browser-paper-footer.is-column-footer span{text-align:center}
body[data-template="book"] .browser-paper-footer{bottom:4.2mm;height:4.2mm;font-family:"Everflow Song",serif}
.browser-paper-watermark{
  position:absolute;right:13mm;bottom:30mm;z-index:0;width:auto;height:34mm;opacity:.09;object-fit:contain;pointer-events:none;
}
.browser-paper-qr{position:absolute;left:3mm;bottom:5.8mm;width:15mm;display:grid;justify-items:center;gap:.4mm;color:#555;font:5.8pt/1 "Everflow Song",serif}
.browser-paper-qr img{display:block;width:13mm;height:13mm}.browser-paper-footer{z-index:2}.browser-paper-columns{z-index:1}
.browser-cover-page{width:210mm!important;height:297mm!important;min-height:297mm!important;font-family:"Everflow Song",serif;page:everflow-cover}
.browser-cover-title{position:absolute;left:18mm;right:18mm;top:120.9mm;text-align:center;font-family:"Everflow Song",serif;font-size:24.7871pt;font-weight:700;line-height:30pt}
.browser-cover-signature{position:absolute;left:18mm;right:18mm;top:148.05mm;text-align:center;font-size:18.3313pt;font-weight:700;line-height:18pt}
.browser-cover-line{position:absolute;left:18mm;top:266mm;width:50mm;border-top:.4pt solid #111}
.browser-cover-brand{position:absolute;left:19.3mm;top:270.55mm;font-size:9.4645pt;font-weight:700;line-height:12pt}
.browser-cover-date{position:absolute;left:19.3mm;top:277.15mm;color:#f00;font-size:8.9664pt;font-weight:700;line-height:11pt}
body[data-template="book"] .browser-cover-title{font-size:21.9178pt}
body[data-template="book"] .browser-cover-date{color:#24272b}
.exact-pdf-btn{min-width:68px!important;font-size:11px!important}

@media(max-width:767px){
  .browser-paper-preview{gap:10px;padding:10px 6px calc(75px + env(safe-area-inset-bottom))!important}
  .browser-paper-page{max-width:none!important}
  .preview-toolbar-right .exact-pdf-btn{display:none!important}
}

@media print{
  html,body{width:auto!important;height:auto!important;margin:0!important;padding:0!important;background:#fff!important}
  body.browser-print-active *{visibility:hidden!important}
  body.browser-print-active #typstPreview,body.browser-print-active #typstPreview *{visibility:visible!important}
  body.browser-print-active #typstPreview{
    position:absolute!important;left:0!important;top:0!important;display:block!important;width:auto!important;height:auto!important;
    min-height:0!important;margin:0!important;padding:0!important;overflow:visible!important;background:#fff!important;
  }
  body.browser-print-active .browser-paper-page{
    display:block!important;zoom:1!important;margin:0!important;border:0!important;border-radius:0!important;box-shadow:none!important;
    break-after:page;page-break-after:always;
  }
  body.browser-print-active .browser-paper-page:last-child{break-after:auto;page-break-after:auto}
  body.browser-print-active .browser-gap-handle{display:none!important}
  body.browser-print-active .editor-topbar,body.browser-print-active .texpage-navigator,
  body.browser-print-active .texpage-editor-pane,body.browser-print-active .pane-resizer,
  body.browser-print-active .preview-toolbar,body.browser-print-active .pdf-status,
  body.browser-print-active #paperStage{display:none!important}
  body.browser-print-active .texpage-workbench,body.browser-print-active .texpage-preview-pane{
    display:block!important;position:static!important;height:auto!important;overflow:visible!important;margin:0!important;padding:0!important;
  }
  body.browser-print-active .texpage-preview-pane #typstPreview{position:static!important}
}
