/* ==========================================================================
   翰墨AI · 基础层（reset / 排版基准 / 浏览器原生表面 / 无障碍）
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-h) + 28px);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--face-ui);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-weight: 400;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5 {
  margin: 0;
  font-weight: 700;
  line-height: var(--lh-h);
  letter-spacing: var(--tr-h);
  color: var(--ink);
  text-wrap: pretty;
}
h1 { font-size: var(--t-h1); line-height: var(--lh-tight); letter-spacing: var(--tr-display); }
h2 { font-size: var(--t-h2); }
h3 { font-size: var(--t-h3); }
h4 { font-size: var(--t-body); font-weight: 600; }

p { margin: 0 0 var(--g4); max-width: 68ch; }
p:last-child { margin-bottom: 0; }

a { color: inherit; text-decoration: none; }

/* 焦点环：品牌色内描边 + 淡光晕，键盘可见 */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--brand-deep), 0 0 0 4px var(--brand-tint);
  border-radius: var(--r-sm);
}

img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }

button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
button { background: none; border: 0; cursor: pointer; padding: 0; }
button:disabled { cursor: not-allowed; }

ul, ol { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
summary { cursor: pointer; }
summary::-webkit-details-marker { display: none; }
table { border-collapse: collapse; width: 100%; }

/* ---------- 浏览器原生表面：未绘制的部分也承设计 ---------- */

::selection { background: var(--brand-deep); color: var(--on-brand); }
:root { caret-color: var(--brand-deep); accent-color: var(--brand-deep); }

* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 11px; height: 11px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 3px solid var(--ground);
  border-radius: var(--r-full);
}
*::-webkit-scrollbar-thumb:hover { background: var(--ink-4); }

input::placeholder, textarea::placeholder {` color: var(--ink-3); opacity: 1; }
input[type="number"], .tnum, time, .fig { font-variant-numeric: tabular-nums; }

/* ---------- 无障碍 ---------- */

.vh {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: fixed; top: 10px; left: 16px; z-index: 999;
  display: inline-flex; align-items: center;
  padding: 10px 18px;
  background: var(--ink); color: var(--on-dark);
  border-radius: var(--r-full); font-size: var(--t-sm); font-weight: 600;
  transform: translateY(-200%);
  transition: transform var(--d3) var(--ease-enter);
}
.skip:focus { transform: none; }

/* ---------- 布局原语 ---------- */

.wrap { width: 100%; max-width: var(--wrap); margin-inline: auto; padding-inline: var(--g6); }
.wrap--wide { max-width: var(--wrap-wide); }
/* 边缘留白：窄屏也保证 ≥20px，内容不贴屏幕边（原先 720px 以下收到 16px 偏挤） */
@media (max-width: 860px) { .wrap { padding-inline: var(--g5); } }
@media (max-width: 560px) { .wrap { padding-inline: var(--g4); } }

.band-pad { padding-block: var(--g10); }
@media (max-width: 860px) { .band-pad { padding-block: var(--g8); } }

.row { display: flex; align-items: center; }
.row--top { align-items: flex-start; }
.row--between { justify-content: space-between; }
.row--wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: var(--g4); }
.stack-sm > * + * { margin-top: var(--g2); }
.stack-lg > * + * { margin-top: var(--g6); }
.grow { flex: 1 1 auto; min-width: 0; }

.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--g5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}

.mt-2 { margin-top: var(--g2); } .mt-3 { margin-top: var(--g3); }
.mt-4 { margin-top: var(--g4); } .mt-5 { margin-top: var(--g5); }
.mt-6 { margin-top: var(--g6); } .mb-2 { margin-bottom: var(--g2); }
.mb-3 { margin-bottom: var(--g3); } .mb-4 { margin-bottom: var(--g4); }
.mb-5 { margin-bottom: var(--g5); } .mb-6 { margin-bottom: var(--g6); }

/* ---------- 文字工具类 ---------- */

.lede { font-size: var(--t-lead); color: var(--ink-2); line-height: 1.62; max-width: 62ch; }
.note { font-size: var(--t-xs); color: var(--ink-3); }
.body-sm { font-size: var(--t-sm); color: var(--ink-2); }
.strong { font-weight: 600; color: var(--ink); }
.fig { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.code-face { font-family: var(--face-code); font-size: 0.92em; }
.u-link { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.u-link:hover { color: var(--brand-deep); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
