/* ============================================================
   LinesTool — "The Ledger Room" 账房点算风 / 浅色超宽
   设计隐喻：行数统计 = 账房点算。文件清单是账页，
   语言小计是结账行，TOTAL 下方双红线是会计的 double rule，
   tally marks（五道一点）是点算符号本身。
   字体：Fraunces（账本衬线）+ Public Sans（正文）+ Spline Sans Mono（数字）。
   ============================================================ */

:root {
  --paper: #f4f1ea;
  --paper-2: #eae6da;
  --card: #fbf9f4;
  --card-2: #f2efe6;

  --ink: #1c2f4a;            /* 账本墨蓝 */
  --ink-soft: #4a5d78;
  --ink-faint: #8d99ad;

  --red: #b3372b;            /* 点算红 */
  --red-deep: #8f2b21;
  --red-soft: rgba(179, 55, 43, .08);
  --red-line: rgba(179, 55, 43, .25);

  --amber: #8a5a00;
  --amber-soft: rgba(138, 90, 0, .12);

  --green: #1e7a4f;
  --green-soft: rgba(30, 122, 79, .10);

  --line: #d9d3c4;
  --line-2: #c4bca8;

  --radius: 14px;
  --radius-sm: 9px;
  --max-width: 1560px;
  --mono: "Spline Sans Mono", "JetBrains Mono", "SF Mono", Consolas, monospace;
  --sans: "Public Sans", "PingFang SC", "Microsoft YaHei", -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;

  --shadow-sm: 0 1px 2px rgba(28, 47, 74, .05), 0 4px 12px rgba(28, 47, 74, .05);
  --shadow-md: 0 2px 6px rgba(28, 47, 74, .06), 0 18px 44px rgba(28, 47, 74, .10);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  color: var(--ink);
  line-height: 1.7;
  font-size: 16px;
  background: var(--paper);
}

/* 账本横线纹理 + 轻渐晕 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgba(28, 47, 74, .035) 31px 32px),
    radial-gradient(ellipse at 50% -10%, rgba(251, 249, 244, .8), transparent 60%);
}

main, .site-header, .site-footer { position: relative; z-index: 1; }

.inner { max-width: var(--max-width); margin: 0 auto; padding: 0 28px; }

/* ==================== 头部 ==================== */

.site-header {
  border-bottom: 1.5px solid var(--line-2);
  background: rgba(244, 241, 234, .92);
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.site-header .inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }

.logo {
  display: inline-flex; align-items: center; gap: 11px;
  font-family: var(--display); font-weight: 600; font-size: 1.28rem;
  color: var(--ink); text-decoration: none; letter-spacing: -.01em;
}
.logo-img { width: 38px; height: 38px; display: block; }
.lt-tag {
  font-family: var(--mono); font-size: .62rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--red-deep); background: var(--red-soft);
  border: 1px solid var(--red-line);
  padding: 2px 8px; border-radius: 999px;
  margin-left: 2px; transform: translateY(-1px);
}

.nav-links { display: flex; gap: 4px; list-style: none; }
.nav-links a {
  color: var(--ink-soft); text-decoration: none; font-size: .9rem; font-weight: 600;
  padding: 7px 13px; border-radius: 8px; transition: all .15s;
}
.nav-links a:hover { color: var(--ink); background: var(--card-2); }

.menu-btn {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 8px;
}
.menu-btn .bar { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: all .2s; }
.menu-btn.open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn.open .bar:nth-child(2) { opacity: 0; }
.menu-btn.open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ==================== 标题条（极简，开屏即见工具） ==================== */

.title-strip { padding: 34px 0 22px; }
.title-row { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 8px 30px; }
h1 {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.7rem, 3.4vw, 2.5rem);
  line-height: 1.15; letter-spacing: -.015em;
}
h1 em { font-style: italic; color: var(--red); }
.title-sub { color: var(--ink-soft); font-size: .98rem; max-width: 640px; }
.title-rule {
  margin-top: 20px; height: 3px;
  background: linear-gradient(to right, var(--ink) 0 22%, var(--red) 22% 26%, var(--line-2) 26% 100%);
  border-radius: 2px;
}

/* ==================== 工具区 ==================== */

.tool-section { padding-bottom: 26px; }

.drop-zone {
  border: 2.5px dashed var(--line-2);
  border-radius: var(--radius);
  background: var(--card);
  padding: 44px 30px 38px;
  text-align: center;
  cursor: pointer;
  transition: all .18s;
  position: relative;
  overflow: hidden;
}
.drop-zone::before {
  content: "";
  position: absolute; inset: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  pointer-events: none;
}
.drop-zone:hover, .drop-zone.over {
  border-color: var(--ink);
  background: #fdfbf6;
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.drop-zone.over { border-color: var(--red); border-style: solid; }

.dz-tally { margin-bottom: 14px; }
.dz-title {
  font-family: var(--display); font-size: 1.42rem; font-weight: 600; letter-spacing: -.01em;
  margin-bottom: 6px;
}
.dz-sub { color: var(--ink-soft); font-size: .92rem; margin-bottom: 22px; }
.dz-sub code {
  font-family: var(--mono); font-size: .82em; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; color: var(--red-deep);
}
.dz-buttons { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  font-family: var(--sans); font-size: .92rem; font-weight: 700;
  border-radius: 10px; padding: 11px 22px; cursor: pointer;
  transition: all .15s; border: 1.5px solid transparent;
}
.btn-primary { background: var(--ink); color: #f4f1ea; }
.btn-primary:hover { background: #142338; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn-ghost { background: var(--card); color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink); background: var(--card-2); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none !important; box-shadow: none !important; }

.options-row {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 14px; padding: 0 6px;
  font-size: .85rem; color: var(--ink-soft);
}
.tgl {
  display: inline-flex; align-items: center; gap: 8px;
  background: none; border: none; cursor: pointer;
  font-size: .85rem; font-weight: 600; color: var(--ink-soft);
  padding: 4px 0; transition: color .15s;
}
.tgl:hover { color: var(--ink); }
.tgl .dot {
  width: 30px; height: 17px; border-radius: 999px;
  background: var(--line-2); position: relative; transition: background .15s;
  flex: none;
}
.tgl .dot::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--card); transition: transform .15s;
  box-shadow: 0 1px 2px rgba(28, 47, 74, .2);
}
.tgl.on .dot { background: var(--ink); }
.tgl.on .dot::after { transform: translateX(13px); }
.tgl.on { color: var(--ink); }

.empty-hint { display: none; margin-top: 10px; font-size: .84rem; color: var(--amber); font-weight: 600; }

/* ==================== 汇总卡 ==================== */

.summary-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px;
  margin-top: 24px;
}
.sum-card {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 18px 14px;
  position: relative;
}
.sum-label {
  display: block; font-family: var(--mono); font-size: .66rem; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint);
  margin-bottom: 4px;
}
.sum-value {
  font-family: var(--mono); font-size: 1.75rem; font-weight: 600;
  color: var(--ink); letter-spacing: -.02em; line-height: 1.2;
}
.sc-code { border-color: var(--ink); box-shadow: var(--shadow-sm); }
.sc-code .sum-value { color: var(--ink); }
.sc-comment { border-color: rgba(138, 90, 0, .35); }
.sc-comment .sum-value { color: var(--amber); }
.sc-blank .sum-value { color: var(--ink-faint); }

/* ==================== 语言结账表（账本 double rule） ==================== */

.report-block {
  background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 24px 26px 20px; margin-top: 22px;
  box-shadow: var(--shadow-sm);
}
.rb-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 14px; }
.rb-title { font-family: var(--display); font-size: 1.22rem; font-weight: 600; letter-spacing: -.01em; }
.rb-note { font-family: var(--mono); font-size: .68rem; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); }

table.ledger { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.ledger th {
  font-family: var(--mono); font-size: .68rem; font-weight: 600;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
  text-align: right; padding: 8px 12px;
  border-bottom: 1.5px solid var(--line-2);
}
table.ledger th:first-child, table.ledger td:first-child { text-align: left; padding-left: 4px; }
table.ledger td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); }
table.ledger td.num { font-family: var(--mono); font-size: .9rem; font-variant-numeric: tabular-nums; }
table.ledger td.strong { font-weight: 600; color: var(--ink); }
table.ledger td.dim { color: var(--ink-faint); }
table.ledger tbody tr:hover td { background: rgba(28, 47, 74, .028); }

.lg-name { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.lg-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* TOTAL 行：上方粗线 + 下方双红线（会计 double rule —— 签名视觉） */
tr.total-row td {
  border-top: 2.5px solid var(--ink);
  border-bottom: none;
  font-weight: 700; background: var(--card-2) !important;
  padding-top: 12px;
  position: relative;
}
tr.total-row td:first-child { letter-spacing: .08em; color: var(--red-deep); }
tr.total-row::after { content: ""; display: block; height: 0; }
.report-block .double-rule {
  height: 8px; margin: 0 0 4px;
  border-top: 2.5px solid var(--red);
  border-bottom: 1.5px solid var(--red);
}

/* 语言分布条 */
.dist-bar {
  display: flex; height: 26px; border-radius: 8px; overflow: hidden;
  margin-top: 16px; border: 1px solid var(--line-2);
  background: var(--paper-2);
}
.db-seg { display: block; height: 100%; min-width: 2px; transition: width .4s ease; }
.dist-legend {
  display: flex; flex-wrap: wrap; gap: 6px 20px; margin-top: 10px;
  font-family: var(--mono); font-size: .78rem; color: var(--ink-soft);
}
.db-key { display: inline-flex; align-items: center; gap: 6px; }
.db-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }

/* ==================== 文件明细表 ==================== */

.table-wrap { overflow-x: auto; }
table.files { min-width: 900px; }
table.files th[data-sort] { cursor: pointer; user-select: none; white-space: nowrap; }
table.files th[data-sort]:hover { color: var(--ink); }
table.files th.sorted-desc::after { content: " ▼"; font-size: .8em; color: var(--red); }
table.files th.sorted-asc::after { content: " ▲"; font-size: .8em; color: var(--red); }

.f-path {
  font-family: var(--mono); font-size: .84rem; text-align: left !important;
  max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--ink);
}
.lg-badge {
  display: inline-block; font-family: var(--mono); font-size: .7rem; font-weight: 600;
  color: #f4f1ea; padding: 2px 9px; border-radius: 6px; letter-spacing: .02em;
  white-space: nowrap;
}

.actions-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 18px; }

/* ==================== 内容区（SEO） ==================== */

.content-section { padding: 52px 0 8px; }
.sec-no {
  font-family: var(--mono); font-size: .7rem; font-weight: 600;
  letter-spacing: .18em; text-transform: uppercase; color: var(--red);
}
.content-section h2 {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.5rem, 2.6vw, 2rem); letter-spacing: -.01em;
  margin: 8px 0 6px;
}
.sec-sub { color: var(--ink-soft); font-size: .98rem; max-width: 760px; margin-bottom: 28px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.metric {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 20px 22px; position: relative; overflow: hidden;
}
.metric::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--ink); }
.metric.m-comment::before { background: var(--amber); }
.metric.m-blank::before { background: var(--line-2); }
.metric.m-total::before { background: var(--red); }
.metric h3 { font-family: var(--mono); font-size: .78rem; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 8px; }
.metric .m-example {
  font-family: var(--mono); font-size: .8rem; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px;
  margin: 10px 0; line-height: 1.75; text-align: left; white-space: pre; overflow-x: auto;
}
.metric p { font-size: .88rem; color: var(--ink-soft); }
.metric .tag-code { color: var(--ink); font-weight: 700; }
.metric .tag-com { color: var(--amber); font-weight: 700; }
.metric .tag-blank { color: var(--ink-faint); }

.fingerprint-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 28px; align-items: start; }
.fp-steps { display: flex; flex-direction: column; gap: 14px; }
.fp-step {
  display: flex; gap: 14px; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 18px;
}
.fp-no {
  font-family: var(--display); font-style: italic; font-size: 1.2rem; font-weight: 600;
  color: var(--red); flex: none; width: 30px; line-height: 1.4;
}
.fp-step h3 { font-size: 1rem; margin-bottom: 4px; }
.fp-step p { font-size: .88rem; color: var(--ink-soft); }
.fp-step code { font-family: var(--mono); font-size: .82em; background: var(--paper-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; color: var(--red-deep); }

.fp-art {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.fp-art pre {
  font-family: var(--mono); font-size: .8rem; line-height: 1.85;
  overflow-x: auto; color: var(--ink);
}
.fp-art .fp-annot { font-size: .8rem; color: var(--ink-faint); margin-top: 10px; font-family: var(--sans); }
.fp-art .ln-no { color: var(--ink-faint); user-select: none; }
.fp-art .cm { color: var(--amber); }
.fp-art .sb { color: var(--red-deep); font-weight: 600; }

/* FAQ */
.faq-block { display: flex; flex-direction: column; gap: 12px; }
details {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  padding: 0; overflow: hidden;
}
summary {
  cursor: pointer; padding: 15px 20px; font-weight: 600; font-size: .98rem;
  list-style: none; display: flex; justify-content: space-between; align-items: center; gap: 14px;
  transition: background .15s;
}
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-family: var(--mono); font-size: 1.2rem; color: var(--red); flex: none; transition: transform .2s; }
details[open] summary::after { transform: rotate(45deg); }
details[open] summary { background: var(--card-2); border-bottom: 1px solid var(--line); }
details p { padding: 15px 20px 17px; color: var(--ink-soft); font-size: .93rem; }
details code { font-family: var(--mono); font-size: .85em; background: var(--paper-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; color: var(--red-deep); }

/* ==================== 文章卡片区（CMS 占位） ==================== */
.article-list { display: flex; flex-direction: column; gap: 12px; }
.article-list a {
  display: block; background: var(--card); border: 1.5px solid var(--line);
  border-radius: var(--radius-sm); padding: 16px 20px; text-decoration: none;
  color: var(--ink); font-weight: 600; transition: all .15s;
}
.article-list a:hover { border-color: var(--ink); background: var(--card-2); }
.article-list .a-date { display: block; font-family: var(--mono); font-size: .74rem; color: var(--ink-faint); font-weight: 500; margin-bottom: 3px; }

/* ==================== 文章/合规页样式 ==================== */

.article-content { padding: 40px 0 50px; }
.article-content .inner { max-width: 800px; }
.article-content h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: 14px; }
.article-meta {
  font-family: var(--mono); font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-faint); margin-bottom: 26px; padding-bottom: 14px;
  border-bottom: 1.5px solid var(--line-2);
}
.article-content h2 { font-family: var(--display); font-weight: 600; font-size: 1.45rem; margin: 38px 0 15px; }
.article-content h3 { font-weight: 700; font-size: 1.16rem; margin: 28px 0 12px; }
.article-content p { margin-bottom: 18px; color: #3a4658; font-size: 1.02rem; }
.article-content ul, .article-content ol { margin: 0 0 18px 26px; }
.article-content li { margin-bottom: 10px; color: #3a4658; font-size: 1.02rem; }
.article-content strong { color: var(--ink); }
.article-content code { font-family: var(--mono); font-size: .86em; background: var(--paper-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 5px; color: var(--red-deep); }
.article-content a { color: var(--red-deep); }

/* ==================== 页脚 ==================== */

.site-footer { margin-top: 70px; border-top: 1.5px solid var(--line-2); background: var(--paper-2); }
.site-footer .inner { padding: 34px 28px; }
.footer-links { display: flex; gap: 6px 22px; flex-wrap: wrap; margin-bottom: 16px; }
.footer-links a { color: var(--ink-soft); text-decoration: none; font-size: .86rem; font-weight: 600; }
.footer-links a:hover { color: var(--red-deep); }
.copyright { font-size: .86rem; color: var(--ink-soft); }
.colophon { font-family: var(--display); font-style: italic; font-size: .88rem; color: var(--ink-faint); margin-top: 6px; }

/* ==================== 响应式 ==================== */

@media (max-width: 1180px) {
  .summary-grid { grid-template-columns: repeat(3, 1fr); }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .fingerprint-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .inner { padding: 0 18px; }
  .menu-btn { display: flex; }
  .nav-links {
    position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; gap: 0;
    background: var(--card); border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    opacity: 0; visibility: hidden; transform: translateY(-8px);
    transition: all .2s;
  }
  .nav-links.open { opacity: 1; visibility: visible; transform: translateY(0); }
  .nav-links li { list-style: none; }
  .nav-links a { display: block; padding: 11px 14px; font-size: .88rem; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-grid { grid-template-columns: 1fr; }
  .drop-zone { padding: 32px 16px 28px; }
  .title-strip { padding-top: 20px; }
  .report-block { padding: 16px 12px 14px; }
  table.ledger th, table.ledger td { padding: 7px 8px; }
}

/* 移动端导航保护：无 JS 汉堡按钮的页面（合规页）恢复可见压缩导航 */
@media (max-width: 640px) {
  .site-header .inner:not(:has(.menu-btn)) nav { display: block; }
  .site-header .inner:not(:has(.menu-btn)) .nav-links {
    position: static; opacity: 1; visibility: visible; transform: none;
    flex-direction: row; flex-wrap: wrap; gap: 0;
    background: none; border: none; box-shadow: none;
  }
  .site-header .inner:not(:has(.menu-btn)) .nav-links a { padding: 6px 9px; font-size: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}
