/* ============================================================
   SPECSMITH · 半自动式样书系统
   纸张质感企业工具风：深藏青顶栏 + 纸白画布 + 蓝图网格预览
   ============================================================ */

:root {
  --navy: #0d2436;
  --navy-deep: #08192a;
  --navy-soft: #16334b;
  --accent: #0a62b5;
  --accent-bright: #0070c0;
  --accent-wash: #eaf2fb;
  --paper: #ffffff;
  --canvas: #e7ecf2;
  --ink: #15212d;
  --muted: #66788b;
  --muted-soft: #8b9cae;
  --line: #d6dee7;
  --line-soft: #e8eef5;
  --warn: #b4682a;
  --ui: "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --serif: "Songti SC", "Source Han Serif SC", "Noto Serif SC", "Yu Mincho", "SimSun", serif;
  --doc: "Yu Gothic", "游ゴシック", "YuGothic", "Meiryo", "Microsoft YaHei", "PingFang SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--ui);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* ---------------- 顶栏 ---------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  height: 62px;
  padding: 0 22px;
  background: linear-gradient(180deg, var(--navy) 0%, var(--navy-deep) 100%);
  border-bottom: 2px solid var(--accent);
  color: #fff;
  flex: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 3px;
  font-family: var(--serif);
  font-size: 17px;
  letter-spacing: 0;
  color: #dce9f7;
  background: rgba(255, 255, 255, .06);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-text strong {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: .26em;
}

.brand-text span {
  font-size: 11px;
  letter-spacing: .12em;
  color: #8fa9c1;
  margin-top: 3px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.save-state {
  font-size: 12px;
  color: #86a2bd;
  letter-spacing: .04em;
}

.save-state.saving { color: #cfe0f0; }

/* ---------------- 通用按钮 ---------------- */
.btn {
  font-family: inherit;
  font-size: 13px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .16s ease, border-color .16s ease, color .16s ease, transform .12s ease;
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, .26);
  color: #d8e5f2;
  padding: 7px 14px;
}

.btn.ghost:hover {
  border-color: rgba(255, 255, 255, .55);
  background: rgba(255, 255, 255, .08);
}

.btn.primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: .06em;
}

.btn.primary:hover { background: #0b6fcc; }
.btn.primary:active { transform: translateY(1px); }
.btn.primary:disabled { opacity: .6; cursor: default; }
.btn.primary svg { width: 10px; height: 6px; }

.mini {
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 3px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.mini:hover { border-color: #a9bccd; }
.mini.subtle { color: var(--muted); }
.mini.subtle:hover { color: var(--accent); border-color: #b9cfe6; }
.mini:disabled { opacity: .4; cursor: default; border-color: var(--line); color: var(--muted-soft); }

/* ---------------- 主工作区 ---------------- */
.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(432px, 478px) minmax(0, 1fr);
  min-height: 0;
}

/* ---------------- 左侧编辑 ---------------- */
.editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: #f8fafc;
  border-right: 1px solid var(--line);
}

.lang-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.lang-switch button {
  font-family: inherit;
  font-size: 13px;
  letter-spacing: .06em;
  padding: 7px 16px;
  border: 1px solid transparent;
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all .16s ease;
}

.lang-switch button:hover { color: var(--ink); }

.lang-switch button.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.lang-hint {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted-soft);
  letter-spacing: .1em;
}

.lang-pane { display: none; }
.lang-pane.active { display: block; }

.editor-scroll {
  overflow-y: auto;
  padding: 16px 18px 72px;
  scrollbar-width: thin;
}

.editor-scroll::-webkit-scrollbar { width: 10px; }
.editor-scroll::-webkit-scrollbar-thumb {
  background: #cfd9e4;
  border: 3px solid #f8fafc;
  border-radius: 6px;
}

/* ---------------- 分区卡片 ---------------- */
.sec {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 16px 18px;
  margin-bottom: 14px;
  box-shadow: 0 1px 2px rgba(13, 36, 54, .04);
}

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin-bottom: 14px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line-soft);
}

.sec-no {
  font-family: var(--serif);
  font-size: 13px;
  font-style: italic;
  color: var(--accent);
  letter-spacing: .04em;
}

.sec-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .04em;
}

.sec-note {
  margin: 0 0 0 auto;
  font-size: 11px;
  color: var(--muted-soft);
  letter-spacing: .08em;
}

.sub {
  margin: 18px 0 9px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .1em;
  color: var(--navy-soft);
  padding-left: 8px;
  border-left: 2px solid var(--accent);
}

/* ---------------- 表单 ---------------- */
.grid { display: grid; gap: 10px 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 1fr 1fr 1fr; margin-top: 10px; }
.grid .wide { grid-column: 1 / -1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.field > span {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field input {
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  padding: 5px 2px 6px;
  border: none;
  border-bottom: 1px solid #c9d5e1;
  background: transparent;
  border-radius: 0;
  width: 100%;
  transition: border-color .16s ease, background .16s ease;
}

.field input:focus {
  outline: none;
  border-bottom-color: var(--accent);
  background: linear-gradient(180deg, transparent 60%, var(--accent-wash) 100%);
}

.field input::placeholder { color: #b3c0cd; }

.oem-list { display: flex; flex-direction: column; gap: 8px; }

.oem-row {
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 8px;
  align-items: stretch;
}

.oem-row .oem-label {
  font-family: inherit;
  font-size: 12.5px;
  color: var(--navy-soft);
  padding: 7px 9px;
  border: 1px solid #dae3f3;
  background: #f3f7fd;
  border-radius: 3px;
  width: 100%;
  text-align: center;
  transition: border-color .16s ease, background .16s ease;
}

.oem-row .oem-label:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.oem-row textarea {
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--ink);
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fcfdfe;
  resize: none;
  width: 100%;
  min-height: 40px;
  overflow: hidden;
  transition: border-color .16s ease, background .16s ease;
}

.oem-row textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.note-row { grid-template-columns: 22px 1fr; }

.note-no {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

/* ---------------- 图片上传 ---------------- */
.shots {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.shot {
  border: 1px dashed #c6d4e2;
  border-radius: 4px;
  background: #fbfdff;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.shot.dragover,
.shot:hover {
  border-color: var(--accent);
  background: #f4f9ff;
}

.shot-thumb {
  height: 86px;
  border-radius: 3px;
  background: #fff
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12'><path d='M0 0h12v12H0z' fill='%23ffffff'/><path d='M0 6h12M6 0v12' stroke='%23eef2f7' stroke-width='1'/></svg>");
  border: 1px solid var(--line-soft);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.shot-thumb img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.shot-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.shot-meta strong {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.shot-meta small {
  font-size: 10.5px;
  color: var(--muted-soft);
}

.shot-actions { display: flex; gap: 6px; }
.shot-actions .mini { flex: 1; text-align: center; }

.hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--muted-soft);
  letter-spacing: .04em;
}

/* ---------------- 右侧预览 ---------------- */
.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.stage-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 52px;
  padding: 0 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex: none;
}

.stage-title {
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.stage-title b {
  color: var(--navy);
  letter-spacing: .04em;
}

.stage-title b::before {
  content: "";
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  margin-right: 6px;
  vertical-align: 1px;
}

.zoom {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

.zoom span {
  font-size: 11.5px;
  color: var(--muted);
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.export-wrap { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 208px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 14px 34px rgba(9, 25, 39, .16);
  padding: 5px;
  display: none;
  z-index: 30;
}

.menu.open { display: block; }

.menu button {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 3px;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.menu button b { font-weight: 600; }
.menu button span { font-size: 11px; color: var(--muted-soft); }
.menu button:hover { background: var(--accent-wash); }
.menu button:hover span { color: var(--accent); }

.canvas {
  flex: 1;
  overflow: auto;
  padding: 26px 26px 40px;
  background-color: #e9eef4;
  background-image:
    linear-gradient(rgba(10, 98, 181, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(10, 98, 181, .055) 1px, transparent 1px);
  background-size: 27px 27px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.holder {
  position: relative;
  flex: none;
  margin: auto;
}

.paper {
  width: 210mm;
  height: 297mm;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  background: var(--paper);
  box-shadow: 0 16px 44px rgba(9, 25, 39, .18), 0 1px 2px rgba(9, 25, 39, .12);
  font-family: var(--doc);
  color: #000;
  overflow: hidden;
}

/* ---- 预览内部构件（数值与导出 Excel 版式对应） ---- */
.pv {
  position: absolute;
  box-sizing: border-box;
  white-space: pre-wrap;
  overflow: hidden;
}

.pv.center { display: flex; align-items: center; justify-content: center; text-align: center; }
.pv.mid { display: flex; align-items: center; }

.pv.bar {
  background: #b4c7e7;
  font-weight: 700;
  display: flex;
  align-items: center;
  padding-left: 1.6mm;
}

.pv.info { border: .22mm solid #1a1a1a; }

.pv.info-label {
  background: #0070c0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
}

.pv.info-value {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  line-height: 1.15;
}

.pv.underline { border-bottom: .19mm solid #111; }
.pv.divider { border-bottom: .08mm solid #111; }

.pv.oem-table { border: .2mm solid #111; }
.pv.oem-label {
  background: #dae3f3;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border-right: .2mm solid #111;
  line-height: 1.2;
}
.pv.oem-value { padding: .5mm .6mm 0 .7mm; line-height: 1.28; }

.pv.note-bar { background: #bfbfbf; display: flex; align-items: center; padding-left: .5mm; }

.pv.chip {
  background: #dee9f7;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.pv.frame { border: .15mm solid #94a3b1; }

.pv img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 10px);
  background: var(--navy);
  color: #eaf3fc;
  font-size: 12.5px;
  letter-spacing: .04em;
  padding: 9px 18px;
  border-radius: 3px;
  box-shadow: 0 12px 30px rgba(9, 25, 39, .28);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 80;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #7d2a1e; }

/* ---------------- 打印 ---------------- */
@media print {
  @page { size: A4; margin: 0; }

  html, body { height: auto; overflow: visible; background: #fff; }

  .topbar, .editor, .stage-bar, .toast { display: none !important; }

  .app, .workspace, .stage, .canvas { display: block !important; height: auto; overflow: visible; padding: 0; background: #fff !important; }

  .holder { width: auto !important; height: auto !important; margin: 0; }
  .paper { position: relative !important; top: 0; left: 0; transform: none !important; box-shadow: none; }
}

/* ---------------- 窄屏 ---------------- */
@media (max-width: 1080px) {
  body { overflow: auto; }
  .app { height: auto; }
  .workspace { grid-template-columns: 1fr; }
  .editor { order: 2; border-right: none; border-top: 1px solid var(--line); }
  .stage { order: 1; min-height: 70vh; }
  .editor-scroll { overflow: visible; }
  .lang-hint { display: none; }
}
