/* ==========================================================
   极乐宫信息查询 · 移动端样式
   配色：宣纸米黄 + 深檀木 + 描金 + 朱砂
   ========================================================== */

:root {
  /* 墨色文字 */
  --ink:        #3a2e26;
  --ink-2:      #7a6a58;
  --ink-3:      #a89881;

  /* 宣纸底 */
  --paper:      #f3ebda;
  --paper-2:    #fffcf5;
  --paper-3:    #fbf6ea;

  /* 描金 */
  --gold:       #c19a4b;
  --gold-2:     #e2c489;
  --gold-soft:  #f0e4c8;
  --gold-deep:  #9c7a2f;

  /* 檀木 */
  --wood:       #6d4a30;
  --wood-2:     #4a3120;
  --wood-3:     #8a6440;

  /* 朱砂 */
  --cinnabar:   #9c3b2e;
  --cinnabar-2: #7d2b21;

  /* 松绿（在供） */
  --pine:       #4f6b46;

  --line:       #e4d8be;
  --line-2:     #efe5cf;

  --radius:     6px;
  --shadow:     0 2px 10px rgba(92, 68, 40, .07);
  --shadow-lg:  0 6px 22px rgba(92, 68, 40, .12);

  --font-hei:   -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
                "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-song:  "Songti SC", "STSong", "SimSun", "Noto Serif SC", "Source Han Serif SC", serif;
  --font-kai:   "STKaiti", "KaiTi", "Kaiti SC", "楷体", var(--font-song);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #e8ddc6;
  color: var(--ink);
  font-family: var(--font-hei);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}

body {
  background-image:
    radial-gradient(circle at 50% 0%, rgba(193, 154, 75, .10), transparent 60%),
    linear-gradient(180deg, #f0e7d4 0%, #e8ddc6 100%);
  min-height: 100vh;
}

/* ---------- 布局容器 ---------- */
.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 50% 4%, rgba(193, 154, 75, .13), transparent 55%),
    repeating-linear-gradient(90deg, rgba(160, 130, 80, .035) 0 1px, transparent 1px 4px);
  box-shadow: 0 0 40px rgba(90, 66, 40, .16);
  position: relative;
  overflow: hidden;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* 背景巨大莲花水印 */
.app::before {
  content: '';
  position: absolute;
  top: 190px;
  left: 50%;
  width: 380px;
  height: 380px;
  transform: translateX(-50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 120'%3E%3Cg fill='%23a07c3d' opacity='.55'%3E%3Cg transform='translate(60,74)'%3E%3Cellipse cx='0' cy='-24' rx='8' ry='24'/%3E%3Cellipse cx='0' cy='-21' rx='7.5' ry='21' transform='rotate(-26)'/%3E%3Cellipse cx='0' cy='-21' rx='7.5' ry='21' transform='rotate(26)'/%3E%3Cellipse cx='0' cy='-18' rx='7' ry='18' transform='rotate(-52)'/%3E%3Cellipse cx='0' cy='-18' rx='7' ry='18' transform='rotate(52)'/%3E%3Cellipse cx='0' cy='-15' rx='6.5' ry='15' transform='rotate(-78)'/%3E%3Cellipse cx='0' cy='-15' rx='6.5' ry='15' transform='rotate(78)'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E") no-repeat center / contain;
  pointer-events: none;
  z-index: 0;
}
.app > * { position: relative; z-index: 1; }

/* ==========================================================
   顶部
   ========================================================== */
.header {
  background:
    radial-gradient(circle at 50% 18%, rgba(226, 196, 137, .22), transparent 62%),
    linear-gradient(165deg, #6d4a30 0%, #563824 55%, #412a1a 100%);
  padding: calc(18px + env(safe-area-inset-top)) 20px 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.header::after {
  /* 底部祥云 */
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 26px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 375 26' preserveAspectRatio='none'%3E%3Cpath fill='%23f3ebda' d='M0 26V14c14 0 18-8 32-8s16 7 30 7 17-9 32-9 18 8 32 8 17-8 31-8 18 8 32 8 17-8 31-8 18 8 32 8 18-7 32-7 18 7 32 7 16-8 30-8v20z'/%3E%3C/svg%3E") no-repeat center bottom / 100% 100%;
}

.hd-mantra {
  font-family: var(--font-song);
  font-size: 11px;
  letter-spacing: .32em;
  color: rgba(226, 196, 137, .72);
  margin-bottom: 10px;
  padding-left: .32em;
}

.hd-lotus {
  width: 40px;
  height: 40px;
  margin: 0 auto 8px;
  display: block;
  opacity: .95;
  filter: drop-shadow(0 0 8px rgba(226, 196, 137, .35));
}

.hd-title {
  font-family: var(--font-song);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: .22em;
  color: #f0dcae;
  margin: 0;
  padding-left: .22em;
  text-shadow: 0 1px 6px rgba(0, 0, 0, .3);
}

.hd-sub {
  font-family: var(--font-song);
  font-size: 12.5px;
  letter-spacing: .18em;
  color: rgba(240, 220, 174, .68);
  margin: 8px 0 0;
  padding: 0 0 34px;
  padding-left: .18em;
}

/* 演示数据提示条 */
.demo-badge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(156, 59, 46, .16);
  border-bottom: 1px solid var(--line);
  color: var(--cinnabar-2);
  font-size: 12px;
  letter-spacing: .04em;
  padding: 7px 14px;
}
.demo-badge.show { display: flex; }

/* ==========================================================
   主体
   ========================================================== */
.main { padding: 18px 16px 0; }

/* ---------- 查询卡 ---------- */
.query-card {
  background: var(--paper-2);
  border: 1px solid var(--gold-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 18px 22px;
  position: relative;
}
.query-card::before {
  /* 内描金线 */
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(193, 154, 75, .3);
  border-radius: 3px;
  pointer-events: none;
}

.qc-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-song);
  font-size: 15px;
  letter-spacing: .16em;
  color: var(--wood);
  margin: 0 0 4px;
  padding-left: .16em;
}
.qc-title::before,
.qc-title::after {
  content: '';
  width: 26px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold));
}
.qc-title::after { background: linear-gradient(90deg, var(--gold), transparent); }

.qc-tip {
  text-align: center;
  font-size: 12px;
  color: var(--ink-3);
  margin: 0 0 18px;
  line-height: 1.7;
}

.field { margin-bottom: 14px; }
.field:last-of-type { margin-bottom: 0; }

.field-label {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 7px;
  letter-spacing: .04em;
}
.field-label::before {
  content: '';
  width: 3px;
  height: 12px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  border-radius: 2px;
  margin-right: 7px;
}

.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font-size: 15px;
  font-family: var(--font-hei);
  color: var(--ink);
  background: var(--paper-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  outline: none;
  transition: border-color .18s, box-shadow .18s, background .18s;
}
.field input::placeholder { color: #c3b59c; }
.field input:focus {
  background: #fffdf8;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(193, 154, 75, .13);
}
.field input.error {
  border-color: var(--cinnabar);
  background: #fdf6f4;
  box-shadow: 0 0 0 3px rgba(156, 59, 46, .08);
}

/* 输入错误提示 */
.err-msg {
  display: none;
  font-size: 12px;
  color: var(--cinnabar);
  margin-top: 6px;
  padding-left: 2px;
}
.err-msg.show { display: block; }

/* ---------- 查询按钮 ---------- */
.btn-query {
  width: 100%;
  height: 48px;
  margin-top: 20px;
  font-family: var(--font-song);
  font-size: 17px;
  letter-spacing: .5em;
  text-indent: .5em;
  color: #fdf3dd;
  background: linear-gradient(180deg, var(--cinnabar) 0%, var(--cinnabar-2) 100%);
  border: 1px solid #6d2419;
  border-radius: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 3px 10px rgba(125, 43, 33, .24);
  cursor: pointer;
  transition: transform .12s, box-shadow .18s, opacity .18s;
}
.btn-query:active {
  transform: translateY(1px);
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, .18);
}
.btn-query[disabled] { opacity: .62; cursor: default; }

.btn-query .spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(253, 243, 221, .35);
  border-top-color: #fdf3dd;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 最近查询 ---------- */
.history {
  display: none;
  margin: 14px 2px 0;
  font-size: 12px;
  color: var(--ink-3);
}
.history.show { display: block; }
.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 7px;
}
.history-tags button {
  font-family: var(--font-hei);
  font-size: 12.5px;
  color: var(--wood-3);
  background: rgba(255, 255, 255, .7);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
}

/* ==========================================================
   结果区
   ========================================================== */
.result { margin-top: 22px; }

.result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-family: var(--font-song);
  font-size: 13.5px;
  color: var(--wood);
  letter-spacing: .08em;
  padding: 0 4px 10px;
}
.result-head .count { font-size: 12px; color: var(--ink-3); font-family: var(--font-hei); }

/* ---------- 牌位卡 ---------- */
.tablet {
  background: linear-gradient(180deg, var(--paper-2), #fdf8ec);
  border: 1px solid var(--gold-soft);
  border-radius: 3px;
  box-shadow: var(--shadow-lg);
  padding: 0 16px 16px;
  margin-bottom: 16px;
  position: relative;
  animation: rise .42s cubic-bezier(.22, .68, .36, 1) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}
.tablet::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(193, 154, 75, .34);
  border-radius: 2px;
  pointer-events: none;
}
/* 牌位顶部木冠 */
.tablet-cap {
  height: 11px;
  margin: 0 -16px 8px;
  background: linear-gradient(180deg, var(--wood-3), var(--wood-2));
  border-radius: 2px 2px 0 0;
  position: relative;
}
.tablet-cap::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translateX(-50%);
  width: 46px;
  height: 9px;
  background: linear-gradient(180deg, var(--wood-3), var(--wood-2));
  clip-path: polygon(0 0, 100% 0, 84% 100%, 16% 100%);
}

/* 牌位主体：照片 + 姓名生卒 */
.tb-main {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding-top: 4px;
}

.tb-photo {
  flex: 0 0 66px;
  width: 66px;
  height: 86px;
  position: relative;
  border: 1px solid var(--gold-soft);
  border-radius: 2px;
  background: var(--paper-3);
  overflow: hidden;
}
.tb-photo .ph-holder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tb-photo .ph-holder svg { width: 30px; height: 30px; opacity: .4; }
.tb-photo .ph-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.tb-id { flex: 1; min-width: 0; }

.tb-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.tb-name {
  font-family: var(--font-kai);
  font-size: 26px;
  line-height: 1.25;
  letter-spacing: .06em;
  color: var(--wood-2);
  font-weight: 700;
}
.tb-gender {
  font-size: 12px;
  color: var(--ink-3);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 1px 5px;
}

.tb-life {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.75;
  word-break: break-all;
}
.tb-life .age { color: var(--ink-3); }

/* 状态徽标 */
.tablet-hd {
  display: flex;
  justify-content: flex-end;
  padding: 6px 0 4px;
}
.tb-status {
  display: inline-block;
  font-size: 11.5px;
  letter-spacing: .06em;
  padding: 2px 8px;
  border-radius: 2px;
  border: 1px solid transparent;
}
.tb-status.active {
  color: var(--pine);
  background: rgba(79, 107, 70, .1);
  border-color: rgba(79, 107, 70, .28);
}
.tb-status.pending {
  color: var(--gold-deep);
  background: rgba(193, 154, 75, .13);
  border-color: rgba(193, 154, 75, .42);
}
.tb-status.other {
  color: var(--wood-3);
  background: rgba(138, 100, 64, .1);
  border-color: rgba(138, 100, 64, .26);
}

/* 分隔 */
.tb-divider {
  height: 1px;
  margin: 14px 0 12px;
  background: repeating-linear-gradient(90deg, var(--gold-soft) 0 5px, transparent 5px 10px);
}

/* 信息行 */
.tb-rows { display: block; }
.tb-row {
  display: flex;
  align-items: flex-start;
  font-size: 13.5px;
  line-height: 1.6;
  padding: 5px 0;
}
.tb-row .k {
  flex: 0 0 74px;
  color: var(--ink-3);
  font-size: 12.5px;
  letter-spacing: .04em;
}
.tb-row .v {
  flex: 1;
  color: var(--ink);
  word-break: break-all;
}
.tb-row .v em {
  font-style: normal;
  color: var(--wood);
  font-weight: 600;
}
.tb-row .v .hl {
  font-family: var(--font-song);
  font-size: 15px;
  color: var(--wood-2);
  font-weight: 600;
  letter-spacing: .03em;
}
.tb-row .v .rel {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 400;
  margin-left: 3px;
  letter-spacing: .02em;
}

/* ---------- 空 / 错误 / 加载 ---------- */
.state {
  text-align: center;
  padding: 40px 24px 44px;
  animation: rise .38s ease both;
}
.state-icon { width: 62px; height: 62px; opacity: .5; margin-bottom: 14px; }
.state-title {
  font-family: var(--font-song);
  font-size: 16px;
  color: var(--wood);
  letter-spacing: .1em;
  margin: 0 0 8px;
  padding-left: .1em;
}
.state-desc {
  font-size: 13px;
  color: var(--ink-3);
  line-height: 1.85;
  margin: 0;
}
.state .contact {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--ink-2);
}
.state .contact b { color: var(--cinnabar); font-weight: 600; }

.state-loading .lotus-breath {
  width: 58px;
  height: 58px;
  margin-bottom: 16px;
  animation: breath 1.7s ease-in-out infinite;
}
@keyframes breath {
  0%, 100% { transform: scale(1);    opacity: .55; }
  50%      { transform: scale(1.1);  opacity: .95; }
}

.state-error .state-icon { opacity: .42; }
.btn-retry {
  margin-top: 18px;
  font-family: var(--font-hei);
  font-size: 13.5px;
  letter-spacing: .1em;
  color: var(--wood-3);
  background: transparent;
  border: 1px solid var(--gold-soft);
  border-radius: 20px;
  padding: 7px 22px;
  cursor: pointer;
}

/* ==========================================================
   页脚
   ========================================================== */
.footer {
  margin-top: 30px;
  padding: 22px 24px 8px;
  text-align: center;
  border-top: 1px solid var(--line);
  margin-left: 16px;
  margin-right: 16px;
}
.footer .verse {
  font-family: var(--font-song);
  font-size: 13px;
  line-height: 2;
  color: var(--wood-3);
  letter-spacing: .06em;
  margin: 0 0 12px;
}
.footer .meta {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.9;
}

/* 装饰分隔：小莲花 */
.ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 4px 0 14px;
}
.ornament i {
  display: block;
  width: 30px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-soft));
}
.ornament i:last-child { background: linear-gradient(90deg, var(--gold-soft), transparent); }
.ornament svg { width: 14px; height: 14px; opacity: .55; }
