@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@500;700;900&family=Noto+Sans+SC:wght@400;500;700&display=swap');

:root {
  --bg-deep: #11181f;
  --bg-deep-2: #1b2733;
  --paper: #f3ead9;
  --paper-2: #efe3cc;
  --paper-line: #d8c8a4;
  --vermilion: #b8392a;
  --vermilion-2: #c1432d;
  --gold: #a9824a;
  --gold-2: #b9974f;
  --ink: #2b2420;
  --ink-soft: #5a4f42;
  --shadow: rgba(0, 0, 0, 0.35);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--paper);
  font-family: 'Noto Sans SC', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% -10%, #233040 0%, var(--bg-deep) 55%),
    var(--bg-deep);
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }

.app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  padding-bottom: 86px;
}

/* ---------- Header ---------- */
.app-header {
  padding: 28px 20px 18px;
  text-align: center;
}

.app-header .brand {
  font-family: 'Noto Serif SC', serif;
  font-weight: 900;
  font-size: 30px;
  color: var(--paper);
  letter-spacing: 4px;
  margin: 0;
}

.app-header .tagline {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--gold-2);
  letter-spacing: 2px;
}

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 22px 20px 16px;
}

.page-header .back {
  color: var(--gold-2);
  font-size: 20px;
  line-height: 1;
  padding: 4px 6px 4px 0;
}

.page-header h1 {
  font-family: 'Noto Serif SC', serif;
  font-size: 21px;
  font-weight: 700;
  color: var(--paper);
  margin: 0;
  letter-spacing: 1px;
}

/* ---------- Seal stamp motif ---------- */
.seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  background: var(--vermilion);
  color: #f7e9d8;
  font-family: 'Noto Serif SC', serif;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.15;
  text-align: center;
  border-radius: 5px;
  transform: rotate(-4deg);
  box-shadow:
    0 2px 5px var(--shadow),
    inset 0 0 0 1px rgba(247, 233, 216, 0.35),
    inset 0 0 9px rgba(0, 0, 0, 0.25);
  letter-spacing: 0;
  white-space: pre-line;
  user-select: none;
}

/* ---------- Sections / cards ---------- */
.section {
  padding: 0 16px;
  margin-bottom: 18px;
}

.card {
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 6px 18px var(--shadow);
  border: 1px solid var(--paper-line);
}

.feature-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--paper);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 6px 16px var(--shadow);
  border: 1px solid var(--paper-line);
}

.feature-card .icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--paper-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.feature-card .icon svg { width: 24px; height: 24px; }

.feature-card .body { flex: 1; min-width: 0; }

.feature-card .title {
  font-family: 'Noto Serif SC', serif;
  font-weight: 700;
  font-size: 16.5px;
  margin: 0 0 4px;
  color: var(--ink);
}

.feature-card .desc {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin: 0;
  line-height: 1.5;
}

.feature-card .arrow {
  color: var(--gold);
  font-size: 18px;
  flex-shrink: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 18px;
  border-radius: 10px;
  border: none;
  font-family: 'Noto Serif SC', serif;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 1px;
  cursor: pointer;
  background: linear-gradient(180deg, var(--vermilion-2), var(--vermilion));
  color: #f7e9d8;
  box-shadow: 0 6px 14px rgba(184, 57, 42, 0.35);
}

.btn:active { transform: translateY(1px); }

.btn-outline {
  background: transparent;
  color: var(--gold-2);
  border: 1px solid var(--gold);
  box-shadow: none;
}

.btn-paper {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-line);
  box-shadow: 0 4px 10px var(--shadow);
}

/* ---------- Form fields ---------- */
.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--gold-2);
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 9px;
  border: 1px solid var(--paper-line);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  font-family: 'Noto Sans SC', sans-serif;
}

.field .row {
  display: flex;
  gap: 10px;
}

.field .row > * { flex: 1; min-width: 0; }

.radio-group {
  display: flex;
  gap: 10px;
}

.radio-pill {
  flex: 1;
  text-align: center;
  padding: 10px 8px;
  border-radius: 9px;
  border: 1px solid var(--gold);
  color: var(--gold-2);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.radio-pill.active {
  background: var(--vermilion);
  border-color: var(--vermilion);
  color: #f7e9d8;
}

/* ---------- Ink-bleed reveal ---------- */
@keyframes inkBleed {
  0% { opacity: 0; filter: blur(7px); transform: scale(0.94); }
  60% { opacity: 1; filter: blur(1px); }
  100% { opacity: 1; filter: blur(0); transform: scale(1); }
}

.ink-reveal {
  animation: inkBleed 0.7s ease-out;
}

/* ---------- BaZi result ---------- */
.pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 16px 0;
}

.pillar {
  text-align: center;
  background: var(--paper-2);
  border-radius: 10px;
  padding: 12px 4px 10px;
  border: 1px solid var(--paper-line);
}

.pillar .label {
  font-size: 11.5px;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.pillar .gz {
  font-family: 'Noto Serif SC', serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.3;
  color: var(--vermilion);
}

.element-bars { margin: 18px 0; }

.element-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.element-bar-row .el-name {
  width: 28px;
  font-family: 'Noto Serif SC', serif;
  font-weight: 700;
  font-size: 14px;
  text-align: center;
}

.element-bar-row .bar-track {
  flex: 1;
  height: 10px;
  background: var(--paper-2);
  border-radius: 6px;
  overflow: hidden;
}

.element-bar-row .bar-fill {
  height: 100%;
  border-radius: 6px;
}

.element-bar-row .el-count {
  width: 18px;
  text-align: right;
  font-size: 13px;
  color: var(--ink-soft);
}

.commentary {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--paper-line);
}

.commentary h3 {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  margin: 0 0 8px;
  color: var(--vermilion);
}

.commentary p {
  font-size: 14px;
  line-height: 1.7;
  margin: 0 0 10px;
  color: var(--ink);
}

/* ---------- Naming results ---------- */
.name-result {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--paper-2);
}

.name-result:last-child { border-bottom: none; }

.name-result .full-name {
  font-family: 'Noto Serif SC', serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--vermilion);
  flex-shrink: 0;
}

.name-result .meaning {
  font-size: 12.5px;
  color: var(--ink-soft);
  text-align: right;
  line-height: 1.5;
}

/* ---------- Qian slip ---------- */
.qian-stage {
  text-align: center;
  padding: 10px 0 6px;
}

.qian-tube {
  width: 150px;
  margin: 10px auto 18px;
}

.qian-level-tag {
  display: inline-block;
  font-size: 12px;
  letter-spacing: 2px;
  padding: 3px 12px;
  border-radius: 20px;
  margin-bottom: 10px;
}

.qian-level-tag.shang { background: #f0e3c2; color: #8a5a1f; }
.qian-level-tag.zhong { background: #e6e0d4; color: var(--ink-soft); }
.qian-level-tag.xia { background: #ecd9d4; color: var(--vermilion); }

.qian-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 24px;
  font-weight: 900;
  color: var(--ink);
  margin: 4px 0 16px;
  letter-spacing: 2px;
}

.qian-verse {
  font-family: 'Noto Serif SC', serif;
  font-size: 16px;
  line-height: 2.1;
  color: var(--ink);
  margin-bottom: 18px;
  letter-spacing: 1px;
}

.qian-verse div { margin-bottom: 2px; }

/* ---------- Dream dictionary ---------- */
.search-box {
  position: relative;
  margin-bottom: 16px;
}

.search-box input {
  width: 100%;
  padding: 13px 16px;
  border-radius: 24px;
  border: 1px solid var(--paper-line);
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
}

.dream-item {
  padding: 14px 4px;
  border-bottom: 1px solid var(--paper-2);
}

.dream-item:last-child { border-bottom: none; }

.dream-item .kw {
  font-family: 'Noto Serif SC', serif;
  font-weight: 700;
  color: var(--vermilion);
  font-size: 15px;
  margin-bottom: 4px;
}

.dream-item .tx {
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
}

.empty-hint {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13.5px;
  padding: 30px 10px;
}

/* ---------- Palm page ---------- */
.palm-lines text {
  font-family: 'Noto Sans SC', sans-serif;
}

.palm-detail {
  margin-top: 14px;
  padding: 14px;
  background: var(--paper-2);
  border-radius: 10px;
  display: none;
}

.palm-detail.show { display: block; }

.palm-detail h4 {
  margin: 0 0 6px;
  font-family: 'Noto Serif SC', serif;
  color: var(--vermilion);
  font-size: 15px;
}

.palm-detail p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
}

/* ---------- Disclaimer ---------- */
.disclaimer {
  text-align: center;
  font-size: 11.5px;
  color: rgba(243, 234, 217, 0.45);
  line-height: 1.8;
  padding: 10px 28px 30px;
}

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg-deep-2);
  border-top: 1px solid rgba(169, 130, 74, 0.25);
  display: flex;
  padding: 8px 4px 10px;
  z-index: 20;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(243, 234, 217, 0.55);
  font-size: 11px;
}

.bottom-nav a svg {
  width: 21px;
  height: 21px;
}

.bottom-nav a.active {
  color: var(--gold-2);
}

.bottom-nav a.active svg { color: var(--vermilion-2); }

/* ---------- Misc ---------- */
.section-title {
  font-family: 'Noto Serif SC', serif;
  font-size: 15px;
  color: var(--gold-2);
  letter-spacing: 2px;
  margin: 0 0 12px 4px;
}

.muted-note {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.6;
  margin-top: 10px;
}

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(247,233,216,0.4);
  border-top-color: #f7e9d8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 0;
  color: var(--ink-soft);
  font-size: 13px;
}
