:root {
  --bg: #f6f2ea;
  --surface: #fbf8f2;
  --surface-tint: #eee7da;
  --ink: #1e1d1b;
  --muted: #5a554d;
  --line: #dcd4c6;
  --accent: #345447;
  --accent-hover: #274137;
  --accent-soft: #e3ece7;
  --warm: #9e5c45;
  --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(620px 420px at 88% 6%, rgba(154, 178, 162, 0.24), transparent 72%),
    radial-gradient(520px 380px at 10% 18%, rgba(214, 178, 152, 0.22), transparent 70%),
    radial-gradient(480px 360px at 80% 82%, rgba(176, 166, 198, 0.16), transparent 70%),
    var(--bg);
  color: var(--ink);
  line-height: 1.68;
}

/* Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(246, 242, 234, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(220, 212, 198, 0.7);
}

.brand {
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.125rem;
  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 container */
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);
}

/* Typography */
h1 {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6.2vw, 3.25rem);
  font-weight: 700;
  line-height: 1.16;
  letter-spacing: -0.03em;
  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;
  letter-spacing: -0.015em;
  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 26px;
  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.55;
  cursor: not-allowed;
}

button.primary, a.btn-link.primary {
  background: var(--accent);
  color: #fbf8f2;
}

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

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

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

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(30, 29, 27, 0.05);
}

/* Landing / Hero */
.hero-sheet {
  padding: 20px 0 32px;
  border-bottom: 1px solid var(--line);
}

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

.access-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  max-width: 460px;
  margin-bottom: 14px;
}

.access-form input {
  flex: 1 1 220px;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--text-body);
  outline: none;
  transition: border-color 180ms var(--ease);
}

.access-form input:focus {
  border-color: var(--accent);
}

.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: #a6342a;
  font-size: var(--text-sm);
  margin: 6px 0 0;
}

/* Editorial Roster Preview on Landing */
.atlas-section {
  padding: 32px 0 12px;
}

.atlas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(128px, 1fr));
  gap: 10px 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.atlas-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
  color: var(--ink);
  padding: 4px 0;
}

.atlas-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.method-list {
  margin: 28px 0 0;
  padding: 24px 0 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 20px;
}

.method-list p {
  font-size: var(--text-sm);
  color: var(--muted);
  margin: 0;
}

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

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

.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 Stage */
.quiz-shell {
  padding-top: 8px;
}

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

.progress-track {
  height: 3px;
  background: var(--line);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 28px;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  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(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}

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

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

.option-item {
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 400;
  font-size: var(--text-body);
  line-height: 1.55;
}

.option-item:hover {
  border-color: var(--accent);
  background: #fdfbf7;
}

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

.option-index {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  margin-right: 10px;
  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: 32px 24px 36px;
}

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

.report-en {
  font-size: var(--text-sm);
  color: var(--muted);
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.report-archetype {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.6rem);
  font-weight: 700;
  line-height: 1.12;
  margin: 0 0 14px;
  letter-spacing: -0.02em;
}

.report-tagline {
  font-family: var(--font-display);
  font-size: var(--text-heading);
  color: var(--ink);
  margin: 0 0 18px;
  line-height: 1.45;
}

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

.report-metrics strong {
  color: var(--accent);
  font-weight: 700;
}

/* Signature Palette */
.report-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

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

.palette-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.swatch {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.swatch-color {
  height: 54px;
  border-radius: 10px;
  border: 1px solid rgba(30, 29, 27, 0.1);
}

.swatch-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
}

.swatch-hex {
  font-size: 0.78rem;
  color: var(--muted);
}

/* Radar + Dimension Bars */
.radar-wrap {
  display: grid;
  grid-template-columns: minmax(220px, 270px) 1fr;
  gap: 24px;
  align-items: center;
  margin-top: 14px;
}

@media (max-width: 600px) {
  .radar-wrap {
    grid-template-columns: 1fr;
  }
  .report-paper {
    padding: 24px 18px 28px;
  }
  .palette-strip {
    gap: 6px;
  }
  .swatch-color {
    height: 44px;
  }
}

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

.dim-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.dim-bar-track {
  height: 6px;
  background: var(--surface-tint);
  border-radius: 99px;
  overflow: hidden;
}

.dim-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
}

/* Editorial Reading Blocks */
.reading-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.cp-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.cp-item {
  padding: 14px 16px;
  background: var(--bg);
  border-radius: var(--radius);
}

.runner-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 12px;
}

.runner-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.runner-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.atlas-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(108px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.atlas-cell {
  padding: 8px 10px;
  border-radius: 8px;
  font-size: var(--text-sm);
  color: var(--muted);
  background: var(--bg);
  display: flex;
  align-items: center;
  gap: 6px;
}

.atlas-cell.is-me {
  background: var(--accent);
  color: #fbf8f2;
  font-weight: 600;
}

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

.promo-note {
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--surface-tint);
  border-radius: var(--radius);
  font-size: var(--text-sm);
  color: var(--ink);
}

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

.poster-card {
  width: 400px;
  background:
    radial-gradient(300px 220px at 88% 8%, rgba(154, 178, 162, 0.28), transparent 72%),
    radial-gradient(280px 220px at 12% 85%, rgba(214, 178, 152, 0.25), transparent 72%),
    #f6f2ea;
  border: 1px solid #d7cebe;
  border-radius: 16px;
  padding: 32px 26px 26px;
  color: #1e1d1b;
  font-family: var(--font-body);
}

.poster-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #5a554d;
  padding-bottom: 14px;
  border-bottom: 1px solid #dcd4c6;
  margin-bottom: 22px;
}

.poster-name {
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 700;
  line-height: 1.15;
  margin: 0 0 6px;
  color: #1e1d1b;
}

.poster-en {
  font-size: 14px;
  color: #5a554d;
  margin: 0 0 18px;
}

.poster-quote {
  font-family: var(--font-display);
  font-size: 17px;
  line-height: 1.55;
  color: #1e1d1b;
  margin: 0 0 20px;
}

.poster-stats {
  display: flex;
  gap: 20px;
  font-size: 14px;
  color: #345447;
  font-weight: 600;
  margin-bottom: 20px;
}

.poster-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}

.poster-swatch-box {
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(30, 29, 27, 0.1);
}

.poster-swatch-lbl {
  font-size: 11px;
  color: #5a554d;
  margin-top: 4px;
  text-align: center;
}

.poster-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 14px;
  border-top: 1px solid #dcd4c6;
  font-size: 12px;
  color: #5a554d;
}

/* Footer */
.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 & Modal */
#toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: var(--text-sm);
  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(30, 29, 27, 0.45);
  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 (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
