:root {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  color: #2c271f;
  background: #f5efe5;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { background: #f5efe5; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: linear-gradient(180deg, #f7f0e3 0%, #f3ede5 100%); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
.app-shell, .viewer-shell { width: min(100%, 620px); margin: 0 auto; min-height: 100vh; padding: max(24px, env(safe-area-inset-top)) 18px max(36px, env(safe-area-inset-bottom)); }
.brand-header { padding: 16px 4px 18px; }
.brand-kicker { color: #a46817; font-weight: 800; font-size: 14px; letter-spacing: .08em; }
.brand-header h1 { margin: 7px 0; font-family: "Songti SC", "STSong", serif; font-size: 36px; letter-spacing: .02em; }
.brand-header p { margin: 0; color: #776e62; font-size: 15px; line-height: 1.6; }
.card { background: rgba(255,255,255,.9); border: 1px solid rgba(151,119,72,.16); box-shadow: 0 10px 34px rgba(94,72,39,.08); border-radius: 22px; }
.form-card { padding: 22px; }
.field-label { display: block; font-weight: 750; margin: 0 0 9px; font-size: 15px; }
.text-input { width: 100%; height: 54px; border-radius: 14px; border: 1.5px solid #ded2c0; background: #fffdf9; padding: 0 15px; font-size: 17px; outline: none; margin-bottom: 22px; }
.text-input:focus, .count-input-wrap:focus-within { border-color: #b78331; box-shadow: 0 0 0 3px rgba(183,131,49,.12); }
.counter-row { display: grid; grid-template-columns: 54px 1fr 54px; gap: 10px; align-items: center; }
.counter-button { height: 54px; border: 0; border-radius: 14px; background: #efe5d5; color: #61451d; font-size: 26px; font-weight: 600; cursor: pointer; }
.counter-button:active { transform: scale(.97); }
.count-input-wrap { height: 54px; border: 1.5px solid #ded2c0; background: #fffdf9; border-radius: 14px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.count-input { width: 90px; border: 0; background: transparent; outline: none; text-align: right; font-size: 23px; font-weight: 800; color: #2c271f; }
.count-input-wrap span { color: #776e62; }
.primary-button, .secondary-button, .danger-button { min-height: 50px; border-radius: 14px; border: 0; padding: 12px 16px; font-weight: 800; cursor: pointer; }
.primary-button { background: #7f581d; color: white; box-shadow: 0 7px 18px rgba(127,88,29,.2); }
.secondary-button { background: #f3eadc; color: #5f471f; border: 1px solid #e1d2bb; }
.danger-button { background: #fff0ee; color: #a23d32; border: 1px solid #f2d4cf; }
.primary-button:active, .secondary-button:active, .danger-button:active { transform: translateY(1px); }
.primary-button:disabled, .secondary-button:disabled, .danger-button:disabled { opacity: .42; cursor: not-allowed; }
.full { width: 100%; }
.create-button { margin-top: 22px; font-size: 16px; min-height: 54px; }
.stats-card, .tools-card { margin-top: 16px; padding: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-bottom: 15px; }
.section-heading.simple { margin-bottom: 8px; }
.section-heading h2 { margin: 2px 0 0; font-size: 19px; }
.eyebrow { font-size: 10px; letter-spacing: .13em; color: #a46817; font-weight: 900; }
.date-chip { background: #f2eadf; border-radius: 999px; padding: 7px 10px; font-size: 12px; color: #766b5d; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.stats-grid > div { background: #fbf8f2; border-radius: 14px; padding: 14px; border: 1px solid #eee5d8; }
.stats-grid strong { display: block; font-size: 25px; }
.stats-grid span { color: #817668; font-size: 12px; }
.record-list { display: flex; flex-direction: column; }
.empty-state { color: #93887a; text-align: center; padding: 18px 5px 8px; font-size: 14px; }
.record-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 2px; border-top: 1px solid #eee7dc; }
.record-main { min-width: 0; }
.record-main strong { display: block; font-size: 15px; margin-bottom: 4px; }
.record-main span { display: block; font-size: 11px; color: #8a8073; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.record-count { flex: none; font-size: 22px; font-weight: 850; color: #79531d; }
.record-count small { font-size: 11px; margin-left: 3px; font-weight: 600; color: #817668; }
.data-warning { margin: 0 0 14px; padding: 11px 12px; border-radius: 12px; background: #fff8e8; color: #765b2c; font-size: 13px; line-height: 1.55; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.history-card { margin-top: 16px; padding: 18px 20px; }
.history-card summary { cursor: pointer; font-weight: 800; }
.history-list { margin-top: 12px; max-height: 420px; overflow: auto; }
.app-footer { text-align: center; color: #aaa092; padding: 22px 0 0; font-size: 11px; }
.toast { position: fixed; z-index: 20; left: 50%; top: calc(18px + env(safe-area-inset-top)); transform: translateX(-50%); background: rgba(40,35,29,.92); color: white; border-radius: 999px; padding: 10px 16px; font-size: 13px; box-shadow: 0 8px 26px rgba(0,0,0,.18); white-space: nowrap; max-width: calc(100vw - 24px); overflow: hidden; text-overflow: ellipsis; }
.success-card { margin-top: 16px; padding: 26px 22px 22px; text-align: center; }
.success-mark { width: 54px; height: 54px; border-radius: 50%; background: #e8f3e7; color: #39733e; display: grid; place-items: center; font-size: 28px; font-weight: 900; margin: 0 auto; }
.success-card h2 { margin: 12px 0 18px; font-size: 25px; }
.receipt { background: #fbf8f2; border: 1px solid #eee4d5; border-radius: 16px; padding: 6px 14px; text-align: left; }
.receipt > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid #eee7dd; }
.receipt > div:last-child { border-bottom: 0; }
.receipt span { color: #85796a; font-size: 13px; }
.receipt strong { text-align: right; font-size: 14px; }
.receipt .mono { font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.qr-code { display: block; width: min(74vw, 310px); height: auto; aspect-ratio: 1; margin: 18px auto 8px; border-radius: 12px; background: white; image-rendering: pixelated; }
.qr-caption { margin: 0 0 18px; color: #766d61; font-size: 13px; }
.stack-buttons { display: grid; gap: 9px; }
.viewer-shell { display: flex; align-items: flex-start; justify-content: center; }
.viewer-card { width: 100%; padding: 24px 16px 20px; text-align: center; }
.heart-badge { width: 45px; height: 45px; display: grid; place-items: center; border-radius: 50%; margin: 0 auto; background: #f9e9e2; color: #b85d4c; font-size: 20px; }
.viewer-card h1 { margin: 11px 0 5px; font-family: "Songti SC", "STSong", serif; font-size: 27px; }
.viewer-meta { margin: 0; color: #71685e; font-size: 14px; }
.verified-pill { display: inline-block; margin: 10px auto 14px; border-radius: 999px; padding: 6px 10px; color: #3f7147; background: #edf7ed; font-size: 11px; font-weight: 700; }
.certificate-image { width: 100%; height: auto; display: block; border-radius: 10px; box-shadow: 0 12px 34px rgba(56,45,27,.13); margin-bottom: 14px; }
.save-tip { color: #8a8075; font-size: 12px; line-height: 1.55; margin: 10px 6px 0; }
.cert-id { color: #aaa095; font: 10px ui-monospace, SFMono-Regular, Menlo, monospace; margin: 12px 0 0; }
.message-card { width: 100%; padding: 42px 24px; text-align: center; margin-top: 50px; }
.message-card h1 { font-size: 22px; margin: 13px 0 7px; }
.message-card p { color: #80766a; margin: 0; line-height: 1.6; }
.message-icon { width: 50px; height: 50px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto; background: #efe8dc; color: #7a633d; font-size: 24px; }
.message-icon.danger { background: #fff0ee; color: #a23d32; }
@media (max-width: 380px) {
  .app-shell, .viewer-shell { padding-left: 12px; padding-right: 12px; }
  .form-card, .stats-card, .tools-card { padding: 17px; }
  .tool-grid { grid-template-columns: 1fr; }
  .brand-header h1 { font-size: 32px; }
}
