:root {
  --bg: #0f1916;
  --surface: #15231f;
  --surface-elevated: #1c2e29;
  --ink: #ede7da;
  --muted: #9eb0a7;
  --line: rgba(212, 175, 106, 0.22);
  --jade: #52b788;
  --jade-hover: #409d73;
  --jade-soft: rgba(82, 183, 136, 0.14);
  --gold: #d4af6a;
  --amber: #df825f;
  --amber-soft: rgba(223, 130, 95, 0.15);
  --font-display: "Noto Serif SC", "Songti SC", "STSong", "Source Han Serif SC", Georgia, serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  --text-heading: 1.375rem;
  --text-body: 0.96875rem;
  --text-sm: 0.84375rem;
  --radius: 14px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: tabular-nums;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(560px 420px at 50% 0%, rgba(82, 183, 136, 0.16), transparent 72%),
    radial-gradient(480px 360px at 90% 85%, rgba(212, 175, 106, 0.10), transparent 72%),
    var(--bg);
  color: var(--ink);
  line-height: 1.7;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 25, 22, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brand {
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: baseline;
  gap: 10px;
}

.brand-sub {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--muted);
}

main#app {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 20px 64px;
}

.loading {
  text-align: center;
  color: var(--muted);
  padding: 72px 0;
  font-size: var(--text-body);
}

h1 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(2.05rem, 6.2vw, 3.1rem);
  font-weight: 700;
  line-height: 1.18;
  letter-spacing: -0.02em;
  color: var(--ink);
}

h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 700;
  line-height: 1.32;
  color: var(--ink);
}

h3 {
  margin: 0 0 8px;
  font-family: var(--font-body);
  font-size: var(--text-body);
  font-weight: 600;
  color: var(--ink);
}

p {
  margin: 0 0 14px;
  font-size: var(--text-body);
  color: var(--ink);
  max-width: 65ch;
}

.muted { color: var(--muted); }
.small { font-size: var(--text-sm); color: var(--muted); }

/* Buttons */
button, a.btn-link {
  font-family: var(--font-body);
  font-size: var(--text-body);
  line-height: 1.3;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 13px 24px;
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background-color 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
}

button:disabled { opacity: 0.52; cursor: not-allowed; }

button.primary, a.btn-link.primary {
  background: var(--jade);
  color: #0b1411;
}

button.primary:hover:not(:disabled), a.btn-link.primary:hover {
  background: var(--jade-hover);
  transform: translateY(-1px);
}

button.secondary, a.btn-link.secondary {
  background: var(--surface-elevated);
  color: var(--ink);
  border-color: var(--line);
}

button.secondary:hover:not(:disabled), a.btn-link.secondary:hover {
  border-color: var(--gold);
}

button.quiet {
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 8px;
  font-size: var(--text-sm);
  font-weight: 500;
}

button.quiet:hover:not(:disabled) {
  color: var(--ink);
  background: rgba(237, 231, 218, 0.08);
}

/* Lotus Emblem */
.lotus-emblem {
  width: 56px;
  height: 56px;
  margin-bottom: 18px;
  display: block;
}

.hero-sheet {
  padding: 16px 0 32px;
  border-bottom: 1px solid var(--line);
}

.hero-lead {
  font-size: var(--text-body);
  color: var(--muted);
  margin: 0 0 26px;
  max-width: 46ch;
}

.entry-note {
  margin-top: 8px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-width: 520px;
}

.form-error {
  color: #f08a72;
  font-size: var(--text-sm);
  margin: 6px 0 12px;
}

.overview-grid {
  padding: 30px 0 10px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
}

.overview-col {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.overview-col ul {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.overview-col strong { color: var(--ink); }

/* Hub */
.hub-panel {
  padding: 14px 0 28px;
  border-bottom: 1px solid var(--line);
}

.hub-meta {
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: 20px;
}

.hub-meta strong { color: var(--gold); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-top: 16px;
}

.history-list { margin-top: 28px; }

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.history-title {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  font-weight: 700;
  color: var(--ink);
}

/* Quiz */
.quiz-shell { padding-top: 8px; }

.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  color: var(--muted);
  margin-bottom: 10px;
}

.progress-track {
  height: 3px;
  background: rgba(237, 231, 218, 0.14);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 28px;
}

.progress-fill {
  height: 100%;
  background: var(--jade);
  transition: width 220ms var(--ease);
}

.question-card { animation: fadeSlide 200ms var(--ease); }

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

.question-facet {
  font-size: var(--text-sm);
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 8px;
}

.question-text {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  line-height: 1.46;
  margin: 0 0 24px;
  color: var(--ink);
}

.options-stack {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.option-item {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  align-items: center;
  padding: 15px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid rgba(237, 231, 218, 0.12);
  color: var(--ink);
  font-weight: 400;
  font-size: var(--text-body);
}

.option-item:hover {
  border-color: var(--jade);
  background: var(--surface-elevated);
}

.option-item.selected {
  border-color: var(--jade);
  background: var(--jade-soft);
  font-weight: 600;
}

.option-index {
  width: 24px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--gold);
  flex-shrink: 0;
}

.quiz-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

/* Report Paper */
.report-paper {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 30px 24px 34px;
}

.report-hero {
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.score-number {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 12vw, 4.8rem);
  font-weight: 700;
  line-height: 1.05;
  margin: 8px 0 10px;
  letter-spacing: -0.03em;
}

.score-number.is-neg { color: var(--amber); }
.score-number.is-pos { color: var(--jade); }

.report-state {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  color: var(--gold);
  margin: 0 0 12px;
}

.report-summary {
  margin: 0 auto 18px;
  color: var(--ink);
  max-width: 44ch;
}

.report-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 18px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.report-metrics strong { color: var(--ink); }

.report-section {
  padding: 24px 0;
  border-bottom: 1px solid var(--line);
}

.report-section:last-child { border-bottom: none; padding-bottom: 0; }

.radar-wrap {
  display: grid;
  grid-template-columns: minmax(230px, 280px) 1fr;
  gap: 22px;
  align-items: center;
  margin-top: 14px;
}

.radar-svg {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  display: block;
}

.dual-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 14px;
}

.dim-group {
  background: var(--bg);
  border: 1px solid rgba(237, 231, 218, 0.08);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.dim-head {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-sm);
  margin-bottom: 5px;
}

.dim-status-pos { color: var(--jade); font-weight: 600; }
.dim-status-neg { color: var(--amber); font-weight: 600; }

.dim-bar-track {
  height: 6px;
  background: rgba(237, 231, 218, 0.1);
  border-radius: 99px;
  overflow: hidden;
}

.dim-bar-pos { height: 100%; background: var(--jade); border-radius: 99px; }
.dim-bar-neg { height: 100%; background: var(--amber); border-radius: 99px; }

.highlight-box {
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--bg);
  border-left: 3px solid var(--jade);
  margin-bottom: 14px;
}

.highlight-box.is-leak { border-left-color: var(--amber); }

.habit-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.habit-list li {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  font-size: var(--text-body);
  color: var(--ink);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: var(--text-sm);
  margin-top: 8px;
}

.tag-pos { color: var(--jade); font-weight: 600; }
.tag-neg { color: var(--amber); font-weight: 600; }

.report-actions {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.report-actions button { padding: 12px 18px; }

.more-explore {
  margin-top: 28px;
  padding: 20px 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.more-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.more-item {
  padding: 12px 14px;
  background: var(--bg);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.more-item strong { font-size: var(--text-sm); color: var(--gold); }
.more-item span { font-size: 0.8125rem; color: var(--muted); line-height: 1.5; }

/* Poster Export Offscreen Canvas */
.export-container {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 440px;
  background: #0f1916;
  padding: 20px;
}

.poster-card {
  width: 400px;
  background:
    radial-gradient(300px 220px at 50% 0%, rgba(82, 183, 136, 0.22), transparent 72%),
    radial-gradient(240px 200px at 90% 90%, rgba(212, 175, 106, 0.14), transparent 70%),
    #13201c;
  border: 1px solid rgba(212, 175, 106, 0.34);
  border-radius: 16px;
  padding: 30px 26px 26px;
  color: #ede7da;
  font-family: var(--font-body);
}

.poster-top {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: #9eb0a7;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(212, 175, 106, 0.22);
  margin-bottom: 20px;
}

.poster-score {
  font-family: var(--font-display);
  font-size: 64px;
  font-weight: 700;
  line-height: 1.05;
  text-align: center;
  margin: 6px 0 8px;
}

.poster-state {
  font-family: var(--font-display);
  font-size: 22px;
  color: #d4af6a;
  text-align: center;
  margin-bottom: 16px;
}

.poster-quote {
  font-size: 15px;
  line-height: 1.65;
  color: #ede7da;
  text-align: center;
  margin-bottom: 20px;
}

.poster-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.poster-box {
  background: #0f1916;
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.poster-box small { display: block; font-size: 12px; color: #9eb0a7; margin-bottom: 4px; }
.poster-box strong { font-size: 15px; }

.poster-foot {
  display: flex;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid rgba(212, 175, 106, 0.22);
  font-size: 12px;
  color: #9eb0a7;
}

.site-footer {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 36px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: var(--text-sm);
  color: var(--muted);
}

.footer-links { display: flex; align-items: center; gap: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--gold);
  color: #0f1916;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: var(--text-sm);
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 60;
}

dialog#modal {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  padding: 24px 22px;
  width: min(92vw, 480px);
  max-height: 88dvh;
  overflow: auto;
}

dialog#modal::backdrop {
  background: rgba(5, 10, 8, 0.72);
  backdrop-filter: blur(4px);
}

.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }

.image-scroll {
  max-height: 52dvh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin: 12px 0;
  background: var(--bg);
}

.image-preview { display: block; width: 100%; height: auto; }

#share-link {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  font-size: var(--text-sm);
}

@media (max-width: 600px) {
  .radar-wrap { grid-template-columns: 1fr; }
  .report-paper { padding: 24px 18px 28px; }
  .report-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .report-actions button.primary { grid-column: 1 / -1; width: 100%; }
  .report-actions button.secondary, .report-actions button.quiet { width: 100%; padding: 12px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
