/* ============ CHÙA OS — MOBILE WEBAPP SHELL ============ */
:root{ --tabbar-h: calc(62px + env(safe-area-inset-bottom, 0px)); }

body.m{background:var(--paper)}
body.m .app{display:block;padding-top:var(--ribbon-h)}
body.m .main{display:block}

/* header app */
.m-head{
  position:sticky;top:var(--ribbon-h);z-index:45;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  background:var(--green-900);color:var(--paper);
  padding:12px 16px;
  border-bottom:1px solid rgba(216,169,62,.35);
}
.m-temple{display:flex;gap:10px;align-items:center;min-width:0}
.m-temple b{display:block;font-family:var(--serif);font-size:15.5px;line-height:1.25;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.m-temple small{display:block;color:var(--gold-bright);font-size:11.5px;font-weight:600}
.m-ai{flex:none;background:rgba(216,169,62,.16);border:1px solid rgba(216,169,62,.45);color:var(--gold-bright)}

/* chip nav màn hình con */
.m-chips{
  position:sticky;top:calc(var(--ribbon-h) + 59px);z-index:44;
  display:flex;gap:8px;overflow-x:auto;-webkit-overflow-scrolling:touch;
  padding:10px 14px;background:rgba(246,238,218,.95);backdrop-filter:blur(10px);
  border-bottom:1px solid var(--line);scrollbar-width:none;
}
.m-chips::-webkit-scrollbar{display:none}
.m-chip{
  flex:none;border:1px solid var(--line);background:#fff;color:var(--ink-soft);
  font-family:var(--sans);font-size:12.5px;font-weight:600;
  padding:7px 14px;border-radius:999px;text-decoration:none;white-space:nowrap;
  transition:background .2s,color .2s;
}
.m-chip.on{background:var(--green-800);border-color:var(--green-800);color:var(--gold-bright)}

/* content */
body.m .content{
  padding:16px 14px calc(var(--tabbar-h) + 24px);
  max-width:none;
}
body.m .view-head h1{font-size:21px}
body.m .view-head{margin-bottom:14px;gap:10px}
body.m .pillar-banner{padding:16px;gap:14px}
body.m .pillar-banner h2{font-size:17px}
body.m .pillar-banner .pb-num{font-size:28px;width:42px;padding-right:12px}
body.m .grid{gap:12px}
body.m .card{padding:16px;border-radius:14px}

/* bảng rộng: cuộn ngang trong card, bảng hẹp giữ nguyên */
body.m .card{overflow-x:auto}
body.m .tbl{min-width:max-content}
body.m .tbl th,body.m .tbl td{padding:9px 8px}

/* AI drawer thành bottom-sheet */
body.m .ai-drawer{
  left:0;right:0;top:auto;bottom:-100%;width:100%;height:78vh;
  border-left:none;border-top:1px solid var(--line);
  border-radius:20px 20px 0 0;overflow:hidden;
  transition:bottom .38s cubic-bezier(.2,.7,.2,1);
  box-shadow:0 -30px 60px -30px rgba(15,42,30,.5);
}
body.m.ai-open .ai-drawer{bottom:0;right:0}
body.m .ai-input{padding-bottom:calc(14px + env(safe-area-inset-bottom, 0px))}

/* bottom tab bar */
.m-tabbar{
  position:fixed;left:0;right:0;bottom:0;z-index:55;
  display:grid;grid-template-columns:repeat(6,1fr);
  background:var(--green-900);
  border-top:1px solid rgba(216,169,62,.4);
  padding-bottom:env(safe-area-inset-bottom, 0px);
}
.m-tab{
  display:flex;flex-direction:column;align-items:center;gap:3px;
  padding:9px 2px 8px;text-decoration:none;
  color:rgba(246,238,218,.55);transition:color .2s;
}
.m-tab svg{width:21px;height:21px;stroke:currentColor;fill:none;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}
.m-tab span{font-family:var(--sans);font-size:9.5px;font-weight:600;letter-spacing:.02em;white-space:nowrap}
.m-tab.on{color:var(--gold-bright)}
.m-tab.on svg{filter:drop-shadow(0 0 6px rgba(216,169,62,.5))}

/* sớ modal trên mobile */
body.m .so-sheet{max-width:94vw}
body.m .so-border{padding:24px 18px}

/* toast tránh tabbar */
body.m .toast{bottom:calc(var(--tabbar-h) + 14px)}
