/* 小罗哥帮你刷公文格式 —— 样式表
   配色取党政机关公文的"红头 + 黑字 + 米白纸"意象，浅色主题。 */

:root {
  --red: #c8102e;
  --red-dark: #a30d25;
  --red-soft: #fdf0f2;
  --ink: #1f2329;
  --ink-2: #4e5969;
  --ink-3: #86909c;
  --line: #e5e6eb;
  --line-2: #eef0f3;
  --bg: #f4f5f7;
  --card: #ffffff;
  --ok: #16a34a;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

/* JS 用 hidden 属性控制显隐；下面这些选择器自带 display:flex/grid，
   会覆盖 UA 样式表里的 [hidden]{display:none}，必须显式兜底 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC",
               "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
}

.wrap { width: min(940px, 100% - 32px); margin: 0 auto; }
main.wrap { padding-top: 22px; }

/* ---------------- 顶栏 ------------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--red); color: #fff;
  display: grid; place-items: center;
  font-family: "Songti SC", "SimSun", serif;
  font-size: 22px; font-weight: 700;
  box-shadow: 0 2px 8px rgba(200, 16, 46, .28);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-text strong { font-size: 17px; letter-spacing: .3px; }
.brand-text span { font-size: 12px; color: var(--ink-3); }
.topbar-link {
  color: var(--ink-2); text-decoration: none; font-size: 14px;
  padding: 6px 12px; border-radius: 8px;
}
.topbar-link:hover { background: var(--line-2); color: var(--red); }

/* ---------------- 免责提示条 ---------------- */
.notice {
  display: flex; align-items: flex-start; gap: 11px;
  background: #fff8e6; border: 1px solid #f5d99b; border-left: 4px solid var(--warn);
  border-radius: 10px; padding: 12px 16px; margin-bottom: 20px;
}
.notice.small { margin: 16px 0 0; padding: 10px 14px; }
.notice-icon {
  flex: none; width: 20px; height: 20px; border-radius: 50%;
  background: var(--warn); color: #fff; font-weight: 800; font-size: 13px;
  display: grid; place-items: center; margin-top: 2px;
}
.notice p { margin: 0; font-size: 13.5px; color: #8a5a06; }
.notice p b { color: #7a4a05; }

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

/* ---------------- 格式版本选择 ---------------- */
.version {
  border: 1px solid var(--line); border-radius: 12px;
  background: #fafbfc; padding: 14px 16px;
}
.version-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.version-title { font-weight: 700; font-size: 15px; }
.version-head select {
  font: inherit; font-size: 15px; font-weight: 600;
  padding: 9px 12px; border: 1px solid #d0d3d9; border-radius: 9px;
  background: #fff; color: var(--ink); min-width: 250px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.version-head select:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, .1);
}

/* ---------------- 拖拽区 ---------------- */
.dropzone {
  border: 2px dashed #d4d7dc; border-radius: 12px;
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all .18s ease; background: #fcfcfd; outline: none;
}
.dropzone:hover, .dropzone:focus-visible {
  border-color: var(--red); background: var(--red-soft);
}
.dropzone.drag {
  border-color: var(--red); background: var(--red-soft);
  transform: scale(1.006);
}
.dz-icon { width: 52px; height: 52px; color: var(--red); margin-bottom: 10px; }
.dz-main { font-size: 17px; font-weight: 700; margin: 0 0 6px; }
.dz-sub { margin: 0; color: var(--ink-3); font-size: 13px; }
.link { color: var(--red); text-decoration: underline; text-underline-offset: 3px; }

/* ---------------- 文件信息 ---------------- */
.fileinfo {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 16px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 10px; background: #fafbfc;
}
.fi-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.fi-icon {
  width: 42px; height: 42px; flex: none; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; letter-spacing: .5px;
}
.fi-name {
  margin: 0; font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw;
}
.fi-meta { margin: 0; font-size: 12px; color: var(--ink-3); }

/* ---------------- 高级选项 ---------------- */
.adv { margin-top: 16px; border: 1px solid var(--line); border-radius: 10px; }
.adv > summary {
  cursor: pointer; padding: 12px 14px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; list-style: none;
}
.adv > summary::-webkit-details-marker { display: none; }
.adv > summary::after { content: "▾"; color: var(--ink-3); transition: transform .2s; }
.adv[open] > summary::after { transform: rotate(180deg); }
.adv-hint { font-weight: 400; color: var(--ink-3); font-size: 12.5px; }
.adv-body { padding: 4px 14px 16px; border-top: 1px solid var(--line-2); }
.adv-more { margin-top: 14px; border-top: 1px dashed var(--line); }
.adv-more summary {
  cursor: pointer; padding: 10px 0 2px; font-size: 13px; font-weight: 600;
  color: var(--ink-2); display: flex; align-items: center; gap: 8px;
  list-style: none;
}
.adv-more summary::-webkit-details-marker { display: none; }
.adv-more summary::after { content: "▾"; color: var(--ink-3); margin-left: auto; }
.adv-more[open] summary::after { transform: rotate(180deg); }
.adv-more .grid { padding-top: 8px; }
.grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  padding-top: 14px;
}
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; }
.field > span { color: var(--ink-2); }
.field.span2 { grid-column: span 2; }
.field input[type=text], .field textarea, .field select {
  width: 100%; font: inherit; font-size: 14px;
  padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input[type=text]:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(200, 16, 46, .1);
}
.field.check { flex-direction: row; align-items: center; gap: 8px; }
.field.check input { width: 16px; height: 16px; accent-color: var(--red); }
.field.check span { color: var(--ink); }

/* ---------------- 按钮 ---------------- */
.actions { margin-top: 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.btn-primary {
  font: inherit; font-weight: 700; font-size: 15px;
  background: var(--red); color: #fff; border: none; border-radius: 10px;
  padding: 11px 26px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 9px;
  transition: background .15s, transform .1s, opacity .15s;
  box-shadow: 0 2px 10px rgba(200, 16, 46, .22);
}
.btn-primary:hover:not(:disabled) { background: var(--red-dark); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-ghost {
  font: inherit; background: #fff; color: var(--ink-2);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 14px; cursor: pointer; font-size: 13.5px;
}
.btn-ghost:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-ghost.wide { width: 100%; margin-top: 6px; padding: 10px; font-size: 14px; }
.btn-spin {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tip { margin: 0; font-size: 12.5px; color: var(--ink-3); }

/* ---------------- 进度 / 提示 ---------------- */
.progress { margin-top: 16px; }
.bar { height: 6px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .25s; }
.progress p { margin: 8px 0 0; font-size: 13px; color: var(--ink-2); }
.alert {
  margin-top: 14px; padding: 12px 14px; border-radius: 10px; font-size: 14px;
  background: #fff7f7; border: 1px solid #ffd9dd; color: #a30d25;
}
.alert.ok { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }

/* ---------------- 结果 ---------------- */
.result-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding-bottom: 16px;
  border-bottom: 1px solid var(--line-2);
}
.result-head h2 { margin: 0 0 4px; font-size: 20px; }
.result-head p { margin: 0; color: var(--ink-2); font-size: 13.5px; }
.panels {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px; margin: 18px 0;
}
.panel {
  border: 1px solid var(--line); border-radius: 10px; padding: 13px 15px; background: #fafbfc;
}
.panel h4 {
  margin: 0 0 9px; font-size: 13px; color: var(--ink-3);
  font-weight: 600; letter-spacing: .4px;
}
.panel dl { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; }
.panel dt { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.panel dd {
  margin: 0; font-size: 13px; font-weight: 600; text-align: right;
  overflow-wrap: anywhere;
}
.panel dd.auto { color: var(--ok); font-weight: 500; }
.panel dd small { color: var(--ink-3); font-weight: 400; }

.rules-box { margin-top: 6px; }
.rules-box h3, .warn-box h3 { font-size: 14px; margin: 0 0 10px; }
.rules-box dl {
  margin: 0; display: grid; grid-template-columns: 160px 1fr;
  gap: 8px 14px; font-size: 13.5px;
}
.rules-box dt { color: var(--ink-2); font-weight: 600; }
.rules-box dd { margin: 0; color: var(--ink-2); }
.rules-box ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); }
.warn-box {
  margin-top: 18px; padding: 13px 16px; border-radius: 10px;
  background: #fffbeb; border: 1px solid #fde68a;
}
.warn-box h3 { color: #92400e; }
.warn-box ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: #92400e; }

/* ---------------- 规则速览 ---------------- */
.rules h2 { font-size: 19px; margin: 0 0 6px; }
.rules-lead { margin: 0 0 18px; color: var(--ink-2); font-size: 14px; }
.rules-lead b { color: var(--ink); }

.rules-cols {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px;
}
.rules-col {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px;
  background: #fafbfc;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.rules-col.active {
  border-color: var(--red); background: #fff;
  box-shadow: 0 0 0 3px rgba(200, 16, 46, .07);
}
.rules-col h3 { margin: 0 0 4px; font-size: 15.5px; color: var(--red); }
.rules-src { margin: 0 0 8px; font-size: 12px; color: var(--ink-3); }
.rules-note { margin: 0 0 12px; font-size: 13px; color: var(--ink-2); }
.rules-dl {
  margin: 0; display: grid; grid-template-columns: 104px 1fr;
  gap: 5px 10px; font-size: 13px;
}
.rules-dl dt { color: var(--ink-2); font-weight: 600; }
.rules-dl dd { margin: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.rules-unspec {
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.rules-unsub {
  margin: 0 0 6px; font-size: 12px; color: var(--ink-3); font-weight: 600;
}
.rules-unspec ul { margin: 0; padding-left: 16px; font-size: 12.5px; color: var(--ink-3); }
.rules-unspec li { margin: 3px 0; }

.unspec-note {
  margin-top: 18px; padding: 13px 16px; border-radius: 10px;
  background: #f7f8fa; border: 1px solid var(--line); font-size: 13.5px;
}
.unspec-note p { margin: 0 0 6px; color: var(--ink); }
.unspec-note p:last-child { margin-bottom: 0; }
.unspec-note ul { margin: 0; padding-left: 18px; color: var(--ink-2); }
.unspec-note li { margin: 2px 0; }

/* ---------------- 页脚 ---------------- */
.foot {
  text-align: center; color: var(--ink-3); font-size: 12.5px;
  padding: 10px 0 44px;
}
.foot p { margin: 0; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 820px) {
  .rules-cols { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .brand-text strong { font-size: 15px; }
  .brand-text span { max-width: 52vw; }
  .card { padding: 17px; border-radius: 12px; }
  .grid { grid-template-columns: 1fr; }
  .field.span2 { grid-column: span 1; }
  .rules-box dl { grid-template-columns: 1fr; gap: 2px 0; }
  .rules-box dd { margin-bottom: 8px; }
  .rules-dl { grid-template-columns: 1fr; gap: 2px 0; }
  .rules-dl dd { margin-bottom: 7px; }
  .adv-hint { display: none; }
  .fi-name { max-width: 46vw; }
  .result-head { flex-direction: column; align-items: stretch; }
  .result-head .btn-primary { justify-content: center; }
  .version-head select { width: 100%; min-width: 0; }
}

@media print {
  .topbar, #uploadCard, .foot, .btn-primary, .btn-ghost { display: none; }
}
