:root {
  --soul-ink: #f6ecd8;
  --soul-muted: rgba(246, 236, 216, .72);
  --soul-gold: #d7b56a;
  --soul-gold-2: #f0d9a2;
  --soul-line: rgba(215, 181, 106, .42);
  --soul-bg: #08070a;
  --paper: #fffdf6;
  --paper-ink: #1d211f;
  --paper-muted: rgba(21, 25, 24, .7);
  --paper-faint: rgba(21, 25, 24, .45);
  --paper-line: #e4d7b8;
  --cinnabar: #c2553f;
  --red-deep: #9e3a2c;
  --radius: 8px;
  --app-height: 100svh;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { background: #fbf4e4; }
html:has(body.is-result) { background: #08070a; }
button, select { font: inherit; color: inherit; }
button { border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }

body.soul-app {
  min-height: var(--app-height, 100svh);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.soul-app.is-birth {
  color: var(--paper-ink);
  background:
    linear-gradient(180deg, rgba(251, 244, 228, .94), rgba(241, 231, 208, .96));
}

body.soul-app.is-result {
  color: var(--soul-ink);
  background:
    radial-gradient(circle at 50% 0%, rgba(215, 181, 106, .12), transparent 42%),
    var(--soul-bg);
}

.soul-birth {
  min-height: var(--app-height, 100svh);
  display: flex;
  flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}

.soul-birth-page {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 8px 0 28px;
}

.soul-birth-back {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  margin-bottom: 18px;
  padding: 0 12px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--paper-ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.soul-birth-page h1 {
  margin: 0 0 18px;
  font-family: "Songti SC", "STSong", "Noto Serif CJK SC", "Source Han Serif SC", serif;
  font-size: 26px;
  font-weight: 650;
  letter-spacing: .12em;
  line-height: 1.25;
}

.soul-birth-card {
  display: block;
  padding: 16px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: 0 10px 28px -22px rgba(47, 36, 17, .35);
}

.soul-field {
  display: block;
}

.soul-field > span {
  display: block;
  margin-bottom: 6px;
  color: var(--paper-muted);
  font-size: 12px;
}

.soul-date-trigger {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--paper-ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .02em;
  text-align: left;
}

.soul-date-trigger.is-empty {
  color: var(--paper-faint);
  font-weight: 500;
}

.soul-date-trigger:focus-visible {
  outline: 2px solid rgba(166, 64, 50, .45);
  outline-offset: 2px;
}

.soul-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  margin-top: 14px;
  border-radius: var(--radius);
  background: var(--cinnabar);
  color: #fff9ec;
  font-weight: 700;
  letter-spacing: .08em;
}

.soul-generate:hover { background: var(--red-deep); }
.soul-generate:active { transform: scale(.985); }
.soul-generate[disabled] { opacity: .55; cursor: wait; }

.soul-form-error {
  margin: 8px 0 0;
  min-height: 1em;
  color: var(--cinnabar);
  font-size: 13px;
}

.soul-sheet[hidden] { display: none !important; }
.soul-sheet {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.soul-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(21, 25, 24, .38);
}

.soul-sheet-card {
  position: relative;
  width: min(440px, 100%);
  padding: 16px 16px max(18px, env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  background: var(--paper);
  box-shadow: 0 -18px 40px -24px rgba(47, 36, 17, .45);
}

.soul-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.soul-sheet-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .04em;
}

.soul-sheet-close {
  min-height: 36px;
  padding: 0 8px;
  background: transparent;
  color: var(--paper-muted);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.soul-dates {
  display: grid;
  grid-template-columns: 1.2fr .86fr .86fr;
  gap: 8px;
}

.soul-dates label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  color: var(--paper-muted);
  font-size: 12px;
}

.soul-dates select {
  width: 100%;
  min-height: 40px;
  padding: 7px 9px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--paper-ink);
  font-size: 16px;
}

.soul-sheet-confirm { margin-top: 16px; }

.soul-loading[hidden] { display: none !important; }
.soul-loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 38%, rgba(215, 181, 106, .16), transparent 42%),
    rgba(8, 7, 10, .88);
}
.soul-loading-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  color: var(--soul-gold-2);
  letter-spacing: .22em;
  font-size: 13px;
}
.soul-loading-ring {
  width: 78px;
  height: 78px;
  border: 1.5px solid rgba(215, 181, 106, .22);
  border-top-color: #f0d9a2;
  border-radius: 50%;
  animation: soulSpin .9s linear infinite;
}
.soul-loading-mark {
  position: absolute;
  top: 19px;
  left: 50%;
  margin-left: -20px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(150deg, var(--cinnabar), var(--red-deep));
  color: #fff6e3;
  font-family: "Songti SC", "STSong", serif;
  font-size: 18px;
  letter-spacing: 0;
  box-shadow: 0 10px 22px -14px rgba(124, 49, 38, .8);
}
.soul-loading-inner p { margin: 0; }
@keyframes soulSpin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  .soul-loading-ring { animation: none; }
}

.soul-stage {
  min-height: var(--app-height, 100svh);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.soul-stage[hidden],
.soul-birth[hidden] { display: none !important; }

.soul-card {
  position: relative;
  width: min(100%, calc((var(--app-height, 100svh) - 148px) * 819 / 1024), 430px);
  aspect-ratio: 819 / 1024;
  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;
}

@media (min-width: 768px) {
  .soul-stage {
    gap: 16px;
    padding: max(16px, env(safe-area-inset-top)) 28px max(24px, env(safe-area-inset-bottom));
  }
  .soul-card {
    width: min(92vw, calc((var(--app-height, 100svh) - 168px) * 819 / 1024), 560px);
  }
  .soul-actions {
    width: min(100%, 560px);
  }
}

.soul-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  -webkit-touch-callout: default;
  -webkit-user-select: none;
  user-select: none;
}

.soul-home {
  position: absolute;
  left: 3.2%;
  top: 3.4%;
  width: 44%;
  height: 11.5%;
  z-index: 3;
  color: transparent;
  text-indent: -9999px;
  overflow: hidden;
}

.soul-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(100%, 430px);
}

.soul-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  letter-spacing: .16em;
  font-size: 13px;
  font-weight: 650;
}

.soul-btn-primary {
  flex: 1 1 170px;
  background: linear-gradient(135deg, #c2553f, #9e3a2c);
  color: #fff9ec;
  box-shadow: 0 18px 38px -18px rgba(124, 49, 38, .85);
}

.soul-btn-ghost {
  flex: 1 1 140px;
  border: 1px solid var(--soul-line);
  background: rgba(255, 255, 255, .04);
  color: var(--soul-gold-2);
}

.soul-btn-text {
  flex: 1 1 100%;
  min-height: 34px;
  background: transparent;
  color: var(--soul-muted);
  letter-spacing: .2em;
  font-size: 12px;
}

.soul-status {
  min-height: 1.2em;
  margin: 0;
  color: var(--soul-gold-2);
  font-size: 12px;
  letter-spacing: .08em;
  text-align: center;
}

@media (max-width: 380px) {
  .soul-birth-page h1 { font-size: 22px; }
}
