/* ===========================================================
   IFA系统 · App Shell 交互层
   三端断点：手机 <768 ／ 平板 768–1180 ／ 桌面 >1180
   设计原则：导航为 fixed 浮层，内容区用 margin 让位，避免 DOM 嵌套
   =========================================================== */
:root{
  --rail:76px;          /* 平板图标导航栏 */
  --rail-lg:236px;      /* 桌面宽侧栏 */
  --bar-h:56px;         /* 手机顶栏 */
  --tab-h:58px;         /* 手机底部标签栏 */
  --pb:env(safe-area-inset-bottom,0px);
  --sheet-bg:rgba(12,20,34,.44);
}
html,body{overflow-x:hidden}
body.app{background:var(--cream);-webkit-tap-highlight-color:transparent}
@media(max-width:767.98px){ body.app{overscroll-behavior-y:contain} }

/* 内容区让位 */
.app-main{min-height:100vh}
@media(max-width:767.98px){
  .app-main{padding-top:var(--bar-h);padding-bottom:calc(var(--tab-h) + var(--pb) + 16px)}
}
@media(min-width:768px){
  .app-main{margin-left:var(--rail);padding-top:60px}
}
@media(min-width:1181px){
  .app-main{margin-left:var(--rail-lg)}
}
.page{max-width:1120px;margin:0 auto;padding:16px}
@media(min-width:768px){ .page{padding:22px 24px 40px} }
.page-narrow{max-width:820px}

/* ---------- 手机顶栏 AppBar ---------- */
.appbar{
  position:fixed;left:0;right:0;top:0;height:var(--bar-h);z-index:60;display:none;
  align-items:center;gap:2px;padding:0 6px;
  background:rgba(255,255,255,.94);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
  border-bottom:1px solid var(--line);
}
.appbar .ab-title{flex:1;min-width:0;font-size:16px;font-weight:600;color:var(--navy);
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-left:8px}
.appbar.has-back .ab-title{padding-left:0}
.ab-btn{width:42px;height:42px;flex:0 0 auto;display:flex;align-items:center;justify-content:center;
  border:0;background:none;border-radius:12px;color:var(--navy);cursor:pointer;font-size:20px}
.ab-btn:active{background:#EEF1F6}
.ab-btn svg{width:21px;height:21px}
.ab-actions{display:flex;align-items:center;gap:4px}
@media(max-width:767.98px){ .appbar{display:flex} }
@media(prefers-reduced-motion:no-preference){
  .appbar.elevated{box-shadow:0 2px 14px rgba(0,32,72,.07);border-bottom-color:transparent}
}

/* ---------- 手机底部标签栏 ---------- */
.tabbar{
  position:fixed;left:0;right:0;bottom:0;z-index:60;display:none;
  height:calc(var(--tab-h) + var(--pb));padding-bottom:var(--pb);
  background:rgba(255,255,255,.96);-webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
  border-top:1px solid var(--line);transition:transform .26s ease,opacity .26s ease;
}
.tb-row{display:flex;height:var(--tab-h)}
.tb-item{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:2px;
  font-size:11px;font-weight:500;color:var(--sub);position:relative;text-decoration:none}
.tb-item svg{width:22px;height:22px}
.tb-item.on{color:var(--red)}
.tb-item.on::before{content:"";position:absolute;top:0;width:24px;height:3px;border-radius:0 0 3px 3px;background:var(--red)}
.tb-item:active{background:#F5F7FA}
@media(max-width:767.98px){ .tabbar{display:block} }
html.pushed .tabbar{transform:translateY(100%);opacity:0;pointer-events:none}

/* ---------- 平板 / 桌面 左侧导航栏 ---------- */
.rail{
  position:fixed;left:0;top:0;bottom:0;width:var(--rail);z-index:70;display:none;
  flex-direction:column;background:#fff;border-right:1px solid var(--line);
  padding:10px 0 calc(10px + var(--pb));
}
.rail-brand{display:flex;align-items:center;justify-content:center;gap:10px;height:58px;flex:0 0 auto;padding:0 8px}
.rail-brand img{height:30px;width:auto;max-width:100%}
.rail-brand .rb-txt{display:none;font-size:15px;font-weight:600;color:var(--navy);line-height:1.3}
.rail-brand .rb-txt span{display:block;font-size:11px;font-weight:400;color:var(--sub);white-space:nowrap}
.rail-nav{flex:1;display:flex;flex-direction:column;gap:4px;padding:10px 10px;overflow-y:auto}
.rail-item{display:flex;flex-direction:column;align-items:center;gap:4px;padding:10px 4px;
  border-radius:12px;color:var(--sub);font-size:11px;font-weight:500;text-decoration:none;text-align:center}
.rail-item svg{width:22px;height:22px;flex:0 0 auto}
.rail-item.on{background:#FDF0F4;color:var(--red)}
@media(hover:hover){ .rail-item:hover{background:var(--cream);color:var(--navy)} }
.rail-foot{flex:0 0 auto;padding:8px 10px;border-top:1px solid var(--line)}
.rail-toggle{display:none}
.rail-user{display:flex;align-items:center;gap:8px;padding:6px;border-radius:12px;cursor:pointer}
.rail-user .av{width:32px;height:32px;flex:0 0 auto;border-radius:50%;background:var(--navy);color:#fff;
  display:flex;align-items:center;justify-content:center;font-size:13px;font-weight:600}
.rail-user .nm{font-size:12px;color:var(--navy);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
@media(min-width:768px){ .rail{display:flex} }
@media(min-width:1181px){
  .rail{width:var(--rail-lg);padding:14px 0 calc(14px + var(--pb))}
  .rail-brand{justify-content:flex-start;height:70px;padding:0 18px;gap:11px}
  .rail-brand img{height:36px}
  .rail-brand .rb-txt{display:block}
  .rail-nav{padding:12px 14px;gap:3px}
  .rail-item{flex-direction:row;gap:12px;padding:11px 14px;font-size:14px;text-align:left}
  .rail-item svg{width:20px;height:20px}
  .rail-item.on{background:#FDF0F4}
  .rail-foot{padding:10px 14px}
  .rail-user .nm{font-size:13px}
  /* 折叠 / 展开按钮（仅桌面显示） */
  .rail-toggle{display:flex;align-items:center;justify-content:center;width:30px;height:30px;margin:0 auto;
    border:1.5px solid var(--line);background:#fff;border-radius:9px;color:var(--sub);cursor:pointer;flex:0 0 auto}
  .rail-toggle svg{width:16px;height:16px}
  .rail-toggle:hover{color:var(--navy);border-color:#C6D0E0}
  .rail-foot{display:flex;flex-direction:column;gap:8px}
  .rail-foot .rail-user{width:100%}
  /* 折叠态：细竖条（与平板同宽），只显示图标 */
  body.rail-min{--rail-lg:var(--rail)}
  body.rail-min .rail{width:var(--rail);padding:14px 0 calc(14px + var(--pb))}
  body.rail-min .rail-brand{justify-content:center;padding:0 8px}
  body.rail-min .rail-brand .rb-txt{display:none}
  body.rail-min .rail-nav{padding:12px 10px}
  body.rail-min .rail-item{flex-direction:column;gap:4px;padding:10px 4px;font-size:10px;text-align:center}
  body.rail-min .rail-foot{padding:10px}
  body.rail-min .rail-user{justify-content:center;padding:4px}
  body.rail-min .rail-user .nm{display:none}
  body.rail-min .rail-user .av{width:34px;height:34px}
  body.rail-min .rail-toggle svg{transform:rotate(180deg)}
  body.rail-min .pagebar{left:var(--rail)}
}

/* ---------- 平板 / 桌面 页面标题条 ---------- */
.pagebar{
  position:fixed;left:var(--rail);right:0;top:0;height:60px;z-index:56;display:none;
  align-items:center;gap:14px;padding:0 24px;
  background:rgba(255,255,255,.92);-webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
  border-bottom:1px solid var(--line);
}
.pagebar .pb-title{font-size:17px;font-weight:600;color:var(--navy);display:flex;align-items:center;gap:10px;min-width:0}
.pagebar .pb-sub{font-size:13px;color:var(--sub);font-weight:400}
.pb-actions{margin-left:auto;display:flex;gap:10px;align-items:center}
@media(min-width:768px){ .pagebar{display:flex} }
@media(min-width:1181px){ .pagebar{left:var(--rail-lg);padding:0 28px} }

/* ---------- 主从双栏 / 推入式导航 ---------- */
.split{display:block}
.split-master{min-width:0}
.split-detail{min-width:0}
@media(max-width:767.98px){
  .split-detail{
    position:fixed;left:0;right:0;top:var(--bar-h);bottom:0;z-index:50;
    background:var(--cream);overflow-y:auto;padding:14px 14px calc(var(--tab-h) + var(--pb) + 20px);
    transform:translateX(100%);
  }
  @media(prefers-reduced-motion:no-preference){
    .split-detail{transition:transform .28s cubic-bezier(.32,.72,0,1)}
  }
  .split-detail.on{transform:none}
}
@media(min-width:768px){
  .split{display:grid;align-items:start;gap:20px}
  .split.cols-2{grid-template-columns:318px minmax(0,1fr)}
  .split.cols-3{grid-template-columns:236px 236px minmax(0,1fr)}
  .split-detail{padding:0}
}
.push-back{display:flex;align-items:center;gap:6px;height:38px;padding:0 12px 0 6px;margin-bottom:12px;
  border:1px solid var(--line);background:#fff;border-radius:12px;color:var(--navy);font-size:14px;font-weight:500;cursor:pointer}
.push-back svg{width:18px;height:18px}
@media(min-width:768px){ .push-back{display:none} }

/* ---------- 卡片 / 列表行 ---------- */
.acard{background:#fff;border:1px solid var(--line);border-radius:14px;box-shadow:var(--shadow);overflow:hidden}
.acard + .acard{margin-top:14px}
.acard-head{padding:16px 18px 12px;display:flex;align-items:center;gap:10px}
.acard-head h3{font-size:15px;color:var(--navy)}
.acard-head .sub{font-size:12px;color:var(--sub)}
.acard-body{padding:0 18px 18px}
.arow{display:flex;align-items:center;gap:12px;min-height:58px;padding:12px 16px;
  border-bottom:1px solid var(--line);background:#fff;cursor:pointer;text-decoration:none;color:inherit}
.arow:last-child{border-bottom:0}
.arow:active{background:#F6F8FC}
@media(hover:hover){ .arow:hover{background:#FAFBFD} }
.arow .ai{width:40px;height:40px;flex:0 0 auto;border-radius:11px;background:var(--cream);
  display:flex;align-items:center;justify-content:center;color:var(--red);font-size:18px}
.arow .at{flex:1;min-width:0}
.arow .at b{display:block;font-size:15px;color:var(--navy);font-weight:600}
.arow .at span{font-size:12px;color:var(--sub)}
.arow .av{margin-left:auto;font-size:13px;color:var(--sub);white-space:nowrap;display:flex;align-items:center;gap:6px}
.arow .chev{width:16px;height:16px;color:#C2C9D6;flex:0 0 auto}

/* ---------- 分段控件（卷切换 / 视图切换） ---------- */
.seg{display:flex;gap:4px;background:#EDF0F5;border-radius:13px;padding:4px;overflow-x:auto;
  scrollbar-width:none;-ms-overflow-style:none}
.seg::-webkit-scrollbar{display:none}
.seg button{flex:1 1 auto;min-width:0;border:0;background:none;padding:9px 14px;border-radius:10px;
  font-size:13px;font-weight:600;color:var(--sub);white-space:nowrap;cursor:pointer;transition:.18s}
.seg button.on{background:#fff;color:var(--navy);box-shadow:0 2px 8px rgba(0,32,72,.09)}
.seg.pill button{border-radius:20px}
.seg.pill button.on{background:var(--navy);color:#fff;box-shadow:none}

/* ---------- 底部抽屉 / 居中弹窗（按端切换形态） ---------- */
.sheet-mask{position:fixed;inset:0;z-index:200;background:var(--sheet-bg);opacity:0;pointer-events:none;
  -webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}
.sheet-mask.on{opacity:1;pointer-events:auto}
@media(prefers-reduced-motion:no-preference){ .sheet-mask{transition:opacity .22s ease} }

.sheet{position:fixed;left:0;right:0;bottom:0;z-index:201;background:#fff;
  border-radius:20px 20px 0 0;padding:6px 18px calc(18px + var(--pb));
  max-height:86vh;overflow-y:auto;transform:translateY(102%)}
.sheet.on{transform:none}
@media(prefers-reduced-motion:no-preference){
  .sheet{transition:transform .3s cubic-bezier(.32,.72,0,1)}
}
.sheet-grip{width:38px;height:4px;border-radius:2px;background:#DCE1E9;margin:8px auto 14px}
.sheet h3{font-size:16px;color:var(--navy);margin-bottom:8px}
.sheet p{font-size:14px;color:#4A5568;line-height:1.85}
.sheet-acts{display:flex;flex-direction:column;gap:10px;margin-top:20px}
.sheet-acts .btn{width:100%}
@media(max-width:767.98px){
  /* 长内容抽屉：操作按钮吸底，避免被列表顶出屏幕 */
  .sheet-acts{position:sticky;bottom:0;background:#fff;padding:14px 0 4px;margin-top:12px;
    box-shadow:0 -10px 14px -6px rgba(255,255,255,.96),0 -1px 0 var(--line)}
}
.sheet-list{margin:4px -6px 0}
.sheet-list button{display:flex;align-items:center;gap:12px;width:100%;padding:14px 8px;border:0;
  background:none;border-bottom:1px solid var(--line);font-size:15px;color:var(--navy);text-align:left;cursor:pointer}
.sheet-list button:last-child{border-bottom:0}
.sheet-list button:active{background:#F6F8FC}
.sheet-list button.danger{color:var(--red)}
.sheet-opt{display:flex;align-items:center;gap:10px;width:100%;padding:13px 10px;border:1.5px solid var(--line);
  border-radius:12px;background:#fff;font-size:15px;color:var(--navy);margin-bottom:10px;cursor:pointer;text-align:left}
.sheet-opt.on{border-color:var(--red);background:#FFF9FA}
.sheet-opt .k{width:26px;flex:0 0 auto;color:var(--sub);font-weight:600}
@media(min-width:768px){
  .sheet{left:50%;right:auto;bottom:auto;top:50%;width:440px;max-height:80vh;
    border-radius:18px;padding:24px 26px;transform:translate(-50%,-46%) scale(.97);opacity:0}
  .sheet.on{transform:translate(-50%,-50%) scale(1);opacity:1}
  @media(prefers-reduced-motion:no-preference){ .sheet{transition:transform .24s ease,opacity .24s ease} }
  .sheet-grip{display:none}
  .sheet-acts{flex-direction:row;justify-content:flex-end}
  .sheet-acts .btn{width:auto;min-width:110px}
}

/* ---------- Toast ---------- */
.ifa-toast{position:fixed;left:50%;z-index:300;max-width:88vw;text-align:center;
  top:calc(var(--bar-h) + 12px);transform:translate(-50%,-10px);opacity:0;pointer-events:none;
  background:rgba(0,32,72,.95);color:#fff;font-size:14px;line-height:1.5;padding:11px 20px;border-radius:24px}
.ifa-toast.on{opacity:1;transform:translate(-50%,0)}
@media(prefers-reduced-motion:no-preference){ .ifa-toast{transition:opacity .22s ease,transform .22s ease} }
@media(min-width:768px){ .ifa-toast{top:78px} }

/* ---------- 骨架屏 ---------- */
.sk{background:linear-gradient(90deg,#EDF0F5 25%,#F7F9FC 37%,#EDF0F5 63%);
  background-size:400% 100%;border-radius:8px}
@media(prefers-reduced-motion:no-preference){ .sk{animation:ifa-sk 1.4s ease infinite} }
@keyframes ifa-sk{0%{background-position:100% 50%}100%{background-position:0 50%}}
.sk-line{height:12px;margin-bottom:10px}
.sk-line.w40{width:40%} .sk-line.w60{width:60%} .sk-line.w80{width:80%}
.sk-block{height:82px;border-radius:13px;margin-bottom:12px}
.sk-avatar{width:64px;height:64px;border-radius:50%;margin:0 auto 12px}

/* ---------- 空状态 ---------- */
.empty-state{text-align:center;padding:52px 22px;color:var(--sub)}
.empty-state .ico{width:60px;height:60px;margin:0 auto 14px;border-radius:18px;background:#fff;
  border:1px solid var(--line);display:flex;align-items:center;justify-content:center;color:#B8C1D0}
.empty-state h3{font-size:17px;color:var(--navy);margin-bottom:8px}
.empty-state p{font-size:14px;line-height:1.9;margin-bottom:20px}

/* ---------- 手机端的通用适配 ---------- */
.only-sm{display:none !important}
@media(max-width:767.98px){
  .only-sm{display:inline-flex !important}
  .hide-sm{display:none !important}  .sec-title{margin-bottom:24px}
  .sec-title h2{font-size:21px}
  .chapter:hover{transform:none}
  .chapter:active{transform:scale(.985)}
  .chapter{padding:16px;gap:12px;border-radius:14px}
  .chapter .num{width:40px;height:40px;font-size:17px;border-radius:11px}
  .chapter .pct{width:52px;font-size:18px}
  .stat-grid{grid-template-columns:repeat(2,1fr)}
  .markbar{grid-template-columns:repeat(2,1fr);gap:10px}
  .markbar a{padding:12px;font-size:13px}
  .markbar a span{font-size:19px}
  .q-card{padding:18px 16px;border-radius:14px}
  .opt{padding:13px 14px}
  .btn{padding:12px 20px}
  .quiz-head{flex-direction:column;align-items:stretch;gap:10px}
  footer .cols{grid-template-columns:1fr;gap:22px}
  section{padding:0}
}
@media(min-width:768px) and (max-width:1180px){
  .cards{grid-template-columns:repeat(2,1fr)}
}

/* ---------- 沉浸式页面（贴图学习 / 模拟考）：隐藏标签栏 ---------- */
@media(max-width:767.98px){
  body.immersive .tabbar{display:none}
  body.immersive .app-main{padding-bottom:calc(78px + var(--pb))}
}

/* ---------- 顶栏返回键：仅在推入子页时出现 ---------- */
.ab-back-auto{display:none}
@media(max-width:767.98px){
  html.pushed .ab-back-auto{display:flex}
  html.pushed .appbar .ab-title{padding-left:0}
}

/* ---------- 平板窄栏：侧栏底部只留头像 ---------- */
@media(min-width:768px) and (max-width:1180px){
  .rail-user{justify-content:center;padding:4px}
  .rail-user .nm{display:none}
  .rail-user .av{width:34px;height:34px}
}

/* ---------- 无障碍：减弱动效 ---------- */
@media(prefers-reduced-motion:reduce){
  .split-detail,.sheet,.sheet-mask,.ifa-toast,.tabbar{transition:none !important}
  .sk{animation:none}
}

/* ---------- 登录墙（功能页对游客的登录门禁） ---------- */
.login-wall {
  position: fixed; inset: 0; z-index: 400; padding: 24px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(248, 248, 248, .95);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
body.login-walled { overflow: hidden }
.lw-box {
  width: 100%; max-width: 384px; text-align: center; background: #fff;
  border-radius: 18px; padding: 30px 26px 24px; box-sizing: border-box;
  box-shadow: 0 20px 54px rgba(0, 32, 72, .16); border: 1px solid #EEF1F5;
}
.lw-brand { font-size: 25px; font-weight: 800; color: #002048; letter-spacing: 1.5px }
.lw-brand span { color: #C8A060; margin-left: 2px }
.lw-box h3 { font-size: 17.5px; margin: 14px 0 8px; color: #002048; font-weight: 700 }
.lw-box p { font-size: 13.5px; color: #6B7280; line-height: 1.78; margin: 0 0 20px; text-align: left }
.lw-box .btn { width: 100%; margin: 0 0 10px; box-sizing: border-box }
.lw-box .btn:last-child { margin-bottom: 0 }
@media (max-width: 420px) {
  .login-wall { padding: 16px; align-items: flex-end }
  .lw-box { max-width: none; padding: 24px 20px 20px; border-radius: 18px 18px 14px 14px }
  .lw-brand { font-size: 22px }
  .lw-box p { font-size: 13px }
}

/* ---------- 我的方案书 列表 ---------- */
.mp-list { display: flex; flex-direction: column; gap: 8px; max-height: 52vh; overflow: auto; margin: 2px 0 4px }
.mp-row {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  padding: 12px 14px; border: 1px solid #E5E7EB; border-radius: 12px;
  background: #fff; cursor: pointer; font: inherit; transition: border-color .15s, background .15s;
}
.mp-row:hover { border-color: #002048; background: #F4F7FB }
.mp-row b { display: block; font-size: 14px; color: #002048; margin-bottom: 3px }
.mp-row span { display: block; font-size: 12px; color: #6B7280 }
