/* =========================================================
   牙齿小宇宙 · 全局主题与共享组件
   设计语言：温暖奶油底 × 珊瑚橘 × 青绿，圆润绘本感
   ========================================================= */
:root {
  --bg: #FBF8F3;
  --bg-soft: #F4EDE4;
  --card: #FFFFFF;
  --ink: #2E2523;
  --ink-soft: #6B5C57;
  --ink-faint: #998A84;
  --line: rgba(93, 42, 40, .10);
  --line-strong: rgba(93, 42, 40, .18);

  /* 中山大学附属口腔医院品牌色 */
  --brand-red: #8C000D;
  --brand-red-2: #9D1F2D;
  --brand-gold: #C8A24A;
  --brand-gold-deep: #8A6218;
  --brand-green: #2F7D63;

  --coral: #9D1F2D;
  --coral-deep: #7C1420;
  --coral-soft: #F7E5E7;
  --teal: #2F7D63;
  --teal-deep: #24614D;
  --teal-soft: #E8F3EE;
  --sun: #C8A24A;
  --sun-soft: #FAF0D8;
  --sky: #4F7396;
  --sky-soft: #EDF3F8;
  --lav: #F0E9E0;
  --lav-deep: #8A6A4A;
  --rose: #C98086;
  --mint: #E8F3EE;

  --radius-xl: 32px;
  --radius-lg: 26px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --radius-pill: 999px;

  --shadow-1: 0 8px 24px rgba(80, 30, 25, .07);
  --shadow-2: 0 18px 48px rgba(80, 30, 25, .13);
  --shadow-3: 0 26px 70px rgba(80, 30, 25, .2);

  --font: "PingFang SC", "HarmonyOS Sans SC", "Hiragino Sans GB", "Source Han Sans SC", "Noto Sans SC", "Microsoft YaHei", "Yuanti SC", system-ui, sans-serif;
  --font-round: "Yuanti SC", "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", var(--font);
  --font-serif: "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", serif;

  --header-h: 64px;
  --tabbar-h: 64px;
  --page-max: 1240px;
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}

/* ---------------- Reset ---------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 88% -10%, rgba(200, 162, 74, .16), transparent 60%),
    radial-gradient(900px 500px at -10% 12%, rgba(140, 0, 13, .07), transparent 55%),
    radial-gradient(800px 500px at 50% 112%, rgba(47, 125, 99, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  padding-top: var(--header-h);
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  line-height: 1.6;
}
body.no-tabbar { padding-bottom: 0; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
img, svg, canvas { display: block; max-width: 100%; }
[hidden] { display: none !important; }
::selection { background: var(--coral-soft); color: var(--ink); }

:focus-visible {
  outline: 3px solid rgba(31, 182, 166, .55);
  outline-offset: 3px;
  border-radius: 8px;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  padding: 10px 16px;
  border-radius: var(--radius-pill);
  background: var(--ink);
  color: #fff;
  transform: translateY(-200%);
  transition: transform .2s var(--ease-out);
}
.skip-link:focus { transform: translateY(0); }

/* ---------------- 顶栏 ---------------- */
.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  height: var(--header-h);
  background: rgba(255, 253, 250, .95);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid rgba(140, 0, 13, .1);
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, #8C000D 0%, #9D1F2D 46%, #C8A24A 100%);
  opacity: .95;
}
.topbar__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  height: 100%;
  padding: 0 clamp(14px, 3vw, 32px);
  display: flex;
  align-items: center;
  gap: clamp(12px, 2.4vw, 32px);
}
.brand { display: flex; align-items: center; gap: 12px; flex-shrink: 0; min-width: 0; }
.brand__logo-box {
  display: flex; align-items: center; justify-content: center;
  padding: 5px 10px;
  background: #fff;
  border: 1px solid rgba(140, 0, 13, .12);
  border-radius: 11px;
  box-shadow: 0 3px 12px rgba(80, 30, 25, .07);
  flex-shrink: 0;
}
.brand__logo { display: block; height: 28px; width: auto; }
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__title { font-family: var(--font-round); font-size: 17px; font-weight: 800; letter-spacing: .01em; color: var(--ink); white-space: nowrap; }
.brand__sub { font-size: 10.5px; color: var(--brand-red-2); letter-spacing: .1em; white-space: nowrap; opacity: .85; }

.main-nav { display: flex; align-items: center; gap: 4px; margin-left: 8px; }
.main-nav__item {
  position: relative;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background .2s var(--ease-out), color .2s var(--ease-out), transform .2s var(--ease-spring);
  white-space: nowrap;
}
.main-nav__item:hover { background: rgba(140, 0, 13, .06); color: var(--ink); }
.main-nav__item.is-active { background: var(--brand-red); color: #FFF9F2; box-shadow: 0 6px 16px rgba(140, 0, 13, .22); }
.main-nav__item:active { transform: scale(.96); }

.topbar__actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }
.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 40px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
  transition: background .18s var(--ease-out), color .18s, transform .18s var(--ease-spring), box-shadow .18s;
}
.icon-btn:hover { background: #fff; color: var(--ink); box-shadow: var(--shadow-1); }
.icon-btn:active { transform: scale(.95); }
.icon-btn__glyph { font-size: 16px; line-height: 1; }
.icon-btn--primary { background: var(--brand-red); color: #FFF9F2; box-shadow: 0 6px 16px rgba(140, 0, 13, .2); }
.icon-btn--primary:hover { background: var(--coral-deep); color: #fff; box-shadow: 0 8px 20px rgba(140, 0, 13, .26); }
.icon-btn__dot {
  position: absolute; top: 7px; right: 9px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0 2px var(--bg);
}

/* ---------------- 主舞台 / 视图切换 ---------------- */
.stage { max-width: var(--page-max); margin: 0 auto; padding: 0 clamp(14px, 3vw, 32px); }
.view { display: none; }
.view.is-active { display: block; animation: view-in .42s var(--ease-out) backwards; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
.view-boot {
  min-height: 52vh;
  display: grid;
  place-items: center;
  color: var(--ink-faint);
  font-size: 14px;
}
.view-boot::before {
  content: "";
  width: 22px; height: 22px;
  margin-right: 10px;
  border-radius: 50%;
  border: 3px solid var(--coral-soft);
  border-top-color: var(--coral);
  animation: spin .8s linear infinite;
  display: inline-block;
  vertical-align: -5px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- 通用组件 ---------------- */
.ui-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, .8);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: .07em;
  color: var(--ink-soft);
}
.eyebrow__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--brand-red-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border-radius: var(--radius-pill);
  font-size: 15.5px;
  font-weight: 700;
  white-space: nowrap;
  transition: transform .2s var(--ease-spring), box-shadow .2s var(--ease-out), background .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.96); }
.btn--primary { background: var(--brand-red); color: #fff; box-shadow: 0 10px 22px rgba(140, 0, 13, .24); }
.btn--primary:hover { background: var(--coral-deep); box-shadow: 0 14px 30px rgba(140, 0, 13, .3); }
.btn--dark { background: var(--ink); color: #FFF7EC; box-shadow: 0 10px 22px rgba(45, 42, 38, .18); }
.btn--dark:hover { background: #413d37; }
.btn--ghost { background: rgba(255, 255, 255, .75); color: var(--ink); border: 1px solid var(--line-strong); }
.btn--ghost:hover { background: #fff; box-shadow: var(--shadow-1); }
.btn--sm { min-height: 40px; padding: 0 18px; font-size: 14px; }
.btn .btn__arrow { transition: transform .2s var(--ease-spring); }
.btn:hover .btn__arrow { transform: translateX(3px); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-soft);
}

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head__title { font-family: var(--font-round); font-size: clamp(21px, 2.6vw, 28px); font-weight: 800; letter-spacing: .01em; }
.section-head__sub { margin-top: 4px; font-size: 13.5px; color: var(--ink-soft); }
.text-link {
  color: var(--brand-red-2);
  font-size: 13.5px;
  font-weight: 700;
  padding: 8px 4px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}
.text-link:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ---------------- Toast ---------------- */
.toast-root {
  position: fixed;
  top: calc(var(--header-h) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 460px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 18px 11px 14px;
  border-radius: var(--radius-pill);
  background: rgba(45, 42, 38, .94);
  color: #FFF9F0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  box-shadow: var(--shadow-2);
  opacity: 0;
  transform: translateY(-10px) scale(.96);
  transition: opacity .26s var(--ease-out), transform .32s var(--ease-spring);
  pointer-events: auto;
  cursor: pointer;
  text-align: left;
}
.toast.is-in { opacity: 1; transform: none; }
.toast__icon { font-size: 16px; }
.toast--success { background: linear-gradient(135deg, #24614D, #2F7D63); }
.toast--warn { background: linear-gradient(135deg, #A9781B, #C8A24A); color: #FFF9F2; }
.toast--error { background: linear-gradient(135deg, #7C1420, #9D1F2D); }

/* ---------------- 彩带 ---------------- */
.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 150;
  pointer-events: none;
}

/* ---------------- 弹层 ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 160;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(45, 38, 28, .42);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .25s var(--ease-out);
}
.modal-backdrop.is-in { opacity: 1; }
.modal {
  width: min(480px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  background: var(--card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-3);
  padding: clamp(22px, 4vw, 32px);
  transform: translateY(20px) scale(.96);
  transition: transform .34s var(--ease-spring);
  position: relative;
  -webkit-overflow-scrolling: touch;
}
.modal-backdrop.is-in .modal { transform: none; }
.modal__close {
  position: absolute;
  top: 14px; right: 14px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--ink-soft);
  font-size: 16px;
  display: grid;
  place-items: center;
  transition: background .2s, transform .2s var(--ease-spring);
}
.modal__close:hover { background: var(--coral-soft); transform: rotate(90deg); }
.modal__title { font-family: var(--font-round); font-size: clamp(20px, 3vw, 24px); font-weight: 800; padding-right: 40px; }
.modal__sub { margin-top: 6px; color: var(--ink-soft); font-size: 13.5px; }

/* 分享 / 二维码 */
.share-qr { display: grid; place-items: center; margin: 20px auto 14px; }
.share-qr__box {
  padding: 14px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
}
.share-qr__box svg { width: min(216px, 58vw); height: auto; }
.share-url {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 8px 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-soft);
  border: 1px dashed var(--line-strong);
}
.share-url__text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.share-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.share-actions .btn { flex: 1; min-width: 140px; }
.share-tip { margin-top: 14px; font-size: 12.5px; color: var(--ink-faint); line-height: 1.7; text-align: center; }

/* 奖章护照 */
.passport { display: grid; gap: 10px; margin-top: 18px; }
.passport__item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: var(--bg);
  border: 1px solid var(--line);
}
.passport__item.is-earned { background: linear-gradient(135deg, #FFF8E6, #FFF1D6); border-color: rgba(224, 162, 30, .28); }
.passport__emoji { font-size: 26px; filter: grayscale(1); opacity: .45; }
.passport__item.is-earned .passport__emoji { filter: none; opacity: 1; }
.passport__name { font-weight: 800; font-size: 15px; }
.passport__desc { font-size: 12.5px; color: var(--ink-soft); line-height: 1.5; }
.passport__status { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--ink-faint); white-space: nowrap; }
.passport__item.is-earned .passport__status { color: var(--teal-deep); }

/* ---------------- 页脚 ---------------- */
.site-foot {
  position: relative;
  margin-top: clamp(36px, 6vw, 72px);
  background: #FFFDFA;
  border-top: 1px solid rgba(140, 0, 13, .1);
}
.site-foot::before {
  content: "";
  display: block;
  height: 3px;
  background: linear-gradient(90deg, #8C000D 0%, #9D1F2D 46%, #C8A24A 100%);
}
.site-foot__inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 30px clamp(16px, 3vw, 32px) 28px;
  display: grid;
  gap: 18px;
}
.site-foot__main {
  display: grid;
  grid-template-columns: minmax(210px, .9fr) minmax(280px, 1.25fr) auto;
  gap: 28px;
  align-items: start;
}
.site-foot__brand { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.site-foot__logo { height: 30px; width: auto; }
.site-foot__tagline { font-size: 12px; color: var(--ink-faint); letter-spacing: .02em; }
.site-foot__motto { font-family: var(--font-serif); font-size: 12.5px; letter-spacing: .16em; color: var(--brand-gold-deep); }
.site-foot__visit { display: flex; flex-direction: column; gap: 3px; }
.site-foot__visit p { font-size: 12.5px; color: var(--ink-soft); line-height: 1.75; }
.site-foot__visit strong { color: var(--brand-red-2); font-weight: 800; margin-right: 8px; }
.site-foot__nav { display: flex; flex-direction: column; align-items: flex-start; gap: 0; }
.site-foot__note { font-size: 12px; color: var(--ink-faint); line-height: 1.8; max-width: 900px; }
.site-foot__bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  color: var(--ink-faint);
}
.site-foot__bottom p { line-height: 1.7; }
.site-foot__links { display: flex; gap: 18px; flex-wrap: wrap; }
.site-foot__links .text-link, .site-foot__bottom .text-link { min-height: 32px; font-size: 12px; color: var(--ink-soft); }
.site-foot__nav .text-link { min-height: 34px; }

/* ---------------- 底部 Tab（移动端） ---------------- */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70;
  display: none;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
  padding: 6px 8px env(safe-area-inset-bottom, 0px);
  background: rgba(255, 250, 242, .94);
  -webkit-backdrop-filter: blur(18px);
  backdrop-filter: blur(18px);
  border-top: 1px solid rgba(61, 48, 33, .08);
}
.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  border-radius: var(--radius-md);
  color: var(--ink-faint);
  font-size: 11px;
  font-weight: 700;
  position: relative;
  transition: color .2s, background .2s, transform .2s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.tabbar__icon { font-size: 21px; line-height: 1; transition: transform .25s var(--ease-spring); filter: grayscale(.45); opacity: .8; }
.tabbar__item.is-active { color: var(--brand-red-2); background: rgba(140, 0, 13, .08); }
.tabbar__item.is-active .tabbar__icon { transform: translateY(-2px) scale(1.12); filter: none; opacity: 1; }
.tabbar__item:active { transform: scale(.94); }
.tabbar__item.is-active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 16px; height: 3px;
  border-radius: 3px;
  background: var(--brand-red);
}

.noscript {
  position: fixed;
  inset: auto 12px 12px 12px;
  z-index: 999;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  background: #2D2A26;
  color: #fff;
  font-size: 13px;
  text-align: center;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 899px) {
  .site-foot { display: none; }
  .main-nav { display: none; }
  .tabbar { display: flex; }
  .topbar__actions .icon-btn__label { display: none; }
  .icon-btn { width: 40px; justify-content: center; padding: 0; }
  .icon-btn--primary { width: 40px; }
  .brand { gap: 9px; }
  .brand__logo-box { padding: 4px 8px; border-radius: 9px; }
  .brand__logo { height: 25px; }
  .brand__sub { display: none; }
  .brand__title { font-size: 16px; }
}
@media (max-width: 420px) {
  .brand__text { display: none; }
  .brand__logo-box { padding: 4px 7px; }
  .brand__logo { height: 23px; }
  .topbar__actions { gap: 2px; }
  .icon-btn { width: 36px; height: 38px; }
  .toast-root { top: calc(var(--header-h) + 8px); }
}
@media (min-width: 900px) {
  :root { --header-h: 72px; }
  body { padding-bottom: 0; }
  .stage { padding-top: 12px; }
  .view.is-active { padding-bottom: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
