:root {
  --bg-paper: #F7F3EB;
  --ink: #2C2419;
  --primary: #8B4513;
  --secondary: #2F5D50;
  --gold: #C9A86C;
  --gold-light: #E8D5A3;
  --card-bg: #FFFFFF;
  --border: #D4C5B0;
  --success: #2F5D50;
  --danger: #9B2C2C;
  --warning: #B45309;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "STKaiti", "KaiTi", serif;
  background: var(--bg-paper);
  color: var(--ink);
  height: 100vh;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* 页面容器 */
.page {
  display: none;
  height: 100vh;
  flex-direction: column;
  animation: fadeIn 0.4s ease;
}
.page.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* 顶部装饰条 */
.header-deco {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  z-index: 200;
  background: linear-gradient(90deg, var(--primary), var(--gold), var(--secondary), var(--gold), var(--primary));
  background-size: 200% 100%;
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* 首页 */
.home-scroll {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.home-hero {
  position: relative;
  padding: 48px 24px 32px;
  text-align: center;
  background: linear-gradient(180deg, rgba(139,69,19,0.08) 0%, transparent 100%);
}

.home-hero::before {
  content: "";
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 2px;
  background: var(--gold);
  border-radius: 1px;
}

.museum-name {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 6px;
  color: var(--primary);
  margin-bottom: 8px;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
}

.museum-sub {
  font-size: 14px;
  color: var(--secondary);
  letter-spacing: 2px;
  margin-bottom: 24px;
}

.hero-img {
  width: 100%;
  max-width: 320px;
  height: 180px;
  margin: 0 auto 24px;
  border-radius: 12px;
  object-fit: cover;
  display: block;
  box-shadow: 0 8px 24px rgba(139,69,19,0.15);
}

.intro-text {
  font-size: 14px;
  line-height: 1.8;
  color: var(--ink);
  opacity: 0.8;
  max-width: 320px;
  margin: 0 auto 32px;
  text-align: justify;
}

.btn-primary {
  display: inline-block;
  width: 240px;
  padding: 14px 0;
  background: linear-gradient(135deg, var(--primary), #A0522D);
  color: #fff;
  border: none;
  border-radius: 28px;
  font-size: 16px;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(139,69,19,0.35);
  transition: transform 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 2px 8px rgba(139,69,19,0.3);
}

.home-nav {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin-top: 28px;
  padding-bottom: 32px;
}
.home-nav-item {
  text-align: center;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.home-nav-item:active { opacity: 1; }
.home-nav-icon {
  width: 48px; height: 48px;
  background: rgba(139,69,19,0.08);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 6px;
  font-size: 20px;
}

/* 页面顶部 */
.page-header {
  flex-shrink: 0;
  position: relative;
  z-index: 100;
  background: rgba(247,243,235,0.95);
  backdrop-filter: blur(8px);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid rgba(139,69,19,0.1);
}
.page-header .back {
  position: absolute;
  left: 16px;
  font-size: 20px;
  color: var(--primary);
  cursor: pointer;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.page-header .title {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--primary);
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
}

/* 表单页 */
.form-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 24px 20px calc(40px + env(safe-area-inset-bottom, 0));
}

.form-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 24px 20px;
  box-shadow: 0 4px 20px rgba(139,69,19,0.08);
  border: 1px solid var(--border);
  position: relative;
}

.form-card::before {
  content: "";
  position: absolute;
  top: 0; left: 20px; right: 20px;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  border-radius: 0 0 2px 2px;
}

.form-title {
  text-align: center;
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 24px;
  letter-spacing: 3px;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
}

.form-group {
  margin-bottom: 20px;
}
.form-label {
  display: block;
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 8px;
  font-weight: 500;
}
.form-label .required {
  color: var(--danger);
  margin-right: 2px;
}
.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
  background: var(--bg-paper);
  color: var(--ink);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(201,168,108,0.15);
}
.form-input::placeholder {
  color: #B0A490;
}

/* 日期输入框兼容处理 */
input[type="date"].form-input {
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}
input[type="date"].form-input::-webkit-date-and-time-value {
  text-align: left;
}
input[type="date"].form-input::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
}

.counter-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}
.form-group:has(.counter-wrap) .form-label {
  text-align: center;
}
.counter-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-paper);
  color: var(--primary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.counter-btn:active { background: var(--gold-light); }
.counter-val {
  font-size: 18px;
  font-weight: 600;
  color: var(--primary);
  min-width: 24px;
  text-align: center;
}

.submit-btn {
  width: 100%;
  margin-top: 8px;
  padding: 14px 0;
  background: linear-gradient(135deg, var(--secondary), #3A7A68);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  letter-spacing: 3px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(47,93,80,0.3);
  transition: transform 0.2s;
  font-family: inherit;
}
.submit-btn:active { transform: scale(0.98); }

.tip-text {
  margin-top: 16px;
  font-size: 12px;
  color: #9B8B7A;
  text-align: center;
  line-height: 1.6;
}

/* 成功页 */
.success-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 48px 24px;
  text-align: center;
}
.success-icon {
  width: 80px; height: 80px;
  background: linear-gradient(135deg, var(--secondary), #3A7A68);
  border-radius: 50%;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: #fff;
  box-shadow: 0 8px 24px rgba(47,93,80,0.3);
}
.success-title {
  font-size: 22px;
  color: var(--secondary);
  margin-bottom: 8px;
  letter-spacing: 3px;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
}
.success-desc {
  font-size: 14px;
  color: #9B8B7A;
  margin-bottom: 32px;
}
.success-detail {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 24px;
  border: 1px solid var(--border);
  text-align: left;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 14px;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { color: #9B8B7A; }
.detail-value { color: var(--ink); font-weight: 500; }

/* 记录页 */
.records-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0));
}
.record-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(139,69,19,0.06);
  position: relative;
  overflow: hidden;
}
.record-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; width: 4px; height: 100%;
  background: var(--gold);
}
.record-card.used::before { background: #9B8B7A; }
.record-card.cancelled::before { background: var(--danger); }

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.record-date {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
}
.record-status {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 12px;
  font-weight: 500;
}
.status-pending {
  background: rgba(47,93,80,0.1);
  color: var(--secondary);
}
.status-used {
  background: rgba(155,139,122,0.15);
  color: #9B8B7A;
}
.status-cancelled {
  background: rgba(155,44,44,0.1);
  color: var(--danger);
}

.record-body {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
  margin-bottom: 16px;
}
.record-item {
  font-size: 13px;
}
.record-item-label {
  color: #9B8B7A;
  margin-bottom: 2px;
}
.record-item-value {
  color: var(--ink);
  font-weight: 500;
}

.qr-section {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}
.qr-box {
  width: 80px; height: 80px;
  background: var(--bg-paper);
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qr-box img,
.qr-box canvas {
  width: 64px !important;
  height: 64px !important;
  display: block;
  border-radius: 4px;
}
.qr-box .qr-expired {
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #9B8B7A;
  text-align: center;
  line-height: 1.4;
}
.qr-info {
  flex: 1;
}
.qr-code-text {
  font-size: 12px;
  color: var(--primary);
  font-family: monospace;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.qr-tip {
  font-size: 11px;
  color: #9B8B7A;
  line-height: 1.5;
}
.cancel-btn {
  margin-top: 8px;
  padding: 6px 14px;
  font-size: 12px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
}
.cancel-btn:active { background: rgba(155,44,44,0.08); }

.empty-state {
  text-align: center;
  padding: 64px 24px;
}
.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-text {
  font-size: 14px;
  color: #9B8B7A;
  margin-bottom: 20px;
}

/* 二维码放大弹窗 */
.qr-large-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 9500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.qr-large-overlay.show { opacity: 1; }
.qr-large-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px 24px;
  text-align: center;
  max-width: 280px;
  width: 100%;
  animation: scaleIn 0.25s ease;
}
.qr-large-title {
  font-size: 16px;
  color: var(--primary);
  margin-bottom: 16px;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
}
.qr-large-box {
  width: 200px;
  height: 200px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-large-box img,
.qr-large-box canvas {
  width: 200px !important;
  height: 200px !important;
  border-radius: 4px;
}
.qr-large-code {
  font-size: 14px;
  color: var(--primary);
  font-family: monospace;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.qr-large-tip {
  font-size: 12px;
  color: #9B8B7A;
  margin-bottom: 16px;
}
.qr-large-close {
  padding: 8px 32px;
  font-size: 14px;
  border: 1px solid var(--border);
  color: var(--ink);
  background: var(--bg-paper);
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.qr-large-close:active { background: rgba(0,0,0,0.05); }

/* 底部安全区 */
.safe-bottom { display: none; }

/* 登录加载遮罩 */
#login-loading {
  position: fixed;
  inset: 0;
  background: var(--bg-paper);
  z-index: 9000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.4s ease;
}
#login-loading.fade-out {
  opacity: 0;
  pointer-events: none;
}
.login-loading-icon {
  font-size: 48px;
  animation: spin 1.2s linear infinite;
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.login-loading-text {
  font-size: 15px;
  color: var(--primary);
  letter-spacing: 2px;
  opacity: 0.75;
}

/* 提示 toast */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(44,36,25,0.9);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* 弹窗 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 28px 24px;
  width: 100%;
  max-width: 300px;
  text-align: center;
  animation: scaleIn 0.25s ease;
  border: 1px solid var(--border);
}
@keyframes scaleIn {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.modal-title {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 8px;
  font-family: "STKaiti", "KaiTi", "SimSun", serif;
}
.modal-desc {
  font-size: 14px;
  color: #9B8B7A;
  margin-bottom: 20px;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  gap: 12px;
}
.modal-btn {
  flex: 1;
  padding: 10px 0;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.modal-btn.cancel {
  background: var(--bg-paper);
  color: var(--ink);
  border: 1px solid var(--border);
}
.modal-btn.confirm {
  background: var(--danger);
  color: #fff;
}