/* AILatest Grant · Redesign shell (Journal paper + orange)
 * Loaded after app.css. Scopes visual chrome without breaking data views. */

:root {
  --paper: #fffdf9;
  --paper-soft: #f9f6ef;
  --ink: #27231f;
  --ink-soft: #514b45;
  --ink-faint: #756f68;
  --rule: #ded8cf;
  --rule-soft: #ece7df;
  --accent: #f97316;
  --accent-soft: #fb923c;
  --deep: #1f2c4c;
  --rail: 72px;
  --bottom: 64px;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

body.grant-redesign {
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(ellipse 680px 420px at 50% 0%, rgba(249,115,22,.08), transparent 70%),
    radial-gradient(ellipse 520px 380px at 90% 80%, rgba(31,44,76,.04), transparent 70%),
    linear-gradient(rgba(39,35,31,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(39,35,31,.035) 1px, transparent 1px);
  background-size: cover, cover, 60px 60px, 60px 60px;
  background-attachment: fixed;
  padding: 0 0 40px var(--rail) !important;
  max-width: none !important;
  margin: 0 !important;
  min-height: 100vh;
}

body.grant-redesign a { border-bottom: 0; }
body.grant-redesign a:hover { border-bottom-color: transparent; }

/* Hide legacy chrome */
body.grant-redesign .home-top-actions,
body.grant-redesign > .header,
body.grant-redesign > .side-rail {
  display: none !important;
}

/* ── App rail ── */
.app-rail {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--rail);
  z-index: 100;
  display: flex; flex-direction: column; align-items: center;
  justify-content: space-between;
  padding: 16px 8px 18px;
  background: rgba(255,255,255,.55);
  border-right: 1px solid rgba(39,35,31,.08);
  backdrop-filter: blur(18px);
}
.rail-top, .rail-bottom { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
.rail-btn {
  width: 52px; min-height: 52px; border: 0; border-radius: 14px;
  background: transparent; color: var(--ink-faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 10px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.rail-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.rail-btn.active, .rail-btn:hover { color: var(--accent); background: rgba(249,115,22,.08); }
.rail-flag {
  width: 22px; height: 18px; border-radius: 4px; background: #f5f0e8;
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; color: var(--ink-soft);
}
.rail-btn.active .rail-flag { background: rgba(249,115,22,.15); color: #c2410c; }

/* ── Topbar ── */
.rd-topbar {
  position: sticky; top: 0; z-index: 80;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 22px 10px;
  background: linear-gradient(180deg, rgba(255,253,249,.94), rgba(255,253,249,.72));
  backdrop-filter: blur(12px);
}
.rd-brand {
  display: inline-flex; align-items: baseline; gap: 5px;
  font-size: 18px; font-weight: 820; color: var(--ink); text-decoration: none !important;
}
.rd-brand em { font-style: italic; font-weight: 650; color: rgba(117,111,104,.9); }
.rd-top-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rd-pill {
  display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px;
  border-radius: 999px; border: 1px solid rgba(90,70,50,.1);
  background: rgba(255,255,255,.85); color: var(--ink-soft);
  font-size: 12.5px; font-weight: 700; text-decoration: none !important; cursor: pointer;
  font-family: inherit;
}
.rd-pill:hover { border-color: rgba(249,115,22,.3); color: #c2410c; }
.rd-pill.primary {
  background: linear-gradient(180deg, #fb923c, #f97316);
  border-color: transparent; color: #fff !important;
  box-shadow: 0 6px 16px rgba(249,115,22,.28);
}

/* ── Shell ── */
.rd-shell { width: min(920px, 100%); margin: 0 auto; padding: 8px 20px 48px; }

/* Hero + search capsule */
.rd-hero { text-align: center; max-width: 720px; margin: 28px auto 28px; }
.rd-hero h1 {
  font-size: clamp(26px, 4.2vw, 38px); font-weight: 820;
  letter-spacing: -.03em; line-height: 1.22; margin: 0 0 22px; color: var(--ink);
}
.rd-hero h1 .grad {
  background: linear-gradient(135deg, #fb923c, #ea580c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

/*
 * 首页搜索胶囊：
 * [输入……（全库）] [查课题|AI优化]
 * 全部在同一 flex 行内；AI 范围在胶囊外正常流式占位，不盖住下方四格
 */
body.grant-redesign .rd-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
}
body.grant-redesign .search-wrap.rd-search {
  position: relative;
  width: min(720px, 100%);
  max-width: min(720px, 100%);
  margin: 0 auto 8px;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  gap: 6px;
  min-height: 52px;
  padding: 5px 6px;
  border-radius: 999px;
  border: 1.5px solid rgba(249, 115, 22, 0.28);
  background: rgba(255, 255, 255, 0.96);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 8px 22px rgba(39, 35, 31, 0.06);
  box-sizing: border-box;
}
body.grant-redesign .search-wrap.rd-search:focus-within {
  border-color: rgba(249, 115, 22, 0.55);
  box-shadow:
    0 0 0 3px rgba(249, 115, 22, 0.12),
    0 8px 22px rgba(39, 35, 31, 0.07);
}

/* 已取消搜索栏自科/社科切换（全库检索） */
body.grant-redesign .rd-search .search-scope { display: none !important; }

/* 输入 */
body.grant-redesign .rd-search #q {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: 40px;
  border: 0;
  background: transparent;
  outline: none;
  padding: 0 8px;
  font-size: 15px;
  color: var(--ink);
  text-align: left;
  order: unset;
  margin: 0;
}
body.grant-redesign .rd-search #q::placeholder {
  color: rgba(117, 111, 104, 0.55);
}

/* 右侧动作组：模式切换 + 搜索 粘在一起 */
body.grant-redesign .rd-search .search-actions {
  display: inline-flex !important;
  flex-direction: row;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  padding: 0;
  margin: 0;
  border-radius: 0;
  background: transparent;
  position: static !important;
  left: auto !important;
  right: auto !important;
  top: auto !important;
  transform: none !important;
  max-width: none !important;
  width: auto !important;
  order: unset;
  box-shadow: none !important;
  border: 0 !important;
}

/* 覆盖 app.css .search-mode-tabs 的居中绝对偏移 */
body.grant-redesign .rd-search .search-mode-tabs {
  display: inline-flex !important;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #f5f0e8;
  border: 0 !important;
  flex: 0 0 auto;
  position: static !important;
  left: auto !important;
  transform: none !important;
  margin: 0 !important;
  max-width: none !important;
  width: auto !important;
  box-shadow: none !important;
}
body.grant-redesign .rd-search .search-mode-btn {
  appearance: none; border: 0;
  min-height: 34px; padding: 0 12px; border-radius: 999px;
  background: transparent; font-size: 12.5px; font-weight: 750; color: var(--ink-faint);
  white-space: nowrap; cursor: pointer; font-family: inherit;
  position: static;
  transform: none;
}
body.grant-redesign .rd-search .search-mode-btn.active {
  background: linear-gradient(180deg, #fb923c, #f97316) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(249,115,22,.22) !important;
  border-color: transparent !important;
}

/* 年份 / AI 面板：不进主行 */
body.grant-redesign .rd-search .search-meta-row,
body.grant-redesign .rd-search .rd-search-meta,
body.grant-redesign .rd-search .search-range-tabs {
  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;
}
/* AI 范围：胶囊下方文档流，占位下推首页四格，不再 absolute 重叠 */
body.grant-redesign #ai-scope-inline.ai-scope-inline {
  display: none;
  width: min(720px, 100%);
  max-width: min(720px, 100%);
  margin: 4px auto 0;
  box-sizing: border-box;
  position: static;
  z-index: auto;
}
body.grant-redesign #ai-scope-inline.ai-scope-inline.is-visible {
  display: grid !important;
  margin: 10px auto 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(90, 70, 50, 0.1);
  background: #fffdf9;
  box-shadow: 0 6px 18px rgba(39, 35, 31, 0.05);
}
body.grant-redesign #ai-inline-result:not(:empty) {
  width: min(720px, 100%);
  margin: 8px auto 0;
}
/* Stats：与搜索区拉开间距 */
.rd-stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px;
  margin: 18px 0 14px;
}
body.grant-redesign #home-view {
  padding-top: 4px;
}
.rd-stat {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 14px 10px; border-radius: 12px; min-height: 76px;
  border: 1px solid rgba(90,70,50,.08);
  background: #fff;
  box-shadow: none;
}
.rd-stat b {
  display: block; font-size: clamp(18px, 2.2vw, 22px); font-weight: 800;
  letter-spacing: -.02em; line-height: 1.1; margin-bottom: 4px; color: #c2410c;
  font-variant-numeric: tabular-nums;
}
.rd-stat small { font-size: 12.5px; font-weight: 600; color: #78716c; }

/* Sections */
.rd-sec {
  margin: 0 0 14px; padding: 20px 18px;
  border-radius: 18px; background: rgba(255,255,255,.86);
  border: 1px solid rgba(90,70,50,.07); box-shadow: 0 8px 24px rgba(40,28,16,.04);
}
.rd-sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 14px;
}
.rd-sec-head h2 { font-size: 16px; font-weight: 820; letter-spacing: -.02em; margin: 0; }
.rd-sec-head .more {
  font-size: 12.5px; font-weight: 700; color: #c2410c; text-decoration: none;
  border: 0; background: none; cursor: pointer; font-family: inherit;
}

.rd-feat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rd-feat-card {
  display: block; padding: 16px; border-radius: 14px; width: 100%; text-align: left;
  background: linear-gradient(180deg, rgba(255,255,255,.97), rgba(255,248,240,.97));
  border: 1px solid rgba(90,70,50,.08);
  text-decoration: none !important; color: inherit; cursor: pointer;
  font: inherit; transition: border-color .12s, box-shadow .12s, transform .12s;
}
.rd-feat-card:hover {
  border-color: rgba(249,115,22,.28); box-shadow: 0 10px 24px rgba(40,28,16,.06);
  transform: translateY(-1px);
}
.rd-feat-card .ey {
  font-size: 11px; font-weight: 800; color: #c2410c; letter-spacing: .04em;
}
.rd-feat-card strong { display: block; margin: 6px 0 4px; font-size: 15px; font-weight: 800; line-height: 1.35; }
.rd-feat-card p { margin: 0; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }

#home-view .rd-feat-card[data-open-browse="sci"],
#home-view .rd-feat-card[data-open-browse="soc"] {
  background: linear-gradient(180deg, rgba(255,244,232,.99), rgba(255,226,198,.99));
  border-color: rgba(249,115,22,.22);
  box-shadow: 0 10px 24px rgba(249,115,22,.06), 0 1px 0 rgba(255,255,255,.7) inset;
}
#home-view .rd-feat-card[data-open-browse="sci"]:hover,
#home-view .rd-feat-card[data-open-browse="soc"]:hover {
  background: linear-gradient(180deg, rgba(255,238,220,.99), rgba(255,214,168,.99));
  border-color: rgba(249,115,22,.34);
  box-shadow: 0 14px 28px rgba(249,115,22,.10), 0 1px 0 rgba(255,255,255,.7) inset;
}

/* Pricing */
.rd-plans { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; margin-top: 4px; }
.rd-plan {
  position: relative; display: flex; flex-direction: column;
  padding: 18px 16px 16px; border-radius: 16px;
  background: #fff; border: 1px solid rgba(90,70,50,.08);
}
.rd-plan.hot {
  border-color: rgba(249,115,22,.35);
  background: linear-gradient(180deg, #fffdfb, #fff7ed);
  box-shadow: 0 12px 28px rgba(249,115,22,.1);
}
.rd-plan-tag {
  position: absolute; top: 12px; right: 12px;
  font-size: 10px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  border-radius: 999px; padding: 3px 8px;
}
.rd-plan h3 { margin: 0 0 4px; font-size: 18px; font-weight: 820; }
.rd-plan .desc { margin: 0 0 12px; font-size: 12.5px; color: var(--ink-faint); }
.rd-plan .price { display: flex; align-items: baseline; gap: 4px; margin-bottom: 2px; }
.rd-plan .price b { font-size: 28px; font-weight: 820; letter-spacing: -.03em; color: #b45309; }
.rd-plan .price span { font-size: 13px; color: var(--ink-faint); font-weight: 650; }
.rd-plan .was { margin: 0 0 12px; font-size: 12px; color: #a8a29e; text-decoration: line-through; }
.rd-plan ul { list-style: none; margin: 0 0 14px; padding: 0; flex: 1; }
.rd-plan li {
  position: relative; padding: 0 0 0 16px; margin: 0 0 7px;
  font-size: 12.5px; color: #57534e; line-height: 1.4;
}
.rd-plan li::before {
  content: "✓"; position: absolute; left: 0; color: #ea580c; font-weight: 900; font-size: 11px;
}
.rd-plan-btn {
  width: 100%; min-height: 40px; border: 0; border-radius: 999px;
  font: 750 13px/1 inherit; cursor: pointer; font-family: inherit;
}
.rd-plan-btn.primary {
  background: linear-gradient(180deg, #fb923c, #f97316);
  color: #fff; box-shadow: 0 6px 16px rgba(249,115,22,.28);
}
.rd-plan-btn.ghost {
  background: #fff; border: 1px solid rgba(90,70,50,.12); color: var(--ink);
}
.rd-plan-btn.edu {
  margin-top: 6px; min-height: 36px;
  background: #fff7ed; border: 1px solid rgba(249,115,22,.25);
  color: #c2410c; font-size: 12px;
}
.rd-price-note {
  margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--ink-faint); line-height: 1.5;
}
.rd-matrix {
  width: 100%; border-collapse: collapse; margin-top: 14px; font-size: 12.5px;
}
.rd-matrix th, .rd-matrix td {
  padding: 9px 10px; border-bottom: 1px solid var(--rule-soft); text-align: left;
}
.rd-matrix th {
  font-size: 11px; font-weight: 800; color: var(--ink-faint); background: #faf7f0;
}
.rd-matrix .ok { color: #c2410c; font-weight: 800; }
.rd-matrix .mid { color: #78716c; font-weight: 700; }
.rd-matrix .no { color: #c4b5a5; font-weight: 900; font-size: 16px; text-align: center; }
.rd-matrix .no::before { content: "×"; }

/* Download strip */
.rd-dl-sec { text-align: center; }
.rd-dl-sec .rd-sec-head { justify-content: center; }
.rd-dl-lead { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-faint); line-height: 1.5; }
.rd-dl-strip {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0;
  max-width: 880px; margin: 0 auto; padding: 22px 10px 18px; border-radius: 20px;
  background:
    radial-gradient(520px 180px at 18% 0%, rgba(251,146,60,.22), transparent 70%),
    radial-gradient(480px 160px at 88% 15%, rgba(249,115,22,.12), transparent 68%),
    linear-gradient(180deg, rgba(255,253,249,.98), rgba(255,247,237,.92));
  border: 1px solid rgba(249,115,22,.12);
  box-shadow: 0 10px 28px rgba(180,100,40,.07);
}
.rd-dl-item {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 8px 12px 6px; min-width: 0; position: relative;
}
.rd-dl-item + .rd-dl-item::before {
  content: ""; position: absolute; left: 0; top: 18%; bottom: 22%; width: 1px;
  background: rgba(249,115,22,.14);
}
.rd-dl-name { font-size: 15px; font-weight: 780; color: var(--ink); }
.rd-dl-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 16px; border-radius: 999px; border: 0;
  background: linear-gradient(180deg, #fb923c, #f97316); color: #fff !important;
  font-size: 12.5px; font-weight: 750; text-decoration: none !important;
  box-shadow: 0 4px 12px rgba(249,115,22,.28); cursor: pointer; font-family: inherit;
}
.rd-dl-btn.ghost {
  background: rgba(255,255,255,.9); color: #c2410c !important;
  border: 1px solid rgba(249,115,22,.22); box-shadow: none;
}
.rd-dl-btn:disabled {
  opacity: .5; cursor: not-allowed; background: #f5f0e8; color: #a8a29e !important; border: 0;
}
.rd-dl-meta { margin: 0; font-size: 11px; color: #a8a29e; font-weight: 650; }
.rd-dl-note {
  margin-top: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: 6px 8px; font-size: 12.5px;
}
.rd-dl-note a, .rd-dl-note button {
  font-size: 12.5px; font-weight: 750; color: #c2410c; text-decoration: none !important;
  border: 0; background: none; cursor: pointer; font-family: inherit; padding: 0;
}
.rd-dl-dot { color: #d6d3d1; }

/* Footer */
.rd-foot {
  margin: 8px 0 0; padding: 20px 18px 16px;
  border-radius: 18px; background: rgba(255,255,255,.86);
  border: 1px solid rgba(90,70,50,.07);
}
.rd-foot h2 { margin: 0 0 8px; font-size: 16px; font-weight: 820; }
.rd-foot-lead { margin: 0 0 16px; font-size: 13.5px; color: var(--ink-faint); line-height: 1.55; }
.rd-foot-grid { display: grid; grid-template-columns: 1.2fr 1fr; gap: 12px; margin-bottom: 16px; }
.rd-foot-card {
  padding: 14px 16px; border-radius: 14px; background: #fff;
  border: 1px solid rgba(90,70,50,.08);
}
.rd-foot-card b { display: block; margin: 0 0 6px; font-size: 13.5px; font-weight: 800; }
.rd-foot-card p { margin: 0 0 10px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5; }
.rd-foot-links { display: flex; flex-wrap: wrap; gap: 6px 4px; font-size: 12.5px; font-weight: 720; }
.rd-foot-links a { color: #c2410c; text-decoration: none !important; }
.rd-foot-links .dot { color: #d6d3d1; }
.rd-site-footer {
  margin-top: 4px; padding-top: 14px; border-top: 1px solid rgba(90,70,50,.08);
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
}
.rd-site-footer .brand-line { font-size: 12.5px; color: var(--ink-faint); font-weight: 650; }
.rd-site-footer .brand-line strong { color: var(--ink); font-weight: 780; }
.rd-site-footer nav { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.rd-site-footer nav a {
  font-size: 12.5px; font-weight: 720; color: #78716c; text-decoration: none !important;
}
.rd-site-footer nav a:hover { color: #c2410c; }

/* Fund tree drawer (legacy rail content) */
.fund-drawer {
  position: fixed; left: var(--rail); top: 0; bottom: 0; width: min(300px, 86vw);
  z-index: 90; background: rgba(255,253,249,.98);
  border-right: 1px solid rgba(39,35,31,.08);
  box-shadow: 12px 0 32px rgba(40,28,16,.08);
  transform: translateX(-110%); transition: transform .2s ease;
  display: flex; flex-direction: column; overflow: hidden;
}
.fund-drawer.open { transform: translateX(0); }
.fund-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px; border-bottom: 1px solid rgba(90,70,50,.08);
  font-weight: 800; font-size: 14px;
}
.fund-drawer-head button {
  border: 0; background: #f5f0e8; width: 32px; height: 32px; border-radius: 999px;
  cursor: pointer; font-size: 16px; color: #57534e;
}
body.grant-redesign .fund-drawer .side-rail {
  display: flex !important; position: relative; width: 100%; border: 0;
  background: transparent; backdrop-filter: none;
}
body.grant-redesign .fund-drawer .rail-tree { flex: 1; overflow: auto; }

/* Results / entry sit in shell width */
body.grant-redesign #home-view,
body.grant-redesign #entry-view,
body.grant-redesign #results {
  max-width: min(920px, 100%);
  margin-left: auto;
  margin-right: auto;
  padding: 0 4px;
}
body.grant-redesign #ai-inline-result {
  max-width: min(920px, 100%);
  margin: 12px auto;
  padding: 0 4px;
}

@media (max-width: 900px) {
  body.grant-redesign {
    padding-left: 0 !important;
    padding-bottom: calc(var(--bottom) + env(safe-area-inset-bottom, 0px) + 12px) !important;
  }

  /*
   * iOS 风格底栏：四等分均分 · 毛玻璃 · 细线 · 简约选中
   * rail-top / rail-bottom 用 contents 打平，4 个按钮直接参与 flex 均分
   */
  .app-rail {
    left: 0;
    right: 0;
    top: auto;
    bottom: 0;
    width: 100%;
    height: calc(var(--bottom) + env(safe-area-inset-bottom, 0px));
    min-height: calc(var(--bottom) + env(safe-area-inset-bottom, 0px));
    flex-direction: row;
    align-items: stretch;
    justify-content: stretch;
    gap: 0;
    padding: 0 0 env(safe-area-inset-bottom, 0px);
    border-right: 0;
    border-top: 0.5px solid rgba(60, 60, 67, 0.18);
    background: rgba(255, 253, 249, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    backdrop-filter: saturate(180%) blur(20px);
    box-shadow: 0 -0.5px 0 rgba(255, 255, 255, 0.6) inset;
  }
  .rail-top,
  .rail-bottom {
    display: contents; /* 子按钮成为 .app-rail 的直接 flex 项 */
  }
  .app-rail .rail-btn {
    flex: 1 1 0;
    width: 0; /* 强制四等分 */
    min-width: 0;
    max-width: none;
    min-height: var(--bottom);
    height: var(--bottom);
    margin: 0;
    padding: 6px 2px 4px;
    border-radius: 0;
    gap: 2px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #8e8e93;
    background: transparent !important;
    -webkit-tap-highlight-color: transparent;
  }
  .app-rail .rail-btn svg {
    width: 24px;
    height: 24px;
    stroke-width: 1.7;
  }
  .app-rail .rail-flag {
    width: 24px;
    height: 20px;
    border-radius: 6px;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.02em;
    background: rgba(142, 142, 147, 0.14);
    color: #636366;
  }
  .app-rail .rail-btn.active {
    color: var(--accent);
    background: transparent !important;
  }
  .app-rail .rail-btn.active .rail-flag {
    background: rgba(249, 115, 22, 0.14);
    color: #ea580c;
  }
  .app-rail .rail-btn:active {
    opacity: 0.55;
  }
  .app-rail .rail-fav-count:not([hidden]) {
    position: absolute;
    top: 4px;
    right: calc(50% - 18px);
    min-width: 15px;
    height: 15px;
    padding: 0 4px;
    border-radius: 999px;
    background: #ff3b30;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 15px;
    text-align: center;
  }
  .app-rail .rail-btn.rail-foot-item {
    position: relative;
  }
  .fund-drawer { left: 0; width: min(100%, 320px); }

  /* Topbar: brand + login only on phone */
  .rd-topbar {
    padding: 10px 14px 8px;
    gap: 8px;
  }
  .rd-brand { font-size: 16px; min-width: 0; }
  .rd-top-actions {
    flex-wrap: nowrap;
    gap: 6px;
    flex-shrink: 0;
  }
  .rd-top-actions .rd-pill:not(.primary) {
    display: none !important;
  }
  .rd-top-actions .rd-pill.primary {
    min-height: 34px;
    padding: 0 14px;
    font-size: 13px;
  }

  .rd-shell { padding: 4px 14px 40px; }
  .rd-hero { margin: 16px auto 20px; }
  .rd-hero h1 { margin-bottom: 16px; font-size: clamp(22px, 6.2vw, 30px); }


  /* Mobile: 仍保持单行胶囊；空间不够时略缩按钮字号 */
  body.grant-redesign .search-wrap.rd-search {
    width: 100%;
    max-width: 100%;
    min-height: 48px;
    padding: 4px 5px;
    border-radius: 999px;
    gap: 4px;
    flex-wrap: nowrap;
  }
  body.grant-redesign .rd-search .scope-pill,
  body.grant-redesign .rd-search .search-mode-btn {
    min-height: 32px;
    padding: 0 8px;
    font-size: 11.5px;
  }
  body.grant-redesign .rd-search #q {
    font-size: 16px;
    height: 36px;
    padding: 0 4px;
    min-width: 0;
  }
  body.grant-redesign .rd-search .search-actions {
    gap: 3px;
  }
  .rd-stats { grid-template-columns: 1fr 1fr; gap: 8px; margin: 18px 0 14px; }
  .rd-stat { min-height: 72px; padding: 12px 8px; }
  .rd-feat-grid, .rd-plans, .rd-foot-grid { grid-template-columns: 1fr; }
  .rd-dl-strip { grid-template-columns: 1fr 1fr; gap: 8px; }
  .rd-dl-item + .rd-dl-item::before { display: none; }
  .rd-matrix { font-size: 11.5px; display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .rd-matrix th, .rd-matrix td { white-space: nowrap; }
}

@media (max-width: 380px) {
  body.grant-redesign .rd-search .scope-pill,
  body.grant-redesign .rd-search .search-mode-btn {
    font-size: 11px;
    padding: 0 6px;
  }
  .rd-brand { font-size: 15px; }
}
}

/* billing cycle + creem checkout states */
.rd-billing {
  display: inline-flex; gap: 4px; margin: 10px 0 12px;
  padding: 3px; border-radius: 999px;
  background: #f5f0e8; border: 1px solid rgba(90,70,50,.08);
}
.rd-billing-btn {
  min-height: 32px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink-faint);
  font: 750 12.5px/1 inherit; cursor: pointer; font-family: inherit;
}
.rd-billing-btn.is-on {
  background: #fff; color: #c2410c;
  box-shadow: 0 1px 4px rgba(90,70,50,.08);
}
.rd-edu-status {
  margin: 0 0 12px; padding: 10px 12px; border-radius: 12px;
  font-size: 12.5px; line-height: 1.45; color: #57534e;
  background: #fff7ed; border: 1px solid rgba(249,115,22,.2);
}
.rd-edu-status[data-state="ok"] { background: #ecfdf5; border-color: rgba(16,185,129,.25); color: #065f46; }
.rd-edu-status[data-state="blocked"] { background: #fef2f2; border-color: rgba(239,68,68,.2); color: #991b1b; }
.rd-plan-btn.std-price-locked,
.rd-plan-btn.edu-locked { opacity: .72; }
.rd-plan-btn[aria-busy="true"] { opacity: .65; pointer-events: none; }

/* ── Mock-aligned browse (full page, not fund drawer) ── */
#fund-drawer { display: none !important; }
body.grant-redesign .drawer-overlay,
body.grant-redesign .drawer {
  /* detail uses full page; keep legacy drawer unused on redesign */
}
body.grant-redesign.grant-redesign #overlay.open,
body.grant-redesign #drawer.open {
  /* no-op: showDetail routes to page */
}

#entry-view {
  width: min(920px, 100%);
  margin: 0 auto;
  padding: 8px 0 40px;
}
body.grant-redesign #entry-view .view-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 14px;
}
body.grant-redesign #entry-view .back-btn {
  appearance: none;
  border: 1px solid rgba(90,70,50,.12);
  background: #fff;
  border-radius: 999px;
  min-height: 34px;
  padding: 0 14px;
  font: 750 12.5px/1 inherit;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}
body.grant-redesign #entry-view .view-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}

.rd-bc {
  display: flex; align-items: center; flex-wrap: wrap; gap: 6px;
  margin: 0 0 14px; font-size: 12.5px; color: var(--ink-faint);
}
.rd-bc-link {
  appearance: none; border: 0; background: none; padding: 0;
  color: #c2410c; font: 750 12.5px/1 inherit; cursor: pointer; font-family: inherit;
}
.rd-bc-sep { color: #cfc6b6; }
.rd-bc-cur { color: var(--ink); font-weight: 780; }

.rd-level-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 14px;
}
.rd-level-card {
  text-align: left;
  padding: 14px 14px 12px;
  border-radius: 14px;
  border: 1px solid rgba(90,70,50,.1);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s, transform .12s;
}
.rd-level-card:hover {
  border-color: rgba(249,115,22,.35);
  box-shadow: 0 4px 12px rgba(249,115,22,.1);
  transform: none;
}
.rd-level-card.on {
  border-color: transparent;
  background: linear-gradient(145deg, #fb923c, #ea580c);
  color: #fff;
  box-shadow: 0 6px 16px rgba(249,115,22,.22);
}
.rd-level-card .lv {
  font-size: 10px; font-weight: 800; letter-spacing: .04em;
  color: #a8a29e; margin-bottom: 4px;
}
.rd-level-card.on .lv { color: rgba(255,255,255,.85); }
.rd-level-card strong { display: block; font-size: 16px; font-weight: 820; margin-bottom: 4px; }
.rd-level-card p { margin: 0; font-size: 12px; line-height: 1.45; color: var(--ink-faint); }
.rd-level-card.on p { color: rgba(255,255,255,.88); }
.rd-level-card .n {
  margin-top: 10px; font-size: 13px; font-weight: 800;
  font-variant-numeric: tabular-nums; color: #c2410c;
}
.rd-level-card.on .n { color: #fff; }

.rd-browse-hint {
  margin: 0 0 12px; font-size: 12.5px; line-height: 1.5; color: var(--ink-faint);
}

.rd-panel-block { margin: 0 0 12px; }
.rd-region-block { margin: 0 0 12px; }
.rd-sub {
  display: block; font-size: 11px; font-weight: 800; color: #a8a29e;
  margin: 0 0 8px; letter-spacing: .02em;
}
.rd-ministry-row, .rd-prov-grid {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.rd-fund-chip, .rd-prov-chip {
  appearance: none; border: 1px solid rgba(90,70,50,.12);
  background: #fff; border-radius: 999px;
  min-height: 34px; padding: 0 12px;
  font: 750 12px/1 inherit; color: var(--ink-soft);
  cursor: pointer; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px;
}
.rd-fund-chip b, .rd-prov-chip small {
  font-weight: 800; font-variant-numeric: tabular-nums; color: #c2410c; font-size: 11.5px;
}
.rd-prov-chip.on {
  background: linear-gradient(180deg, #fb923c, #f97316);
  border-color: transparent; color: #fff;
}
.rd-prov-chip.on small { color: #fff; }
.rd-prov-chip.muted { opacity: .55; }
.rd-prov-chip.hot { border-color: rgba(249,115,22,.28); }

/* Fund cards — mock layout */
body.grant-redesign .fund-list.rd-fund-list,
body.grant-redesign .rd-fund-list {
  display: grid; gap: 10px;
}
body.grant-redesign .fund-item.rd-fund-item,
body.grant-redesign .rd-fund-item {
  display: flex; align-items: stretch; justify-content: space-between; gap: 14px;
  width: 100%; text-align: left;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(90,70,50,.1);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
body.grant-redesign .rd-fund-item:hover {
  border-color: rgba(249,115,22,.35);
  box-shadow: 0 4px 14px rgba(249,115,22,.1);
}
body.grant-redesign .rd-fund-item .fund-item-main { min-width: 0; flex: 1; }
body.grant-redesign .rd-fund-item .fund-item-title,
body.grant-redesign .rd-fund-item h3 {
  margin: 0 0 4px; font-size: 15px; font-weight: 800; color: var(--ink);
}
body.grant-redesign .rd-fund-item .fund-item-desc {
  margin: 0 0 8px; font-size: 12.5px; line-height: 1.45; color: var(--ink-faint);
}
body.grant-redesign .rd-fund-item .fund-item-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
}
body.grant-redesign .rd-fund-item .fund-item-badge {
  display: inline-flex; align-items: center;
  min-height: 22px; padding: 0 8px; border-radius: 999px;
  background: #f5f0e8; font-size: 11px; font-weight: 750; color: var(--ink-soft);
}
body.grant-redesign .rd-fund-item .fund-item-badge.accent {
  background: #fff7ed; color: #c2410c;
}
body.grant-redesign .rd-fund-item .count {
  flex-shrink: 0; min-width: 72px;
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center;
  gap: 2px;
}
body.grant-redesign .rd-fund-item .count b {
  font-size: 18px; font-weight: 820; color: #c2410c;
  font-variant-numeric: tabular-nums;
}
body.grant-redesign .rd-fund-item .count small {
  font-size: 11px; color: var(--ink-faint); font-weight: 650;
}

/* Full-page project detail */
.rd-detail-page {
  background: #fff;
  border: 1px solid rgba(90,70,50,.08);
  border-radius: 16px;
  padding: 18px 18px 22px;
  box-shadow: 0 8px 24px rgba(39,35,31,.05);
}
.rd-detail-title {
  margin: 10px 0 16px;
  font-size: clamp(18px, 3.5vw, 22px);
  font-weight: 820;
  line-height: 1.35;
  color: var(--ink);
  letter-spacing: -.02em;
}

@media (max-width: 900px) {
  .rd-level-cards { grid-template-columns: 1fr; }
  body.grant-redesign .rd-fund-item {
    flex-direction: column;
    align-items: flex-start;
  }
  body.grant-redesign .rd-fund-item .count {
    flex-direction: row; align-items: baseline; gap: 8px;
    min-width: 0;
  }
}


/* Analysis / entry: keep orange brand accents, flat not flashy */
body.grant-redesign #entry-view .stat-card {
  background: #fff !important;
  border: 1px solid rgba(90,70,50,.1) !important;
  box-shadow: none !important;
  border-radius: 12px !important;
}
body.grant-redesign #entry-view .stat-num {
  color: #c2410c !important;
  font-weight: 800 !important;
}
body.grant-redesign #entry-view .overview-section {
  background: #fff;
  border: 1px solid rgba(90,70,50,.08);
  border-radius: 12px;
  padding: 14px 14px 12px;
  margin-bottom: 12px;
  box-shadow: none;
}
body.grant-redesign #entry-view .ov-bar-fill {
  background: linear-gradient(90deg, #fb923c, #f97316) !important;
  opacity: 1;
}
body.grant-redesign #entry-view .ov-bar-fill.cat-fill {
  background: linear-gradient(90deg, #fdba74, #f97316) !important;
}
/* Search chips: orange selected (match site brand) — override legacy app.css if needed */
body.grant-redesign .search-mode-btn.active,
body.grant-redesign .scope-pill.on,
body.grant-redesign .rd-search .scope-pill.on,
body.grant-redesign .rd-search .search-mode-btn.active {
  background: linear-gradient(180deg, #fb923c, #f97316) !important;
  color: #fff !important;
  box-shadow: 0 2px 8px rgba(249,115,22,.22) !important;
  border-color: transparent !important;
}
body.grant-redesign .search-mode-btn:not(.active):hover {
  background: rgba(249,115,22,.1) !important;
  color: #c2410c !important;
}
/* Primary CTAs orange */
body.grant-redesign .rd-plan-btn.primary,
body.grant-redesign .rd-pill.primary {
  background: linear-gradient(180deg, #fb923c, #f97316) !important;
  color: #fff !important;
  box-shadow: 0 4px 12px rgba(249,115,22,.22) !important;
}
body.grant-redesign .rd-plan.hot {
  border-color: rgba(249,115,22,.35);
  background: linear-gradient(180deg, #fffdfb, #fff7ed);
  box-shadow: 0 8px 20px rgba(249,115,22,.08);
}
body.grant-redesign .rd-plan-tag {
  background: linear-gradient(135deg, #fb923c, #ea580c);
}
body.grant-redesign .rd-fund-item .count b {
  color: #c2410c !important;
}
body.grant-redesign .rd-plan .price b {
  color: #c2410c;
}

/* ═══════════════════════════════════════════════════════════
   Analysis page — mock-aligned (grant-redesign-v1 view-dash)
   ═══════════════════════════════════════════════════════════ */
.rd-analysis-page { min-width: 0; }
.rd-analysis-sec {
  margin: 0 0 14px;
  padding: 18px 16px 20px;
  border-radius: 18px;
  background: rgba(255,255,255,.86);
  border: 1px solid rgba(90,70,50,.07);
  box-shadow: 0 8px 24px rgba(40,28,16,.04);
}

/* Scope chips */
.quota-meter {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px;
}
.quota-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 11px; border-radius: 999px;
  background: #fff; border: 1px solid rgba(90,70,50,.1);
  font-size: 12px; font-weight: 700; color: var(--ink-soft);
}
.quota-chip b { color: #c2410c; font-variant-numeric: tabular-nums; }

/* Year filter row + level/cat segments (mock) */
.browse-step {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-bottom: 10px;
}
.browse-step .lbl {
  font-size: 12px; font-weight: 750; color: var(--ink-faint); min-width: 2.5em;
}
.rd-analysis-page .seg {
  display: inline-flex; gap: 4px; padding: 4px;
  border-radius: 999px; background: #f5f0e8; border: 1px solid rgba(90,70,50,.08);
}
.rd-analysis-page .seg button {
  appearance: none; border: 0; min-height: 32px; padding: 0 14px; border-radius: 999px;
  background: transparent; font-size: 12.5px; font-weight: 720; color: var(--ink-faint);
  cursor: pointer; font-family: inherit;
}
.rd-analysis-page .seg button.on {
  background: linear-gradient(180deg, #fb923c, #f97316);
  color: #fff; box-shadow: 0 4px 12px rgba(249,115,22,.25);
}
.year-select {
  appearance: none;
  min-height: 36px; min-width: 160px; max-width: 100%;
  padding: 0 36px 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(90,70,50,.12);
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2378716c' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
  font: 720 13px/1 var(--sans, inherit);
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(40,28,16,.04);
  font-family: inherit;
}
.year-select:hover { border-color: rgba(249,115,22,.35); }
.year-select:focus {
  outline: none;
  border-color: rgba(249,115,22,.5);
  box-shadow: 0 0 0 3px rgba(249,115,22,.12);
}
.browse-hint {
  margin: 0 0 12px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.5;
}
.sec-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px;
}
.sec-head h2 { font-size: 15px; font-weight: 820; letter-spacing: -.02em; margin: 0; color: var(--ink); }
.year-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 12px;
  align-items: center; justify-content: flex-start;
}
.rd-source-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid #ebe6dc; background: #fff;
  font-size: 12px; font-weight: 650; color: var(--ink-soft);
}
.rd-source-chip b {
  font-weight: 800; font-variant-numeric: tabular-nums;
  color: #c2410c; font-size: 11.5px;
}

/* Stats 6-up (warm paper cards) */
.rd-analysis-page .stats,
.dash-analysis .stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0 0 14px;
}
.rd-analysis-page .stats.stats-6,
.dash-analysis .stats.stats-6 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
.rd-analysis-page .stat,
.dash-analysis .stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px 12px;
  border-radius: 14px;
  min-height: 88px;
  border: 0;
  background: linear-gradient(180deg, #fffbf7 0%, #fff3e8 50%, #ffe8d4 100%);
  box-shadow:
    0 1px 2px rgba(120, 80, 40, 0.04),
    0 8px 20px rgba(180, 120, 70, 0.09);
}
.rd-analysis-page .stats.stats-6 .stat,
.dash-analysis .stats.stats-6 .stat {
  min-height: 78px; padding: 12px 8px;
}
.rd-analysis-page .stat b,
.dash-analysis .stat b {
  display: block;
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
  color: #b45309;
}
.rd-analysis-page .stats.stats-6 .stat b,
.dash-analysis .stats.stats-6 .stat b {
  font-size: clamp(16px, 1.8vw, 22px);
}
.rd-analysis-page .stat small,
.dash-analysis .stat small {
  font-size: 12.5px;
  font-weight: 600;
  color: #78716c;
}

/* Insight */
.insight-box {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px;
  background: linear-gradient(180deg, #fffbf7, #fff7ed);
  border: 1px solid rgba(249,115,22,.16);
  font-size: 12.5px; color: #9a3412; line-height: 1.55;
}
.insight-box strong { color: #c2410c; }

/* Chart cards */
.dash-analysis { margin-top: 4px; }
.chart-card {
  background: #fff; border-radius: 14px; padding: 16px 16px 14px;
  border: 1px solid rgba(90,70,50,.08);
  box-shadow: 0 4px 14px rgba(40,28,16,.04);
  min-width: 0; margin-bottom: 12px;
}
.chart-card .chart-title {
  font-size: 14px; font-weight: 800; color: var(--deep, var(--ink)); margin: 0 0 4px;
  letter-spacing: -.01em;
}
.chart-card .chart-sub {
  font-size: 12px; color: var(--ink-faint); margin: 0 0 12px; line-height: 1.45;
}
.chart-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 4px;
}
.chart-head .chart-title { margin-bottom: 0; }
.dash-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 0;
}
.dash-col { display: flex; flex-direction: column; min-width: 0; }

/* Horizontal bars */
.bar-chart { font-size: 13px; }
.bar-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 5px;
}
.bar-label {
  width: 88px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-align: right; font-size: 12px; color: var(--ink-soft); flex-shrink: 0;
  font-weight: 650;
}
.bar-label.wide { width: 108px; }
.bar-track {
  flex: 1; height: 14px; background: #f5f0e8; border-radius: 4px; overflow: hidden;
}
.bar-fill {
  height: 100%; background: var(--deep, #292524); border-radius: 4px;
  min-width: 2px; opacity: .88;
}
.bar-fill.accent { background: var(--accent, #f97316); opacity: 1; }
.bar-fill.muted { background: #a8a29e; opacity: .75; }
.bar-val {
  width: 40px; text-align: right; font-size: 11.5px; font-weight: 720;
  color: var(--ink-soft); flex-shrink: 0; font-variant-numeric: tabular-nums;
}

/* Year column bars */
.year-bar-chart {
  min-height: 168px; display: flex; align-items: end; gap: 8px;
  overflow-x: auto; padding: 6px 2px 2px;
}
.year-bar-col {
  display: grid; grid-template-rows: 18px 110px 18px;
  justify-items: center; align-items: end; min-width: 36px; flex: 1;
  color: var(--ink-soft);
}
.year-bar-value {
  font-size: 11px; font-weight: 780; color: var(--deep, var(--ink));
  font-variant-numeric: tabular-nums;
}
.year-bar-track {
  width: 28px; height: 110px; display: flex; align-items: end; justify-content: center;
}
.year-bar-fill {
  display: block; width: 28px; border-radius: 5px 5px 2px 2px;
  background: #2563eb; min-height: 4px;
}
.year-bar-col.recent .year-bar-fill { background: var(--accent, #f97316); }
.year-bar-col.prev .year-bar-fill { background: #a8a29e; }
.year-bar-label { font-size: 11px; font-weight: 650; }

/* Tags */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

.keyword-strip.keyword-strip-compact,
.tag-cloud.keyword-strip-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: flex-start;
}

.compact-keyword {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid rgba(39,35,31,.08);
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  box-shadow: 0 1px 0 rgba(255,255,255,.9) inset;
  line-height: 1;
  max-width: 100%;
  white-space: nowrap;
}

.compact-keyword .compact-keyword-word {
  display: inline-block;
  letter-spacing: -.01em;
}

.compact-keyword .compact-keyword-count {
  display: inline-block;
  font-size: .72em;
  color: rgba(39,35,31,.56);
  font-weight: 700;
  letter-spacing: 0;
}

.keyword-strip.keyword-strip-compact .compact-keyword {
  margin-bottom: 2px;
}

.drill-keywords .compact-keyword {
  padding: 5px 11px;
}

.drill-keywords .compact-keyword .compact-keyword-count {
  font-size: .76em;
}
.kw-tag {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px; padding: 0 11px; border-radius: 999px;
  background: #fff7ed; border: 1px solid rgba(249,115,22,.18);
  font-size: 12.5px; font-weight: 720; color: #9a3412;
}
.kw-tag em {
  font-style: normal; font-size: 11px; font-weight: 800;
  color: #c2410c; opacity: .85;
}
.kw-tag.cool {
  background: #f5f0e8; border-color: rgba(90,70,50,.1); color: #57534e;
}
.kw-tag.cool em { color: #78716c; }

/* Keyword change table (mock optional) */
.kw-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.kw-table th, .kw-table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid rgba(90,70,50,.08);
}
.kw-table th {
  font-size: 11px; font-weight: 780; color: var(--ink-faint);
  letter-spacing: .02em; background: #faf7f0;
}
.kw-table td { color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.kw-table tr:last-child td { border-bottom: 0; }
.kw-table .num { text-align: right; }
.delta-up { color: #b45309; font-weight: 800; }
.delta-down { color: #64748b; font-weight: 800; }
.delta-flat { color: var(--ink-faint); font-weight: 700; }

.empty-analysis {
  padding: 28px 16px; text-align: center; color: var(--ink-faint);
  font-size: 13.5px; line-height: 1.5;
}

/* Project list under analysis */
.rd-project-list { display: grid; gap: 8px; }
.rd-project-row {
  appearance: none; width: 100%; text-align: left;
  display: block; padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(90,70,50,.1);
  background: #fff;
  cursor: pointer; font-family: inherit; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.rd-project-row:hover {
  border-color: rgba(249,115,22,.35);
  box-shadow: 0 4px 12px rgba(249,115,22,.08);
}
.rd-project-main strong {
  display: block; font-size: 13.5px; font-weight: 780;
  color: var(--ink); line-height: 1.4; margin-bottom: 6px;
}
.rd-project-main .meta {
  display: flex; flex-wrap: wrap; gap: 8px 12px;
  font-size: 11.5px; font-weight: 650; color: var(--ink-faint);
}

@media (max-width: 900px) {
  .rd-analysis-page .stats,
  .dash-analysis .stats,
  .rd-analysis-page .stats.stats-6,
  .dash-analysis .stats.stats-6 {
    grid-template-columns: 1fr 1fr;
  }
  .dash-grid { grid-template-columns: 1fr; }
  .bar-label, .bar-label.wide { width: 72px; }
  .rd-analysis-sec { padding: 14px 12px 16px; }
}

/* ═══════════════════════════════════════════════════
   Settings shell (mock view-settings · Journal style)
   ═══════════════════════════════════════════════════ */
.settings-scrim {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(28,22,12,.45); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.settings-scrim.open { display: flex; }
.settings-shell {
  position: relative;
  width: min(920px, 100%);
  height: min(86vh, 780px);
  min-height: min(560px, 86vh);
  max-height: min(90vh, 840px);
  display: flex; flex-direction: column;
  background: #fffdf9; border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 60px rgba(40,28,16,.18);
  border: 1px solid rgba(90,70,50,.08);
}
.settings-layout {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}
.settings-nav {
  padding: 18px 12px; background: #faf7f0;
  border-right: 1px solid rgba(90,70,50,.08);
  display: flex; flex-direction: column; gap: 4px;
  height: 100%; min-height: 0; overflow: auto;
}
.settings-nav-title {
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #a8a29e; padding: 4px 10px 10px;
}
.settings-nav button {
  appearance: none; border: 0; text-align: left;
  min-height: 40px; padding: 0 12px; border-radius: 10px;
  background: transparent; font: 720 13.5px/1 var(--sans, inherit);
  color: #57534e; cursor: pointer; font-family: inherit;
}
.settings-nav button:hover { background: rgba(249,115,22,.08); color: #c2410c; }
.settings-nav button.active { background: #fff7ed; color: #c2410c; font-weight: 780; }
.settings-body {
  position: relative; padding: 22px 22px 24px; overflow: auto;
  min-height: 0; height: 100%;
}
.settings-back {
  display: none;
  appearance: none; border: 0; background: transparent;
  color: #c2410c; font: inherit; font-size: 14px; font-weight: 650;
  padding: 0 0 12px; cursor: pointer; align-items: center; gap: 4px;
  font-family: inherit;
}
.settings-close {
  position: absolute; top: 12px; right: 12px; z-index: 5;
  width: 36px; height: 36px; border: 0; border-radius: 999px;
  background: #f5f0e8; font-size: 20px; cursor: pointer; color: #57534e;
  font-family: inherit; line-height: 1;
}
.settings-section[hidden] { display: none !important; }
.settings-section-title {
  margin: 0 0 14px; font-size: 18px; font-weight: 820; letter-spacing: -.02em;
  padding-right: 40px;
}
.me-hero {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 14px; border-radius: 14px; background: #fff;
  border: 1px solid rgba(90,70,50,.08); margin-bottom: 12px;
}
.me-avatar {
  width: 48px; height: 48px; border-radius: 14px;
  background: linear-gradient(180deg, #fb923c, #f97316);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 820; font-size: 18px; flex-shrink: 0;
}
.me-hero h1 {
  margin: 0; font-size: 17px; font-weight: 820; line-height: 1.25;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.me-hero .name-text { line-height: 1.25; display: inline-flex; align-items: center; }
.me-tier, .me-rank {
  display: inline-flex; align-items: center; justify-content: center;
  height: 24px; min-height: 24px; max-height: 24px;
  padding: 0 9px; border-radius: 999px;
  font-size: 11px; font-weight: 800; box-sizing: border-box; flex-shrink: 0;
}
.me-tier { background: #f5f0e8; color: #57534e; padding-top: 1px; line-height: 1; }
.me-tier.pro, .me-tier.max { background: #fff7ed; color: #c2410c; }
.me-rank { line-height: 1; }
.me-rank.r1 { background: #f5f0e8; color: #78716c; }
.me-rank.r2 { background: #ffedd5; color: #c2410c; }
.me-rank.r3 { background: #fed7aa; color: #9a3412; }
.me-rank.r4 { background: linear-gradient(180deg,#fb923c,#f97316); color: #fff; }
.me-rank.r5 { background: linear-gradient(135deg,#1f2c4c,#c2410c); color: #fff; }
.me-meta { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-faint); }
.me-stat-strip {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px;
  margin-bottom: 14px;
}
.me-stat-item {
  padding: 12px 10px; border-radius: 12px; text-align: center;
  background: linear-gradient(180deg, #fffbf7, #fff3e8); border: 0;
}
.me-stat-item strong {
  display: block; font-size: 18px; font-weight: 820; color: #b45309; margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.me-stat-item span { font-size: 11px; font-weight: 650; color: #78716c; }
.settings-link-row {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; min-height: 48px; padding: 0 14px; margin: 0 0 6px;
  border-radius: 12px; border: 1px solid rgba(90,70,50,.08);
  background: #fff; font: 720 13.5px/1 var(--sans, inherit); color: var(--ink);
  cursor: pointer; text-decoration: none !important; font-family: inherit;
  box-sizing: border-box;
}
.settings-link-row:hover { border-color: rgba(249,115,22,.3); }
.settings-link-row span { color: #a8a29e; }
.settings-hint { font-size: 12.5px; color: var(--ink-faint); margin: 0 0 12px; line-height: 1.5; }
.settings-hint strong { color: #c2410c; }

.s-plans {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0 0 12px;
}
.s-plan {
  position: relative; display: flex; flex-direction: column;
  padding: 14px 12px 12px; border-radius: 14px; background: #fff;
  border: 1px solid rgba(90, 70, 50, 0.08);
  box-shadow: 0 4px 14px rgba(40, 28, 16, 0.04); min-width: 0;
}
.s-plan.hot {
  border-color: rgba(249, 115, 22, 0.35);
  background: linear-gradient(180deg, #fffdfb, #fff7ed);
  box-shadow: 0 10px 28px rgba(249, 115, 22, 0.1);
}
.s-plan-tag {
  position: absolute; top: 10px; right: 10px;
  font-size: 9px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, #fb923c, #ea580c);
  border-radius: 999px; padding: 2px 7px;
}
.s-plan h3 {
  margin: 0 0 2px; font-size: 15px; font-weight: 820;
  padding-right: 40px;
}
.s-plan .desc { margin: 0 0 8px; font-size: 11.5px; color: var(--ink-faint); line-height: 1.35; }
.s-plan .price { display: flex; align-items: baseline; gap: 3px; margin-bottom: 2px; }
.s-plan .price b { font-size: 22px; font-weight: 820; letter-spacing: -.03em; color: #b45309; }
.s-plan .price span { font-size: 12px; color: var(--ink-faint); font-weight: 650; }
.s-plan .was { margin: 0 0 8px; font-size: 11px; color: #a8a29e; text-decoration: line-through; }
.s-plan ul { list-style: none; margin: 0 0 10px; padding: 0; flex: 1; }
.s-plan li {
  position: relative; padding: 0 0 0 14px; margin: 0 0 5px;
  font-size: 11.5px; color: #57534e; line-height: 1.35;
}
.s-plan li::before {
  content: "✓"; position: absolute; left: 0; color: #ea580c; font-weight: 900; font-size: 10px;
}
.s-plan li.no { color: #a8a29e; }
.s-plan li.no::before { content: "×"; color: #c4b5a5; font-weight: 900; }
.s-plan-actions { display: flex; flex-direction: column; gap: 5px; margin-top: auto; }
.s-plan-actions .plan-btn,
.settings-shell .plan-btn {
  appearance: none; border: 0; width: 100%; min-height: 34px; font-size: 12px; padding: 0 8px;
  border-radius: 999px; font-weight: 750; cursor: pointer; font-family: inherit;
}
.s-plan-actions .plan-btn.primary,
.settings-shell .plan-btn.primary {
  background: linear-gradient(180deg, #fb923c, #f97316); color: #fff;
  box-shadow: 0 4px 12px rgba(249,115,22,.22);
}
.s-plan-actions .plan-btn.ghost,
.settings-shell .plan-btn.ghost {
  background: #f5f0e8; color: #57534e;
}
.s-plan-actions .plan-btn.edu { min-height: 30px; font-size: 11px; background: #fff7ed; color: #c2410c; border: 1px solid rgba(249,115,22,.2); }
.s-billing-toggle {
  display: inline-flex; gap: 4px; padding: 4px; margin: 0 0 12px;
  border-radius: 999px; background: #f5f0e8; border: 1px solid rgba(90,70,50,.08);
}
.s-billing-toggle button {
  appearance: none; border: 0; min-height: 32px; padding: 0 14px; border-radius: 999px;
  background: transparent; font: 720 12.5px/1 var(--sans, inherit); color: var(--ink-faint);
  cursor: pointer; font-family: inherit;
}
.s-billing-toggle button.on {
  background: linear-gradient(180deg, #fb923c, #f97316);
  color: #fff; box-shadow: 0 4px 12px rgba(249,115,22,.25);
}
.s-billing-toggle button em {
  font-style: normal; font-size: 10px; font-weight: 800; margin-left: 4px; opacity: .9;
}

.me-activity-card {
  margin: 0 0 14px; padding: 14px; border-radius: 14px;
  background: #fff; border: 1px solid rgba(90,70,50,.08);
}
.me-activity-card h3 { margin: 0 0 4px; font-size: 13.5px; font-weight: 800; color: var(--deep, var(--ink)); }
.me-activity-card .sub { margin: 0 0 12px; font-size: 12px; color: var(--ink-faint); }
.me-summary-strip {
  display: flex; flex-wrap: wrap; margin: 0 0 12px; border-radius: 12px; overflow: hidden;
  border: 1px solid rgba(90,70,50,.08); background: #faf7f0;
}
.me-summary-item {
  flex: 1 1 0; min-width: 72px; padding: 10px 8px; text-align: center;
  border-right: 1px solid rgba(90,70,50,.06);
}
.me-summary-item:last-child { border-right: 0; }
.me-summary-item strong {
  display: block; font-size: 16px; font-weight: 820; color: #b45309; margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}
.me-summary-item span { font-size: 10.5px; font-weight: 650; color: #78716c; }
.me-rec-tabs {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 10px;
  padding: 4px; border-radius: 999px; background: #f5f0e8;
  border: 1px solid rgba(90,70,50,.06);
}
.me-rec-tabs button {
  appearance: none; border: 0; min-height: 32px; padding: 0 12px; border-radius: 999px;
  background: transparent; font: 720 12px/1 var(--sans, inherit); color: var(--ink-faint);
  cursor: pointer; font-family: inherit;
}
.me-rec-tabs button.on {
  background: linear-gradient(180deg, #fb923c, #f97316);
  color: #fff; box-shadow: 0 3px 10px rgba(249,115,22,.25);
}
.me-rec-list { display: flex; flex-direction: column; gap: 0; }
.me-rec-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 4px; border-bottom: 1px solid rgba(90,70,50,.08);
}
.me-rec-item:last-child { border-bottom: 0; }
.me-rec-item .t {
  flex-shrink: 0; width: 72px; font-size: 11px; font-weight: 700; color: #a8a29e;
  font-variant-numeric: tabular-nums; padding-top: 2px;
}
.me-rec-item .body { flex: 1; min-width: 0; }
.me-rec-item .body strong {
  display: block; font-size: 13px; font-weight: 750; color: var(--ink);
  line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.me-rec-item .body p { margin: 3px 0 0; font-size: 11.5px; color: var(--ink-faint); line-height: 1.4; }
.me-rec-item .tag {
  display: inline-flex; min-height: 18px; padding: 0 6px; border-radius: 999px;
  font-size: 10px; font-weight: 800; margin-right: 4px;
  background: #fff7ed; color: #c2410c;
}
.me-rec-item .tag.gray { background: #f5f0e8; color: #78716c; }
.me-rec-empty { text-align: center; padding: 20px 8px; font-size: 13px; color: var(--ink-faint); }
.fav-empty { text-align: center; padding: 28px 12px; color: var(--ink-faint); font-size: 13.5px; }
.settings-fav-list { display: grid; gap: 8px; }
.settings-fav-row {
  appearance: none; width: 100%; text-align: left; padding: 12px 14px;
  border-radius: 12px; border: 1px solid rgba(90,70,50,.1); background: #fff;
  cursor: pointer; font-family: inherit; color: inherit;
}
.settings-fav-row:hover { border-color: rgba(249,115,22,.35); }
.settings-fav-row strong { display: block; font-size: 13.5px; font-weight: 780; margin-bottom: 6px; line-height: 1.4; }
.settings-fav-row .meta { display: flex; flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: var(--ink-faint); font-weight: 650; }

.me-gift-card { display: grid; gap: 14px; }
.gift-redeem, .gift-admin {
  display: grid; gap: 10px; padding: 14px 16px;
  border: 1px solid rgba(90,70,50,.1); border-radius: 14px; background: #fff;
}
.gift-redeem strong, .gift-admin strong {
  display: block; font-size: 14px; font-weight: 800; color: var(--ink);
}
.gift-redeem p, .gift-admin p {
  margin: 4px 0 0; color: var(--ink-faint); font-size: 12.5px; line-height: 1.45;
}
.gift-redeem-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
}
.gift-redeem input {
  flex: 1 1 180px; min-height: 40px; padding: 0 12px;
  border: 1px solid rgba(90,70,50,.12); border-radius: 10px;
  background: #fff; color: var(--ink); font: inherit;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.gift-redeem button {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 10px;
  background: linear-gradient(180deg, #fb923c, #f97316); color: #fff;
  font: inherit; font-weight: 750; cursor: pointer;
  box-shadow: 0 4px 12px rgba(249,115,22,.22);
}
.gift-message { margin: 0; font-size: 13px; font-weight: 650; color: #2f6b45; }
.gift-message.is-error { color: #a33a36; }
.gift-redeem small { color: var(--ink-faint); font-size: 12px; }

@media (max-width: 720px) {
  /* 手机：全屏两级设置（对齐 Journal） */
  .settings-scrim {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    background: #fff;
  }
  .settings-scrim.open { display: block; }
  .settings-shell {
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: 0;
    box-shadow: none;
    background: #fff;
  }
  .settings-layout {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 100%;
    grid-template-columns: none;
    overflow: hidden;
  }
  /* 一级：全屏菜单列表 */
  .settings-layout:not(.settings-subpage) .settings-nav {
    display: flex !important;
    position: absolute;
    inset: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    border-right: 0;
    border-bottom: 0;
    background: #fff;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 2;
    box-sizing: border-box;
  }
  .settings-layout:not(.settings-subpage) .settings-body {
    display: none !important;
  }
  .settings-layout:not(.settings-subpage) .settings-nav-title {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: #1c1917;
    text-transform: none;
    letter-spacing: -.03em;
    margin: 8px 4px 20px;
    padding: 0;
    line-height: 1.15;
  }
  .settings-layout:not(.settings-subpage) .settings-nav button {
    flex: 0 0 auto;
    width: 100%;
    min-height: 52px;
    white-space: normal;
    padding: 16px 4px;
    font-size: 16px;
    font-weight: 550;
    border-radius: 0;
    border: 0;
    border-bottom: 1px solid #ebe9e6;
    background: transparent;
    margin: 0;
    color: #1c1917;
  }
  .settings-layout:not(.settings-subpage) .settings-nav button.active,
  .settings-layout:not(.settings-subpage) .settings-nav button:hover {
    background: transparent;
    color: #1c1917;
    box-shadow: none;
    font-weight: 550;
  }
  /* 二级：全屏内容 + 返回 */
  .settings-layout.settings-subpage .settings-nav {
    display: none !important;
  }
  .settings-layout.settings-subpage .settings-body {
    display: block !important;
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
    padding: calc(12px + env(safe-area-inset-top, 0px)) 16px calc(28px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
    background: #fff;
    z-index: 2;
  }
  .settings-layout.settings-subpage .settings-back {
    display: inline-flex;
    position: sticky;
    top: 0;
    z-index: 3;
    margin: 0 0 8px;
    padding: 8px 0 12px;
    background: #fff;
  }
  .settings-close {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: 10px;
  }
  .s-plans { grid-template-columns: 1fr; }
  .me-stat-strip { grid-template-columns: 1fr 1fr; }
  .settings-section-title { padding-right: 44px; }
}

/* Auth modal above settings panel */
.auth-modal-overlay { z-index: 500 !important; }
.auth-modal-overlay.open { display: flex !important; }
body.grant-redesign .auth-modal {
  background: #fffdf9;
  border: 1px solid rgba(90,70,50,.1);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(40,28,16,.18);
}
body.grant-redesign #rd-login-btn.is-logged-in {
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
