/* 技术标工作台 · 浏览器版
   设计取向：紧凑、信息密度高、不花哨。工程类工具，桌面优先。 */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #e3e6ea;
  --line-strong: #cfd4da;
  --text: #1f2328;
  --text-dim: #656d76;
  --text-faint: #8b949e;
  --accent: #1a6dff;
  --accent-soft: #eaf1ff;
  --ok: #1a7f37;
  --warn: #9a6700;
  --bad: #cf222e;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(27, 31, 36, .08), 0 4px 12px rgba(27, 31, 36, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px; height: 26px;
  border-radius: 6px;
  background: linear-gradient(135deg, #1a6dff, #4f8bff);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
}

.brand-name { font-weight: 650; letter-spacing: .2px; }

.brand-tag {
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 1px 7px;
}

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

.env-badge {
  font-size: 12px;
  color: var(--text-dim);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.env-badge.is-ok { color: var(--ok); border-color: #b7e0c4; background: #eefbf2; }
.env-badge.is-bad { color: var(--bad); border-color: #f3c2c5; background: #fff0f1; }
.env-badge.is-warn { color: var(--warn); border-color: #eed9a5; background: #fffaeb; }

/* ---------- 标签页 ---------- */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex: 0 0 auto;
  overflow-x: auto;
}

.tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 9px 14px;
  font: inherit;
  font-size: 13.5px;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.tab:hover { color: var(--text); }

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.tab:disabled { color: var(--text-faint); cursor: default; }

/* ---------- 主视图 ---------- */
.view {
  flex: 1 1 auto;
  overflow: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-title { font-weight: 650; font-size: 14.5px; }

.card-sub {
  font-size: 12.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 按钮 ---------- */
.btn {
  appearance: none;
  font: inherit;
  font-size: 13px;
  padding: 6px 13px;
  border-radius: 6px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}

.btn:hover { background: #f3f4f6; }
.btn:active { background: #eceef1; }
.btn:disabled { color: var(--text-faint); cursor: not-allowed; background: #fafbfc; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: #155fe0; border-color: #155fe0; }
.btn-primary:disabled { background: #b9ceff; border-color: #b9ceff; color: #fff; }

.btn-ghost { border-color: transparent; background: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

.btn-sm { font-size: 12.5px; padding: 4px 10px; }
.btn-danger { color: var(--bad); border-color: #f3c2c5; }
.btn-danger:hover { background: #fff0f1; }

/* ---------- 表单 ---------- */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field > label { font-size: 12.5px; color: var(--text-dim); font-weight: 600; }

input[type="text"], input[type="number"], input[type="password"], select, textarea {
  font: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 120px; line-height: 1.6; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* ---------- 表格 ---------- */
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.grid th, table.grid td {
  text-align: left;
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.grid th {
  font-size: 12px;
  font-weight: 650;
  color: var(--text-dim);
  background: #fafbfc;
  position: sticky;
  top: 0;
  z-index: 1;
}

table.grid tr:hover td { background: #fafbfc; }

table.grid td.mono, .mono {
  font-variant-numeric: tabular-nums;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

table.grid td.num { text-align: right; }

/* ---------- 提示文字 ---------- */
.hint { font-size: 12.5px; color: var(--text-dim); }
.faint { font-size: 12.5px; color: var(--text-faint); }

.pill {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  background: #fff;
}

.pill.ok { color: var(--ok); border-color: #b7e0c4; background: #eefbf2; }
.pill.warn { color: var(--warn); border-color: #eed9a5; background: #fffaeb; }
.pill.bad { color: var(--bad); border-color: #f3c2c5; background: #fff0f1; }

/* ---------- 拖放区 ---------- */
.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  padding: 26px 18px;
  text-align: center;
  background: #fcfcfd;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}

.dropzone:hover, .dropzone.hot {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dropzone strong { display: block; margin-bottom: 4px; font-size: 14px; }

/* ---------- 进度条 ---------- */
.progress {
  height: 8px;
  border-radius: 999px;
  background: #eceef1;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), #4f8bff);
  transition: width .18s;
}

/* ---------- 状态栏 ---------- */
.statusbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 16px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 12.5px;
}

.status-text { color: var(--text-dim); }
.status-detail { color: var(--text-faint); }

.status-text.is-bad { color: var(--bad); }
.status-text.is-ok { color: var(--ok); }

/* ---------- 模态 ---------- */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(27, 31, 36, .38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.modal-root[hidden] { display: none; }

.modal {
  background: var(--panel);
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(27, 31, 36, .22);
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
}

.modal-body { padding: 16px 18px; overflow: auto; }

.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---------- 不支持提示 ---------- */
.unsupported {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.unsupported[hidden] { display: none; }

.unsupported-card {
  max-width: 460px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 26px 28px;
  box-shadow: var(--shadow);
}
.unsupported-card h2 { margin: 0 0 10px; font-size: 17px; }
.unsupported-card p { margin: 0 0 8px; color: var(--text-dim); font-size: 13.5px; }

/* ---------- 空状态 ---------- */
.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

/* ---------- 正文编辑器 ---------- */
.editor {
  width: 100%;
  min-height: 480px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 13px;
  line-height: 1.75;
}

/* ---------- 正文 Markdown 预览 ----------
   故意做得像 Word：宋体、两端对齐、首行缩进 2 字符、表格细边框。
   目的是让用户在这里看到的样子接近导出 docx 的效果，而不是「另一个网页」。 */
.mdview {
  min-height: 320px;
  max-height: 720px;
  overflow: auto;
  padding: 18px 22px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: simsun, "宋体", serif;
  font-size: 15px;
  line-height: 1.9;
  color: #1a1a1a;
}
.mdview-h1 { font-size: 19px; margin: 18px 0 10px; font-weight: 600; }
.mdview-h2 { font-size: 17px; margin: 16px 0 8px; font-weight: 600; }
.mdview-h3 { font-size: 15.5px; margin: 14px 0 7px; font-weight: 600; }
.mdview-h4 { font-size: 15px; margin: 12px 0 6px; font-weight: 600; }
.mdview-p {
  margin: 0 0 8px;
  text-align: justify;
  text-indent: 2em;
  word-break: break-word;
}
.mdview-caption {
  margin: 4px 0 10px;
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}
.mdview-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 14px;
  font-size: 13.5px;
}
.mdview-table th,
.mdview-table td {
  border: 1px solid #999;
  padding: 5px 8px;
  text-align: left;
  vertical-align: top;
}
.mdview-table th { background: #f2f2f2; font-weight: 600; text-align: center; }
.mdview-figure {
  margin: 8px 0;
  padding: 8px 10px;
  background: #f7f7f7;
  border: 1px dashed #bbb;
  font-size: 13px;
  color: #666;
}
.mdview-empty {
  padding: 40px 0;
  text-align: center;
  color: #999;
  font-size: 13.5px;
}
.mdview strong { font-weight: 700; }
.mdview em { font-style: italic; }
.mdview code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  background: #f2f2f2;
  padding: 0 3px;
  border-radius: 3px;
}

/* 暗标：与 docx 导出一致——不加粗、不高亮（导出时 cleanInline 会把这些标记全剥掉，
   预览里若显示粗体，用户会以为格式坏了） */
.mdview-blind strong,
.mdview-blind em,
.mdview-blind del { font-weight: normal; font-style: normal; text-decoration: none; }
.mdview-blind .mdview-h1,
.mdview-blind .mdview-h2,
.mdview-blind .mdview-h3,
.mdview-blind .mdview-h4 { font-weight: normal; }
.mdview-blind code { background: none; padding: 0; }

/* 预览/编辑切换的分段按钮 */
.seg {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
}
.seg button {
  border: 0;
  background: #fff;
  padding: 4px 11px;
  font-size: 12.5px;
  cursor: pointer;
  color: #444;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: #2f6feb; color: #fff; }

/* 整页拖拽遮罩 */
.drop-veil {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(47, 111, 235, 0.08);
  border: 3px dashed #2f6feb;
  font-size: 17px;
  color: #2f6feb;
  pointer-events: none;
}
.drop-veil.on { display: flex; }

/* ---------- 工具类 ---------- */
.spacer { flex: 1 1 auto; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* 非安全上下文提示条：只在顶部占一行，不再整屏遮住应用 */
/* 关键：`.unsupported.is-bar` 是「两个类」，特异性高于 `.unsupported[hidden]`
   （一个类 + 一个属性），所以它里面的 display:block 会覆盖 [hidden] 的 display:none，
   结果**提示条在任何环境下都显示**（实测踩过）。这里补一条更高特异性把它压回去。 */
.unsupported.is-bar[hidden] { display: none; }

.unsupported.is-bar {
  position: static;
  inset: auto;
  display: block;
  background: #fff8e1;
  border-bottom: 1px solid #ffe082;
  padding: 10px 16px;
  z-index: auto;
}
.unsupported.is-bar .unsupported-card {
  max-width: none;
  margin: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.unsupported.is-bar .unsupported-card p { margin: 0; font-size: 13px; color: #6d4c41; }
.unsupported.is-bar .unsupported-card .hint { color: #8d6e63; font-size: 12px; flex: 1 1 320px; }

/* 正文页：左列表 + 右预览（左右布局）
   左栏窄、自成滚动区；右栏宽、放预览。窄屏（<=1000px）自动回到上下。 */
.body-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}
.body-col-left {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 100px);
  overflow: auto;
}
.body-col-left .card { margin: 0; }
.body-col-right { min-width: 0; }
.body-col-right .card { margin: 0; }
@media (max-width: 1000px) {
  .body-layout { grid-template-columns: 1fr; }
  .body-col-left { position: static; max-height: none; }
}
