:root {
  --bg: #0a0a12;
  --panel: #171526;
  --border: rgba(212, 175, 55, 0.45);
  --border-dim: rgba(212, 175, 55, 0.25);
  --gold: #d4af37;
  --gold-dim: rgba(212, 175, 55, 0.6);
  --text: #ece6d6;
  --text-dim: rgba(236, 230, 214, 0.5);
  --danger: #d95a4d;
  --crit: #8fdd73;
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif;
  min-height: 100%;
  height: 100%;
}

/* iOS 主屏幕 standalone 模式:顶部避开状态栏,底部避开 Home 条 */
body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior: none;
}

#app { max-width: 480px; margin: 0 auto; }

main#main {
  padding: 16px 14px calc(84px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---- 卡片 ---- */
.card {
  background: var(--panel);
  border: 1px solid var(--border-dim);
  border-radius: 12px;
  padding: 16px;
}
.card.center { text-align: center; }
.card-title { font-weight: 600; margin-bottom: 10px; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row.small, .small { font-size: 12px; color: var(--text-dim); }

/* ---- 境界卡 ---- */
.realm-name {
  font-size: 30px;
  font-weight: 700;
  color: var(--gold);
  font-family: "Songti SC", "STSong", serif;
  margin: 6px 0 10px;
}

.bar {
  height: 7px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin: 8px 0;
}
.bar.grow { flex: 1; margin: 0; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--gold); transition: width .5s; }
.bar-fill[style*="--c"] { background: var(--c); }

/* ---- 打卡卡 ---- */
.habit-card { display: flex; align-items: center; gap: 12px; }
.attr-orb {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--c) 20%, transparent);
  color: var(--c);
  border: 1px solid color-mix(in srgb, var(--c) 45%, transparent);
  font-weight: 700;
  flex-shrink: 0;
}
.attr-orb.small { width: 26px; height: 26px; font-size: 12px; }
.habit-info { flex: 1; min-width: 0; }
.habit-name { font-weight: 600; font-size: 16px; }
.habit-meta { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.attr-tag {
  font-size: 11px; padding: 2px 7px; border-radius: 99px;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, transparent);
}
.streak { font-size: 11px; color: var(--gold-dim); }

.btn-check {
  background: var(--gold); color: #141208;
  border: none; border-radius: 9px;
  padding: 9px 18px; font-size: 14px; font-weight: 700;
  flex-shrink: 0;
}
.btn-check.done {
  background: transparent; color: var(--gold-dim);
  border: 1px solid var(--border);
}

/* ---- 面板 ---- */
.stat-row { display: flex; margin-top: 14px; }
.stat { flex: 1; text-align: center; }
.stat-num { font-size: 22px; font-weight: 700; color: var(--gold); }
.stat-label { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.attr-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.attr-name { font-size: 14px; width: 32px; }
.attr-value { font-size: 14px; font-weight: 600; width: 42px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---- 设置按钮 ---- */
.btn-line {
  display: block; width: 100%;
  background: transparent; color: var(--text);
  border: 1px solid var(--border);
  border-radius: 9px; padding: 11px;
  font-size: 14px; margin: 8px 0;
}
.btn-line.on { color: var(--gold); border-color: var(--gold); }
.btn-line.danger { color: var(--danger); border-color: rgba(217, 90, 77, 0.5); }

/* ---- 消息 ---- */
.msg-list { display: flex; flex-direction: column; gap: 10px; }
.msg {
  background: var(--panel);
  border: 1px solid var(--border-dim);
  border-radius: 10px; padding: 12px 14px;
}
.msg-time { font-size: 11px; color: var(--text-dim); margin-bottom: 5px; }
.msg-text { font-size: 14px; line-height: 1.55; }

/* ---- 绑定页 ---- */
.onboard { padding: 48px 20px 32px; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.seal {
  width: 84px; height: 84px; border-radius: 50%;
  border: 2px solid var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 34px; color: var(--gold);
  font-family: "Songti SC", "STSong", serif;
  box-shadow: 0 0 24px rgba(212, 175, 55, 0.25);
}
.title { font-size: 24px; color: var(--gold); font-family: "Songti SC", "STSong", serif; }
.subtitle { font-size: 13px; color: var(--text-dim); }
.field { width: 100%; }
.field label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 12px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 15px; outline: none;
}
.section-label { width: 100%; font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.preset-list { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.preset {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--panel); border: 1px solid var(--border-dim);
  border-radius: 8px; padding: 12px 14px; color: var(--text);
}
.preset.on { border-color: var(--border); }
.preset .check { font-size: 12px; color: var(--text-dim); }
.preset.on .check { color: var(--gold); }
.attr-badge { color: var(--c); font-size: 14px; }
.preset .attr-badge { color: var(--text); }
.preset.on .attr-badge { color: var(--gold); }
.btn-gold {
  width: 100%; padding: 14px;
  background: var(--gold); color: #141208;
  border: none; border-radius: 10px;
  font-size: 16px; font-weight: 700; letter-spacing: 6px;
  margin-top: 10px;
}
.hint { font-size: 11px; color: var(--text-dim); text-align: center; }

/* ---- 底栏 ---- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0;
  max-width: 480px; margin: 0 auto;
  display: flex;
  background: rgba(13, 12, 22, 0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-dim);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; padding: 8px 0 7px;
  background: none; border: none;
  color: var(--text-dim);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab.active { color: var(--gold); }
.tab-label { font-size: 11px; }

/* ---- 弹toast ---- */
.toast {
  position: fixed; left: 50%; top: 18%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 16px 22px;
  min-width: 240px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  z-index: 99;
  animation: pop .25s;
}
.toast.crit { border-color: var(--crit); }
.toast-title { color: var(--gold); font-weight: 700; font-size: 16px; margin-bottom: 6px; }
.toast.crit .toast-title { color: var(--crit); }
.toast-body { font-size: 14px; }
@keyframes pop {
  from { transform: translateX(-50%) scale(.9); opacity: 0; }
  to { transform: translateX(-50%) scale(1); opacity: 1; }
}
