:root {
  --bg: #f5efe7;
  --bg-strong: #eadfce;
  --surface: rgba(255, 250, 244, 0.78);
  --surface-strong: rgba(255, 250, 244, 0.94);
  --ink: #1e241f;
  --muted: #5f6a62;
  --accent: #b85c38;
  --accent-deep: #7e3d24;
  --line: rgba(30, 36, 31, 0.08);
  --shadow: 0 22px 60px rgba(61, 39, 25, 0.14);
  --radius-xl: 32px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --transition: 180ms ease;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(184, 92, 56, 0.18), transparent 30%),
    radial-gradient(circle at bottom right, rgba(28, 72, 58, 0.18), transparent 28%),
    linear-gradient(180deg, #f9f3eb 0%, #efe4d4 100%);
  color: var(--ink);
  font-family: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

body {
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  position: relative;
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.ambient {
  position: absolute;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(18px);
  opacity: 0.9;
}

.ambient-one {
  top: 40px;
  right: 6%;
  width: 220px;
  height: 220px;
  background: rgba(184, 92, 56, 0.18);
}

.ambient-two {
  top: 360px;
  left: -40px;
  width: 180px;
  height: 180px;
  background: rgba(48, 101, 81, 0.16);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 30px;
}

.hero-copy {
  max-width: 760px;
}

.eyebrow {
  margin-bottom: 14px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-deep);
}

.hero h1 {
  font-size: clamp(2.2rem, 4vw, 3.6rem);
  line-height: 1;
  margin-bottom: 12px;
  max-width: none;
}

.lede {
  max-width: 40ch;
  font-size: 1rem;
}

.lang-toggle,
.primary-button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  transition:
    transform var(--transition),
    box-shadow var(--transition),
    background var(--transition);
}

.lang-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100;
  padding: 9px 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
  box-shadow: 0 4px 16px rgba(64, 47, 31, 0.12);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
}

.lang-toggle:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.panel,
.result-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.form-panel {
  padding: 26px;
}

.panel-head {
  margin-bottom: 22px;
}

.panel-head h2 {
  margin-bottom: 8px;
  font-size: 1.6rem;
}

.chart-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.chart-form label {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chart-form label span {
  font-size: 0.88rem;
  color: var(--ink);
}

.chart-form label.wide,
.actions {
  grid-column: 1 / -1;
}

.chart-form input,
.chart-form select {
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(53, 42, 31, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.chart-form input:focus,
.chart-form select:focus {
  outline: 2px solid rgba(184, 92, 56, 0.28);
  outline-offset: 2px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 8px;
}

.primary-button {
  min-height: 52px;
  padding: 0 18px;
  background: linear-gradient(135deg, var(--accent), #cf7a54);
  color: white;
  box-shadow: 0 16px 40px rgba(184, 92, 56, 0.28);
}

.status-copy {
  font-size: 0.92rem;
}

.results {
  display: grid;
  gap: 18px;
}

.result-card {
  padding: 22px;
  animation: fadeUp 420ms ease both;
}

.hidden {
  display: none;
}

.summary-card {
  padding: 26px;
  background:
    linear-gradient(135deg, rgba(255, 248, 241, 0.95), rgba(247, 236, 221, 0.86)),
    var(--surface-strong);
}

.summary-card h2 {
  margin-bottom: 12px;
  font-size: 1.9rem;
}

.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.chip {
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(30, 36, 31, 0.05);
  color: var(--ink);
  font-size: 0.88rem;
}

.pillar-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.pillar-card {
  border-radius: var(--radius-lg);
  padding: 16px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(30, 36, 31, 0.08);
}

.pillar-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 18px;
}

.pillar-title {
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.pillar-glyph {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 10px;
}

.pillar-glyph strong {
  font-size: 2.5rem;
  font-family: "Songti TC", "Songti SC", "STSong", serif;
  line-height: 1;
  color: var(--ink);
}

.pillar-meta,
.data-list,
.warning-list,
.assumptions-list {
  display: grid;
  gap: 8px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.metric-panel {
  padding: 18px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(30, 36, 31, 0.08);
}

.metric-panel h3,
.section-title {
  margin-bottom: 12px;
  font-size: 1.16rem;
}

.bars {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  gap: 6px;
}

.bar-track {
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: rgba(30, 36, 31, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #316551, var(--accent));
}

.section-copy {
  white-space: pre-line;
}

.technical details {
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(30, 36, 31, 0.08);
  padding: 0 18px;
}

.technical summary {
  padding: 18px 0;
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.technical-body {
  padding: 0 0 18px;
}

.list-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(30, 36, 31, 0.08);
}

.list-row:first-child {
  border-top: none;
}

.error-card {
  border-left: 4px solid #aa2e25;
}

/* --- Fun personality cards --- */
.fun-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.fun-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  background: linear-gradient(135deg, rgba(184, 92, 56, 0.08), rgba(48, 101, 81, 0.06));
  border: 1px solid rgba(184, 92, 56, 0.14);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fun-card-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-deep);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  font-weight: 600;
}

.fun-card-body {
  font-size: 0.97rem;
  color: var(--ink);
  line-height: 1.55;
}

/* --- Tab navigation --- */
.tab-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(30, 36, 31, 0.05);
  border-radius: 999px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.tab-btn {
  flex: 1;
  min-width: 80px;
  padding: 10px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.tab-btn.active {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: 0 4px 12px rgba(61, 39, 25, 0.1);
  font-weight: 600;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* --- Narrative sections --- */
.narrative-section {
  padding: 18px 0;
  border-top: 1px solid var(--line);
}

.narrative-section:first-child {
  border-top: none;
  padding-top: 0;
}

.narrative-section h4 {
  font-size: 0.88rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  margin-bottom: 8px;
}

.narrative-section p {
  white-space: pre-line;
}

/* --- Domain sub-tabs --- */
.domain-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.domain-btn {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  cursor: pointer;
  transition: all var(--transition);
}

.domain-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.domain-panel {
  display: none;
}

.domain-panel.active {
  display: block;
}

.domain-read {
  font-size: 0.97rem;
  color: var(--ink);
  line-height: 1.65;
  margin-bottom: 18px;
}

.guidance-blocks {
  display: grid;
  gap: 10px;
}

.guidance-block {
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.guidance-block.watch {
  background: rgba(184, 92, 56, 0.07);
  border-left: 3px solid var(--accent);
}

.guidance-block.lean {
  background: rgba(48, 101, 81, 0.07);
  border-left: 3px solid #316551;
}

.guidance-block.avoid {
  background: rgba(30, 36, 31, 0.05);
  border-left: 3px solid rgba(30, 36, 31, 0.2);
}

.guidance-label {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.guidance-text {
  font-size: 0.94rem;
  color: var(--ink);
  line-height: 1.5;
}

/* --- Annual overlay --- */
.annual-card {
  border-radius: var(--radius-lg);
  padding: 20px;
  background: linear-gradient(135deg, rgba(48, 101, 81, 0.08), rgba(48, 101, 81, 0.03));
  border: 1px solid rgba(48, 101, 81, 0.16);
  margin-bottom: 18px;
}

.annual-pillar {
  font-size: 2rem;
  font-family: "Songti TC", "Songti SC", "STSong", serif;
  color: var(--ink);
  margin-bottom: 4px;
}

.annual-theme {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: #316551;
  margin-bottom: 12px;
  font-weight: 600;
}

.annual-body {
  font-size: 0.97rem;
  color: var(--ink);
  line-height: 1.65;
}

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

@media (max-width: 980px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 26px 14px 60px;
  }

  .chart-form,
  .pillar-grid,
  .metric-grid,
  .fun-strip {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    max-width: none;
    font-size: 2.7rem;
  }
}

/* --- Share card --- */
.share-card-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-card-inner {
  background: linear-gradient(145deg, #231510 0%, #1a2a1e 100%);
  border-radius: var(--radius-lg);
  padding: 32px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.share-card-glow {
  position: absolute;
  top: -60px;
  right: -60px;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(184, 92, 56, 0.22), transparent 70%);
  pointer-events: none;
  border-radius: 999px;
}

.sc-brand {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.35;
  margin-bottom: 18px;
}

.sc-identity {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
  line-height: 1.1;
}

.sc-summary {
  font-size: 0.88rem;
  line-height: 1.65;
  opacity: 0.6;
  color: #fff;
  margin-bottom: 26px;
  max-width: 480px;
}

.sc-pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 26px;
}

.sc-pillar {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px 6px;
  text-align: center;
}

.sc-pillar-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  opacity: 0.38;
  margin-bottom: 10px;
}

.sc-pillar-glyph {
  font-family: "Songti TC", "Songti SC", "STSong", "FangSong", serif;
  font-size: 1.9rem;
  font-weight: 700;
  line-height: 1.25;
  color: #fff;
}

.sc-quote {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 16px;
  margin-bottom: 22px;
}

.sc-quote-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  opacity: 0.9;
  margin-bottom: 6px;
}

.sc-quote-body {
  font-size: 0.9rem;
  line-height: 1.6;
  opacity: 0.75;
  color: #fff;
}

.sc-footer {
  font-size: 11px;
  letter-spacing: 0.12em;
  opacity: 0.25;
  margin-top: 4px;
}

/* --- Mode toggle --- */
.mode-toggle {
  display: flex;
  gap: 6px;
  margin-bottom: 4px;
}

.mode-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.mode-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* --- Fun mode output --- */
.fun-mode-wrap {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.fun-mode-reveal {
  background: linear-gradient(160deg, #fdf8f0 0%, #f5e2c0 100%);
  border-radius: var(--radius-lg);
  padding: 44px 32px 32px;
  text-align: center;
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(120, 70, 20, 0.14);
}

.fun-mode-question {
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 22px;
}

.fun-mode-answer {
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 3.8rem;
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 18px;
  color: var(--accent-deep);
  letter-spacing: -0.02em;
}

.fun-mode-body {
  font-size: 0.98rem;
  line-height: 1.72;
  color: #5a3e22;
  max-width: 380px;
  margin: 0 auto 28px;
}

.fun-mode-why {
  border-top: 1px solid rgba(120, 70, 20, 0.12);
  padding-top: 18px;
  margin-bottom: 18px;
}

.fun-mode-why-text {
  font-size: 0.82rem;
  line-height: 1.65;
  color: #8a6040;
  opacity: 0.8;
}

.fun-mode-site {
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent);
  opacity: 0.5;
}


.fun-mode-share {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  transition: var(--transition);
}

.fun-mode-share:hover { background: var(--accent-deep); }
.fun-mode-share:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 720px) {
  .fun-mode-answer { font-size: 3rem; }
  .fun-mode-reveal { padding: 36px 24px 28px; }
}

/* Share card tab bar */
.sc-tab-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.sc-tab-btn {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid rgba(30, 36, 31, 0.14);
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.sc-tab-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

/* Character variant */
.sc-sections {
  display: grid;
  gap: 16px;
  margin-bottom: 4px;
}

.sc-section-title {
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 5px;
}

.sc-section-body {
  font-size: 0.88rem;
  line-height: 1.6;
  opacity: 0.75;
  color: #fff;
  margin: 0;
}

/* Timing variant */
.sc-annual {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 4px;
}

.sc-annual-pillar {
  font-family: "Songti TC", "Songti SC", "STSong", serif;
  font-size: 3.2rem;
  font-weight: 700;
  line-height: 1;
  opacity: 0.9;
  flex-shrink: 0;
}

.sc-annual-theme {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}

.sc-annual-body {
  font-size: 0.88rem;
  line-height: 1.6;
  opacity: 0.72;
  color: #fff;
  margin: 0;
}

.sc-luck-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-size: 0.9rem;
}

.sc-luck-age { opacity: 0.5; }
.sc-luck-pillar {
  font-family: "Songti TC", "Songti SC", "STSong", serif;
  font-size: 1.1rem;
}

/* Fun variant */
.sc-fun-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 4px;
}

.sc-fun-card {
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  padding: 14px;
  border: 1px solid rgba(255,255,255,0.1);
}

.sc-fun-title {
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}

.sc-fun-body {
  font-size: 0.83rem;
  line-height: 1.55;
  opacity: 0.75;
  color: #fff;
  margin: 0;
}

.sc-actions {
  display: flex;
  gap: 10px;
}

.sc-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: var(--transition);
}

.sc-save-btn:hover {
  background: var(--accent-deep);
}

.sc-save-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

@media (max-width: 720px) {
  .sc-pillars {
    grid-template-columns: repeat(4, 1fr);
  }

  .sc-pillar-glyph {
    font-size: 1.5rem;
  }

  .share-card-inner {
    padding: 24px 20px;
  }
}
