/* qidian-studio · 手机端独立 UI */
:root {
  --bg: #F5F5F7;
  --card: #FFFFFF;
  --ink: #1D1D1F;
  --sub: #6E6E73;
  --muted: #AEAEB2;
  --line: #E5E5EA;
  --accent: #FF6A00;
  --accent-soft: #FFF3E6;
  --r: 14px;
  --nav-h: 56px;
  --tab-h: 56px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  padding-bottom: calc(var(--tab-h) + 12px);
}
a { color: inherit; text-decoration: none; }
button { font: inherit; border: none; background: none; cursor: pointer; color: inherit; }
img { display: block; max-width: 100%; }

/* Top bar */
.m-top {
  position: sticky; top: 0; z-index: 50;
  height: var(--nav-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: rgba(245,245,247,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.m-top .brand {
  font-size: 17px; font-weight: 700; letter-spacing: .02em;
}
.m-top .title {
  flex: 1; min-width: 0;
  font-size: 15px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.m-top .back {
  width: 36px; height: 36px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  background: var(--card); border: 1px solid var(--line);
  font-size: 18px;
}

/* Page */
.m-page { padding: 12px 12px 24px; }

/* Cards */
.m-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 12px;
}
.m-card-h {
  padding: 14px 14px 10px;
}
.m-kicker { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.m-title { font-size: 18px; font-weight: 700; line-height: 1.3; }
.m-desc { font-size: 13px; color: var(--sub); margin-top: 6px; line-height: 1.65; }
.m-meta { font-size: 11px; color: var(--muted); margin-top: 6px; }

/* 16:9 thumbs */
.m-thumb {
  aspect-ratio: 16 / 9;
  background: #D9CFC4;
  overflow: hidden;
}
.m-thumb img { width: 100%; height: 100%; object-fit: cover; }
.m-thumb .ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: rgba(28,25,23,.35);
  background: linear-gradient(135deg, #E5E5EA, #D9CFC4);
}

/* List rows */
.m-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.m-row .m-title { font-size: 15px; font-weight: 600; }
.m-row .m-desc {
  font-size: 12px; color: var(--muted); margin-top: 4px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* Section */
.m-sec-title {
  font-size: 13px; font-weight: 700; color: var(--muted);
  margin: 18px 2px 10px; letter-spacing: .04em;
}

/* Chips / tabs */
.m-chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.m-chips::-webkit-scrollbar { display: none; }
.m-chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 13px;
  font-weight: 600;
  color: var(--sub);
}
.m-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Accordion series */
.m-acc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  margin-bottom: 10px;
  overflow: hidden;
}
.m-acc-h {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  min-height: 52px;
  padding: 14px;
  background: var(--bg);
  text-align: left;
}
.m-acc.open .m-acc-h { background: var(--accent-soft); }
.m-acc-h .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ink); opacity: .3; flex-shrink: 0;
}
.m-acc.open .m-acc-h .dot { background: var(--accent); opacity: 1; }
.m-acc-h .name { flex: 1; font-size: 16px; font-weight: 700; }
.m-acc.open .m-acc-h .name { color: var(--accent); }
.m-acc-h .n { font-size: 12px; color: var(--muted); }
.m-acc-h .car { font-size: 11px; color: var(--muted); }
.m-acc-b {
  padding: 8px 10px 12px 18px;
  border-top: 1px solid var(--line);
}
.m-acc-b[hidden] { display: none !important; }
.m-acc-item {
  width: 100%;
  min-height: 44px;
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 10px;
  text-align: left;
}
.m-acc-item:active { background: var(--bg); }
.m-acc-item .idx {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); color: var(--muted);
  font-size: 11px; display: flex; align-items: center; justify-content: center;
}
.m-acc-item .nm {
  flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Buttons */
.m-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px;
  border-radius: 12px;
  font-size: 14px; font-weight: 600;
}
.m-btn.primary { background: var(--accent); color: #fff; }
.m-btn.ghost {
  background: var(--card); color: var(--accent);
  border: 1px solid var(--accent);
}
.m-btn.block { width: 100%; }

/* Bottom tab */
.m-tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  height: var(--tab-h);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.m-tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--muted);
}
.m-tab .ico { font-size: 16px; }
.m-tab .ico { font-size: 18px; line-height: 1; }
.m-tab.active { color: var(--accent); font-weight: 600; }

/* Detail */
.m-media {
  aspect-ratio: 16 / 9;
  border-radius: var(--r);
  overflow: hidden;
  background: #D9CFC4;
  margin-bottom: 12px;
}
.m-media img { width: 100%; height: 100%; object-fit: cover; }
.m-block {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px;
  margin-bottom: 12px;
}
.m-block h2 {
  font-size: 15px; font-weight: 700; margin-bottom: 10px;
}
.m-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.m-actions .m-btn { width: 100%; }

/* 3:4 dict gallery */
.m-gal {
  aspect-ratio: 3 / 4;
  max-width: 280px;
  margin: 0 auto 12px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
  position: relative;
}
.m-gal img { width: 100%; height: 100%; object-fit: cover; }
.m-gal-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border-radius: 50%;
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
}
.m-gal-nav.prev { left: 8px; }
.m-gal-nav.next { right: 8px; }

/* Shop icons 1:1 */
.m-shop {
  display: flex; align-items: center; gap: 12px;
  width: 100%; padding: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); margin-bottom: 8px;
}
.m-shop img {
  width: 44px; height: 44px; aspect-ratio: 1/1;
  object-fit: cover; border-radius: 8px; background: var(--bg);
}

/* Stepper */
.m-stepbar {
  position: fixed; left: 12px; right: 12px;
  bottom: calc(var(--tab-h) + 10px);
  z-index: 55;
  display: grid; grid-template-columns: 64px 1fr 64px;
  gap: 8px; padding: 8px;
  background: rgba(255,255,255,.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
}
.m-stepbar button {
  min-height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 13px; font-weight: 600;
}
.m-stepbar button.mid {
  background: var(--accent-soft); color: var(--accent);
  border-color: rgba(255,106,0,.35);
}
.m-stepbar button:disabled { opacity: .4; }

/* Empty / toast */
.m-empty {
  text-align: center; color: var(--muted);
  padding: 48px 16px; font-size: 14px;
}

/* QR pop */
.qr-pop {
  position: fixed; z-index: 100; pointer-events: none;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; width: 180px; box-shadow: 0 12px 40px rgba(0,0,0,.16);
}
.qr-pop img {
  width: 156px; height: 156px; aspect-ratio: 1/1; object-fit: contain;
  border-radius: 8px; background: var(--bg);
}
.qr-pop .lbl { font-size: 11px; color: var(--muted); text-align: center; margin-top: 8px; }

@media (min-width: 901px) {
  body { max-width: 480px; margin: 0 auto; box-shadow: 0 0 0 1px var(--line); min-height: 100vh; }
}

/* 首页精选：每行 2 个，共 1 行 */
.m-feat-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}
.m-feat-grid .m-card {
    margin-bottom: 0;
    min-width: 0;
}
.m-feat-grid .m-title {
    font-size: 13px;
}
.m-feat-grid .m-card-h {
    padding: 10px 12px 12px;
}

/* 底栏：一行 5 个菜单按钮 */
.m-tabbar {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: stretch;
  gap: 6px;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)) !important;
}
.m-tab {
  flex: 1 1 0 !important;
  min-width: 0 !important;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--bg);
  padding: 6px 2px;
  font-size: 10px !important;
}
.m-tab.active {
  background: var(--accent-soft) !important;
  border-color: rgba(255,106,0,.35) !important;
  color: var(--accent) !important;
  font-weight: 700 !important;
}

/* 顶栏搜索 */
.m-top .m-search {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
}
.m-top .m-search input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  padding: 0 12px;
  font-size: 14px;
  outline: none;
}
.m-top .m-search input:focus {
  border-color: var(--accent);
}
.m-top .m-search button {
  height: 36px;
  min-width: 44px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.m-search-panel {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 8px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,.12);
  max-height: 50vh;
  overflow: auto;
  z-index: 80;
}
.m-search-item {
  display: block;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.m-search-item:last-child { border-bottom: none; }
.m-search-item .nm { font-size: 14px; font-weight: 600; }
.m-search-item .ds {
  font-size: 12px; color: var(--muted); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 顶栏布局：标题占位，搜索/首页靠右 */
.m-top {
  display: flex !important;
  align-items: center;
  gap: 8px;
}
.m-top .back { flex-shrink: 0; }
.m-top .title {
  display: block !important;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}
.m-top .m-search {
  flex: 0 0 auto !important;
  width: auto !important;
  position: relative;
}
.m-top .m-search input {
  display: none;
  width: 160px;
}
.m-top .m-search.open input {
  display: block;
}
.m-top .m-search .m-icon-btn,
.m-top .m-home-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  flex-shrink: 0;
}
.m-top .m-search .m-icon-btn:hover,
.m-top .m-home-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
.m-top .m-search .m-icon-btn svg,
.m-top .m-home-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.m-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.m-search-panel {
  left: auto !important;
  right: 0 !important;
  width: min(280px, 80vw);
}

/* 顶栏修正：图标不溢出，搜索常显 */
.m-top {
  height: 56px !important;
  padding: 0 12px !important;
  overflow: visible;
  align-items: center !important;
}
.m-top .m-top-actions {
  display: flex !important;
  align-items: center !important;
  gap: 8px !important;
  margin-left: auto !important;
  flex-shrink: 0 !important;
  height: 36px !important;
}
.m-top .m-home-btn,
.m-top .m-search .m-icon-btn {
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  min-height: 36px !important;
  max-height: 36px !important;
  padding: 0 !important;
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
  background: var(--card) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  text-decoration: none !important;
}
.m-top .m-home-btn svg,
.m-top .m-search .m-icon-btn svg {
  width: 18px !important;
  height: 18px !important;
  max-width: 18px !important;
  max-height: 18px !important;
  display: block !important;
  flex-shrink: 0 !important;
}
/* 搜索：输入框 + 图标并排，完整可见 */
.m-top .m-search {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex: 0 1 auto !important;
  min-width: 0 !important;
  width: auto !important;
  max-width: calc(100vw - 180px) !important;
  overflow: visible !important;
}
.m-top .m-search input {
  display: block !important;
  width: 120px !important;
  min-width: 72px !important;
  height: 36px !important;
  border-radius: 10px !important;
  border: 1px solid var(--line) !important;
  background: var(--card) !important;
  padding: 0 10px !important;
  font-size: 13px !important;
  box-sizing: border-box !important;
}
.m-top .m-search.open input,
.m-top .m-search input {
  display: block !important;
}
.m-search-panel {
  right: 0 !important;
  left: auto !important;
  width: min(280px, 78vw) !important;
}
/* 标题给搜索让位 */
.m-top .title {
  flex: 1 1 auto !important;
  min-width: 48px !important;
}
@media (max-width: 360px) {
  .m-top .m-search input { width: 80px !important; }
}


/* 首页大米购买：一行 5 个 */
.m-shop-row {
  display: grid !important;
  grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
  gap: 8px;
  padding: 4px 12px 14px;
}
.m-shop-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 10px 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  text-align: center;
}
.m-shop-btn img {
  width: 40px; height: 40px;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--line);
}
.m-shop-btn span {
  font-size: 10px;
  color: var(--sub);
  font-weight: 600;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

/* 大米页购买：每行 2 个 */
#shopList, #shopListDict, #shopListVideo {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 10px;
  padding: 12px;
}
#shopList .rice-shop,
#shopListDict .rice-shop,
#shopListVideo .rice-shop {
  position: relative;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  flex-direction: column;
  align-items: flex-start;
}

/* 购买渠道紧凑双列 */
#shopList, #shopListDict, #shopListVideo {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 8px !important;
  padding: 10px !important;
}
#shopList .rice-shop,
#shopListDict .rice-shop,
#shopListVideo .rice-shop {
  position: relative;
  margin: 0 !important;
  padding: 10px !important;
  gap: 10px !important;
  border: 1px solid var(--line) !important;
  border-radius: 12px !important;
  flex-direction: row !important;
  align-items: center !important;
}
#shopList .rice-shop img,
#shopListDict .rice-shop img,
#shopListVideo .rice-shop img {
  width: 36px !important;
  height: 36px !important;
  border-radius: 8px !important;
}
#shopList .rice-shop .nm { font-size: 13px !important; }
#shopList .rice-shop .ds,
#shopListDict .rice-shop .ds,
#shopListVideo .rice-shop .ds { display: none !important; }
#shopList .rice-shop .tag,
#shopListDict .rice-shop .tag,
#shopListVideo .rice-shop .tag {
  margin-top: 2px;
  padding: 1px 6px;
  font-size: 9px;
}
#shopList .rice-shop .arrow,
#shopListDict .rice-shop .arrow,
#shopListVideo .rice-shop .arrow {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  font-size: 12px;
}


/* 顶部分段切换 */
.seg-tabs { margin-top: 16px; }
.seg-tabs-track {
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
  gap: 4px;
  padding: 4px;
  background: #F0EEEA;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.seg-tab {
  min-height: 44px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sub);
  font-size: 15px;
  font-weight: 700;
  position: relative;
}
.seg-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(255,106,0,.18);
  border-color: rgba(255,106,0,.35);
}
.seg-tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--accent);
}
.seg-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* 统一交互按钮：分段控件样式 */
.seg-tabs {
  margin: 4px 0 12px;
}
.seg-tabs-track {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 4px;
  background: #F0EEEA;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.seg-tabs-track.cols-2 { display: grid !important; grid-template-columns: 1fr 1fr !important; }
.seg-tabs-track.cols-3 { display: grid !important; grid-template-columns: 1fr 1fr 1fr !important; }
.seg-tabs-track.cols-4 { display: grid !important; grid-template-columns: 1fr 1fr 1fr 1fr !important; }
.seg-tabs-track.cols-5 { display: grid; grid-template-columns: repeat(5, 1fr); }

.seg-tab {
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sub);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}
.seg-tabs-track.cols-2 .seg-tab,
.seg-tabs-track.cols-3 .seg-tab,
.seg-tabs-track.cols-4 .seg-tab,
.seg-tabs-track.cols-5 .seg-tab {
  font-size: 12px;
  padding: 0 6px;
}
.seg-tab.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 2px 8px rgba(255,106,0,.18);
  border-color: rgba(255,106,0,.35);
}
.seg-tab.active::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 5px;
  transform: translateX(-50%);
  width: 16px;
  height: 3px;
  border-radius: 99px;
  background: var(--accent);
}
.seg-hint {
  margin: 8px 0 0;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* CTA 保持 m-btn 默认样式 */

/* hero image cover */
.m-thumb {
  position: relative !important;
}
.m-thumb > img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  z-index: 1;
}
.m-thumb > .ph {
  position: absolute !important;
  inset: 0 !important;
  z-index: 0;
}
.m-thumb > img[style*="display: none"],
.m-thumb > img[hidden] {
  display: none !important;
}

.m-shop-btn img {
  width: 40px !important;
  height: 40px !important;
  aspect-ratio: 1 / 1 !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 8px !important;
  background: var(--card) !important;
  border: 1px solid var(--line) !important;
}
