/* ============================================================
   基础层 · 重置 / 排版基元 / 应用骨架 / 启动屏
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: var(--lh-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

/* 数字：等宽对齐，金额/数量不跳动 */
.num, .money, .qty { font-variant-numeric: tabular-nums lining-nums; font-feature-settings: "tnum" 1; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--fw-bold); line-height: var(--lh-tight); letter-spacing: var(--tracking-tight); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { border: none; background: none; padding: 0; cursor: pointer; touch-action: manipulation; }
a { color: var(--accent); text-decoration: none; }
img, svg { display: block; }

::selection { background: var(--cinnabar-mist); color: var(--ink-900); }

/* 细滚动条（桌面） */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: var(--r-full); border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-track { background: transparent; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-xs); }

/* ---------- 应用骨架 ---------- */
#app {
  position: relative;
  height: 100%;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}
@media (min-width: 1100px) {
  /* POS 等宽页可放宽；这里给整体列一个上限，页面内部可再突破 */
  #app { max-width: var(--app-max); }
}

/* 顶栏 */
.appbar {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  flex: 0 0 auto;
  padding-top: var(--safe-top);
  background: var(--paper);
  border-bottom: 1px solid transparent;
  transition: border-color var(--d2) var(--ease);
}
.appbar.is-scrolled { border-bottom-color: var(--line); }
.appbar__row {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
}
.appbar__title {
  font-family: var(--font-serif);
  font-size: var(--fs-title3);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide);
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.appbar__actions { display: flex; align-items: center; gap: var(--sp-2); flex: 0 0 auto; }

/* 大标题（iOS Large Title），滚动可折叠 */
.largetitle {
  padding: var(--sp-2) var(--sp-4) var(--sp-3);
}
.largetitle__text {
  font-family: var(--font-serif);
  font-size: var(--fs-large-title);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.1;
  transform-origin: left center;
  transition: transform var(--d3) var(--ease-out), opacity var(--d3) var(--ease-out);
}
.largetitle.is-collapsed .largetitle__text { opacity: 0; transform: translateY(-8px) scale(.82); pointer-events: none; }
.largetitle__hint { margin-top: var(--sp-1); color: var(--text-3); font-size: var(--fs-footnote); }

/* 可滚动内容区 */
.content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom) + var(--sp-6));
}
.content::-webkit-scrollbar { width: 10px; }
.content::-webkit-scrollbar-track { background: transparent; }
.content::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: var(--r-full); border: 3px solid transparent; background-clip: padding-box; }
.content::-webkit-scrollbar-thumb:hover { background: var(--ink-300); background-clip: padding-box; }
.content--flush { padding-bottom: 0; }
.page { padding: 0 var(--sp-4) var(--sp-6); }
.page__section + .page__section { margin-top: var(--sp-6); }

/* 底部标签栏 */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: var(--app-max);
  z-index: var(--z-tabbar);
  display: flex;
  align-items: stretch;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--paper-3);
  border-top: 1px solid var(--line);
}
.tabbar__item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: none;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px 0 4px;
  position: relative;
  transition: color var(--d2) var(--ease), transform var(--d1) var(--ease-spring);
  -webkit-user-select: none; user-select: none;
}
.tabbar__item:active { transform: scale(.9); }
.tabbar__item.is-active { color: var(--brand); }
.tabbar__icon { width: 26px; height: 26px; display: grid; place-items: center; }
.tabbar__icon svg { width: 26px; height: 26px; }
.tabbar__label { font-size: var(--fs-micro); font-weight: var(--fw-medium); letter-spacing: .02em; }
.tabbar__badge {
  position: absolute; top: 4px; right: 50%; margin-right: -22px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--r-full); background: var(--brand); color: #fff;
  font-size: 10px; font-weight: var(--fw-bold); line-height: 16px; text-align: center;
  box-shadow: 0 0 0 2px var(--paper-3);
}

/* ---------- 启动屏 ---------- */
.splash {
  position: fixed; inset: 0; z-index: var(--z-splash);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3);
  background:
    radial-gradient(80% 60% at 50% 30%, #fffdf8, var(--paper) 70%);
  transition: opacity var(--d4) var(--ease), visibility var(--d4);
}
.splash.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.splash__seal {
  width: 84px; height: 84px; display: grid; place-items: center;
  font-family: var(--font-serif); font-size: 46px; font-weight: var(--fw-bold); color: #fffaf2;
  background: var(--cinnabar);
  border-radius: 20px;
  box-shadow: var(--sh-brand);
  transform: rotate(-4deg);
  animation: splashSeal var(--d5) var(--ease-spring) both;
}
.splash__name { font-family: var(--font-serif); font-size: var(--fs-title2); font-weight: var(--fw-bold); letter-spacing: var(--tracking-wider); color: var(--ink-800); }
.splash__sub { font-size: var(--fs-footnote); letter-spacing: var(--tracking-wider); color: var(--text-3); }
.splash__loading { margin-top: var(--sp-4); width: 96px; height: 2px; border-radius: 2px; background: var(--line); overflow: hidden; }
.splash__loading span { display: block; height: 100%; width: 40%; background: var(--brand); border-radius: 2px; animation: splashBar 1.1s var(--ease-in-out) infinite; }
@keyframes splashSeal { from { opacity: 0; transform: scale(.7) rotate(-6deg); } to { opacity: 1; transform: none; } }
@keyframes splashBar { 0% { transform: translateX(-100%); } 100% { transform: translateX(320%); } }

/* ---------- 通用工具类 ---------- */
.row { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.col { display: flex; flex-direction: column; }
.gap-1 { gap: var(--sp-1); } .gap-2 { gap: var(--sp-2); } .gap-3 { gap: var(--sp-3); } .gap-4 { gap: var(--sp-4); }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: grid; place-items: center; }
.muted { color: var(--text-3); }
.t2 { color: var(--text-2); }
.serif { font-family: var(--font-serif); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }
.mt-2 { margin-top: var(--sp-2);} .mt-4 { margin-top: var(--sp-4);} .mt-6 { margin-top: var(--sp-6);}
.money { font-family: var(--font-num); font-weight: var(--fw-semi); letter-spacing: -.01em; }
.money--brand { color: var(--brand); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
