/*
 * 建考帮 · 移动端 App 壳层（汉堡菜单 + 底部 Tab）
 * 仅在 html.ks-mobile-app 时生效（≤768px 由 ks_mobile_shell.js 切换）
 */

html.ks-mobile-app {
  --ks-appbar-h: 48px;
  --ks-tabbar-h: 56px;
  scroll-padding-top: var(--ks-appbar-h);
  scroll-padding-bottom: var(--ks-tabbar-h);
}

html.ks-mobile-app body:not(.ks-mobile-chrome-hidden) {
  padding-top: var(--ks-appbar-h);
  padding-bottom: calc(var(--ks-tabbar-h) + env(safe-area-inset-bottom, 0px));
}

html.ks-mobile-app body.ks-mobile-chrome-hidden {
  padding-top: 0;
  padding-bottom: 0;
}

/* 隐藏桌面顶栏，交给 App 壳层 */
html.ks-mobile-app .header,
html.ks-mobile-app .pageHeader,
html.ks-mobile-app .headerSecond {
  display: none !important;
}

html.ks-mobile-app .bottomNavigation {
  display: none !important;
}

html.ks-mobile-app .footer {
  display: none !important;
}

html.ks-mobile-app .ant-layout-content {
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: hidden !important;
  box-sizing: border-box !important;
}

/* ── 顶栏 ── */
.ks-mapp-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10080;
  height: var(--ks-appbar-h);
  background: linear-gradient(180deg, #fff 0%, #faf8f2 100%);
  border-bottom: 1px solid #ead9a6;
  display: flex;
  align-items: center;
  padding: 0 8px;
  box-sizing: border-box;
  box-shadow: 0 1px 8px rgba(194, 141, 19, 0.08);
}

.ks-mapp-bar__btn {
  border: none;
  background: transparent;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #9e7410;
  padding: 0;
  flex-shrink: 0;
}

.ks-mapp-bar__btn svg {
  width: 22px;
  height: 22px;
}

.ks-mapp-bar__logo {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  text-decoration: none;
}

.ks-mapp-bar__logo img {
  height: 32px;
  width: auto;
  max-width: 140px;
  object-fit: contain;
}

.ks-mapp-bar__action {
  flex-shrink: 0;
  font-size: 13px;
  color: #c28d13;
  text-decoration: none;
  padding: 6px 10px;
  white-space: nowrap;
  max-width: 88px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── 抽屉 ── */
.ks-mdrawer {
  position: fixed;
  inset: 0;
  z-index: 10090;
  pointer-events: none;
  visibility: hidden;
  transition: visibility 0.25s;
}

.ks-mdrawer.is-open {
  pointer-events: auto;
  visibility: visible;
}

.ks-mdrawer__mask {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.25s;
}

.ks-mdrawer.is-open .ks-mdrawer__mask {
  opacity: 1;
}

.ks-mdrawer__panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 86vw);
  background: #fff;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  transform: translateX(-100%);
  transition: transform 0.28s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.ks-mdrawer.is-open .ks-mdrawer__panel {
  transform: translateX(0);
}

.ks-mdrawer__hd {
  padding: 16px 16px 12px;
  background: linear-gradient(135deg, #c28d13 0%, #bd8a13 100%);
  color: #fff;
}

.ks-mdrawer__hd-title {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
}

.ks-mdrawer__hd-sub {
  font-size: 12px;
  opacity: 0.92;
  margin: 0;
}

.ks-mdrawer__nav {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 0 16px;
}

.ks-mdrawer__nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 15px;
  color: #333;
  text-decoration: none;
  border-bottom: 1px solid #f3f3f3;
}

.ks-mdrawer__nav a.is-active {
  color: #c28d13;
  background: rgba(194, 141, 19, 0.08);
  font-weight: 600;
}

.ks-mdrawer__nav a img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.ks-mdrawer__ft {
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #eee;
  font-size: 11px;
  color: #999;
  line-height: 1.6;
  text-align: left;
  background: #fafafa;
}

.ks-mdrawer__ft a {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #888;
  text-decoration: none;
  line-height: 1.5;
}

.ks-mdrawer__ft a + a {
  margin-top: 6px;
}

.ks-mdrawer__ft img {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* ── 底部 Tab ── */
.ks-mtabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10070;
  height: calc(var(--ks-tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: #fff;
  border-top: 1px solid #ead9a6;
  display: flex;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
}

.ks-mtabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: #888;
  font-size: 10px;
  padding: 4px 2px 0;
  min-width: 0;
}

.ks-mtabbar__item.is-active {
  color: #c28d13;
  font-weight: 600;
}

.ks-mtabbar__icon {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ks-mtabbar__icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.ks-mtabbar__icon svg {
  width: 22px;
  height: 22px;
}

.ks-mtabbar__item.is-active .ks-mtabbar__icon svg {
  stroke: #c28d13;
  fill: #c28d13;
}

.ks-mtabbar__label {
  line-height: 1.2;
  white-space: nowrap;
}

html.ks-mobile-app .ks-mapp-bar,
html.ks-mobile-app .ks-mtabbar {
  display: flex;
}

html:not(.ks-mobile-app) .ks-mapp-bar,
html:not(.ks-mobile-app) .ks-mtabbar,
html:not(.ks-mobile-app) .ks-mdrawer {
  display: none !important;
}

html.ks-mobile-app body.ks-mobile-chrome-hidden .ks-mtabbar {
  display: none !important;
}

html.ks-mobile-app body.ks-mobile-chrome-hidden .ks-mapp-bar {
  display: none !important;
}
