/* ============================================================
 * 商标服务协议 · 界面与 A4 纸面样式
 * 外壳（页眉/页脚）统一由 site.css 提供；本文件只负责工具内部。
 * 断点：360 / 768 / 1024 / 1440（移动优先）；触控目标 ≥44px
 * ============================================================ */

:root {
  --cw-brand:       var(--pt-brand, #1557D6);
  --cw-brand-deep:  var(--pt-brand-deep, #0B3F9E);
  --cw-brand-soft:  var(--pt-brand-soft, #EAF1FF);
  --cw-ink:         var(--pt-ink, #1B2333);
  --cw-ink-2:       var(--pt-ink-2, #4C5870);
  --cw-ink-3:       var(--pt-ink-3, #8A93A6);
  --cw-line:        var(--pt-line, #E2E7F0);
  --cw-bg:          var(--pt-bg, #F4F6FA);
  --cw-stage:       #E9EDF4;
  --cw-white:       #FFFFFF;
  --cw-danger:      #C8362F;
  --cw-radius:      12px;
  --cw-header-h:    var(--pt-header-h, 60px);
  --cw-footer-h:    var(--pt-footer-h, 44px);
  --cw-mobile-bar:  62px;
  --cw-font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  /* 导出文档默认字体：宋体。Win7/Win10 必带 SimSun（宋体），其后 NSimSun（新宋体）兜底；
   * macOS 本地预览回退到 Songti SC / STSong。标题同样用宋体加粗。宋体为系统字体，不随包分发。 */
  --cw-font-doc: "SimSun", "宋体", "NSimSun", "新宋体", "STSong", "Songti SC", "Noto Serif CJK SC", serif;
  --cw-font-hei: "SimSun", "宋体", "NSimSun", "新宋体", "STSong", "Songti SC", "Noto Serif CJK SC", serif;
}

body.cw-page {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--cw-bg); color: var(--cw-ink);
  font-family: var(--cw-font-ui); font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------------- 页眉内工具动作 ---------------- */
.privacy-pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px; border-radius: 999px;
  background: #EAF6EF; color: #1E7A47; font-size: 12px; font-weight: 500;
  white-space: nowrap;
}
.link-btn { border: 0; background: none; color: var(--cw-brand); font-size: 13px; padding: 8px 4px; }
.link-btn:hover { color: var(--cw-brand-deep); text-decoration: underline; }

/* ---------------- 工作台 ---------------- */
.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 420px) minmax(0, 1fr);
  gap: 16px;
  height: calc(100dvh - var(--cw-header-h) - var(--cw-footer-h));
  padding: 16px;
}
.panel {
  min-height: 0; min-width: 0;
  background: var(--cw-white); border: 1px solid var(--cw-line);
  border-radius: var(--cw-radius); box-shadow: 0 2px 12px rgba(24, 48, 92, .06);
  display: flex; flex-direction: column; overflow: hidden;
}

/* ---------------- 左：填写区 ---------------- */
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 18px 20px 16px; border-bottom: 1px solid var(--cw-line);
}
.panel-head h2 { margin: 0 0 4px; font-size: 16px; }
.panel-head p { margin: 0; font-size: 12px; color: var(--cw-ink-3); }
.required-note { font-size: 12px; color: var(--cw-ink-3); white-space: nowrap; }
.required-note i, .field label i { color: var(--cw-danger); font-style: normal; }
.form-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; }
.form-scroll form { margin: 0; }
.form-note {
  margin: 0 0 16px; padding: 10px 12px; border-radius: 8px;
  background: #F5F8FF; color: var(--cw-ink-2); font-size: 12px; line-height: 1.7;
}
.form-note--seal { margin: 14px 0 0; background: #F7F9FC; }
.form-note--tiny { margin: 10px 0 0; padding: 8px 10px; background: #F7F9FC; font-size: 11.5px; line-height: 1.6; color: var(--cw-ink-3); }
.default-row { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.mini-btn--save { border-color: var(--cw-brand); color: var(--cw-brand); }
.mini-btn--save:hover { background: var(--cw-brand-soft); }
.default-clear { border: 0; background: none; color: var(--cw-ink-3); font-size: 12px; padding: 6px 2px; text-decoration: underline; }
.default-clear:hover { color: var(--cw-danger); }
.default-tip { font-size: 11.5px; color: var(--cw-ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.seal-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.seal-actions .mini-btn { min-height: 36px; }
.file-input {
  display: block; width: 100%; padding: 9px 11px; border: 1px dashed var(--cw-line);
  border-radius: 8px; background: #fff; color: var(--cw-ink-2); font-size: 12px;
}
.file-input::file-selector-button {
  margin-right: 10px; padding: 5px 10px; border: 1px solid var(--cw-line);
  border-radius: 6px; background: #F5F8FF; color: var(--cw-brand); cursor: pointer; font-size: 12px;
}
.fsec { margin: 0 0 20px; padding: 0; border: 0; }
.fsec legend {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--cw-ink);
}
.step-no {
  display: inline-grid; place-items: center; width: 22px; height: 22px; flex: none;
  border-radius: 6px; background: var(--cw-brand-soft); color: var(--cw-brand);
  font-size: 12px; font-weight: 700;
}
.field { margin-bottom: 14px; min-width: 0; }
.field label { display: block; margin-bottom: 7px; font-size: 13px; font-weight: 600; }
.opt-tag {
  display: inline-block; margin-left: 4px; padding: 1px 6px; border-radius: 4px;
  background: #F0F2F6; color: var(--cw-ink-3); font-size: 11px; font-weight: 400;
}
.field textarea, .field input[type="date"] {
  width: 100%; padding: 9px 11px; border: 1px solid var(--cw-line); border-radius: 8px;
  background: #fff; color: var(--cw-ink); font-size: 13.5px; line-height: 1.6;
  outline: none; resize: none; overflow-y: hidden;
}
.field textarea { min-height: 40px; }
.field input[type="date"] { height: 42px; }
.field textarea:focus, .field input[type="date"]:focus { border-color: var(--cw-brand); box-shadow: 0 0 0 3px rgba(21, 87, 214, .1); }
.field textarea.is-invalid, .field input.is-invalid { border-color: var(--cw-danger); background: #FFF7F6; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.date-row { display: flex; align-items: center; gap: 8px; }
.date-row input[type="date"] { flex: 1 1 auto; min-width: 0; }
.mini-btn {
  flex: none; min-height: 42px; padding: 0 12px; border: 1px solid var(--cw-line);
  border-radius: 8px; background: #fff; color: var(--cw-ink-2); font-size: 12px;
}
.mini-btn:hover { border-color: var(--cw-brand); color: var(--cw-brand); }
.form-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 20px; border-top: 1px solid var(--cw-line); flex: none;
}
.text-btn { border: 0; background: none; color: var(--cw-ink-2); font-size: 13px; padding: 8px 0; }
.text-btn:hover { color: var(--cw-brand); }
.draft-status { font-size: 11.5px; color: var(--cw-ink-3); }

/* ---------------- 右：预览与操作 ---------------- */
.preview-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; min-height: 58px; padding: 10px 16px;
  border-bottom: 1px solid var(--cw-line); flex: none;
}
.preview-title { font-size: 13px; font-weight: 700; white-space: nowrap; }
.preview-title span { margin-left: 6px; font-size: 11.5px; font-weight: 400; color: var(--cw-ink-3); }
.zoom-ctrl { display: inline-flex; align-items: center; gap: 4px; }
.zoom-btn {
  min-width: 32px; height: 32px; border: 1px solid var(--cw-line); border-radius: 7px;
  background: #fff; color: var(--cw-ink-2); font-size: 15px; line-height: 1;
}
.zoom-btn:hover { border-color: var(--cw-brand); color: var(--cw-brand); }
.zoom-btn.zoom-fit { padding: 0 9px; font-size: 12px; }
#zoomLabel { min-width: 42px; text-align: center; font-size: 12px; color: var(--cw-ink-2); }
.export-ctrl { display: flex; align-items: center; gap: 8px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.btn-ghost { border: 1px solid var(--cw-line); background: #fff; color: var(--cw-ink-2); }
.btn-ghost:hover { border-color: var(--cw-brand); color: var(--cw-brand); }
.btn-primary { border: 1px solid var(--cw-brand); background: var(--cw-brand); color: #fff; }
.btn-primary:hover { background: var(--cw-brand-deep); border-color: var(--cw-brand-deep); }
.btn:disabled { opacity: .6; cursor: wait; }
.paper-stage {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  display: flex; align-items: center; justify-content: center;
  padding: 20px; background: var(--cw-stage);
}
.paper-scaler { position: relative; flex: none; }
.stage-tip { margin: 0; padding: 8px 16px; flex: none; text-align: center; font-size: 11.5px; color: var(--cw-ink-3); }

/* ---------------- A4 纸面：按原稿内容固定分为 3 页 ---------------- */
/* 三页纵向排列，间距 24px；缩放作用于整组，页与页之间可见分隔 */
.cw-pages {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; gap: 24px;
  transform-origin: top left;
}
.cw-paper {
  position: relative; flex: none;
  width: 794px; height: 1123px; padding: 0; overflow: hidden;
  background: #fff; color: #000;
  font-family: var(--cw-font-doc); font-size: 14px; line-height: 25px;
  box-shadow: 0 6px 28px rgba(24, 40, 76, .14);
}
.cw-page--body { box-sizing: border-box; padding: 30px 60px 48px; }
/* 原稿无页码，仅作 DOM 标记不显示 */
.cw-page-no { display: none; }
/* 第 1 页：带边框封面，满幅一页 */
.cw-cover {
  box-sizing: border-box; width: 794px; height: 1123px;
  padding: 8px 90px 20px; display: flex; flex-direction: column;
  font-family: var(--cw-font-doc);
}
.cw-cover-top {
  display: flex; align-items: baseline; justify-content: space-between;
  flex: none; height: 30px;
}
.cw-cover-brand {
  font-family: "KaiTi", "楷体", "STKaiti", "SimSun", serif;
  font-size: 26px; line-height: 1;
}
.cw-cover-slogan {
  font-family: var(--cw-font-hei); font-size: 11.5px; color: #000;
  letter-spacing: .5px;
}
.cw-cover-box {
  position: relative; box-sizing: border-box; flex: 1 1 auto; min-height: 0;
  border: 1px solid #000; padding: 0 16px;
}
.cw-cover-title {
  margin: 200px 0 0; font-family: var(--cw-font-doc); font-weight: 400;
  font-size: 30px; line-height: 1.35; text-align: center; letter-spacing: 3px;
}
.cw-cover-parties { margin-top: 178px; padding-left: 60px; padding-right: 70px; }
.cw-cover-party { margin: 0 0 10px; font-size: 15px; line-height: 1.8; }
.cw-cover-party--a { display: flex; align-items: baseline; }
.cw-cover-fill {
  display: inline-block; min-width: 14px; min-height: 1em;
  border-bottom: 1px solid #000; line-height: 1.2;
}
.cw-cover-party--a .cw-cover-fill { flex: 1 1 auto; margin: 0 2px; }
.cw-cover-foot {
  position: absolute; left: 16px; right: 16px; bottom: 16px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 20px;
}
.cw-cover-logo { display: block; width: 140px; height: auto; object-fit: contain; }
.cw-cover-contact { font-size: 10px; line-height: 1.7; text-align: right; white-space: nowrap; }
/* 协议正文标题与条款 */
.cw-title {
  margin: 0 0 8px; font-family: var(--cw-font-hei); font-size: 20px; font-weight: 700;
  text-align: center; line-height: 32px; letter-spacing: 2px;
}
.cw-body p {
  margin: 0 0 2px; text-align: justify; text-justify: inter-ideograph;
  line-height: var(--cw-doc-lh, 25px); word-break: break-word;
}
.cw-body p.indent { text-indent: 2em; }
.cw-body p.cw-h { font-weight: 700; margin-top: 6px; }
.cw-body p.cw-party { font-weight: 400; text-indent: 0; }
/* 服务事项多选：4 列网格，与原件紧凑排布一致 */
.cw-body p.cw-services { line-height: 25px; }
.cw-service-grid { display: grid; grid-template-columns: repeat(4, 1fr); column-gap: 8px; }
.cw-service-item { white-space: nowrap; }
.cw-checkbox { display: inline-block; min-width: 16px; font-weight: 700; }
.cw-checkbox.is-checked { color: #000; }
.cw-other-inline { min-width: 90px; }
/* 商标复审子表 */
.cw-subtable-wrap { margin: 4px 0 6px; }
.cw-subtable { width: 100%; border-collapse: collapse; }
.cw-subtable td { border: 1px solid #000; padding: 3px 8px; height: 28px; font-size: 13px; }
.cw-subtable td.cw-sublabel { width: 34%; white-space: nowrap; }
.cw-subfill { display: inline-block; min-width: 100px; min-height: 1em; border-bottom: 1px solid #000; }
/* 固定文字中的填空（费用、工作内容） */
.cw-fill-inline { display: inline-block; min-width: 26px; min-height: 1em; border-bottom: 1px solid #000; text-align: center; vertical-align: baseline; line-height: 1.3; }
.cw-fill.is-wrap, .cw-fill-inline.is-wrap, .cw-subfill.is-wrap, .cw-cover-fill.is-wrap { white-space: normal; word-break: break-all; }
.cw-fill { display: inline-block; width: 420px; min-height: 1em;
  border-bottom: 1px solid #000; vertical-align: baseline;
  white-space: nowrap; font-weight: 400; line-height: 1.3;
}
.cw-sign {
  display: flex; justify-content: space-between; gap: 20px;
  margin-top: 40px;
}
.cw-sign-col { width: 50%; min-width: 0; padding-left: 18px; position: relative; }
.cw-sign-col p { margin: 0 0 2px; line-height: 26px; font-weight: 400; }
.cw-sign-label { font-weight: 700 !important; }
.cw-sign-sub { padding-left: 2em; }
.cw-sign-line { display: inline-block; width: 250px; max-width: 100%; letter-spacing: -1px; white-space: nowrap; min-height: 1.2em; line-height: 1.4; }
.cw-sign-name { display: inline-block; max-width: 100%; white-space: nowrap; vertical-align: baseline; }
.cw-sign-name.is-wrap { white-space: normal; word-break: break-all; }
.cw-sign-blank { height: 30px; }
.cw-sign-date { text-indent: 1.5em; }
.cw-date-fill { display: inline-block; min-width: 30px; text-align: center; }
.cw-seal {
  /* 盖在乙方落款右侧的盖章留白处，避让「乙方：（盖章）」标签与名称文字 */
  position: absolute; right: 2px; top: 20px; z-index: 2;
  width: 66px; height: 66px; object-fit: contain;
  opacity: .92; pointer-events: none;
}
.cw-seal[hidden] { display: none; }

/* ---------------- 移动端吸底导航 ---------------- */
.mobile-bar { display: none; }

/* ---------------- 弹窗 / 提示 ---------------- */
.help-dialog {
  width: min(480px, calc(100vw - 32px)); padding: 0 22px 22px;
  border: 1px solid var(--cw-line); border-radius: 14px;
  box-shadow: 0 18px 60px rgba(20, 36, 72, .22); color: var(--cw-ink);
}
.help-dialog::backdrop { background: rgba(20, 30, 50, .42); }
.help-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 0 12px; border-bottom: 1px solid var(--cw-line); }
.help-head h3 { margin: 0; font-size: 16px; }
.close-btn { border: 0; background: none; font-size: 24px; line-height: 1; color: var(--cw-ink-3); padding: 0 4px; }
.help-list { padding-left: 20px; margin: 16px 0; font-size: 13px; line-height: 1.8; color: var(--cw-ink-2); }
.help-list li { margin-bottom: 8px; }
.help-list strong { color: var(--cw-ink); }
.privacy-note { background: #F0F7F2; border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: #2A6042; }
.privacy-note strong { display: block; margin-bottom: 4px; }
.privacy-note p { margin: 0; line-height: 1.7; }
.help-foot { margin: 14px 0 0; font-size: 11.5px; line-height: 1.6; color: var(--cw-ink-3); }
.toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 60;
  transform: translate(-50%, 14px); opacity: 0; pointer-events: none;
  max-width: min(420px, calc(100vw - 32px));
  padding: 11px 18px; border-radius: 10px;
  background: #25324A; color: #fff; font-size: 13px; line-height: 1.5;
  box-shadow: 0 8px 26px rgba(20, 30, 50, .25);
  transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #A92D27; }
.noscript { margin: 16px; padding: 14px; border-radius: 10px; background: #FFF4E5; color: #8A5A10; font-size: 13px; }

/* ---------------- 响应式 ---------------- */
/* 触控目标 ≥44px：≤1024 平板/手机下所有可点控件补足点击区 */
@media (max-width: 1024px) {
  .mini-btn, .mini-btn--save, .seal-actions .mini-btn { min-height: 44px; }
  .text-btn, #btnReset { min-height: 44px; }
  .zoom-btn { min-width: 44px; height: 44px; }
  .zoom-btn.zoom-fit { padding: 0 10px; }
  .export-ctrl .btn, .btn { min-height: 44px; }
}
@media (max-width: 1439px) {
  .workspace { grid-template-columns: minmax(340px, 396px) minmax(0, 1fr); gap: 12px; padding: 12px; }
  .preview-bar { gap: 8px; }
  .export-ctrl .btn { padding: 0 12px; }
}
@media (max-width: 1023px) {
  .workspace {
    display: block; overflow: hidden;
    height: calc(100dvh - var(--cw-header-h) - var(--cw-mobile-bar) - var(--cw-footer-h));
    padding: 12px;
  }
  .panel { height: 100%; }
  .panel:not(.is-active) { display: none; }
  .form-scroll { padding: 16px; }
  .field-row { grid-template-columns: 1fr 1fr; }
  /* 触控目标 ≥44px：平板/手机下缩放与导出按钮补足点击区 */
  .zoom-btn { min-width: 44px; height: 44px; }
  .zoom-btn.zoom-fit { padding: 0 10px; }
  .export-ctrl .btn { min-height: 44px; }
  .paper-stage { padding: 18px 12px; }
  .mobile-bar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    display: grid; grid-template-columns: repeat(3, 1fr);
    height: var(--cw-mobile-bar); padding-bottom: env(safe-area-inset-bottom);
    background: #fff; border-top: 1px solid var(--cw-line);
    box-shadow: 0 -3px 14px rgba(24, 48, 92, .06);
  }
  .mb-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    min-height: 44px; border: 0; background: none; color: var(--cw-ink-3); font-size: 11px;
  }
  .mb-item.is-active { color: var(--cw-brand); font-weight: 600; }
  .toast { bottom: 80px; }
}
@media (max-width: 767px) {
  .privacy-pill { display: none; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .form-note { font-size: 11.5px; padding: 9px 10px; }
  .preview-title span { display: none; }
  /* 触控目标 ≥44px：缩放与导出按钮移动端补足点击区 */
  .zoom-btn { min-width: 44px; height: 44px; }
  .zoom-btn.zoom-fit { padding: 0 10px; }
  #zoomLabel { min-width: 34px; font-size: 11px; }
  .export-ctrl { width: 100%; }
  .export-ctrl .btn { flex: 1; min-height: 44px; }
  .paper-stage { padding: 14px 10px; }
  .stage-tip { display: none; }
  .form-footer { padding: 10px 16px; }
  .mini-btn { min-height: 44px; }
}
@media (max-width: 359px) {
  .panel-head { padding: 14px; }
  .form-scroll { padding: 12px; }
  .preview-bar { padding: 8px 10px; }
  .btn { padding: 0 10px; }
}

/* ---------------- 打印 / 另存为 PDF 兜底 ---------------- */
@media print {
  @page { size: A4 portrait; margin: 0; }
  html, body { width: 210mm; height: 297mm; background: #fff !important; overflow: visible !important; }
  body > *:not(main) { display: none !important; }
  .workspace { display: block !important; height: auto !important; padding: 0 !important; margin: 0 !important; }
  .panel { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
  .form-panel, .preview-bar, .stage-tip, .mobile-bar { display: none !important; }
  .preview-panel { display: block !important; background: #fff !important; }
  .paper-stage { display: block !important; overflow: visible !important; padding: 0 !important; background: #fff !important; }
  .paper-scaler { position: static !important; width: 794px !important; height: auto !important; }
  .cw-pages { position: static !important; transform: none !important; gap: 0 !important; }
  .cw-paper {
    position: static !important; transform: none !important;
    width: 794px !important; min-height: 1123px !important; height: 1123px !important;
    box-shadow: none !important; break-after: page; page-break-after: always;
  }
  .cw-paper:last-child { break-after: auto; page-break-after: auto; }
}
