/* 祖师商城 — mobile layout (FIX-1784). Own design; no external fonts or images. */
:root {
  --ink: #1f2a29;
  --ink-2: #3c4a48;
  --muted: #857c6e;
  --paper: #f6f1e6;
  --paper-2: #efe7d6;
  --card: #fffdf8;
  --line: #e9d8b6;
  --line-soft: #f1e6cf;
  --teal: #174a47;
  --teal-2: #24625d;
  --teal-soft: #e3efec;
  --gold: #c39a57;
  --gold-soft: #f6e7c8;
  --accent: #b0592f;
  --ok: #2c7a58;
  --lock: #8d9196;
  --danger: #b23a2b;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 14px rgba(60, 45, 20, .06);
  --radius: 12px;
  --nav-h: 60px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Source Han Sans SC", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(36, 98, 93, .10), transparent 60%),
    radial-gradient(90% 40% at 0% 100%, rgba(195, 154, 87, .12), transparent 70%),
    var(--paper);
  background-attachment: fixed;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }
body.noscroll { overflow: hidden; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.noscript, .boot { text-align: center; padding: 40vh 16px 0; color: var(--muted); }
.boot { position: fixed; inset: 0; background: var(--paper); z-index: 50; }

.view { max-width: 480px; margin: 0 auto; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  border: 0; border-radius: 9px; padding: 7px 14px; font-weight: 600; white-space: nowrap;
  transition: filter .15s, opacity .15s;
}
.btn:active:not(:disabled) { filter: brightness(.92); }
.btn-primary { background: linear-gradient(180deg, var(--teal-2), var(--teal)); color: #fff; box-shadow: 0 2px 6px rgba(23, 74, 71, .25); }
.btn-gold { background: linear-gradient(180deg, #fbf0d8, #ecd3a3); color: #4a3412; }
.btn-ghost { background: var(--card); color: var(--teal); border: 1px solid var(--teal); }
.btn-lock { background: var(--lock); color: #fff; }
.btn-done { background: #d9dcdf; color: #6b7076; }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 13px 16px; font-size: 18px; letter-spacing: .2em; border-radius: 12px; }
/* FIX-4772: these buttons name the zone and character (FIX-4632), which is wider than a phone: the text wraps. */
.btn-long { white-space: normal; letter-spacing: .06em; line-height: 1.35; }
.btn:disabled { opacity: .7; }
.btn.busy { opacity: .6; pointer-events: none; }
.link-btn { background: none; border: 0; color: var(--teal); padding: 6px 2px; font-weight: 600; }

/* ---------- login ---------- */
.login { padding: 0 16px 32px; }
.login-hero { text-align: center; padding: 56px 0 22px; }
.brand-big { font-family: var(--serif); font-size: 40px; letter-spacing: .12em; margin: 0; color: var(--teal); }
.brand-sub { margin: 6px 0 0; color: var(--muted); letter-spacing: .3em; }
.brand-sub::before, .brand-sub::after { content: ""; display: inline-block; width: 36px; height: 1px; background: var(--gold); vertical-align: middle; margin: 0 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.login-card { padding: 22px 18px 20px; }
.login-title { font-family: var(--serif); font-size: 24px; margin: 0; }
.login-card .muted { margin: 4px 0 14px; }
.field-label { display: block; font-weight: 700; margin: 14px 0 6px; }
.input {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: #fffaf1;
  outline: none; min-width: 0;
}
.input:focus { border-color: var(--gold); background: #fff; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 44px; }
.pw-eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--muted); padding: 6px; }
.pw-eye[aria-pressed="true"] { color: var(--teal); }
.form-error { color: var(--danger); margin: 10px 0 0; font-size: 13px; }
#login-submit { margin-top: 20px; }
.login-foot { text-align: center; color: var(--teal); margin-top: 18px; }

/* ---------- app frame ---------- */
.app { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: rgba(246, 241, 230, .94); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line-soft);
}
.brand { font-family: var(--serif); font-size: 22px; font-weight: 700; letter-spacing: .08em; color: var(--teal); }
.page { padding: 10px 12px 0; }
.page-title {
  font-family: var(--serif); text-align: center; font-size: 22px; margin: 6px 0 12px; color: var(--teal); letter-spacing: .1em;
}
.page-title::before, .page-title::after { content: ""; display: inline-block; width: 28px; height: 1px; background: var(--gold); vertical-align: middle; margin: 0 10px; }

.wallet {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); color: #fff;
  background: linear-gradient(135deg, #1d5752, var(--teal) 60%, #12403d);
  box-shadow: 0 3px 10px rgba(23, 74, 71, .25);
}
.wallet-label { font-size: 13px; opacity: .9; }
.wallet-num { font-size: 26px; font-weight: 700; letter-spacing: .02em; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.wallet-sep { width: 1px; height: 20px; background: rgba(255, 255, 255, .35); }
.wallet-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; }
.wallet-rate { font-size: 12px; opacity: .9; white-space: nowrap; }
.wallet-log { background: none; border: 0; padding: 2px 0; font-size: 12px; color: var(--gold-soft); white-space: nowrap; }
.wallet .btn { padding: 7px 18px; border-radius: 18px; }

.notice {
  display: flex; align-items: center; gap: 6px; width: 100%; margin: 10px 0 0; padding: 8px 12px;
  background: #fbf3e4; border: 1px solid var(--line); border-radius: 9px; color: var(--accent); text-align: left; font-size: 13px;
}
.notice span:first-of-type { flex: 1; }
.chev { color: var(--muted); }
.char-chip {
  display: flex; align-items: center; gap: 6px; width: 100%; margin: 8px 0 0; padding: 8px 12px;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 9px; text-align: left; font-size: 13px;
}
.char-chip b { color: var(--teal); }
.char-chip .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- shop ---------- */
.shop-body { display: flex; gap: 8px; margin-top: 10px; align-items: flex-start; }
.side-tabs {
  flex: 0 0 76px; position: sticky; top: 56px; display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden;
}
.side-tab {
  position: relative; border: 0; background: none; padding: 14px 4px; font-size: 13px; color: var(--ink-2);
  border-bottom: 1px solid var(--line-soft);
}
.side-tab:last-child { border-bottom: 0; }
.side-tab.on { background: var(--paper); color: var(--teal); font-weight: 700; }
.side-tab.on::before { content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--teal); }
.shop-list { flex: 1; min-width: 0; }
.ladder-head { padding: 2px 2px 10px; }
.ladder-head h3 { font-family: var(--serif); font-size: 20px; margin: 0; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.ladder-head h3 small { font-family: var(--sans); font-size: 13px; color: var(--muted); font-weight: 400; }
.ladder-head h3 small b { color: var(--teal); font-size: 16px; }
.ladder-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 12px; }
.ladder-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 4px; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pack {
  position: relative; display: flex; flex-direction: column; min-width: 0; padding: 10px 9px 9px;
  background: linear-gradient(180deg, #fffaf0, var(--card) 40%); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); overflow: hidden;
}
.pack::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 3px; pointer-events: none;
  background: linear-gradient(90deg, var(--teal-2), var(--gold) 70%, transparent);
}
.pack-tag { font-family: var(--serif); font-size: 12px; color: var(--teal); font-weight: 700; }
.pack-name { font-weight: 700; font-size: 14px; margin: 2px 0 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-limit { font-size: 11.5px; color: var(--accent); }
.pack-limit.dim { color: var(--muted); }
.pack-lines { flex: 1; margin: 5px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--ink-2); min-height: 36px; }
.pack-lines li { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pack-more { align-self: flex-end; background: none; border: 0; padding: 2px 0; font-size: 12px; color: var(--muted); }
.pack-odds { background: none; border: 0; padding: 0; font-size: 12px; color: var(--teal); text-align: left; }
.pack-foot { display: flex; align-items: center; justify-content: space-between; gap: 4px; margin-top: 6px; }
.price { font-family: var(--serif); font-weight: 700; color: var(--teal); font-size: 22px; line-height: 1; white-space: nowrap; }
.price::before { content: "¥"; font-size: 13px; margin-right: 1px; }
.pack-foot .btn { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.pack-note { text-align: center; font-size: 11px; color: var(--muted); margin-top: 5px; }
.empty { text-align: center; color: var(--muted); padding: 32px 8px; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(20, 28, 27, .45);
}
.modal-panel {
  position: relative; width: 100%; max-width: 440px; max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--card); border: 1px solid var(--gold); border-radius: 14px; padding: 16px 16px 14px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25); overscroll-behavior: contain;
}
.modal-x { position: absolute; right: 8px; top: 6px; border: 0; background: none; font-size: 28px; line-height: 1; color: var(--muted); padding: 4px 8px; }
.modal-title { font-family: var(--serif); text-align: center; font-size: 20px; margin: 2px 28px 12px; color: var(--ink); }
.modal-body > * + * { margin-top: 12px; }
.sec-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.sec-title h4 { margin: 0; font-family: var(--serif); font-size: 19px; }
.sec-title span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.label { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.items { background: var(--paper); border-radius: 9px; padding: 4px 12px; }
.items-row { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.items-row:last-child { border-bottom: 0; }
.items-row b { font-weight: 600; white-space: nowrap; }
.items-row .pct { color: var(--teal); }
.items-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 12px; padding: 6px 12px; }
.items-2col .items-row { border-bottom: 0; padding: 3px 0; }
.buyline { display: flex; justify-content: space-between; align-items: flex-end; }
.buyline .big { font-family: var(--serif); font-size: 26px; font-weight: 700; color: var(--teal); line-height: 1; }
.buyline .big small { font-size: 14px; margin-left: 4px; }
.buyline .sub { font-size: 11px; color: var(--muted); text-align: right; }
.status { padding: 8px 10px; border-radius: 8px; font-size: 13px; background: var(--teal-soft); color: var(--teal); }
.status.warn { background: #fbecdf; color: var(--accent); }
.status.bad { background: #f8e3df; color: var(--danger); }
.foot-note { text-align: center; font-size: 12px; color: var(--muted); }
.result-big { text-align: center; font-size: 15px; }
.result-big b { color: var(--teal); }

/* character picker */
.picker { display: grid; grid-template-columns: 1fr auto; gap: 8px 8px; align-items: end; }
.picker .p-field { grid-column: 1 / -1; }
.picker .p-field.with-btn { grid-column: 1; }
.picker .p-btn { grid-column: 2; }
.select {
  width: 100%; min-width: 0; padding: 9px 30px 9px 10px; border: 1px solid var(--line); border-radius: 9px;
  background: #fffaf1; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%; background-size: 5px 5px; background-repeat: no-repeat;
}
.picker-card { padding: 12px; }
.picker-hint { font-size: 12px; color: var(--muted); margin: 8px 0 0; }

/* ---------- rewards ---------- */
.seg { display: flex; justify-content: center; gap: 4px; margin: 4px 0 10px; }
.seg button { flex: 1; max-width: 180px; border: 0; background: none; padding: 8px 4px; font-family: var(--serif); font-size: 17px; color: var(--ink-2); border-bottom: 2px solid transparent; }
.seg button small { font-family: var(--sans); font-size: 12px; color: var(--muted); }
.seg button.on { color: var(--teal); font-weight: 700; border-bottom-color: var(--teal); }
.sum { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); color: #fff; background: linear-gradient(135deg, #1d5752, var(--teal)); }
.sum .t { font-size: 13px; opacity: .9; }
.sum .n { font-family: var(--serif); font-size: 26px; font-weight: 700; flex: 1; }
.sum .n::before { content: "¥"; font-size: 15px; margin-right: 2px; }
.sum .btn { border-radius: 18px; }
.explain { margin-top: 10px; padding: 10px 12px; }
.explain h4 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
.explain p { margin: 0; font-size: 12.5px; color: var(--ink-2); }
.tiers-head { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 2px 8px; }
.tiers-head h4 { margin: 0; font-family: var(--serif); font-size: 17px; }
.tiers-head span { color: var(--muted); font-size: 12px; }
.tier { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin-bottom: 8px; }
.tier.can { background: #eef6f3; border-color: #a9cfc3; }
.tier-ico { flex: 0 0 38px; height: 38px; border-radius: 50%; background: var(--gold-soft); display: flex; align-items: center; justify-content: center; color: var(--accent); }
.tier-main { flex: 1; min-width: 0; }
.tier-name { font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tier-sub { font-size: 12px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 5px; background: #ececec; color: #777; }
.badge.ok { background: var(--teal); color: #fff; }
.badge.got { background: var(--teal-soft); color: var(--teal); }
.tier .btn { padding: 6px 14px; border-radius: 16px; }

/* ---------- CDK ---------- */
.block { padding: 12px; margin-bottom: 10px; }
.block-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-family: var(--serif); font-size: 17px; }
.block-title .pill { font-family: var(--sans); font-size: 11px; padding: 1px 8px; border: 1px solid var(--gold); border-radius: 10px; color: var(--accent); background: #fff8ea; }
.cdk-row { display: flex; gap: 8px; }
.cdk-row .input { flex: 1; text-transform: uppercase; }
.cdk-list { margin-top: 10px; font-size: 12.5px; }
.cdk-list .items-row { padding: 5px 0; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; padding: 10px; margin-top: 8px; text-align: left;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
}
.choice.on { border-color: var(--teal-2); background: #eef6f3; }
.choice .dot { flex: 0 0 18px; height: 18px; margin-top: 2px; border-radius: 50%; border: 2px solid var(--lock); }
.choice.on .dot { border-color: var(--teal); background: radial-gradient(circle, var(--teal) 45%, transparent 50%); }
.choice .c-main { flex: 1; min-width: 0; }
.choice .c-name { font-weight: 700; font-size: 15px; display: flex; justify-content: space-between; gap: 6px; }
.choice .c-sub { font-size: 12px; color: var(--ink-2); }
.choice:disabled { opacity: .75; }

/* ---------- 月卡 ---------- */
.mcard { padding: 12px; margin-bottom: 10px; }
.mcard-head { display: flex; align-items: center; gap: 8px; }
.mcard-head h4 { margin: 0; font-family: var(--serif); font-size: 21px; }
.mcard-head .pill { font-size: 12px; padding: 1px 8px; border-radius: 6px; background: var(--gold-soft); color: var(--accent); }
.mcard-head .btn { margin-left: auto; border-radius: 18px; padding: 8px 14px; }
.mcard-state { font-size: 13px; color: var(--ok); margin-top: 2px; }
.mcard-state.off { color: var(--muted); }
.mcard .label { margin: 10px 0 4px; color: var(--accent); }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 253, 248, .97); border-top: 1px solid var(--line-soft);
}
.nav-item {
  flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--muted); font-size: 12px;
}
.nav-item.on { color: var(--teal); font-weight: 700; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%); z-index: 60;
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 10px; background: rgba(25, 35, 34, .9); color: #fff;
  font-size: 14px; text-align: center;
}

/* ---------- 充值 popup, 充值记录, 充值结果 (FIX-1811) ---------- */
.amt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.amt, .pay-type {
  position: relative; border: 1px solid var(--line); background: var(--card); border-radius: 9px;
  padding: 10px 4px; font-weight: 600; font-size: 15px; color: var(--ink); white-space: nowrap;
}
.amt.on, .pay-type.on { border-color: var(--teal-2); background: #eef6f3; color: var(--teal); }
.amt.on::after, .pay-type.on::after {
  content: "✓"; position: absolute; top: -1px; right: -1px; padding: 0 4px; font-size: 10px; line-height: 15px;
  color: #fff; background: var(--teal-2); border-radius: 0 9px 0 6px;
}
.modal-body .pay-custom { margin-top: 8px; }
/* FIX-6169: the in-app browser warning, the pay link box and the off-screen copy buffer. */
.inapp-warn { display: grid; gap: 8px; }
.pay-link { font-size: 12px; }
.copy-buf { position: fixed; top: 0; left: -9999px; width: 1px; height: 1px; opacity: 0; font-size: 16px; }
.pay-hint { margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.pay-hint.bad { color: var(--danger); }
.pay-types { display: flex; flex-wrap: wrap; gap: 8px; }
.pay-type { flex: 1 1 30%; }
.pay-got-line { display: flex; justify-content: space-between; align-items: baseline; padding-top: 10px; border-top: 1px solid var(--line-soft); font-weight: 700; }
.pay-got-line b { font-family: var(--serif); font-size: 22px; color: var(--teal); }
.pay-loading { text-align: center; padding: 8px 0; }
.agent-way.second { border-top: 1px dashed var(--line); padding-top: 10px; }
.agent-way p { margin: 0; }
.ledger-link { display: block; margin-left: auto; margin-right: auto; font-size: 13px; }
.ledger { padding: 2px 12px; }
.ledger-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.ledger-row:last-child { border-bottom: 0; }
.l-main { flex: 1; min-width: 0; }
.l-note { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.l-time, .l-after { font-size: 11.5px; color: var(--muted); }
.l-side { flex: none; text-align: right; }
.l-delta { font-size: 15px; font-weight: 700; }
.l-delta.up { color: var(--ok); }
.l-delta.down { color: var(--accent); }
.pay-result { text-align: center; padding: 16px 10px; border-radius: 10px; background: var(--paper); }
.pr-title { font-family: var(--serif); font-size: 22px; font-weight: 700; }
.pr-num { margin-top: 4px; font-size: 20px; font-weight: 700; color: var(--teal); }
.pr-sub { margin-top: 4px; font-size: 13px; color: var(--ink-2); }
.pay-result.ok .pr-title { color: var(--ok); }
.pay-result.bad .pr-title { color: var(--danger); }
.pay-result.wait .pr-title { color: var(--accent); }

@media (max-width: 374px) {
  .amt, .pay-type { font-size: 14px; padding: 9px 2px; }
  .page { padding: 8px 8px 0; }
  .side-tabs { flex-basis: 68px; }
  .side-tab { font-size: 12px; padding: 12px 2px; }
  .price { font-size: 19px; }
  .pack { padding: 9px 7px 8px; }
  .pack-foot .btn { padding: 5px 8px; font-size: 12px; }
  .wallet { gap: 8px; padding: 10px 12px; }
  .wallet-num { font-size: 22px; }
}
