/* M31HotISM handbook stylesheet (skill handbook 1.5.6).
   lang.css (skill 0.5.0) is pasted in unchanged below the site rules. */
:root {
  --bg: #ffffff; --fg: #111827; --muted: #4b5563; --line: #e5e7eb;
  --accent: #0b5f8c; --accent-2: #2563eb; --card: #f9fafb;
  --code-bg: #f3f4f6; --nav-bg: #ffffff; --shadow: 0 1px 3px rgba(0,0,0,0.08);
}
html[data-lang="zh"] { }
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120; --fg: #e5e7eb; --muted: #9ca3af; --line: #1f2937;
    --accent: #38bdf8; --accent-2: #60a5fa; --card: #111827;
    --code-bg: #111827; --nav-bg: #0b1120; --shadow: 0 1px 3px rgba(0,0,0,0.4);
  }
}
* { box-sizing: border-box; }
html { scroll-padding-top: 72px; }
body {
  margin: 0; font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, Helvetica, Arial, "Noto Sans CJK SC", "PingFang SC", sans-serif;
  background: var(--bg); color: var(--fg); line-height: 1.55; font-size: 15px;
  overflow-x: hidden;
}
article code, article pre, .article table td, .article table th,
.stamp span, figcaption { overflow-wrap: anywhere; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
table { display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; white-space: normal; overflow-wrap: anywhere; word-break: break-all; }
.stamp span { white-space: normal; display: block; max-width: 100%; }
@media (max-width: 640px) {
.article code, .article pre, .article table td, .article table th, .stamp span, figcaption { overflow-wrap: break-word; word-break: break-all; }
table.compact { font-size: 9.5px; }
}
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

/* ---------- header & nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--nav-bg); border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.header-inner {
  max-width: 980px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; justify-content: space-between; height: 56px;
}
.brand { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand .zh { display: none; }
html[data-lang="zh"] .brand .en { display: none; }
html[data-lang="zh"] .brand .zh { display: inline; }
.nav-links { display: flex; gap: 10px; align-items: center; }
.nav-links a { font-size: 14px; padding: 4px 10px; border-radius: 6px; }
.nav-links a:hover { background: var(--card); text-decoration: none; }
.lang-toggle { margin-left: 8px; }

/* ---------- layout ---------- */
.wrap { max-width: 980px; margin: 0 auto; padding: 24px 16px 48px 16px; }
main { display: grid; grid-template-columns: 250px 1fr; gap: 24px; min-width: 0; }
article { min-width: 0; overflow-wrap: anywhere; }
aside.toc { position: sticky; top: 76px; }
.toc ol { list-style: none; padding: 0; margin: 0 0 16px 0; font-size: 13.5px; }
.toc ol li { margin: 2px 0; }
.toc ol a { color: var(--muted); }
.toc ol a:hover, .toc ol a.current { color: var(--accent-2); text-decoration: none; font-weight: 600; }
.toc h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--muted); margin: 0 0 8px 0; padding-top: 6px; }
.article h1 { font-size: 26px; margin: 0 0 6px 0; line-height: 1.25; }
.article h2 { font-size: 19px; margin: 26px 0 8px 0; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.article h3 { font-size: 15px; margin: 20px 0 6px 0; color: var(--fg); }
.article p, .article li { margin: 8px 0; }
.article ul, .article ol { margin: 8px 0 12px 0; padding-left: 20px; }
.article blockquote { border-left: 3px solid var(--accent); margin: 12px 0; padding: 8px 14px; background: var(--card); }
.article code { background: var(--code-bg); padding: 1px 6px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.92em; }
.article pre { background: var(--code-bg); padding: 10px 12px; border-radius: 6px; overflow-x: auto; font-size: 12.5px; line-height: 1.45; }
.article pre code { background: transparent; padding: 0; font-size: inherit; }
table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
table, th, td {
  overflow-x: auto;
}
table { display: block; overflow-x: auto; }
th, td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; white-space: normal; overflow-wrap: anywhere; word-break: break-all; }
th { background: var(--card); font-weight: 600; }
figure { margin: 14px 0; text-align: center; }
figure img { margin: 0 auto; }
figcaption { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.src-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.alert { border: 1px solid var(--line); background: var(--card); border-radius: 6px; padding: 10px 14px; margin: 12px 0; }
.katex { font-size: 1.08em; }
.katex-html { max-width: 100%; overflow-wrap: anywhere; }

/* ---------- animations ---------- */
.anim { border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; margin: 16px 0; background: var(--card); }
.anim h3 { margin: 0 0 6px 0; font-size: 14px; }
.anim svg { width: 100%; height: auto; display: block; color: var(--fg); }
.anim .ctrl { margin-top: 8px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.anim input[type="range"] { flex: 1 1 180px; min-width: 140px; accent-color: var(--accent-2); }
.anim .val { font-variant-numeric: tabular-nums; }

/* ---------- bilingual stamps ---------- */
.stamp { font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 26px; padding-top: 8px; }
.stamp span { white-space: nowrap; }

@media (max-width: 1280px) {
  main { grid-template-columns: 1fr; gap: 16px; }
  aside.toc { display: none; }
}
/* header must not overflow at 1280px: let the nav links wrap */
@media (max-width: 1280px) {
  .nav-links { flex-wrap: wrap; gap: 8px; justify-content: space-between; }
  .nav-links a { font-size: 13px; padding: 3px 8px; }
}

/* ---------- mobile ---------- */
@media (max-width: 640px) {
  main { grid-template-columns: 1fr; }
  aside.toc { position: static; top: 0; }
  .wrap { padding: 16px 12px 32px 12px; }
  .header-inner { height: 48px; }
  .nav-links a:not(.lang-toggle) { display: none; }
}

/* ---------- lang.css (skill 0.5.0, pasted unchanged) ---------- */
/* Without JavaScript nothing sets data-lang, so Chinese shows. */
html[data-lang="zh"] .l-en,
html:not([data-lang="zh"]) .l-zh { display: none !important; }

.lang-toggle {
  font: inherit; font-size: 0.9rem; padding: 0.3rem 0.8rem; min-height: 44px; min-width: 44px;
  border: 1px solid currentColor; border-radius: 999px; background: transparent; color: inherit; cursor: pointer;
}
.lang-toggle:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
