@font-face{
  font-family:"PDD Number";
  src:url("../assets/PDDSansStd06-Regular.otf") format("opentype");
  font-style:normal;
  font-weight:400;
  font-display:swap;
}
:root{
  --red:#e6382d;
  --page:#f5f5f5;
  --course-bg:#f2f2f2;
  --card:#fff;
  --text:#2b2b2b;
  --muted:#a7a7a7;
  --blue:#5575ff;
  font-family:-apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Noto Sans CJK SC","Microsoft YaHei",sans-serif;
  color:var(--text);
  /* body 背景与底部导航同色：浏览器底部工具栏透出的灰条与导航融为一体，
     视觉上导航一直延伸到屏幕底边（对齐原版全面屏效果） */
  background:#fafafa;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{
  width:100%;
  height:100%;
  min-height:100%;
  overflow:hidden;
  margin:0;
  background:#fafafa;
  overscroll-behavior:none;
  touch-action:pan-y;
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}
/* iOS PWA：让页面根层真正覆盖到物理屏幕四边，安全区只由具体 UI 自己处理。 */
body{
  position:fixed;
  inset:0;
  display:flex;
  justify-content:center;
}
button,input{font:inherit}
button{border:0;background:none;padding:0;color:inherit;cursor:pointer}
img{display:block;user-select:none;-webkit-user-drag:none}
[hidden]{display:none!important}

/* ===== App 容器：PWA 独立模式固定铺满整个屏幕 ===== */
.app{
  position:fixed;
  inset:0;
  margin:auto;
  width:min(100vw,430px);
  height:100%;
  min-height:100%;
  background:var(--page);
  display:flex;
  flex-direction:column;
  overflow:hidden;
  isolation:isolate;
}

/* ===== Header：系统状态栏由系统绘制，网页只避让安全区 ===== */
.topbar{
  flex:none;
  position:relative;
  z-index:5;
  background:var(--red);
  color:#fff;
  padding-top:env(safe-area-inset-top);
}
.merchant-row{height:45px;display:flex;align-items:flex-start;justify-content:space-between;padding:0 15px 0 14px}
.merchant-left{display:flex;align-items:center;min-width:0;text-align:left;color:#fff}
.merchant-logo{width:34px;height:34px;flex:none;border-radius:4px;object-fit:cover;align-self:flex-start;transition:filter .2s ease}
.merchant-meta{margin-left:7px;min-width:0;display:block}
.merchant-name-line{height:18px;display:flex;align-items:center;gap:4px;white-space:nowrap}
.merchant-name{font-size:14px;font-weight:500;line-height:18px;letter-spacing:-.1px}
.merchant-eye{width:19px;height:18px;object-fit:contain;flex:none}
.merchant-caret{width:14px;height:11px;object-fit:contain;margin-left:3px;transition:transform .16s ease}
.merchant-left[aria-expanded="true"] .merchant-caret{transform:rotate(180deg)}
.message-pill{margin-top:2px;width:93px;height:17px;border-radius:9px;background:#fff;color:#e34a37;padding:0;font-size:10.5px;line-height:17px;text-align:center;display:block;white-space:nowrap;overflow:hidden}
.top-actions{display:flex;gap:18px;margin-top:-3px;margin-right:-1px}
.top-action{width:30px;color:#fff;display:flex;flex-direction:column;align-items:center;font-size:12px;line-height:18px;gap:1px;font-weight:400}
.top-action img{width:30px;height:24px;object-fit:contain}
.top-action:first-child img{width:29px}

.merchant-dropdown{position:absolute;top:calc(100% - 2px);left:12px;width:220px;padding:7px;background:#fff;border-radius:9px;box-shadow:0 7px 24px rgba(0,0,0,.16);z-index:20;color:#333}
.merchant-option{width:100%;display:flex;align-items:center;text-align:left;padding:6px;border-radius:7px}
.merchant-option img{width:34px;height:34px;border-radius:4px;margin-right:9px;object-fit:cover}
.merchant-option span{display:flex;flex-direction:column;min-width:0}
.merchant-option strong{font-size:14px;line-height:19px;font-weight:600}
.merchant-option small{font-size:11px;line-height:16px;color:#999}

/* ===== 隐私隐藏：仅影响头像 / 店铺名 / 眼睛图标，不影响数据 ===== */
.avatar{transition:filter .2s ease}
.avatar.hidden{filter:blur(5px)}

/* ===== Scroll 内容区域 ===== */
.content{
  flex:1;
  min-height:0;
  overflow-y:auto;
  -webkit-overflow-scrolling:touch;
  scrollbar-width:none;
  padding:3px 8px 10px;
  background:linear-gradient(to bottom,var(--page) 0 340px,var(--course-bg) 340px 100%);
}
.content::-webkit-scrollbar{display:none}
.page-mine{background:var(--page)}

/* 数据统计卡：隐私模式不影响数字 */
.stats-card{background:var(--card);border-radius:8px;margin-bottom:8px;overflow:hidden}
.stats-grid{height:120px;display:grid;grid-template-columns:repeat(5,1fr);grid-template-rows:repeat(2,1fr);padding:7px 5px 4px}
.stat{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:5px;min-width:0}
.stat strong{font-family:"PDD Number",-apple-system,BlinkMacSystemFont,sans-serif;font-size:20px;font-weight:400;line-height:20px;color:#202020;min-width:28px;text-align:center}
.stat span{font-size:13px;font-weight:400;line-height:16px;color:#666;white-space:nowrap}

/* 功能宫格 */
.apps-card{background:var(--card);border-radius:8px;margin-bottom:8px;overflow:hidden}
.apps-grid{height:144px;display:grid;grid-template-columns:repeat(5,1fr);grid-template-rows:repeat(2,1fr)}
.app-item{display:flex;flex-direction:column;align-items:center;justify-content:flex-start;gap:0;color:#333;font-size:13px;font-weight:400;line-height:18px;min-width:0}
.app-item img{width:41px;height:42px;object-fit:contain}
.app-item:nth-child(-n+5) img{margin-top:5px}
.app-item:nth-child(n+6) img{margin-top:0}
.app-item span{white-space:nowrap}

/* Banner */
.survey-banner{height:56px;background:var(--card);border-radius:8px;margin-bottom:8px;display:flex;align-items:center;padding:4px 10px 4px 8px;background:linear-gradient(90deg,#ffecdd 0%,#fff 28%,#fff 100%)}
.survey-icon{width:27px;height:27px;flex:none;object-fit:contain;margin-left:1px;margin-right:7px;transform:translateY(-3px)}
.survey-banner p{margin:0;flex:1;min-width:0;font-size:13px;line-height:18px;color:#333;font-weight:400;letter-spacing:-.08px;transform:translateY(-2px)}
.survey-banner p strong{font-weight:600}
.survey-banner p span{color:#ff5b00;font-weight:600}
.link-btn,.course-link{color:var(--blue);white-space:nowrap;font-weight:400}
.link-btn{font-size:13px;margin-left:4px;display:flex;align-items:center;gap:2px;transform:translateY(-1px)}
.link-btn b,.course-link b{display:inline-block;width:6px;height:6px;border-top:1px solid currentColor;border-right:1px solid currentColor;transform:rotate(45deg);flex:none;margin-left:0}

/* 课程列表 */
.course-list{display:flex;flex-direction:column;gap:8px}
.course-card{height:104px;position:relative;display:flex;padding:9px 12px 8px 12px;background:var(--card);border-radius:8px;overflow:visible}
.close-card{position:absolute;right:4px;top:3px;width:10px;height:10px;z-index:3}
.close-card::before,.close-card::after{content:"";position:absolute;left:4.5px;top:0;width:1px;height:10px;background:#c8c8c8;transform-origin:center}
.close-card::before{transform:rotate(45deg)}
.close-card::after{transform:rotate(-45deg)}
.course-main{flex:1;min-width:0;padding-right:7px;display:flex;flex-direction:column}
.course-main h2{margin:0 0 4px;font-size:16px;line-height:22px;font-weight:500;color:#292929;letter-spacing:-.3px;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden}
.course-meta{font-size:13px;font-weight:400;color:#a3a3a3;line-height:20px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.course-source{margin-top:auto;font-size:12px;font-weight:400;color:#aaa;line-height:18px}
.course-side{width:80px;flex:none;display:flex;flex-direction:column;align-items:stretch;justify-content:space-between;gap:2px}
.thumb{width:80px;height:60px;border-radius:5px;object-fit:cover;transform:translateY(-1px)}
.course-link{text-align:right;font-size:13px;line-height:20px;display:flex;align-items:center;justify-content:flex-end;gap:2px}

/* ===== 底部 Tab：固定底部、不覆盖内容、安全区避让 ===== */
.bottom-nav{
  flex:0 0 calc(54px + env(safe-area-inset-bottom));
  height:calc(54px + env(safe-area-inset-bottom));
  min-height:calc(54px + env(safe-area-inset-bottom));
  display:flex;
  align-items:flex-start;
  background:#fafafa;
  border-top:1px solid #efefef;
  padding:2px 1px env(safe-area-inset-bottom);
  box-sizing:border-box;
  z-index:10;
}
.nav-item{flex:1;height:50px;color:#5d5d5d;display:flex;flex-direction:column;align-items:center;justify-content:flex-start;font-size:11px;font-weight:400;line-height:15px;-webkit-tap-highlight-color:transparent}
/* 原版导航图标：方形线框，选中态为红色填充。单图 + JS 切 src。
   尺寸对齐正版实测（正版图标画布 72px @3x = 24pt，字形约 21pt），全排统一固定、点击不变大 */
.nav-ico{display:block;height:24px;width:24px;object-fit:contain;flex:none}
.nav-item.active{color:var(--red)}

/* 聊天图标角标：素材已去除内置角标，角标由 JS 动态渲染。包裹层与其余 tab 图标同尺寸保证整排对齐 */
.nav-icon-wrap{position:relative;display:flex;align-items:center;justify-content:center;height:24px;width:24px}
.nav-badge{
  position:absolute;
  top:-3px;
  right:-9px;
  min-width:17px;
  height:17px;
  padding:0 4px;
  border-radius:9px;
  background:#ff3b30;
  color:#fff;
  font-size:10px;
  line-height:17px;
  text-align:center;
  font-weight:600;
  box-sizing:border-box;
}

/* ===== 我的页面 ===== */
.mine-hero{margin:10px 8px 8px;border-radius:8px;background:var(--card);display:flex;align-items:center;padding:16px}
.mine-avatar{width:56px;height:56px;border-radius:10px;object-fit:cover;flex:none;transition:filter .2s ease}
.mine-meta{margin-left:12px;min-width:0}
.mine-name{font-size:17px;font-weight:600;line-height:24px;color:#292929}
.mine-account{font-size:12px;color:#999;line-height:18px;margin-top:2px}
.mine-card{margin:0 8px 8px;border-radius:8px;background:var(--card);overflow:hidden}
.mine-row{width:100%;display:flex;align-items:center;justify-content:space-between;height:52px;padding:0 14px;font-size:15px;color:#333;border-bottom:1px solid #f2f2f2}
.mine-row:last-child{border-bottom:0}
.row-arrow{width:7px;height:7px;border-top:1.5px solid #c0c0c0;border-right:1.5px solid #c0c0c0;transform:rotate(45deg);flex:none}
.mine-card-title{font-size:13px;color:#999;padding:10px 14px 2px;font-weight:400}
.mine-form{padding:4px 14px 14px}
.mine-field{display:flex;align-items:center;height:46px;border-bottom:1px solid #f5f5f5}
.mine-field span{width:76px;font-size:15px;color:#333;flex:none}
.mine-field input{flex:1;border:0;outline:0;background:none;text-align:right;font-size:15px;font-family:"PDD Number",-apple-system,BlinkMacSystemFont,sans-serif;color:#202020}
.mine-save{width:100%;height:44px;margin-top:14px;border-radius:22px;background:var(--red);color:#fff;font-size:16px;font-weight:500}

/* ===== 弹层 ===== */
.overlay{position:absolute;inset:0;background:rgba(0,0,0,.22);z-index:50;opacity:0;pointer-events:none;transition:opacity .18s ease}
.overlay.open{opacity:1;pointer-events:auto}
.search-panel{background:#fff;padding:12px 12px 18px;transform:translateY(-100%);transition:transform .22s ease;padding-top:max(12px,env(safe-area-inset-top))}
.overlay.open .search-panel{transform:translateY(0)}
.search-input-wrap{display:flex;align-items:center;gap:8px}
.search-mini{font-size:24px;color:#999;line-height:1}
.search-input-wrap input{flex:1;border:0;outline:0;background:#f2f2f2;border-radius:18px;height:35px;padding:0 14px;font-size:14px}
.search-input-wrap button{color:#555;font-size:14px}
.search-empty{height:80px;display:flex;align-items:center;justify-content:center;color:#aaa;font-size:13px}

.scan-overlay{background:rgba(0,0,0,.74)}
.scan-backdrop-close{position:absolute;inset:0;width:100%;height:100%}
.scan-panel{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);width:230px;height:270px;display:flex;flex-direction:column;align-items:center;justify-content:center;color:#fff}
.scan-frame{width:190px;height:190px;position:relative}
.scan-frame i{position:absolute;width:32px;height:32px;border-color:#fff;border-style:solid}
.scan-frame i:nth-child(1){left:0;top:0;border-width:3px 0 0 3px}
.scan-frame i:nth-child(2){right:0;top:0;border-width:3px 3px 0 0}
.scan-frame i:nth-child(3){left:0;bottom:0;border-width:0 0 3px 3px}
.scan-frame i:nth-child(4){right:0;bottom:0;border-width:0 3px 3px 0}
.scan-caption{margin-top:22px;font-size:15px}

.name-sheet{position:absolute;left:0;right:0;bottom:0;background:#fff;border-radius:14px 14px 0 0;padding:18px 16px calc(18px + env(safe-area-inset-bottom));transform:translateY(105%);transition:transform .24s ease}
.overlay.open .name-sheet{transform:translateY(0)}
.sheet-title{font-size:16px;font-weight:600;text-align:center;margin-bottom:14px;color:#292929}
.sheet-input{width:100%;height:42px;border:0;outline:0;background:#f2f2f2;border-radius:10px;padding:0 14px;font-size:14px}
.sheet-actions{display:flex;gap:10px;margin-top:14px}
.sheet-btn{flex:1;height:42px;border-radius:10px;background:#f2f2f2;color:#333;font-size:15px}
.sheet-btn.primary{background:var(--red);color:#fff}

/* 聊天角标弹层 */
.badge-tip{font-size:12px;color:#999;text-align:center;margin:-6px 0 12px;line-height:17px}
.badge-opts{display:flex;gap:10px;margin-bottom:12px}
.badge-opt{flex:1;height:40px;border-radius:10px;background:#f2f2f2;color:#333;font-size:15px}
.badge-opt.active{background:#fdeceb;color:var(--red);font-weight:600}

.toast{position:absolute;left:50%;bottom:calc(74px + env(safe-area-inset-bottom));transform:translate(-50%,10px);background:rgba(0,0,0,.72);color:#fff;border-radius:6px;padding:7px 11px;font-size:12px;opacity:0;pointer-events:none;z-index:60;transition:opacity .18s ease,transform .18s ease;white-space:nowrap}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ===== PWA / 桌面预览 ===== */
@media (display-mode:standalone){
  html,body{height:100%;min-height:100%}
  .app{top:0;right:0;bottom:0;left:0;height:100%;min-height:100%}
}
html.standalone .app{top:0;right:0;bottom:0;left:0;height:100%;min-height:100%}

@media (min-width:431px){
  body{position:relative;align-items:flex-start;background:#e3e3e3}
  .app{position:relative;inset:auto;margin:16px auto 0;height:calc(100% - 32px);min-height:0;border-radius:22px;box-shadow:0 12px 45px rgba(0,0,0,.18)}
}
@media (max-height:700px){
  .stats-grid{height:108px}
  .apps-grid{height:132px}
}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{scroll-behavior:auto!important;transition:none!important;animation:none!important}
}
