/* =========================================================
   PaperCraft · 论文排版工坊
   A self-contained academic writing companion.
   ========================================================= */

:root {
  color-scheme: light;
  --bg: #f4f0e7;
  --bg-deep: #ebe5d8;
  --surface: #fffdf8;
  --surface-soft: #f9f5ec;
  --surface-tint: #f1ebdf;
  --ink: #1c2a25;
  --ink-soft: #4f5d56;
  --muted: #7c857d;
  --line: #dfd8c9;
  --line-strong: #c8bfae;
  --accent: #c65f3a;
  --accent-deep: #a94828;
  --accent-soft: #f5e1d5;
  --green: #1e5c4c;
  --green-bright: #2d7561;
  --green-soft: #dce9e2;
  --gold: #c79a3e;
  --gold-soft: #f4e8ca;
  --blue: #315c88;
  --blue-soft: #e0e8f1;
  --purple: #755b88;
  --purple-soft: #ece5f0;
  --sidebar: #163d34;
  --sidebar-deep: #0f2d26;
  --sidebar-ink: #f7f1e3;
  --sidebar-muted: #a9bdb4;
  --code-bg: #14221d;
  --code-bg-2: #0f1a16;
  --code-ink: #e9e2d3;
  --code-muted: #7e9188;
  --danger: #b64532;
  --danger-soft: #f8e0da;
  --success: #2c7457;
  --success-soft: #deeee5;
  --shadow-sm: 0 2px 8px rgba(32, 44, 38, .05);
  --shadow-md: 0 14px 38px rgba(32, 44, 38, .08);
  --shadow-lg: 0 28px 70px rgba(32, 44, 38, .14);
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --serif: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "STSong", "SimSun", Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --topbar-bg: rgba(244, 240, 231, .86);
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121814;
  --bg-deep: #0d120f;
  --surface: #19211c;
  --surface-soft: #1d2721;
  --surface-tint: #222d26;
  --ink: #f1ebdd;
  --ink-soft: #c4ccc4;
  --muted: #919d94;
  --line: #334038;
  --line-strong: #48574d;
  --accent: #e07a50;
  --accent-deep: #ef9670;
  --accent-soft: #3a2820;
  --green: #75b69d;
  --green-bright: #8fceb4;
  --green-soft: #1e342b;
  --gold: #ddb15c;
  --gold-soft: #372f1d;
  --blue: #88aad0;
  --blue-soft: #202f3e;
  --purple: #b69bc8;
  --purple-soft: #30283a;
  --sidebar: #0d1b16;
  --sidebar-deep: #08110d;
  --sidebar-ink: #f6f0e2;
  --sidebar-muted: #94aaa0;
  --code-bg: #0c1511;
  --code-bg-2: #09100d;
  --code-ink: #e9e2d3;
  --code-muted: #7e9188;
  --danger: #f08a74;
  --danger-soft: #3c211c;
  --success: #8ac9a9;
  --success-soft: #1b3429;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .2);
  --shadow-md: 0 16px 40px rgba(0, 0, 0, .26);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .36);
  --topbar-bg: rgba(18, 24, 20, .88);
}

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

html {
  scroll-behavior: smooth;
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: clip;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: .55;
  background:
    radial-gradient(circle at 82% 6%, rgba(198, 95, 58, .09), transparent 28rem),
    radial-gradient(circle at 20% 92%, rgba(30, 92, 76, .08), transparent 30rem),
    repeating-linear-gradient(90deg, transparent 0, transparent 79px, rgba(80, 70, 50, .025) 80px);
}

[data-theme="dark"] body::before {
  opacity: .7;
  background:
    radial-gradient(circle at 82% 6%, rgba(224, 122, 80, .08), transparent 28rem),
    radial-gradient(circle at 20% 92%, rgba(117, 182, 157, .07), transparent 30rem),
    repeating-linear-gradient(90deg, transparent 0, transparent 79px, rgba(255, 255, 255, .018) 80px);
}

::selection {
  background: var(--accent);
  color: #fffaf2;
}

img,
svg {
  display: block;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 3px;
}

code,
kbd,
pre {
  font-family: var(--mono);
}

code {
  font-size: .92em;
}

p code,
li code,
.route-body code,
.terminal-copy code,
.section-head p code,
.paper-abstract code {
  padding: .1em .34em;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-tint);
  color: var(--green);
  white-space: nowrap;
}

[data-theme="dark"] p code,
[data-theme="dark"] li code,
[data-theme="dark"] .route-body code,
[data-theme="dark"] .terminal-copy code,
[data-theme="dark"] .section-head p code {
  color: var(--green-bright);
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  transform: translateY(-160%);
  transition: transform .2s;
}

.skip-link:focus {
  transform: translateY(0);
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

/* =========================================================
   Shell
   ========================================================= */

.app-shell {
  display: grid;
  grid-template-columns: 258px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 26px 18px 18px;
  overflow-y: auto;
  color: var(--sidebar-ink);
  background:
    radial-gradient(circle at 100% 0%, rgba(219, 170, 88, .17), transparent 18rem),
    radial-gradient(circle at 0% 80%, rgba(87, 153, 128, .14), transparent 16rem),
    linear-gradient(165deg, #18463b 0%, var(--sidebar) 50%, var(--sidebar-deep) 100%);
  border-right: 1px solid rgba(255, 255, 255, .06);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.sidebar::after {
  content: "TEX";
  position: absolute;
  right: -13px;
  bottom: 40px;
  font-family: var(--serif);
  font-size: 96px;
  font-weight: 700;
  color: rgba(255, 255, 255, .025);
  letter-spacing: -.08em;
  pointer-events: none;
  transform: rotate(-90deg);
}

.sidebar-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 6px 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  flex: 0 0 auto;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 12px;
  background: rgba(255, 255, 255, .065);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1);
}

.brand-mark::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px dashed rgba(255, 255, 255, .12);
  border-radius: 8px;
}

.brand-mark span {
  position: relative;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.04em;
  color: #f7e8cb;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 20px;
  letter-spacing: -.02em;
}

.brand-copy small {
  margin-top: 4px;
  color: var(--sidebar-muted);
  font-size: 11px;
  letter-spacing: .16em;
}

.sidebar-close {
  display: none;
}

.sidebar .sidebar-close {
  display: none;
}

.nav-label {
  padding: 0 13px 9px;
  color: var(--sidebar-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .2em;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: #d8e2db;
  font-size: 14px;
  transition: background .2s, color .2s, border-color .2s, transform .2s;
}

.nav-item svg {
  width: 19px;
  height: 19px;
  color: #a9c2b6;
  transition: color .2s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, .06);
  color: #fff9ec;
}

.nav-item.is-active {
  background: rgba(255, 255, 255, .1);
  border-color: rgba(255, 255, 255, .11);
  color: #fffaf0;
  box-shadow: inset 3px 0 0 #e0aa5b;
}

.nav-item.is-active svg {
  color: #f0c477;
}

.nav-item span:nth-child(2) {
  flex: 1;
}

.nav-count {
  min-width: 26px;
  padding: 2px 6px;
  border-radius: 20px;
  background: rgba(255, 255, 255, .07);
  color: var(--sidebar-muted);
  font-family: var(--mono);
  font-size: 9.5px;
  text-align: center;
}

.nav-item.is-active .nav-count {
  background: rgba(224, 170, 91, .16);
  color: #f1cd8d;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e0aa5b;
  opacity: 0;
}

.nav-item.is-active .nav-dot {
  opacity: 1;
}

.sidebar-progress {
  position: relative;
  margin: 24px 4px 0;
  padding: 15px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 14px;
  background: rgba(255, 255, 255, .045);
}

.sidebar-progress::after {
  content: "";
  position: absolute;
  width: 90px;
  height: 90px;
  right: -40px;
  top: -45px;
  border: 1px solid rgba(224, 170, 91, .2);
  border-radius: 50%;
}

.sp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #dde7e0;
  font-size: 11.5px;
}

.sp-head strong {
  font-family: var(--serif);
  font-size: 17px;
  color: #f4c97d;
}

.progress-track {
  height: 5px;
  margin: 10px 0 9px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, .1);
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #d99c4d, #f3ce8b);
  transition: width .7s var(--ease);
}

.sp-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--sidebar-muted);
  font-size: 10px;
}

.sp-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  color: #f1d196;
  font-size: 11.5px;
  font-weight: 600;
}

.sp-link svg {
  width: 16px;
  height: 16px;
  transition: transform .2s;
}

.sp-link:hover svg {
  transform: translateX(3px);
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 24px;
}

.sidebar-tools {
  padding: 5px 5px 11px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 8px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #c5d4cb;
  font-size: 11.5px;
  cursor: pointer;
  transition: background .2s;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, .05);
}

.theme-icon {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
}

.theme-icon svg {
  width: 17px;
  height: 17px;
}

.theme-icon-sun {
  display: none;
}

[data-theme="dark"] .theme-icon-sun {
  display: grid;
}

[data-theme="dark"] .theme-icon-moon {
  display: none;
}

.theme-label {
  flex: 1;
  text-align: left;
}

.switch {
  position: relative;
  width: 29px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 99px;
  background: rgba(0, 0, 0, .14);
  transition: background .2s;
}

.switch i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d5e0d9;
  transition: transform .25s var(--ease), background .2s;
}

[data-theme="dark"] .switch {
  background: #d8a85a;
  border-color: #d8a85a;
}

[data-theme="dark"] .switch i {
  transform: translateX(13px);
  background: #1a2a23;
}

.local-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 8px 8px;
  color: var(--sidebar-muted);
  font-size: 9.5px;
}

.pulse-dot {
  position: relative;
  display: inline-block;
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #6fbf95;
}

.pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 1px solid rgba(111, 191, 149, .5);
  animation: pulse 2.4s infinite;
}

.reset-link {
  margin-left: 8px;
  padding: 0;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, .28);
  font-size: 9.5px;
  text-decoration: underline;
  text-decoration-color: transparent;
  cursor: pointer;
  transition: color .2s, text-decoration-color .2s;
}

.reset-link:hover {
  color: #efc17c;
  text-decoration-color: currentColor;
}

.main-column {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 45;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 70px;
  padding: 0 38px;
  background: var(--topbar-bg);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

.topbar-left,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar-left {
  gap: 12px;
  min-width: 0;
}

.topbar-actions {
  gap: 11px;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 11.5px;
}

.breadcrumb svg {
  width: 12px;
  height: 12px;
}

.breadcrumb strong {
  color: var(--ink-soft);
  font-weight: 600;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .2s;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface-soft);
}

.menu-btn {
  display: none;
}

.search-trigger {
  display: flex;
  align-items: center;
  gap: 9px;
  width: min(320px, 30vw);
  height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, box-shadow .2s;
}

.search-trigger:hover {
  border-color: var(--line-strong);
  box-shadow: var(--shadow-sm);
}

.search-trigger svg {
  width: 15px;
  height: 15px;
}

.search-trigger span {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-color: var(--line-strong);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
  white-space: nowrap;
}

.offline-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: .03em;
  white-space: nowrap;
}

.mobile-theme {
  display: none;
}

main {
  width: 100%;
  max-width: 1330px;
  margin: 0 auto;
  padding: 0 38px 70px;
  outline: none;
}

.view {
  display: none;
  padding-top: 34px;
  animation: viewIn .45s var(--ease) both;
}

.view.is-active {
  display: block;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(7px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes pulse {
  0% { transform: scale(.75); opacity: 1; }
  75%, 100% { transform: scale(1.7); opacity: 0; }
}

/* =========================================================
   Shared type & controls
   ========================================================= */

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .15em;
  text-transform: uppercase;
}

.eyebrow-line {
  display: inline-block;
  width: 23px;
  height: 1px;
  background: currentColor;
  opacity: .7;
}

.eyebrow-light {
  color: #e5b56b;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.18;
  letter-spacing: -.02em;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 44px;
  padding: 0 19px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .01em;
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s, border-color .2s, box-shadow .2s;
}

.btn svg {
  width: 16px;
  height: 16px;
  transition: transform .2s;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:hover svg {
  transform: translateX(2px);
}

.btn-primary {
  background: var(--accent);
  color: #fffaf3;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 25%, transparent);
}

.btn-primary:hover {
  background: var(--accent-deep);
}

.btn-ghost {
  border-color: var(--line-strong);
  background: transparent;
  color: var(--ink);
}

.btn-ghost:hover {
  background: var(--surface);
  border-color: var(--ink-soft);
}

.btn-soft {
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--ink-soft);
}

.btn-soft:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.btn-full {
  width: 100%;
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.soft-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
}

.soft-tag svg {
  width: 13px;
  height: 13px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 34px;
  margin-bottom: 30px;
}

.page-head h1 {
  margin-top: 10px;
  font-size: clamp(38px, 4vw, 54px);
  line-height: 1.05;
}

.page-head p {
  max-width: 660px;
  margin: 13px 0 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.75;
}

.head-stamp {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
  padding: 12px 15px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  transform: rotate(-1.2deg);
}

.head-stamp svg {
  width: 22px;
  height: 22px;
  color: var(--accent);
}

.head-stamp span {
  display: flex;
  flex-direction: column;
  line-height: 1.35;
}

.head-stamp b {
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 600;
}

.head-stamp small {
  color: var(--muted);
  font-size: 9.5px;
}

.page-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 30px;
  margin-top: 58px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
}

.page-footer p {
  max-width: 620px;
  margin: 0;
  line-height: 1.7;
}

.page-footer > div {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.page-footer a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ink-soft);
  transition: color .2s;
}

.page-footer a:hover {
  color: var(--accent);
}

.page-footer svg {
  width: 11px;
  height: 11px;
}

.text-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink-soft);
  font-size: 10.5px;
  cursor: pointer;
}

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

.text-link svg {
  width: 12px;
  height: 12px;
}

/* =========================================================
   Home hero
   ========================================================= */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, .9fr);
  align-items: center;
  gap: 48px;
  min-height: 540px;
  padding: 22px 0 50px;
}

.hero-copy {
  padding-left: 3px;
}

.hero h1 {
  margin: 19px 0 20px;
  font-size: clamp(48px, 6.2vw, 78px);
  line-height: 1.02;
  letter-spacing: -.045em;
}

.hero h1 em {
  position: relative;
  display: inline-block;
  color: var(--accent);
  font-style: normal;
}

.hero h1 em::after {
  content: "";
  position: absolute;
  left: 1%;
  right: -1%;
  bottom: 2px;
  height: 9px;
  border-top: 3px solid currentColor;
  border-radius: 50%;
  opacity: .42;
  transform: rotate(-1.2deg);
}

.hero-lede {
  max-width: 575px;
  margin: 0;
  color: var(--ink-soft);
  font-size: 16px;
  line-height: 1.9;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 28px;
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  margin-top: 30px;
  border-top: 1px solid var(--line);
  padding-top: 15px;
}

.hero-meta span {
  padding: 0 17px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: .03em;
}

.hero-meta span:first-child {
  padding-left: 0;
}

.hero-meta span:last-child {
  border-right: 0;
}

.hero-meta b {
  margin-right: 4px;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}

/* Manuscript illustration */

.paper-stage {
  position: relative;
  min-height: 510px;
  margin-right: 8px;
  isolation: isolate;
}

.paper-stage::before {
  content: "";
  position: absolute;
  width: 86%;
  height: 86%;
  top: 7%;
  left: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(198, 95, 58, .17), rgba(30, 92, 76, .08) 46%, transparent 70%);
  filter: blur(28px);
  z-index: -1;
}

.paper-shadow {
  position: absolute;
  left: 18%;
  right: 2%;
  bottom: 21px;
  height: 47px;
  border-radius: 50%;
  background: rgba(38, 35, 26, .18);
  filter: blur(22px);
  transform: rotate(2deg);
}

[data-theme="dark"] .paper-shadow {
  background: rgba(0, 0, 0, .48);
}

.paper-back {
  position: absolute;
  top: 48px;
  left: 56px;
  width: 330px;
  height: 442px;
  border: 1px solid rgba(120, 105, 80, .18);
  border-radius: 2px;
  background: #e9e2d2;
  box-shadow: 0 12px 26px rgba(45, 40, 30, .1);
  transform: rotate(-5.2deg);
}

[data-theme="dark"] .paper-back {
  background: #cfc6b3;
}

.paper-sheet {
  position: absolute;
  top: 31px;
  left: 82px;
  width: 342px;
  height: 454px;
  padding: 25px 25px 18px;
  overflow: hidden;
  border: 1px solid rgba(119, 103, 78, .24);
  border-radius: 2px;
  background:
    linear-gradient(90deg, transparent 0, transparent 23px, rgba(181, 94, 63, .1) 23px, rgba(181, 94, 63, .1) 24px, transparent 24px),
    #fffdf7;
  box-shadow: 0 24px 44px rgba(48, 40, 27, .16), 0 2px 4px rgba(48, 40, 27, .1);
  color: #222c27;
  transform: rotate(1.6deg);
}

.paper-sheet::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, rgba(255, 255, 255, .55), transparent 32%, rgba(120, 92, 54, .035) 80%);
  mix-blend-mode: multiply;
}

.paper-runhead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 7px;
  border-bottom: 1px solid #c9c1b1;
  color: #77796f;
  font-family: var(--mono);
  font-size: 4.3px;
  letter-spacing: .06em;
}

.paper-title {
  margin-top: 17px;
  color: #1b2621;
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -.03em;
}

.paper-authors {
  margin-top: 10px;
  font-family: var(--serif);
  font-size: 7.6px;
  font-weight: 600;
  color: #303c35;
}

.paper-affil {
  margin-top: 3px;
  font-family: var(--serif);
  font-size: 5.4px;
  font-style: italic;
  color: #788078;
}

.paper-abstract {
  margin-top: 13px;
  padding: 8px 10px;
  border-top: 1px solid #d6cfc1;
  border-bottom: 1px solid #d6cfc1;
  color: #59635d;
  font-family: var(--serif);
  font-size: 5.4px;
  line-height: 1.55;
  text-align: justify;
}

.paper-abstract b {
  color: #26312c;
  font-variant: small-caps;
}

.paper-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 13px;
}

.paper-col {
  min-width: 0;
}

.paper-h {
  margin-bottom: 5px;
  color: #26332d;
  font-family: var(--serif);
  font-size: 7.2px;
  font-weight: 700;
}

.paper-h-small {
  margin-top: 9px;
  font-size: 6.4px;
  font-style: italic;
}

.rule {
  display: block;
  width: 100%;
  height: 2.25px;
  margin-bottom: 3.3px;
  border-radius: 2px;
  background: #d6d0c4;
}

.rule.w96 { width: 96%; }
.rule.w94 { width: 94%; }
.rule.w92 { width: 92%; }
.rule.w90 { width: 90%; }
.rule.w88 { width: 88%; }
.rule.w86 { width: 86%; }
.rule.w84 { width: 84%; }
.rule.w72 { width: 72%; }
.rule.w64 { width: 64%; }

.paper-equation {
  margin: 7px 0;
  padding: 5px 0;
  border-top: 1px solid #ded8cd;
  border-bottom: 1px solid #ded8cd;
  color: #33423a;
  font-family: var(--serif);
  font-size: 7px;
  font-style: italic;
  text-align: center;
}

.paper-figure {
  position: relative;
  height: 48px;
  margin: 7px 0 3px;
  border: 1px solid #d8d1c3;
  border-radius: 1px;
  background: #f4f1e9;
}

.fig-node {
  position: absolute;
  width: 12px;
  height: 12px;
  border: 1px solid #6d8277;
  border-radius: 50%;
  background: #fffdf7;
}

.fig-node.n1 { left: 26px; top: 19px; }
.fig-node.n2 { left: 70px; top: 11px; }
.fig-node.n3 { left: 70px; top: 28px; }

.fig-line {
  position: absolute;
  height: 1px;
  background: #87988f;
  transform-origin: left center;
}

.fig-line.l1 { left: 37px; top: 24px; width: 36px; transform: rotate(-14deg); }
.fig-line.l2 { left: 82px; top: 18px; width: 24px; transform: rotate(64deg); }

.paper-caption {
  color: #767c76;
  font-family: var(--serif);
  font-size: 4.7px;
  font-style: italic;
  text-align: center;
}

.paper-page {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 9px;
  color: #8d908a;
  font-family: var(--serif);
  font-size: 6px;
  text-align: center;
}

.float-card {
  position: absolute;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 10px;
  background: rgba(255, 253, 248, .9);
  box-shadow: 0 12px 30px rgba(37, 42, 36, .16);
  color: #1e2b25;
  backdrop-filter: blur(12px);
}

.float-card b {
  display: block;
  font-family: var(--sans);
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.25;
}

.float-card small {
  display: block;
  color: #7b847d;
  font-family: var(--mono);
  font-size: 7.5px;
  line-height: 1.3;
}

.float-compile {
  left: 25px;
  bottom: 59px;
  transform: rotate(-2deg);
}

.compile-check {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border-radius: 50%;
  background: #dfeee5;
  color: #2c7457;
}

.compile-check svg {
  width: 15px;
  height: 15px;
  stroke-width: 2.4;
}

.float-ready {
  top: 16px;
  right: 4px;
  transform: rotate(2.3deg);
}

.ready-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c78a3d;
  box-shadow: 0 0 0 4px rgba(199, 138, 61, .14);
}

.stage-note {
  position: absolute;
  right: 23px;
  bottom: 10px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .08em;
  text-transform: uppercase;
  transform: rotate(-3deg);
}

/* =========================================================
   Home stats, route, progress
   ========================================================= */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 11px 0 55px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.stat-item {
  position: relative;
  padding: 21px 22px 19px;
  border-right: 1px solid var(--line);
}

.stat-item:last-child {
  border-right: 0;
}

.stat-num {
  display: block;
  color: var(--ink);
  font-family: var(--serif);
  font-size: 35px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -.04em;
}

.stat-label {
  display: block;
  margin-top: 9px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
}

.stat-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.section-block {
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 22px;
}

.section-head h2 {
  margin-top: 8px;
  font-size: clamp(28px, 3vw, 38px);
}

.section-head p {
  max-width: 570px;
  margin: 8px 0 0;
  color: var(--ink-soft);
  font-size: 12.5px;
}

.section-head.compact {
  margin-bottom: 18px;
}

.section-head.compact h2 {
  font-size: 30px;
}

.route-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(270px, .75fr);
  gap: 22px;
  align-items: start;
}

.route-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.route-step {
  display: grid;
  grid-template-columns: 33px minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  min-height: 108px;
  padding: 16px 14px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 74%, transparent);
  text-align: left;
  cursor: pointer;
  transition: transform .22s var(--ease), border-color .22s, background .22s, box-shadow .22s;
}

.route-step:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.route-num {
  padding-top: 2px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .04em;
}

.route-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.route-body strong {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}

.route-body small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.route-time {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
  white-space: nowrap;
}

.route-arrow {
  display: none;
}

.progress-card {
  position: relative;
  padding: 23px 23px 21px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 100% 0%, rgba(199, 154, 62, .12), transparent 13rem),
    var(--surface);
  box-shadow: var(--shadow-sm);
}

.progress-card::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 110px;
  right: -55px;
  top: -55px;
  border: 1px solid color-mix(in srgb, var(--gold) 30%, transparent);
  border-radius: 50%;
  pointer-events: none;
}

.progress-ring {
  --p: 0;
  display: grid;
  place-items: center;
  width: 132px;
  height: 132px;
  margin: 2px auto 16px;
  border-radius: 50%;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-tint) 0);
  position: relative;
}

.progress-ring::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
}

.progress-ring > div {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.progress-ring strong {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -.04em;
}

.progress-ring span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  letter-spacing: .12em;
}

.progress-message {
  margin: 0 0 16px;
  color: var(--ink-soft);
  font-size: 10.5px;
  line-height: 1.65;
  text-align: center;
}

.mini-metrics {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.mini-metrics > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--line);
  line-height: 1.3;
}

.mini-metrics > div:last-child {
  border-right: 0;
}

.mini-metrics strong {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 600;
}

.mini-metrics span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.week-wrap {
  margin: 14px 0 17px;
}

.week-head {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 8.5px;
}

.week-chart {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 6px;
  height: 62px;
  margin-top: 8px;
}

.week-day {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 5px;
  height: 100%;
}

.week-bar-wrap {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 43px;
}

.week-bar {
  width: 100%;
  min-height: 3px;
  border-radius: 3px 3px 2px 2px;
  background: var(--surface-tint);
  transition: height .5s var(--ease), background .2s;
}

.week-day.has-activity .week-bar {
  background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--surface)));
}

.week-day.today .week-bar {
  background: linear-gradient(180deg, var(--gold), #e0b568);
}

.week-day span {
  color: var(--muted);
  font-size: 7.5px;
}

.week-day.today span {
  color: var(--ink-soft);
  font-weight: 700;
}

/* Daily + quick templates */

.home-split {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(300px, .88fr);
  gap: 22px;
  margin-top: 44px;
}

.daily-card {
  position: relative;
  min-height: 300px;
  padding: 25px 27px 24px;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(circle at 100% 100%, rgba(219, 170, 88, .18), transparent 18rem),
    linear-gradient(145deg, #1d5144 0%, #153c32 60%, #102e27 100%);
  color: #f9f3e5;
  box-shadow: 0 20px 40px rgba(24, 51, 42, .16);
}

.daily-card::before {
  content: "\\begin{document}";
  position: absolute;
  right: -12px;
  bottom: -6px;
  color: rgba(255, 255, 255, .035);
  font-family: var(--mono);
  font-size: 39px;
  white-space: nowrap;
  pointer-events: none;
}

.daily-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.daily-badge {
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, .17);
  border-radius: 99px;
  color: #cfded6;
  font-size: 8px;
  letter-spacing: .04em;
}

.daily-card h2 {
  max-width: 520px;
  margin: 17px 0 7px;
  font-size: clamp(24px, 2.7vw, 33px);
  line-height: 1.3;
}

.daily-card p {
  max-width: 580px;
  margin: 0;
  color: #b8ccc2;
  font-size: 11.5px;
  line-height: 1.75;
}

.daily-card .daily-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-top: 13px;
}

.daily-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .08);
  color: #d4e3db;
  font-size: 8.5px;
}

.daily-chip svg {
  width: 11px;
  height: 11px;
}

.daily-actions {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-top: 21px;
}

.daily-card .btn {
  background: #e3b05e;
  color: #1c2f27;
  box-shadow: none;
}

.daily-card .btn:hover {
  background: #efc37a;
}

.daily-card .daily-link {
  border: 0;
  background: none;
  color: #bfd4c9;
  font-size: 10px;
  text-decoration: underline;
  text-underline-offset: 4px;
  cursor: pointer;
}

.daily-card .daily-link:hover {
  color: #fff8e6;
}

.daily-done {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #d8eadf;
  font-size: 11px;
}

.daily-done svg {
  width: 16px;
  height: 16px;
  color: #e3b05e;
}

.quick-templates {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
}

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

.quick-head h3 {
  font-size: 18px;
}

.quick-head a {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
  transition: color .2s;
}

.quick-head a:hover {
  color: var(--accent);
}

.quick-head svg {
  width: 12px;
  height: 12px;
}

.template-mini {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
  padding: 12px 12px 10px;
  border: 1px solid transparent;
  border-bottom-color: var(--line);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .2s, border-color .2s, border-radius .2s;
}

.template-mini:last-child {
  border-bottom-color: transparent;
}

.template-mini:hover {
  border-color: var(--line);
  border-radius: 10px;
  background: var(--surface);
}

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

.tm-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 21px;
  padding: 0 6px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .03em;
}

.mark-ieee {
  background: var(--blue-soft);
  color: var(--blue);
}

.mark-elsevier {
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.mark-springer {
  background: var(--green-soft);
  color: var(--green);
}

.tm-kind {
  color: var(--muted);
  font-size: 8.5px;
}

.template-mini code {
  overflow: hidden;
  color: var(--ink-soft);
  font-size: 9.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tm-link {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--accent);
  font-size: 8.5px;
  font-weight: 600;
}

.tm-link svg {
  width: 11px;
  height: 11px;
}

/* Terminal band */

.terminal-band {
  display: grid;
  grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr);
  gap: 40px;
  align-items: center;
  margin-top: 24px;
  padding: 31px 34px;
  overflow: hidden;
  border-radius: 20px;
  background:
    radial-gradient(circle at 0% 100%, rgba(224, 170, 91, .11), transparent 17rem),
    #1a2c25;
  color: #f6f0e2;
}

.terminal-copy h2 {
  margin: 10px 0 9px;
  font-size: clamp(24px, 2.6vw, 32px);
  color: #fffaf0;
}

.terminal-copy p {
  max-width: 440px;
  margin: 0;
  color: #aabeb4;
  font-size: 11.5px;
  line-height: 1.7;
}

.terminal-copy code {
  border-color: rgba(255, 255, 255, .12);
  background: rgba(255, 255, 255, .07);
  color: #f0c477;
}

.terminal-window {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 10px;
  background: #0f1a16;
  box-shadow: 0 17px 33px rgba(0, 0, 0, .22);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 29px;
  padding: 0 11px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .035);
}

.terminal-bar span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .25);
}

.terminal-bar span:nth-child(1) { background: #c6745a; }
.terminal-bar span:nth-child(2) { background: #c9a355; }
.terminal-bar span:nth-child(3) { background: #589d7b; }

.terminal-bar em {
  margin-left: 7px;
  color: #71877d;
  font-family: var(--mono);
  font-size: 8px;
  font-style: normal;
}

.terminal-line {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 13px 10px;
}

.terminal-line .prompt {
  color: #7fbb9f;
  font-family: var(--mono);
  font-size: 12px;
}

.terminal-line code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: #f1dec0;
  font-size: 11px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.copy-mini {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 5px;
  background: transparent;
  color: #94aa9e;
  cursor: pointer;
  transition: background .2s, color .2s;
}

.copy-mini:hover {
  background: rgba(255, 255, 255, .08);
  color: #f5d69b;
}

.copy-mini svg {
  width: 12px;
  height: 12px;
}

.terminal-out {
  padding: 0 13px 14px;
  color: #758d81;
  font-family: var(--mono);
  font-size: 8.5px;
}

.terminal-out .ok {
  margin-right: 5px;
  color: #78c79c;
}

/* =========================================================
   Templates
   ========================================================= */

.pub-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin-bottom: 22px;
}

.pub-tab {
  position: relative;
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
  padding: 14px 15px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: color-mix(in srgb, var(--surface) 65%, transparent);
  text-align: left;
  cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s, background .2s, box-shadow .2s;
}

.pub-tab:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.pub-tab.is-active {
  border-color: color-mix(in srgb, var(--pub-color) 50%, var(--line));
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.pub-tab.is-active::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--pub-color);
}

.pub-monogram {
  display: grid;
  place-items: center;
  width: 43px;
  height: 43px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--pub-color) 22%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--pub-color) 9%, var(--surface));
  color: var(--pub-color);
  font-family: var(--serif);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: -.02em;
}

.pub-tab-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.35;
}

.pub-tab-copy strong {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}

.pub-tab-copy small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 8.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.pub-tab-arrow {
  margin-left: auto;
  width: 14px;
  height: 14px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .2s, transform .2s;
}

.pub-tab.is-active .pub-tab-arrow {
  opacity: 1;
  transform: translateX(2px);
  color: var(--pub-color);
}

.pub-hero {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 24px 26px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  border-bottom: 0;
  background:
    radial-gradient(circle at 100% 0%, color-mix(in srgb, var(--pub-color) 11%, transparent), transparent 22rem),
    var(--surface);
}

.pub-hero::after {
  content: attr(data-ghost);
  position: absolute;
  right: 20px;
  bottom: -24px;
  color: color-mix(in srgb, var(--pub-color) 7%, transparent);
  font-family: var(--serif);
  font-size: 104px;
  font-weight: 700;
  line-height: .8;
  letter-spacing: -.08em;
  pointer-events: none;
}

.pub-emblem {
  display: grid;
  place-items: center;
  width: 69px;
  height: 69px;
  flex: 0 0 auto;
  border: 1px solid color-mix(in srgb, var(--pub-color) 26%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--pub-color) 9%, var(--surface));
  color: var(--pub-color);
  font-family: var(--serif);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -.03em;
  box-shadow: inset 0 0 0 5px color-mix(in srgb, var(--surface) 55%, transparent);
}

.pub-hero-copy {
  position: relative;
  z-index: 1;
  min-width: 0;
  flex: 1;
}

.pub-kicker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--pub-color);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.pub-kicker span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--pub-color) 24%, var(--line));
  border-radius: 4px;
  background: color-mix(in srgb, var(--pub-color) 5%, transparent);
  color: color-mix(in srgb, var(--pub-color) 80%, var(--ink));
  font-family: var(--sans);
  font-size: 8px;
  font-weight: 500;
  letter-spacing: .02em;
  text-transform: none;
}

.pub-kicker span svg {
  width: 10px;
  height: 10px;
}

.pub-hero h2 {
  margin: 7px 0 2px;
  font-size: clamp(27px, 3vw, 38px);
}

.pub-hero p {
  max-width: 730px;
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.7;
}

.pub-hero-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding-top: 4px;
}

.pub-hero-actions .btn {
  min-height: 38px;
  padding: 0 13px;
  font-size: 10.5px;
}

.hero-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9.5px;
  white-space: nowrap;
  transition: color .2s;
}

.hero-link:hover {
  color: var(--pub-color);
}

.hero-link svg {
  width: 12px;
  height: 12px;
}

.template-body {
  padding: 20px;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 18px 18px;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
}

.variant-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  margin-bottom: 17px;
}

.variant-label {
  color: var(--muted);
  font-size: 9px;
  letter-spacing: .06em;
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
}

.segmented button {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 9.5px;
  cursor: pointer;
  transition: background .2s, color .2s, box-shadow .2s;
}

.segmented button:hover {
  color: var(--ink);
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 5px rgba(30, 40, 34, .08);
  font-weight: 600;
}

.segmented button .mini-badge {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--pub-color);
  color: #fff;
  font-size: 6.5px;
  letter-spacing: .02em;
}

.variant-note {
  margin-left: auto;
  color: var(--muted);
  font-size: 9px;
}

.template-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, .8fr);
  gap: 18px;
  align-items: start;
}

.code-card {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .08);
  border-radius: 13px;
  background: var(--code-bg);
  box-shadow: 0 16px 35px rgba(14, 27, 21, .15);
}

@media (min-width: 861px) {
  .code-card {
    position: sticky;
    top: 87px;
  }
}

.code-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 45px;
  padding: 0 12px 0 15px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  background: rgba(255, 255, 255, .025);
}

.code-file {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: #cfdbd3;
  font-family: var(--mono);
  font-size: 9.5px;
}

.code-file svg {
  width: 14px;
  height: 14px;
  color: #d5a85b;
}

.code-file span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.code-meta {
  margin-left: auto;
  color: #6f857a;
  font-family: var(--mono);
  font-size: 7.5px;
  white-space: nowrap;
}

.code-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: 5px;
}

.code-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 27px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, .1);
  border-radius: 5px;
  background: transparent;
  color: #9bb0a5;
  font-size: 8px;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}

.code-btn:hover {
  border-color: rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .07);
  color: #f4e5c8;
}

.code-btn.is-copied,
.copy-card.is-copied {
  border-color: rgba(106, 179, 139, .45);
  background: rgba(106, 179, 139, .12);
  color: #8fd1a8;
}

.code-btn svg {
  width: 11px;
  height: 11px;
}

.code-pre {
  max-height: 535px;
  margin: 0;
  padding: 12px 0 16px;
  overflow: auto;
  color: var(--code-ink);
  font-size: 11px;
  line-height: 1.66;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .18) transparent;
}

.code-pre::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

.code-pre::-webkit-scrollbar-thumb {
  border: 2px solid var(--code-bg);
  border-radius: 10px;
  background: rgba(255, 255, 255, .2);
}

.code-line {
  display: flex;
  min-width: max-content;
  padding-right: 18px;
}

.code-line:hover {
  background: rgba(255, 255, 255, .035);
}

.line-no {
  width: 38px;
  flex: 0 0 38px;
  padding-right: 10px;
  color: #4e6158;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.9;
  text-align: right;
  user-select: none;
}

.line-code {
  white-space: pre;
}

.tok-cmd { color: #e8b267; }
.tok-brace { color: #94b8a7; }
.tok-comment { color: #637d70; font-style: italic; }
.tok-math { color: #b7cbe3; }
.tok-env { color: #c7a7d2; }

.code-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  color: #71867b;
  font-size: 7.5px;
}

.code-foot span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.code-foot svg {
  width: 10px;
  height: 10px;
}

.code-foot .dot-ok {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6ab38b;
}

.aside-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.side-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

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

.side-card-head h3 {
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 600;
}

.side-card-head span {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .06em;
}

.side-card-head svg {
  width: 14px;
  height: 14px;
  color: var(--pub-color);
}

.fact-list {
  display: flex;
  flex-direction: column;
}

.fact-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 9px;
}

.fact-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.fact-row dt {
  flex: 0 0 auto;
  color: var(--muted);
}

.fact-row dd {
  margin: 0;
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 8.5px;
  text-align: right;
}

.cmd-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.cmd-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cmd-row code {
  align-self: flex-start;
  max-width: 100%;
  padding: 2px 5px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 8.5px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cmd-row span {
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.5;
}

.checklist-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.checklist-progress .progress-track {
  flex: 1;
  height: 4px;
  margin: 0;
  background: var(--surface-tint);
}

.checklist-progress .progress-track span {
  background: var(--pub-color);
}

.checklist-progress b {
  color: var(--pub-color);
  font-family: var(--mono);
  font-size: 8.5px;
  font-weight: 600;
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 5px;
  border-radius: 6px;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.55;
  cursor: pointer;
  transition: background .2s;
}

.check-item:hover {
  background: var(--surface-soft);
}

.check-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.check-box {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  margin-top: 1px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  transition: background .2s, border-color .2s;
}

.check-box svg {
  width: 10px;
  height: 10px;
  color: #fff;
  opacity: 0;
  stroke-width: 2.6;
  transition: opacity .15s;
}

.check-item input:checked + .check-box {
  border-color: var(--pub-color);
  background: var(--pub-color);
}

.check-item input:checked + .check-box svg {
  opacity: 1;
}

.check-item input:focus-visible + .check-box {
  outline: 3px solid color-mix(in srgb, var(--pub-color) 35%, transparent);
  outline-offset: 2px;
}

.check-item:has(input:checked) {
  color: var(--muted);
}

.check-item:has(input:checked) .check-label {
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 50%, transparent);
}

.check-label small {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 7.5px;
  line-height: 1.45;
}

.pitfall-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.pitfall {
  border-bottom: 1px solid var(--line);
}

.pitfall:last-child {
  border-bottom: 0;
}

.pitfall summary {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 0;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 500;
  line-height: 1.5;
  list-style: none;
  cursor: pointer;
}

.pitfall summary::-webkit-details-marker {
  display: none;
}

.pitfall summary::before {
  content: "";
  width: 4px;
  height: 4px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--pub-color);
  opacity: .7;
}

.pitfall summary svg {
  width: 12px;
  height: 12px;
  margin-left: auto;
  color: var(--muted);
  transition: transform .2s;
}

.pitfall[open] summary svg {
  transform: rotate(180deg);
}

.pitfall p {
  margin: -2px 0 9px 11px;
  color: var(--muted);
  font-size: 8.5px;
  line-height: 1.65;
}

.pitfall p code {
  white-space: normal;
}

.side-links {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.side-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 8.5px;
  transition: color .2s;
}

.side-link:last-child {
  border-bottom: 0;
}

.side-link:hover {
  color: var(--pub-color);
}

.side-link svg {
  width: 11px;
  height: 11px;
  color: var(--muted);
}

.side-link span {
  flex: 1;
}

.anatomy {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 12px;
}

.anatomy span {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 7.5px;
}

.anatomy i {
  color: var(--pub-color);
  font-family: var(--mono);
  font-size: 6.5px;
  font-style: normal;
}

.template-footnote {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 8px;
  line-height: 1.6;
}

.template-footnote svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  color: var(--pub-color);
}

/* Cross-publisher compare */

.compare-block {
  margin-top: 30px;
}

.compare-block .section-head {
  margin-bottom: 12px;
}

.compare-block h2 {
  font-size: 25px;
}

.compare-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.compare-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 9.5px;
}

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

.compare-table tr:last-child td {
  border-bottom: 0;
}

.compare-table thead th {
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
  font-weight: 500;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.compare-table td:first-child {
  color: var(--muted);
  font-size: 8.5px;
  white-space: nowrap;
}

.compare-table code {
  color: var(--green);
  font-size: 8.5px;
}

.compare-table b {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--serif);
  font-size: 11px;
  font-weight: 600;
}

.compare-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dot-color);
}

/* =========================================================
   Manual
   ========================================================= */

.manual-toolbar {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 17px;
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}

.field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent);
}

.field > svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--muted);
}

.field input {
  min-width: 0;
  flex: 1;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 11.5px;
}

.field input::placeholder {
  color: var(--muted);
}

.search-field {
  width: 320px;
  flex: 0 0 auto;
}

.search-field kbd {
  color: var(--muted);
}

.category-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
  padding-top: 2px;
}

.cat-pill {
  height: 29px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 99px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}

.cat-pill:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}

.cat-pill.is-active {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.manual-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
  color: var(--muted);
  font-size: 9px;
}

.manual-meta > span:first-child {
  font-family: var(--mono);
}

.meta-hint {
  display: flex;
  align-items: center;
  gap: 4px;
}

.meta-hint svg {
  width: 11px;
  height: 11px;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.manual-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .22s var(--ease), border-color .22s, box-shadow .22s;
  animation: cardIn .35s var(--ease) both;
}

.manual-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow-md);
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.manual-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 0;
}

.manual-cat {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  padding: 3px 7px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--cat-color, var(--muted)) 12%, var(--surface));
  color: var(--cat-color, var(--muted));
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: .03em;
}

.manual-cat::before {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.copy-card {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}

.copy-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.copy-card svg {
  width: 12px;
  height: 12px;
}

.manual-card-copy {
  padding: 10px 14px 12px;
}

.manual-card h3 {
  font-size: 16px;
  font-weight: 600;
}

.manual-card p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 9.5px;
  line-height: 1.6;
}

.manual-code {
  position: relative;
  margin: 0 9px 9px;
  overflow: hidden;
  border-radius: 7px;
  background: var(--code-bg);
}

.manual-code pre {
  margin: 0;
  padding: 10px 12px;
  overflow: auto;
  color: #d9e2da;
  font-size: 8.5px;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .15) transparent;
}

.manual-code pre::-webkit-scrollbar {
  height: 6px;
}

.manual-code pre::-webkit-scrollbar-thumb {
  border-radius: 6px;
  background: rgba(255, 255, 255, .17);
}

.manual-tip {
  display: flex;
  gap: 6px;
  margin: 0 14px 13px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 8px;
  line-height: 1.55;
}

.manual-tip svg {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--gold);
}

.empty-state {
  grid-column: 1 / -1;
  padding: 50px 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  background: var(--surface-soft);
  text-align: center;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  margin: 0 auto 10px;
  color: var(--muted);
}

.empty-state h3 {
  font-size: 18px;
}

.empty-state p {
  margin: 6px 0 14px;
  color: var(--muted);
  font-size: 10px;
}

/* Error clinic */

.error-section {
  margin-top: 48px;
}

.error-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 9px;
}

.error-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}

.error-item[open] {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--line));
}

.error-item summary {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 47px;
  padding: 9px 13px;
  list-style: none;
  cursor: pointer;
}

.error-item summary::-webkit-details-marker {
  display: none;
}

.error-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: var(--danger-soft);
  color: var(--danger);
}

.error-icon svg {
  width: 13px;
  height: 13px;
}

.error-item summary code {
  flex: 1;
  color: var(--ink-soft);
  font-size: 8.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.error-item summary > svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  color: var(--muted);
  transition: transform .2s;
}

.error-item[open] summary > svg {
  transform: rotate(180deg);
}

.error-body {
  padding: 0 13px 13px 46px;
}

.error-body p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.65;
}

.error-body p b {
  color: var(--ink-soft);
  font-weight: 600;
}

.error-fix {
  padding: 7px 9px;
  border-left: 2px solid var(--success);
  border-radius: 0 5px 5px 0;
  background: var(--success-soft);
  color: var(--ink-soft);
  font-size: 8.5px;
  line-height: 1.6;
}

.error-fix code {
  color: var(--green);
}

/* =========================================================
   Practice
   ========================================================= */

.practice-head {
  align-items: flex-end;
}

.practice-metrics {
  display: flex;
  flex: 0 0 auto;
  padding: 11px 2px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.practice-metrics > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 74px;
  padding: 0 15px;
  border-right: 1px solid var(--line);
  line-height: 1.3;
}

.practice-metrics > div:last-child {
  border-right: 0;
}

.practice-metrics strong {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 600;
  letter-spacing: -.03em;
}

.practice-metrics span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 8px;
}

.practice-layout {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 17px;
  align-items: start;
  min-width: 0;
}

.module-rail {
  position: sticky;
  top: 87px;
  min-width: 0;
}

.rail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 9px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.rail-random {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s, transform .2s;
}

.rail-random:hover {
  color: var(--accent);
  border-color: var(--accent);
  transform: rotate(-14deg);
}

.rail-random svg {
  width: 13px;
  height: 13px;
}

.module-rail > div#moduleRail {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.module-btn {
  position: relative;
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}

.module-btn:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.module-btn.is-active {
  border-color: color-mix(in srgb, var(--mod-color) 45%, var(--line));
  background: var(--surface);
  box-shadow: inset 3px 0 0 var(--mod-color);
}

.module-btn-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.module-icon {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: color-mix(in srgb, var(--mod-color) 11%, var(--surface));
  color: var(--mod-color);
}

.module-icon svg {
  width: 14px;
  height: 14px;
}

.module-btn strong {
  flex: 1;
  font-family: var(--serif);
  font-size: 12.5px;
  font-weight: 600;
}

.module-btn-count {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
}

.module-btn-desc {
  margin: 6px 0 8px 34px;
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
}

.module-bar {
  display: block;
  height: 3px;
  margin-left: 34px;
  overflow: hidden;
  border-radius: 4px;
  background: var(--surface-tint);
}

.module-bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--mod-color);
  transition: width .4s var(--ease);
}

.module-btn.all-module .module-icon {
  background: var(--ink);
  color: var(--surface);
}

.rail-note {
  display: flex;
  gap: 7px;
  margin-top: 13px;
  padding: 11px;
  border: 1px dashed var(--line-strong);
  border-radius: 9px;
  color: var(--muted);
}

.rail-note svg {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  margin-top: 1px;
  color: var(--gold);
}

.rail-note p {
  margin: 0;
  font-size: 8px;
  line-height: 1.6;
}

.practice-stage {
  min-width: 0;
  width: 100%;
}

.question-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.question-top {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-soft);
}

.q-module {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--mod-color) 11%, var(--surface));
  color: var(--mod-color);
  font-size: 8px;
  font-weight: 600;
}

.q-module::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.q-count {
  margin-left: auto;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
}

.q-solved {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 7px;
  padding: 3px 6px;
  border: 1px solid color-mix(in srgb, var(--success) 24%, transparent);
  border-radius: 4px;
  background: var(--success-soft);
  color: var(--success);
  font-size: 7.5px;
  font-weight: 600;
  white-space: nowrap;
}

.q-solved svg {
  width: 10px;
  height: 10px;
  stroke-width: 2.4;
}

.q-difficulty {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-left: 7px;
}

.q-difficulty i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--line-strong);
}

.q-difficulty i.on {
  background: var(--gold);
}

.question-main {
  padding: 24px 27px 22px;
}

.question-main h2 {
  max-width: 780px;
  font-family: var(--sans);
  font-size: clamp(19px, 2.2vw, 25px);
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -.015em;
}

.question-main h2 code {
  padding: .08em .3em;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: .88em;
  white-space: normal;
}

.q-context {
  margin-top: 15px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
}

.q-context pre {
  margin: 0;
  padding: 11px 13px;
  overflow-x: auto;
  color: #d8e2da;
  font-size: 9.5px;
  line-height: 1.65;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 19px;
}

.option {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 48px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink-soft);
  text-align: left;
  cursor: pointer;
  transition: border-color .2s, background .2s, transform .2s;
}

.option:hover:not(:disabled) {
  border-color: var(--ink-soft);
  background: var(--surface-soft);
  transform: translateX(2px);
}

.option:disabled {
  cursor: default;
}

.option-key {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
}

.option-text {
  font-size: 11px;
  line-height: 1.55;
}

.option-text code {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface-soft);
  color: var(--green);
  font-size: 9.5px;
}

.option.is-correct {
  border-color: var(--success);
  background: var(--success-soft);
}

.option.is-correct .option-key {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-soft);
}

.option.is-wrong .option-key {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}

.option.is-muted {
  opacity: .5;
}

.option-mark {
  margin-left: auto;
  color: var(--success);
  font-size: 9px;
  font-weight: 700;
}

.option.is-wrong .option-mark {
  color: var(--danger);
}

.fill-answer {
  margin-top: 19px;
}

.fill-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
}

.fill-row {
  display: flex;
  gap: 8px;
}

.fill-input {
  flex: 1;
  min-width: 0;
  height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  transition: border-color .2s, box-shadow .2s, background .2s;
}

.fill-input:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent);
}

.fill-input:disabled {
  color: var(--success);
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 40%, var(--line));
}

.fill-input::placeholder {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
}

.check-answer {
  min-width: 100px;
  height: 48px;
}

.hint-box {
  margin-top: 13px;
  border-top: 1px dashed var(--line);
  padding-top: 11px;
}

.hint-box summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 9px;
  list-style: none;
  cursor: pointer;
}

.hint-box summary::-webkit-details-marker {
  display: none;
}

.hint-box summary svg {
  width: 12px;
  height: 12px;
  color: var(--gold);
}

.hint-box p {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.65;
}

.feedback {
  display: flex;
  gap: 10px;
  margin-top: 17px;
  padding: 13px;
  border: 1px solid transparent;
  border-radius: 9px;
  animation: feedbackIn .25s var(--ease) both;
}

@keyframes feedbackIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.feedback.is-correct {
  border-color: color-mix(in srgb, var(--success) 28%, transparent);
  background: var(--success-soft);
}

.feedback.is-wrong {
  border-color: color-mix(in srgb, var(--danger) 28%, transparent);
  background: var(--danger-soft);
}

.feedback-icon {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
}

.feedback.is-wrong .feedback-icon {
  background: var(--danger);
}

.feedback-icon svg {
  width: 13px;
  height: 13px;
  stroke-width: 2.5;
}

.feedback-copy {
  min-width: 0;
  flex: 1;
}

.feedback-copy strong {
  display: block;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 700;
}

.feedback-copy p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.65;
}

.feedback-answer {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  color: var(--green);
  font-family: var(--mono);
  font-size: 8.5px;
}

.feedback-answer code {
  color: inherit;
}

.question-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-soft);
  font-size: 9px;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.nav-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.nav-btn svg {
  width: 12px;
  height: 12px;
}

.nav-btn.next {
  margin-left: auto;
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.nav-btn.next:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.question-dots {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 11px 22px 13px;
  border-top: 1px solid var(--line);
}

.q-dot {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 6.5px;
  cursor: pointer;
  transition: background .2s, color .2s, border-color .2s;
}

.q-dot:hover {
  border-color: var(--ink-soft);
  color: var(--ink);
}

.q-dot.is-current {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--surface);
}

.q-dot.is-solved {
  border-color: color-mix(in srgb, var(--success) 45%, var(--line));
  background: var(--success-soft);
  color: var(--success);
}

.q-dot.is-current.is-solved {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}

.q-dot.is-wrong {
  border-color: color-mix(in srgb, var(--danger) 35%, var(--line));
  color: var(--danger);
}

.dots-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 7.5px;
}

.session-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 55px 30px;
  text-align: center;
}

.session-done .big-check {
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  margin-bottom: 16px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
}

.session-done .big-check svg {
  width: 30px;
  height: 30px;
  stroke-width: 2.2;
}

.session-done h2 {
  font-size: 29px;
}

.session-done p {
  max-width: 460px;
  margin: 8px 0 20px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.7;
}

/* =========================================================
   Search modal
   ========================================================= */

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: min(10vh, 90px) 18px 30px;
  background: rgba(11, 23, 18, .52);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  animation: fadeIn .18s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.search-dialog {
  width: min(670px, 100%);
  max-height: min(760px, 84vh);
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  border-radius: 15px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  animation: dialogIn .25s var(--ease) both;
}

@keyframes dialogIn {
  from { opacity: 0; transform: translateY(-8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.search-dialog-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  height: 59px;
  border-bottom: 1px solid var(--line);
}

.search-dialog-field > svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

.search-dialog-field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.search-dialog-field input::placeholder {
  color: var(--muted);
}

.esc-btn {
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface-soft);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 8px;
  cursor: pointer;
}

.search-results {
  max-height: min(580px, 65vh);
  overflow-y: auto;
  padding: 7px;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.search-empty {
  padding: 38px 20px;
  text-align: center;
  color: var(--muted);
}

.search-empty svg {
  width: 23px;
  height: 23px;
  margin: 0 auto 9px;
  opacity: .6;
}

.search-empty p {
  margin: 0;
  font-size: 10.5px;
}

.search-section-label {
  padding: 9px 10px 5px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 7.5px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.search-result:hover,
.search-result.is-active {
  border-color: var(--line);
  background: var(--surface-soft);
}

.search-result-icon {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: var(--surface-tint);
  color: var(--ink-soft);
}

.search-result-icon svg {
  width: 14px;
  height: 14px;
}

.search-result-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.4;
}

.search-result-copy strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-result-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.search-result-type {
  flex: 0 0 auto;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--muted);
  font-size: 6.5px;
}

.search-result > svg {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  color: var(--muted);
  opacity: 0;
}

.search-result.is-active > svg,
.search-result:hover > svg {
  opacity: 1;
}

.search-footer {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 7.5px;
}

.search-footer span {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.search-scope {
  margin-left: auto;
}

/* =========================================================
   Toast / misc
   ========================================================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 27px;
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 15px;
  border: 1px solid rgba(255, 255, 255, .12);
  border-radius: 8px;
  background: #1c332a;
  color: #f6f0e2;
  font-size: 10.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .24);
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 12px);
  transition: opacity .2s, transform .2s, visibility .2s;
}

.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

.toast svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: #e9bb6d;
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(7, 17, 13, .48);
  backdrop-filter: blur(3px);
}

.mobile-nav {
  display: none;
}

.noscript {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 30px;
  background: #f4f0e7;
  color: #1c2a25;
  font-size: 14px;
  text-align: center;
}

/* Code highlighting utility */
.tok-cmd { color: #e8b267; }
.tok-brace { color: #9ab8a7; }
.tok-comment { color: #607a6c; font-style: italic; }
.tok-math { color: #b9cbe2; }
.tok-env { color: #c6a5d2; }

/* =========================================================
   Responsive
   ========================================================= */

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: 236px minmax(0, 1fr);
  }

  .topbar {
    padding: 0 28px;
  }

  main {
    padding: 0 28px 62px;
  }

  .hero {
    gap: 28px;
  }

  .paper-sheet {
    left: 63px;
  }

  .paper-back {
    left: 40px;
  }

  .route-layout {
    grid-template-columns: minmax(0, 1.4fr) minmax(255px, .8fr);
  }

  .route-list {
    grid-template-columns: 1fr;
  }

  .route-step {
    min-height: 86px;
  }

  .template-grid {
    grid-template-columns: minmax(0, 1.28fr) minmax(285px, .82fr);
  }

  .manual-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 1024px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: 272px;
    transform: translateX(-105%);
    transition: transform .3s var(--ease);
    box-shadow: 20px 0 60px rgba(0, 0, 0, .18);
  }

  body.nav-open .sidebar {
    transform: translateX(0);
  }

  .sidebar .sidebar-close {
    display: grid;
    border-color: rgba(255, 255, 255, .13);
    background: rgba(255, 255, 255, .06);
    color: #f1e6cf;
  }

  .sidebar-close:hover {
    background: rgba(255, 255, 255, .1);
    border-color: rgba(255, 255, 255, .22);
  }

  .menu-btn {
    display: grid;
  }

  .mobile-theme {
    display: grid;
  }

  .topbar {
    height: 64px;
    padding: 0 24px;
  }

  main {
    padding: 0 24px 100px;
  }

  .view {
    padding-top: 28px;
  }

  .hero {
    grid-template-columns: minmax(0, 1.08fr) minmax(300px, .92fr);
    min-height: 490px;
  }

  .paper-stage {
    transform: scale(.9);
    transform-origin: center right;
    margin-left: -25px;
  }

  .route-layout {
    grid-template-columns: 1fr;
  }

  .route-list {
    grid-template-columns: 1fr 1fr;
  }

  .progress-card {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) minmax(170px, .8fr);
    gap: 18px;
    align-items: center;
    padding: 18px 20px;
  }

  .progress-ring {
    width: 105px;
    height: 105px;
    margin: 0;
    grid-row: span 3;
  }

  .progress-ring strong {
    font-size: 24px;
  }

  .progress-message {
    margin: 0;
    text-align: left;
    grid-column: 2;
  }

  .mini-metrics {
    grid-column: 2;
    padding: 8px 0;
  }

  .week-wrap {
    grid-column: 3;
    grid-row: 1 / span 3;
    margin: 0;
  }

  .progress-card > .btn {
    grid-column: 2;
    width: auto;
    justify-self: start;
    min-height: 34px;
    padding: 0 13px;
    font-size: 10px;
  }

  .template-grid {
    grid-template-columns: minmax(0, 1.2fr) minmax(270px, .8fr);
  }

  .practice-layout {
    grid-template-columns: 1fr;
  }

  .module-rail {
    position: static;
    width: 100%;
    overflow: hidden;
  }

  .module-rail > div#moduleRail {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .module-btn {
    padding: 10px;
  }

  .module-btn-desc {
    display: none;
  }

  .module-btn-top {
    flex-wrap: wrap;
  }

  .module-btn strong {
    font-size: 11px;
  }

  .module-btn-count {
    margin-left: 34px;
  }

  .module-bar {
    margin: 7px 0 0;
  }

  .module-icon {
    width: 23px;
    height: 23px;
  }

  .rail-note {
    display: none;
  }

  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: 61px;
    padding: 5px max(10px, env(safe-area-inset-left)) calc(5px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
  }

  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--muted);
    font-size: 8px;
    transition: color .2s;
  }

  .mobile-nav a svg {
    width: 19px;
    height: 19px;
  }

  .mobile-nav a.is-active {
    color: var(--accent);
  }

  .mobile-nav a.is-active svg {
    stroke-width: 2.1;
  }

  .toast {
    bottom: 76px;
  }
}

@media (max-width: 860px) {
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 13px;
  }

  .hero-copy {
    position: relative;
    z-index: 2;
  }

  .hero h1 {
    font-size: clamp(45px, 9vw, 66px);
  }

  .paper-stage {
    width: min(440px, 100%);
    min-height: 500px;
    margin: 5px auto 0;
    transform: none;
  }

  .paper-sheet {
    left: 50%;
    transform: translateX(-50%) rotate(1.6deg);
  }

  .paper-back {
    left: 50%;
    transform: translateX(-53%) rotate(-5.2deg);
  }

  .stat-strip {
    margin-top: 5px;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
  }

  .route-list {
    grid-template-columns: 1fr;
  }

  .progress-card {
    grid-template-columns: 105px minmax(0, 1fr);
  }

  .progress-message {
    grid-column: 2;
  }

  .mini-metrics {
    grid-column: 2;
  }

  .week-wrap {
    grid-column: 1 / -1;
    grid-row: auto;
    margin-top: 2px;
  }

  .progress-card > .btn {
    grid-column: 1 / -1;
    width: 100%;
  }

  .home-split {
    grid-template-columns: 1fr;
  }

  .terminal-band {
    grid-template-columns: 1fr;
    gap: 23px;
    padding: 25px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 17px;
  }

  .page-head p {
    font-size: 12.5px;
  }

  .head-stamp {
    display: none;
  }

  .pub-tabs {
    grid-template-columns: 1fr;
  }

  .pub-tab {
    padding: 11px 13px;
  }

  .pub-tab-arrow {
    opacity: 1;
  }

  .pub-hero {
    flex-wrap: wrap;
    padding: 20px;
  }

  .pub-hero-actions {
    width: 100%;
    padding-left: 89px;
  }

  .template-grid {
    grid-template-columns: 1fr;
  }

  .aside-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .aside-stack .side-card:first-child,
  .aside-stack .side-card:last-child {
    grid-column: auto;
  }

  .manual-toolbar {
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }

  .category-pills {
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .category-pills::-webkit-scrollbar {
    display: none;
  }

  .cat-pill {
    flex: 0 0 auto;
  }

  .manual-grid {
    grid-template-columns: 1fr;
  }

  .error-list {
    grid-template-columns: 1fr;
  }

  .practice-head {
    align-items: flex-start;
  }

  .practice-metrics {
    width: 100%;
    justify-content: space-between;
  }

  .practice-metrics > div {
    flex: 1;
    min-width: 0;
  }

  .module-rail > div#moduleRail {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding-bottom: 3px;
    scrollbar-width: none;
    overscroll-behavior-inline: contain;
    -webkit-overflow-scrolling: touch;
  }

  .module-rail > div#moduleRail::-webkit-scrollbar {
    display: none;
  }

  .module-btn {
    flex: 0 0 155px;
  }

  .module-btn-desc {
    display: block;
    margin-left: 0;
    font-size: 7.5px;
  }

  .module-bar {
    margin-left: 0;
  }

  .question-main {
    padding: 20px;
  }

  .question-top,
  .question-nav,
  .question-dots {
    padding-left: 16px;
    padding-right: 16px;
  }

  .page-footer {
    flex-direction: column;
    gap: 12px;
    margin-top: 40px;
  }

  .search-trigger {
    width: 205px;
  }

  .search-trigger span {
    display: none;
  }

  .search-trigger::after {
    content: "搜索";
    flex: 1;
    color: var(--muted);
    font-size: 10px;
  }

  .offline-pill {
    display: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
  }

  .breadcrumb span,
  .breadcrumb svg {
    display: none;
  }

  .breadcrumb strong {
    font-size: 11px;
  }

  main {
    padding: 0 16px 93px;
  }

  .view {
    padding-top: 22px;
  }

  .hero {
    padding-bottom: 31px;
  }

  .hero h1 {
    font-size: clamp(41px, 12vw, 56px);
    margin-top: 15px;
  }

  .hero-lede {
    font-size: 13.5px;
    line-height: 1.8;
  }

  .hero-actions {
    margin-top: 22px;
  }

  .hero-actions .btn {
    flex: 1;
    min-width: 142px;
    padding: 0 12px;
    font-size: 11px;
  }

  .hero-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px 0;
    margin-top: 23px;
  }

  .hero-meta span {
    padding: 0 11px;
    font-size: 8.5px;
  }

  .hero-meta span:nth-child(2) {
    border-right: 0;
  }

  .hero-meta span:nth-child(3) {
    padding-left: 0;
  }

  .hero-meta b {
    font-size: 13px;
  }

  .paper-stage {
    min-height: 424px;
    margin-top: 2px;
    transform: scale(.83);
    transform-origin: top center;
    margin-bottom: -64px;
  }

  .paper-sheet {
    left: 50%;
    top: 21px;
  }

  .paper-back {
    left: 50%;
    top: 35px;
  }

  .float-compile {
    left: 4%;
  }

  .float-ready {
    right: 0;
  }

  .stat-strip {
    grid-template-columns: 1fr 1fr;
  }

  .stat-item {
    padding: 15px 12px;
    border-bottom: 1px solid var(--line);
  }

  .stat-item:nth-child(2) {
    border-right: 0;
  }

  .stat-item:nth-child(3),
  .stat-item:nth-child(4) {
    border-bottom: 0;
  }

  .stat-num {
    font-size: 28px;
  }

  .stat-label {
    font-size: 10px;
  }

  .stat-note {
    font-size: 8px;
  }

  .section-head h2 {
    font-size: 27px;
  }

  .section-head p {
    font-size: 11px;
  }

  .route-step {
    padding: 13px 11px;
    grid-template-columns: 27px minmax(0, 1fr) auto;
    min-height: 80px;
  }

  .route-body strong {
    font-size: 14px;
  }

  .route-body small {
    font-size: 9px;
  }

  .progress-card {
    display: block;
    padding: 19px;
  }

  .progress-ring {
    width: 112px;
    height: 112px;
    margin: 0 auto 12px;
  }

  .progress-message {
    margin-bottom: 13px;
    text-align: center;
  }

  .mini-metrics {
    margin-bottom: 5px;
  }

  .week-wrap {
    margin-top: 14px;
  }

  .progress-card > .btn {
    margin-top: 14px;
  }

  .daily-card {
    min-height: 305px;
    padding: 20px;
  }

  .daily-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .daily-card h2 {
    font-size: 25px;
  }

  .quick-templates {
    padding: 15px;
  }

  .terminal-band {
    padding: 20px;
  }

  .terminal-line code {
    font-size: 9.5px;
  }

  .page-head h1 {
    font-size: 39px;
  }

  .page-head p {
    font-size: 11.5px;
    line-height: 1.7;
  }

  .pub-hero {
    padding: 17px;
  }

  .pub-emblem {
    width: 54px;
    height: 54px;
    font-size: 10px;
  }

  .pub-hero h2 {
    font-size: 27px;
  }

  .pub-hero-actions {
    padding-left: 0;
  }

  .template-body {
    padding: 12px;
  }

  .variant-note {
    width: 100%;
    margin: 4px 0 0;
  }

  .code-head {
    flex-wrap: wrap;
    gap: 5px;
    padding: 9px 10px;
    min-height: 44px;
  }

  .code-meta {
    display: none;
  }

  .code-actions {
    margin-left: auto;
  }

  .code-btn span {
    display: none;
  }

  .code-btn {
    width: 27px;
    justify-content: center;
    padding: 0;
  }

  .code-pre {
    max-height: 410px;
    font-size: 9.5px;
  }

  .line-no {
    width: 30px;
    flex-basis: 30px;
    font-size: 8px;
  }

  .aside-stack {
    grid-template-columns: 1fr;
  }

  .aside-stack .side-card {
    width: 100%;
  }

  .manual-meta {
    font-size: 8px;
  }

  .meta-hint {
    display: none;
  }

  .manual-card h3 {
    font-size: 15px;
  }

  .error-item summary code {
    font-size: 8px;
  }

  .error-body {
    padding-left: 13px;
  }

  .practice-metrics > div {
    padding: 0 8px;
  }

  .practice-metrics strong {
    font-size: 20px;
  }

  .module-btn {
    flex-basis: 145px;
  }

  .question-main h2 {
    font-size: 18px;
  }

  .option-text {
    font-size: 10px;
  }

  .fill-row {
    flex-direction: column;
  }

  .fill-input {
    flex: none;
    width: 100%;
  }

  .check-answer {
    width: 100%;
    min-height: 42px;
    height: 42px;
  }

  .nav-btn span {
    display: none;
  }

  .nav-btn.next span {
    display: inline;
  }

  .dots-hint {
    display: none;
  }

  .question-dots .q-dot {
    width: 18px;
    height: 18px;
  }

  .search-trigger {
    width: auto;
    padding: 0 9px;
    border: 0;
    background: transparent;
  }

  .search-trigger::after {
    display: none;
  }

  .search-trigger kbd {
    display: none;
  }

  .search-trigger svg {
    width: 18px;
    height: 18px;
  }

  .modal {
    padding: 55px 10px 15px;
  }

  .search-dialog {
    max-height: 85vh;
  }

  .search-footer .search-scope {
    display: none;
  }

  .search-footer {
    justify-content: space-between;
  }

  .page-footer a {
    font-size: 9px;
  }

  .toast {
    font-size: 9.5px;
  }
}

@media (max-width: 390px) {
  .paper-stage {
    transform: scale(.75);
    margin-bottom: -100px;
  }

  .float-compile {
    left: -2%;
  }

  .hero-actions .btn {
    min-width: 100%;
  }
}

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