/* ============================================================
   Maths · 数学资料站  —  light academic theme
   ============================================================ */

:root {
  --bg:        #f6f7fb;
  --surface:   #ffffff;
  --surface-2: #f0f2f9;
  --ink:       #171a24;
  --ink-2:     #3d4457;
  --muted:     #6b7488;
  --line:      #e2e6f0;
  --line-2:    #d3d9e8;

  --accent:    #3b5bdb;
  --accent-d:  #2f49b0;
  --accent-l:  #eaeefc;
  --teal:      #0c8f7a;
  --amber:     #b45309;
  --rose:      #be123c;
  --violet:    #6d28d9;

  --radius:    14px;
  --radius-sm: 9px;
  --shadow:    0 1px 2px rgba(23,26,36,.05), 0 10px 28px -14px rgba(23,26,36,.22);
  --shadow-lg: 0 2px 6px rgba(23,26,36,.06), 0 26px 60px -30px rgba(23,26,36,.34);

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", "Source Han Serif SC", "Noto Serif SC", serif;
  --sans:  -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --mono:  "SF Mono", ui-monospace, "Cascadia Mono", "JetBrains Mono", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 84px; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); }

.wrap { width: min(1140px, 100% - 48px); margin: 0 auto; }

/* ---------------- topbar ---------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 66px; }

.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; flex: none;
  background: linear-gradient(140deg, var(--accent), #5f7ae8);
  color: #fff; font-family: var(--serif); font-size: 21px; line-height: 1;
  box-shadow: 0 6px 16px -8px var(--accent);
}
.brand-mark-sm { width: 24px; height: 24px; font-size: 14px; border-radius: 7px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-family: var(--serif); font-size: 17px; }
.brand-text em { font-style: normal; font-size: 11.5px; color: var(--muted); letter-spacing: .06em; }

.nav { margin-left: auto; display: flex; gap: 4px; }
.nav-link {
  padding: 7px 14px; border-radius: 999px; font-size: 14.5px; color: var(--ink-2);
  transition: background .18s, color .18s;
}
.nav-link:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav-link.active { background: var(--accent-l); color: var(--accent-d); font-weight: 500; }

.nav-toggle {
  display: none; margin-left: auto; border: 1px solid var(--line-2); background: #fff;
  width: 40px; height: 36px; border-radius: 9px; font-size: 17px; color: var(--ink-2); cursor: pointer;
}

/* ---------------- hero ---------------- */
.hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--line); }
.hero-bg { position: absolute; inset: 0; pointer-events: none; }
.hero-bg .glyph {
  position: absolute; font-family: var(--serif); color: var(--accent);
  opacity: .055; user-select: none;
}
.g1 { font-size: 260px; top: -60px; left: -30px; }
.g2 { font-size: 190px; bottom: -70px; left: 24%; }
.g3 { font-size: 150px; top: 20px; right: 14%; }
.g4 { font-size: 210px; bottom: -60px; right: -20px; }
.g5 { font-size: 120px; top: 46%; left: 46%; opacity: .04 !important; }
.g6 { font-size: 130px; top: 8%; left: 66%; opacity: .035 !important; }

.hero-inner { position: relative; padding: 96px 0 78px; max-width: 900px; }
.eyebrow {
  font-size: 12px; letter-spacing: .22em; color: var(--accent);
  font-weight: 600; margin: 0 0 20px;
}
.hero h1 {
  font-size: clamp(30px, 4.6vw, 52px); line-height: 1.24; margin: 0 0 22px;
}
.hero h1 em {
  font-style: normal; position: relative; white-space: nowrap;
  background-image: linear-gradient(transparent 64%, #cdd8fb 64%);
  background-repeat: no-repeat; background-size: 100% .5em; background-position: 0 92%;
}
.lede { font-size: 17.5px; color: var(--ink-2); max-width: 660px; }

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin: 30px 0 40px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 10px; border: 1px solid transparent;
  font-size: 15px; font-family: var(--sans); font-weight: 500; cursor: pointer;
  transition: transform .14s, box-shadow .18s, background .18s, border-color .18s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 10px 22px -12px var(--accent); }
.btn-primary:hover { background: var(--accent-d); }
.btn-ghost { background: #fff; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-block { width: 100%; margin-top: 6px; }
.btn-mini { padding: 6px 12px; font-size: 13px; border-radius: 8px; background: var(--surface-2); color: var(--ink-2); border-color: var(--line-2); }
.btn-mini:hover { background: var(--accent-l); color: var(--accent-d); }

.hero-stats { display: flex; gap: 40px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 24px; }
.stat-num { font-family: var(--serif); font-size: 30px; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--muted); }

/* ---------------- sections ---------------- */
.section { padding: 74px 0; }
.section-alt { background: var(--surface); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.section-head { margin-bottom: 34px; }
.section-head h2 { font-size: 29px; margin-bottom: 8px; }
.section-sub { color: var(--muted); margin: 0; font-size: 15.5px; }

/* ---------------- category cards ---------------- */
.cat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 14px; margin-bottom: 40px;
}
.cat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 16px; cursor: pointer; text-align: left;
  transition: box-shadow .2s, transform .2s, border-color .2s;
  display: flex; flex-direction: column; gap: 6px;
}
.cat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--line-2); }
.cat-card.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-l); }
.cat-top { display: flex; align-items: center; gap: 10px; }
.cat-icon { font-family: var(--serif); font-size: 20px; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.cat-name { font-family: var(--serif); font-size: 16.5px; font-weight: 600; }
.cat-en { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.cat-desc { font-size: 13.5px; color: var(--muted); margin: 2px 0 0; }
.cat-meta { font-size: 12.5px; color: var(--accent); margin-top: 4px; }

/* ---------------- filters ---------------- */
.filters {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.filter-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.filter-row + .filter-row { margin-top: 13px; padding-top: 13px; border-top: 1px dashed var(--line); }
.filter-row-inline { border-top: 1px dashed var(--line) !important; padding-top: 13px !important; margin-top: 13px !important; }
.filter-label { font-size: 13px; color: var(--muted); width: 34px; flex: none; letter-spacing: .04em; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line-2); background: #fff; color: var(--ink-2);
  padding: 5px 13px; border-radius: 999px; font-size: 13.5px; cursor: pointer;
  transition: all .16s; font-family: var(--sans);
}
.chip:hover { border-color: var(--accent); color: var(--accent-d); }
.chip.is-active { background: var(--accent); color: #fff; border-color: var(--accent); }
.search {
  flex: 1 1 280px; min-width: 200px; padding: 9px 14px; font-size: 14.5px;
  border: 1px solid var(--line-2); border-radius: 9px; background: var(--surface-2);
  font-family: var(--sans); color: var(--ink); outline: none; transition: border-color .16s, background .16s;
}
.search:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-l); }
.count { font-size: 13px; color: var(--muted); white-space: nowrap; }

.lib-note {
  font-size: 13.5px; color: var(--muted); background: var(--accent-l);
  border: 1px solid #d5ddfa; border-radius: var(--radius-sm);
  padding: 11px 16px; margin: 0 0 16px;
}
.lib-note b { color: var(--accent-d); }

/* ---------------- material list ---------------- */
.material-list { display: grid; gap: 12px; }
.material {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: grid; grid-template-columns: 46px 1fr auto; gap: 16px; align-items: start;
  transition: box-shadow .2s, border-color .2s;
}
.material:hover { box-shadow: var(--shadow); border-color: var(--line-2); }
.m-icon { width: 46px; height: 46px; border-radius: 11px; display: grid; place-items: center; font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.m-title { font-family: var(--serif); font-size: 17.5px; font-weight: 600; margin: 0 0 5px; }
.m-desc { font-size: 14px; color: var(--muted); margin: 0 0 9px; }
.m-tags { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.tag { font-size: 12px; padding: 2px 9px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.tag-branch { background: var(--accent-l); color: var(--accent-d); }
.m-side { text-align: right; font-size: 12.5px; color: var(--muted); white-space: nowrap; display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.m-action { font-size: 13px; color: var(--accent); }
.m-action.pending { color: var(--muted); }

.empty { text-align: center; padding: 46px 0 10px; color: var(--muted); }
.empty p { font-size: 15px; }

/* ---------------- tools ---------------- */
.tool-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  padding: 26px; box-shadow: var(--shadow-lg);
}
.tool-head h3 { font-size: 20px; margin-bottom: 6px; }
.tool-head p { color: var(--muted); font-size: 14.5px; margin-bottom: 20px; }
.tool-head code { background: var(--surface-2); padding: 2px 7px; border-radius: 6px; font-size: 13px; color: var(--accent-d); }

.plot-form { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; flex: 1 1 300px; }
.field-sm { flex: 0 0 118px; }
.field label { font-size: 12.5px; color: var(--muted); letter-spacing: .03em; }
.input {
  padding: 10px 13px; font-size: 14.5px; border: 1px solid var(--line-2); border-radius: 9px;
  background: var(--surface-2); color: var(--ink); outline: none; transition: border-color .16s, background .16s, box-shadow .16s;
  width: 100%;
}
.input:focus { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 3px var(--accent-l); }
.input-xs { width: 90px; padding: 6px 9px; font-size: 13px; }

.plot-toggles { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; }
.switch { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.switch input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.plot-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; }
#plotCanvas { display: block; width: 100%; height: auto; }

.plot-analysis { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 12px; margin-top: 16px; }
.analysis-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; }
.analysis-label { display: block; font-size: 12px; color: var(--muted); letter-spacing: .08em; margin-bottom: 8px; }
.analysis-inputs { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 9px; }
.analysis-out { display: block; font-size: 14.5px; color: var(--accent-d); word-break: break-all; }
.analysis-hint { font-size: 12.5px; color: var(--muted); margin: 0; line-height: 1.6; }

/* ---------------- formulas ---------------- */
.formula-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.formula-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; transition: box-shadow .2s, border-color .2s;
}
.formula-card:hover { box-shadow: var(--shadow); }
.f-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.f-name { font-family: var(--serif); font-size: 16px; font-weight: 600; }
.f-group { font-size: 11.5px; color: var(--accent); background: var(--accent-l); padding: 2px 8px; border-radius: 6px; white-space: nowrap; }
.f-body { overflow-x: auto; padding: 2px 0; }
.f-body .katex-display { margin: 6px 0; }
.f-body::-webkit-scrollbar { height: 6px; }
.f-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 3px; }
.f-body::-webkit-scrollbar-track { background: transparent; }
.f-note { font-size: 13px; color: var(--muted); margin: 10px 0 0; border-top: 1px dashed var(--line); padding-top: 10px; }

/* ---------------- about ---------------- */
.about-wrap { display: grid; grid-template-columns: minmax(0,1.55fr) minmax(280px,1fr); gap: 46px; align-items: start; }
.about-main h2 { font-size: 27px; margin-bottom: 14px; }
.about-main h3 { font-size: 17px; margin: 26px 0 10px; }
.about-main p { color: var(--ink-2); font-size: 15.5px; }
.plan-list { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: 15.5px; }
.plan-list li { margin-bottom: 7px; }
.plan-list b { color: var(--ink); }

.about-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); position: sticky; top: 88px;
}
.about-card-row { display: flex; justify-content: space-between; gap: 14px; padding: 10px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.about-card-row:last-of-type { border-bottom: none; }
.about-key { color: var(--muted); flex: none; }
.about-val { text-align: right; color: var(--ink); word-break: break-all; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--teal); margin-right: 6px; vertical-align: middle; }

/* ---------------- footer ---------------- */
.footer { background: #12141c; color: #9aa2b5; padding: 26px 0; font-size: 13.5px; }
.footer-inner { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: center; }
.footer-left { display: flex; align-items: center; gap: 10px; color: #d7dbe6; }
.footer-right { display: flex; align-items: center; gap: 10px; }
.footer a { color: #b9c2d8; }
.footer .sep { opacity: .4; }

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .about-wrap { grid-template-columns: 1fr; gap: 28px; }
  .about-card { position: static; }
  .hero-inner { padding: 66px 0 54px; }
}
@media (max-width: 720px) {
  .wrap { width: min(1140px, 100% - 32px); }
  .nav-toggle { display: block; }
  .nav {
    position: absolute; top: 66px; left: 0; right: 0; background: #fff;
    flex-direction: column; gap: 0; padding: 8px 16px 14px; border-bottom: 1px solid var(--line);
    display: none; box-shadow: 0 18px 30px -22px rgba(0,0,0,.4);
  }
  .nav.open { display: flex; }
  .nav-link { padding: 11px 12px; border-radius: 8px; }
  .material { grid-template-columns: 40px 1fr; }
  .m-side { grid-column: 2; flex-direction: row; align-items: center; gap: 12px; }
  .m-icon { width: 40px; height: 40px; }
  .section { padding: 54px 0; }
  .tool-card { padding: 18px; }
  .hero-stats { gap: 26px; }
}
