/* ============================================================
   印章邮局 · 视觉系统
   纸张 / 朱砂 / 宋体 / 双线印框
   ============================================================ */
:root {
  --paper: #f4eee2;
  --paper-2: #faf5ea;
  --card: #fffcf5;
  --ink: #26201b;
  --ink-2: #6b6157;
  --ink-3: #9a8f82;
  --red: #b1392c;
  --red-dark: #8c2a20;
  --gold: #a4771c;
  --line: rgba(38, 32, 27, 0.13);
  --line-soft: rgba(38, 32, 27, 0.07);
  --shadow: 0 12px 34px rgba(63, 48, 31, 0.09);
  --shadow-lg: 0 28px 70px rgba(50, 36, 20, 0.18);
  --r: 20px;
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  --noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='.4'/%3E%3C/svg%3E");
}

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

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

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(177, 57, 44, 0.07), transparent 60%),
    radial-gradient(900px 600px at -10% 20%, rgba(164, 119, 28, 0.08), transparent 55%),
    linear-gradient(180deg, #f6f0e4 0%, #f2ebde 100%);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: var(--noise);
  opacity: 0.035;
  pointer-events: none;
  z-index: 1;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

svg {
  display: block;
}

::selection {
  background: rgba(177, 57, 44, 0.18);
}

/* ---------- 基础组件 ---------- */
.boot {
  min-height: 100dvh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: var(--ink-2);
  position: relative;
  z-index: 2;
}

.brand-seal {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  background: var(--red);
  color: #fff7e8;
  display: grid;
  place-items: center;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  transform: rotate(-4deg);
  box-shadow: 0 4px 12px rgba(140, 42, 32, 0.28);
  flex: none;
}

.brand-seal.big {
  width: 64px;
  height: 64px;
  font-size: 38px;
  border-radius: 14px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(18px, 4vw, 48px);
  background: rgba(246, 240, 228, 0.82);
  backdrop-filter: blur(14px) saturate(1.1);
  border-bottom: 1px solid var(--line-soft);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  text-decoration: none;
  min-width: 0;
}

.brand-text {
  display: grid;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.06em;
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--ink-3);
  text-transform: uppercase;
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: 14px;
}

.topnav a {
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 14px;
  transition: 0.18s ease;
}

.topnav a:hover {
  background: rgba(38, 32, 27, 0.05);
  color: var(--ink);
}

.topnav a.active {
  background: var(--ink);
  color: var(--paper-2);
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 252, 245, 0.7);
  font-size: 13px;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #efe5d3;
  font-size: 16px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  transition: 0.18s ease;
}

.icon-btn:hover {
  background: rgba(38, 32, 27, 0.06);
  color: var(--ink);
}

.page {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px clamp(16px, 4vw, 44px) 70px;
}

.kicker {
  font-size: 11px;
  letter-spacing: 0.32em;
  color: var(--red);
  font-weight: 600;
  text-transform: uppercase;
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--ink-3);
}

/* ---------- 首页 hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: center;
  padding: 26px 0 14px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(34px, 5.2vw, 60px);
  line-height: 1.16;
  letter-spacing: -0.01em;
  margin: 14px 0 16px;
  font-weight: 700;
}

.hero h1 .em {
  position: relative;
  color: var(--red);
  white-space: nowrap;
}

.hero h1 .em::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  height: 8px;
  background: rgba(177, 57, 44, 0.16);
  border-radius: 4px;
  z-index: -1;
}

.hero-sub {
  color: var(--ink-2);
  max-width: 38em;
  font-size: 15px;
}

.hero-art {
  position: relative;
  height: 300px;
  min-width: 0;
}

.float-stamp {
  position: absolute;
  display: block;
  filter: drop-shadow(0 14px 22px rgba(70, 50, 30, 0.13));
  animation: floaty 7s ease-in-out infinite;
}

.float-stamp .stamp {
  --w: 100%;
  width: 100%;
  background: var(--soft);
}

.float-stamp:nth-child(1) {
  width: 128px;
  left: 4%;
  top: 12%;
  transform: rotate(-9deg);
  animation-delay: -0.4s;
}
.float-stamp:nth-child(2) {
  width: 104px;
  right: 6%;
  top: 2%;
  transform: rotate(7deg);
  animation-delay: -2.1s;
}
.float-stamp:nth-child(3) {
  width: 148px;
  right: 14%;
  bottom: 2%;
  transform: rotate(-3deg);
  animation-delay: -3.4s;
}
.float-stamp:nth-child(4) {
  width: 92px;
  left: 12%;
  bottom: 12%;
  transform: rotate(11deg);
  animation-delay: -1.3s;
}
.float-stamp:nth-child(5) {
  width: 78px;
  left: 46%;
  top: 40%;
  transform: rotate(4deg);
  animation-delay: -4.6s;
  opacity: 0.9;
}

.postmark {
  position: absolute;
  right: 2%;
  top: 46%;
  width: 118px;
  height: 118px;
  border: 2px solid rgba(38, 32, 27, 0.18);
  border-radius: 50%;
  color: rgba(38, 32, 27, 0.38);
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 9px;
  letter-spacing: 0.22em;
  line-height: 1.8;
  transform: rotate(-12deg);
  pointer-events: none;
}

.postmark::before {
  content: "";
  position: absolute;
  inset: 7px;
  border: 1px dashed rgba(38, 32, 27, 0.16);
  border-radius: 50%;
}

.postmark b {
  display: block;
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0.3em;
  color: rgba(38, 32, 27, 0.45);
}

@keyframes floaty {
  0%,
  100% {
    translate: 0 0;
  }
  50% {
    translate: 0 -9px;
  }
}

/* ---------- 统计 ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0 30px;
}

.stat-row.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-card {
  background: rgba(255, 252, 245, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 15px 16px 13px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: "";
  position: absolute;
  right: -18px;
  bottom: -26px;
  width: 76px;
  height: 76px;
  border: 1.5px solid rgba(177, 57, 44, 0.12);
  border-radius: 50%;
}

.stat-num {
  font-family: var(--serif);
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.stat-num small {
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 400;
  margin-left: 3px;
  letter-spacing: 0;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 4px;
}

.stat-note {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------- 区块头 ---------- */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 26px 0 14px;
  flex-wrap: wrap;
}

.section-title {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title::before {
  content: "";
  width: 5px;
  height: 21px;
  border-radius: 3px;
  background: var(--red);
  display: inline-block;
}

.section-sub {
  color: var(--ink-3);
  font-size: 12px;
}

.filter-row {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin: 4px 0 18px;
}

.chip {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 12.5px;
  color: var(--ink-2);
  transition: 0.16s ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: rgba(38, 32, 27, 0.3);
  color: var(--ink);
}

.chip.active {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper-2);
}

/* ---------- 印章本体 ---------- */
.stamp {
  --w: 64px;
  position: relative;
  display: inline-block;
  vertical-align: middle;
  width: var(--w);
  aspect-ratio: 1;
  color: var(--ink);
  border: 1.5px solid currentColor;
  border-radius: 15%;
  min-width: 0;
  background: transparent;
  line-height: 0;
  isolation: isolate;
}

.stamp::before {
  content: "";
  position: absolute;
  inset: 3px;
  border: 1px solid currentColor;
  opacity: 0.42;
  border-radius: 11%;
  pointer-events: none;
}

.stamp::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image: var(--noise);
  opacity: 0.22;
  mix-blend-mode: multiply;
  pointer-events: none;
}

.stamp svg {
  position: absolute;
  inset: 5.5%;
  width: 89%;
  height: 89%;
}

.stamp.on {
  background: var(--soft);
}

.stamp.locked {
  color: #c5bbaa;
  border-style: dashed;
  opacity: 0.62;
}

.stamp.locked::before {
  border-style: dashed;
  opacity: 0.5;
}

.stamp.locked::after {
  opacity: 0.1;
}

.stamp.s-sm {
  --w: 40px;
  border-radius: 12%;
}
.stamp.s-md {
  --w: 64px;
}
.stamp.s-lg {
  --w: 92px;
}
.stamp.s-xl {
  --w: 118px;
}

/* ---------- 图鉴 ---------- */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(158px, 1fr));
  gap: 12px;
}

.pattern-card {
  position: relative;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px 14px 14px;
  box-shadow: 0 2px 0 rgba(38, 32, 27, 0.02);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  overflow: hidden;
  animation: rise 0.5s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: var(--d, 0ms);
}

.pattern-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(38, 32, 27, 0.22);
}

.pattern-card::after {
  content: "";
  position: absolute;
  right: -22px;
  top: -22px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 1px solid rgba(177, 57, 44, 0.09);
}

.pc-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.16em;
  color: var(--ink-3);
}

.pc-index {
  font-family: var(--mono);
}

.pc-theme {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  letter-spacing: 0.08em;
}

.pc-stamp {
  display: grid;
  place-items: center;
  padding: 13px 0 10px;
}

.pc-stamp .stamp {
  --w: 78px;
  transform: rotate(-3deg);
  transition: transform 0.25s ease;
}

.pattern-card:hover .pc-stamp .stamp {
  transform: rotate(0deg) scale(1.03);
}

.pc-name {
  font-family: var(--serif);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.02em;
}

.pc-rarity {
  font-family: var(--sans);
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--gold);
  border: 1px solid rgba(164, 119, 28, 0.35);
  border-radius: 4px;
  padding: 1px 4px;
  vertical-align: 2px;
}

.pc-progress {
  height: 3px;
  border-radius: 2px;
  background: rgba(38, 32, 27, 0.08);
  margin: 10px 0 7px;
  overflow: hidden;
}

.pc-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
  opacity: 0.75;
  transition: width 0.5s ease;
}

.pc-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-3);
}

.pc-colors {
  display: flex;
  gap: 4px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: transparent;
}

.dot.on {
  border-color: transparent;
}

/* ---------- 最近动态 ---------- */
.recent-list {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.recent-item:last-child {
  border-bottom: 0;
}

.ri-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: rgba(177, 57, 44, 0.07);
  color: var(--red);
  display: grid;
  place-items: center;
  flex: none;
}

.ri-main {
  min-width: 0;
  flex: 1;
}

.ri-title {
  font-size: 13.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ri-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 1px;
}

.ri-amount {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--red);
  flex: none;
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--ink-3);
  font-size: 13px;
}

.empty .stamp {
  margin: 0 auto 14px;
  opacity: 0.5;
}

/* ---------- 兑换 ---------- */
.recipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}

.recipe-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  animation: rise 0.5s ease both;
  animation-delay: var(--d, 0ms);
}

.recipe-card.ready {
  border-color: rgba(177, 57, 44, 0.34);
  box-shadow: 0 8px 28px rgba(177, 57, 44, 0.07);
}

.recipe-card.ready::before {
  content: "可兑换";
  position: absolute;
  right: 14px;
  top: 14px;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #fff8ea;
  background: var(--red);
  border-radius: 999px;
  padding: 3px 9px;
  transform: rotate(3deg);
}

.recipe-card.locked {
  opacity: 0.78;
}

.rc-head {
  display: flex;
  align-items: baseline;
  gap: 9px;
}

.rc-index {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-3);
}

.rc-name {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.rc-tagline {
  font-size: 12px;
  color: var(--ink-3);
}

.rc-req {
  background: rgba(38, 32, 27, 0.035);
  border-radius: 12px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 62px;
  flex-wrap: wrap;
}

.mini-stamps {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  align-items: center;
}

.mini-stamps .stamp {
  --w: 32px;
}

.req-text {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
}

.rc-reward {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
}

.rc-reward b {
  font-family: var(--serif);
  font-size: 22px;
  color: var(--red);
  font-weight: 700;
  line-height: 1.2;
}

.rc-limit {
  font-size: 10.5px;
  color: var(--ink-3);
  text-align: right;
  line-height: 1.5;
}

.rc-note {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.55;
  border-top: 1px dashed var(--line);
  padding-top: 9px;
}

.rc-actions {
  display: flex;
  gap: 8px;
}

/* ---------- 记录 ---------- */
.history {
  position: relative;
  padding-left: 24px;
}

.history::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

.history-item {
  position: relative;
  padding: 0 0 20px;
}

.hi-dot {
  position: absolute;
  left: -24px;
  top: 5px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--paper);
  border: 1.5px solid var(--ink-3);
  display: grid;
  place-items: center;
}

.hi-dot::after {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.history-item.gain .hi-dot {
  color: var(--red);
  border-color: var(--red);
}

.history-item.spend .hi-dot {
  color: var(--gold);
  border-color: var(--gold);
}

.hi-body {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}

.hi-title {
  font-size: 13.5px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.hi-title b {
  font-weight: 600;
}

.hi-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 3px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.hi-amount {
  font-family: var(--mono);
  font-size: 12px;
  flex: none;
}

.gain .hi-amount {
  color: var(--red);
}

.spend .hi-amount {
  color: var(--gold);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  border-radius: 999px;
  padding: 2px 8px;
  background: rgba(38, 32, 27, 0.06);
  color: var(--ink-2);
}

.badge.red {
  background: rgba(177, 57, 44, 0.1);
  color: var(--red);
}

.badge.gold {
  background: rgba(164, 119, 28, 0.12);
  color: var(--gold);
}

.badge.green {
  background: rgba(60, 124, 96, 0.12);
  color: #2f6a50;
}

.form-error {
  font-size: 12px;
  color: var(--red);
  min-height: 16px;
  margin-top: 8px;
  line-height: 1.6;
}

.form-error:empty {
  min-height: 0;
  margin-top: 0;
}

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: rgba(38, 32, 27, 0.06);
  border-radius: 5px;
  padding: 1px 5px;
}

/* ---------- 兑换单 / 核销 ---------- */
.pending-strip {
  display: grid;
  gap: 10px;
}

.pending-card {
  background: linear-gradient(135deg, rgba(177, 57, 44, 0.055), rgba(164, 119, 28, 0.04));
  border: 1px dashed rgba(177, 57, 44, 0.3);
  border-radius: 16px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.pending-card .pc-code {
  font-family: var(--mono);
  font-size: 26px;
  letter-spacing: 0.16em;
  color: var(--red);
  line-height: 1;
}

.pending-card .pc-info {
  flex: 1;
  min-width: 180px;
}

.pending-card .pc-title {
  font-size: 13.5px;
  font-weight: 600;
}

.pending-card .pc-meta {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
}

/* ---------- 家长端 ---------- */
.parent-wrap {
  max-width: 1040px;
}

.parent-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin: 20px 0 22px;
  overflow-x: auto;
  scrollbar-width: none;
}

.parent-tabs::-webkit-scrollbar {
  display: none;
}

.parent-tab {
  border: 0;
  background: transparent;
  padding: 10px 4px;
  margin-right: 20px;
  color: var(--ink-3);
  font-size: 14px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.parent-tab.active {
  color: var(--ink);
  border-bottom-color: var(--red);
  font-weight: 600;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 16px;
}

.panel-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.panel-head h3 {
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.panel-body {
  padding: 16px 18px;
}

.panel-note {
  font-size: 12px;
  color: var(--ink-3);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  align-items: end;
}

.field {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 11.5px;
  color: var(--ink-2);
  letter-spacing: 0.04em;
}

.input,
.select {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 252, 245, 0.85);
  padding: 0 12px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  font-size: 14px;
}

.input:focus,
.select:focus {
  border-color: rgba(177, 57, 44, 0.5);
  box-shadow: 0 0 0 3px rgba(177, 57, 44, 0.09);
}

.input.code {
  font-family: var(--mono);
  letter-spacing: 0.28em;
  font-size: 18px;
  text-align: center;
  max-width: 220px;
}

textarea.input {
  height: auto;
  min-height: 74px;
  padding: 10px 12px;
  resize: vertical;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.spacer {
  flex: 1;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  height: 40px;
  padding: 0 18px;
  font-size: 13.5px;
  color: var(--ink);
  transition: 0.16s ease;
  white-space: nowrap;
}

.btn:hover {
  background: rgba(38, 32, 27, 0.05);
}

.btn.primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff8ea;
  box-shadow: 0 6px 16px rgba(140, 42, 32, 0.2);
}

.btn.primary:hover {
  background: var(--red-dark);
  border-color: var(--red-dark);
}

.btn.ghost {
  border-color: var(--line);
}

.btn.danger {
  color: var(--red);
  border-color: rgba(177, 57, 44, 0.35);
}

.btn.danger:hover {
  background: rgba(177, 57, 44, 0.07);
}

.btn.small {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.btn.block {
  width: 100%;
}

.verify-box {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: rgba(177, 57, 44, 0.045);
  border: 1px dashed rgba(177, 57, 44, 0.26);
  border-radius: 14px;
  padding: 14px 16px;
}

.verify-box .input {
  max-width: 210px;
}

.key-row,
.student-row,
.ledger-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.key-row:last-child,
.student-row:last-child,
.ledger-row:last-child {
  border-bottom: 0;
}

.key-prefix {
  font-family: var(--mono);
  font-size: 12px;
  background: rgba(38, 32, 27, 0.05);
  border-radius: 6px;
  padding: 3px 8px;
}

.key-meta {
  font-size: 11.5px;
  color: var(--ink-3);
}

.ledger-row {
  font-size: 12.5px;
  gap: 9px;
}

.ledger-row .lr-main {
  flex: 1;
  min-width: 160px;
}

.ledger-row .lr-time {
  font-size: 10.5px;
  color: var(--ink-3);
  font-family: var(--mono);
}

.ledger-row .lr-qty {
  font-family: var(--mono);
  font-weight: 600;
  min-width: 34px;
  text-align: right;
}

.lr-qty.pos {
  color: var(--red);
}
.lr-qty.neg {
  color: var(--gold);
}

.stat-inline {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.stat-inline div {
  display: grid;
}

.stat-inline b {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.2;
}

.stat-inline span {
  font-size: 11px;
  color: var(--ink-3);
}

/* ---------- 登录 / 初始化 ---------- */
.auth {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
}

.auth-art {
  position: relative;
  overflow: hidden;
  padding: clamp(30px, 5vw, 64px);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    radial-gradient(700px 500px at 80% 10%, rgba(177, 57, 44, 0.1), transparent 60%),
    radial-gradient(600px 500px at 0% 90%, rgba(164, 119, 28, 0.1), transparent 60%);
}

.auth-art .brand {
  position: relative;
  z-index: 2;
}

.auth-copy {
  position: relative;
  z-index: 2;
  max-width: 460px;
}

.auth-copy h1 {
  font-family: var(--serif);
  font-size: clamp(38px, 5vw, 64px);
  line-height: 1.15;
  margin: 18px 0 18px;
  font-weight: 700;
}

.auth-copy p {
  color: var(--ink-2);
  max-width: 30em;
}

.auth-stamps {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.auth-stamps .float-stamp {
  filter: drop-shadow(0 16px 26px rgba(70, 50, 30, 0.14));
}

.auth-stamps .fs1 {
  width: 104px;
  right: 6%;
  top: 8%;
  transform: rotate(8deg);
}
.auth-stamps .fs2 {
  width: 76px;
  right: 28%;
  top: 3%;
  transform: rotate(-12deg);
  opacity: 0.9;
}
.auth-stamps .fs3 {
  width: 92px;
  right: 10%;
  top: 24%;
  transform: rotate(-6deg);
}
.auth-stamps .fs4 {
  width: 64px;
  right: 37%;
  top: 20%;
  transform: rotate(14deg);
  opacity: 0.85;
}

.auth-panel {
  display: grid;
  place-items: center;
  padding: 26px;
  background: rgba(255, 252, 245, 0.55);
  border-left: 1px solid var(--line-soft);
}

.auth-card {
  width: min(400px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px 28px;
  box-shadow: var(--shadow);
}

.auth-card h2 {
  font-family: var(--serif);
  font-size: 26px;
  font-weight: 700;
  margin: 10px 0 4px;
}

.auth-card .sub {
  color: var(--ink-3);
  font-size: 12.5px;
  margin-bottom: 20px;
}

.role-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: rgba(38, 32, 27, 0.05);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}

.role-tab {
  border: 0;
  background: transparent;
  border-radius: 9px;
  padding: 8px;
  font-size: 13px;
  color: var(--ink-2);
}

.role-tab.active {
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(38, 32, 27, 0.09);
  font-weight: 600;
}

.avatar-pick {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.avatar-option {
  width: 54px;
  height: 58px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  gap: 1px;
  padding: 6px 2px;
}

.avatar-option .em {
  font-size: 20px;
  line-height: 1.2;
}

.avatar-option .nm {
  font-size: 9.5px;
  color: var(--ink-3);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.avatar-option.active {
  border-color: var(--red);
  background: rgba(177, 57, 44, 0.05);
  box-shadow: 0 0 0 3px rgba(177, 57, 44, 0.07);
}

.pin-input {
  letter-spacing: 0.42em;
  text-align: center;
  font-family: var(--mono);
  font-size: 22px;
  height: 50px;
  padding-left: 0.42em;
}

.auth-foot {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--ink-3);
  text-align: center;
  line-height: 1.7;
}

.setup-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  position: relative;
  z-index: 2;
}

.setup-card {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.setup-card h1 {
  font-family: var(--serif);
  font-size: 28px;
  margin: 12px 0 4px;
}

.setup-card .sub {
  color: var(--ink-3);
  font-size: 12.5px;
  margin-bottom: 20px;
}

.student-editor {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 12px;
  background: rgba(255, 252, 245, 0.5);
}

.student-editor .se-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--ink-3);
  margin-bottom: 9px;
}

/* ---------- 弹窗 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(32, 24, 16, 0.46);
  backdrop-filter: blur(7px);
  display: grid;
  place-items: center;
  padding: 18px;
  animation: fade 0.18s ease;
}

.modal {
  width: min(520px, 100%);
  max-height: 88dvh;
  overflow: auto;
  background: var(--paper-2);
  border-radius: 24px;
  padding: 26px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: pop 0.26s cubic-bezier(0.2, 0.75, 0.2, 1);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.modal-head h2 {
  font-family: var(--serif);
  font-size: 23px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.modal-head .sub {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 2px;
}

.modal-close {
  border: 1px solid var(--line);
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-2);
  flex: none;
}

.modal-close:hover {
  background: rgba(38, 32, 27, 0.06);
}

.modal > .row:last-child {
  position: sticky;
  bottom: -26px;
  z-index: 3;
  background: var(--paper-2);
  padding: 12px 0 4px;
  margin-top: 12px;
}

.stamp-detail-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 14px 0 18px;
}

.sd-item {
  text-align: center;
  display: grid;
  justify-items: center;
  gap: 6px;
}

.sd-item .stamp {
  --w: 100%;
  width: 100%;
  max-width: 78px;
}

.sd-name {
  font-size: 10px;
  color: var(--ink-3);
}

.sd-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--red);
  font-weight: 600;
}

.lore {
  font-size: 13px;
  color: var(--ink-2);
  line-height: 1.75;
  background: rgba(38, 32, 27, 0.035);
  border-left: 3px solid rgba(177, 57, 44, 0.3);
  border-radius: 0 10px 10px 0;
  padding: 10px 14px;
  margin: 12px 0 18px;
}

.consume-list {
  display: grid;
  gap: 7px;
  margin: 12px 0 16px;
}

.consume-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 7px 10px;
}

.consume-item .stamp {
  --w: 38px;
  flex: none;
}

.consume-item .ci-name {
  flex: 1;
}

.consume-item .ci-qty {
  font-family: var(--mono);
  color: var(--ink-3);
}

.reward-banner {
  background: linear-gradient(135deg, rgba(177, 57, 44, 0.09), rgba(164, 119, 28, 0.06));
  border: 1px dashed rgba(177, 57, 44, 0.28);
  border-radius: 14px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 8px 0 16px;
}

.reward-banner .rb-label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}

.reward-banner .rb-value {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  line-height: 1.3;
}

.code-display {
  text-align: center;
  padding: 8px 0 4px;
}

.code-digits {
  font-family: var(--mono);
  font-size: clamp(38px, 9vw, 54px);
  letter-spacing: 0.18em;
  color: var(--red);
  padding: 18px 10px;
  border: 2px dashed rgba(177, 57, 44, 0.34);
  border-radius: 16px;
  background: rgba(255, 252, 245, 0.7);
  line-height: 1;
  margin: 6px 0 14px;
}

.code-note {
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.75;
  text-align: left;
  background: rgba(38, 32, 27, 0.035);
  border-radius: 12px;
  padding: 11px 14px;
}

.countdown {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--gold);
  text-align: center;
  margin-top: 8px;
}

.secret-key {
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
  background: #2a211b;
  color: #f3e7cf;
  border-radius: 12px;
  padding: 14px;
  line-height: 1.7;
  user-select: all;
}

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(26px + env(safe-area-inset-bottom));
  translate: -50% 20px;
  z-index: 90;
  background: var(--ink);
  color: var(--paper-2);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: 0.25s ease;
  max-width: min(90vw, 520px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  translate: -50% 0;
}

.toast.error {
  background: var(--red-dark);
}

/* ---------- 底部导航 ---------- */
.tabbar {
  display: none;
}

/* ---------- 动画 ---------- */
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes stampIn {
  0% {
    opacity: 0;
    transform: scale(1.4) rotate(-10deg);
  }
  60% {
    opacity: 1;
    transform: scale(0.97) rotate(1deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

.pop-in {
  animation: stampIn 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 10px;
  }
  .hero-art {
    height: 230px;
    order: -1;
  }
  .float-stamp:nth-child(1) {
    width: 100px;
  }
  .float-stamp:nth-child(2) {
    width: 84px;
  }
  .float-stamp:nth-child(3) {
    width: 112px;
  }
  .float-stamp:nth-child(4) {
    width: 74px;
  }
  .float-stamp:nth-child(5) {
    display: none;
  }
  .postmark {
    width: 92px;
    height: 92px;
    font-size: 7px;
  }
  .auth {
    grid-template-columns: 1fr;
  }
  .auth-art {
    min-height: 0;
    padding: 22px 22px 18px;
  }
  .auth-copy h1 {
    font-size: 27px;
    margin: 10px 0 0;
    line-height: 1.25;
  }
  .auth-copy p {
    display: none;
  }
  .auth-stamps {
    opacity: 0.45;
  }
  .auth-stamps .fs1 {
    width: 78px;
    right: -4px;
    top: 14px;
  }
  .auth-stamps .fs2 {
    width: 56px;
    right: 32%;
    top: 4px;
  }
  .auth-stamps .fs3 {
    width: 66px;
    right: 2%;
    bottom: -18px;
  }
  .auth-stamps .fs4 {
    display: none;
  }
  .auth-panel {
    border-left: 0;
    padding: 18px 16px 34px;
    align-items: start;
  }
  .auth-card {
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 8px 2px;
  }
}

@media (max-width: 860px) {
  .topnav {
    display: none;
  }
  .topbar {
    padding-top: 12px;
    padding-bottom: 12px;
  }
  .page {
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }
  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    background: rgba(250, 245, 234, 0.94);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  }
  .tab {
    border: 0;
    background: transparent;
    display: grid;
    justify-items: center;
    gap: 1px;
    padding: 6px 2px;
    color: var(--ink-3);
    font-size: 10px;
    text-decoration: none;
    border-radius: 10px;
  }
  .tab svg {
    width: 21px;
    height: 21px;
  }
  .tab.active {
    color: var(--red);
  }
  .stat-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pattern-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px;
  }
  .pattern-card {
    padding: 11px 11px 12px;
  }
  .pc-stamp .stamp {
    --w: 66px;
  }
  .recipe-grid {
    grid-template-columns: 1fr;
  }
  .section-title {
    font-size: 21px;
  }
  .modal {
    padding: 22px 18px;
    border-radius: 20px;
  }
  .stamp-detail-grid {
    gap: 5px;
  }
  .sd-item .stamp {
    max-width: 56px;
  }
  .brand-sub {
    display: none;
  }
}

@media (max-width: 420px) {
  .pc-stamp .stamp {
    --w: 58px;
  }
  .pc-name {
    font-size: 14.5px;
  }
  .stat-num {
    font-size: 25px;
  }
  .user-chip .uname {
    display: none;
  }
  .code-digits {
    letter-spacing: 0.1em;
  }
}

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