:root {
  color-scheme: dark;
  --bg: #100e20;
  --surface: rgba(28, 25, 53, 0.84);
  --surface-strong: rgba(38, 33, 71, 0.94);
  --line: rgba(210, 198, 255, 0.16);
  --muted: #a9a3c2;
  --text: #f6f3ff;
  --lavender: #c6a9ff;
  --lavender-strong: #a477ff;
  --mint: #8fe1d5;
  font-family: Pretendard, "Noto Sans KR", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 4%, rgba(177, 140, 255, 0.22), transparent 30rem),
    radial-gradient(circle at 88% 18%, rgba(109, 225, 210, 0.08), transparent 24rem),
    linear-gradient(145deg, #100e20 0%, #17142d 55%, #0d1020 100%);
}

button, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.story-page {
  width: min(860px, calc(100% - 32px));
  min-height: 100svh;
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 0 max(28px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  margin-bottom: clamp(48px, 9vw, 92px);
}

.brand {
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  text-decoration: none;
}

.brand span { color: var(--lavender); }

.back-link {
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: none;
}

.back-link:hover { color: var(--text); }

.intro { max-width: 690px; }

.eyebrow, .panel-kicker {
  margin: 0 0 12px;
  color: var(--lavender);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1, h2, p { margin-top: 0; }

h1 {
  margin-bottom: 20px;
  font-size: clamp(2.6rem, 7vw, 5.2rem);
  font-weight: 750;
  letter-spacing: -0.075em;
  line-height: 0.98;
}

h1 em {
  color: var(--lavender);
  font-style: normal;
}

.intro-copy {
  margin-bottom: clamp(34px, 6vw, 58px);
  color: var(--muted);
  font-size: clamp(0.96rem, 2vw, 1.08rem);
  line-height: 1.7;
}

.workspace { display: grid; gap: 16px; }

.auth-panel, .score-form, .result-panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 18px 70px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(20px);
}

.auth-panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
}

.auth-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(198, 169, 255, 0.38);
  border-radius: 14px;
  color: var(--lavender);
  font-size: 1.6rem;
}

.panel-kicker { margin-bottom: 4px; }

.panel-copy { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.45; }

.button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 750;
  text-decoration: none;
  transition: transform 160ms ease, filter 160ms ease, opacity 160ms ease;
}

.button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.button:active { transform: translateY(0); }

.button-primary { color: #171127; background: var(--lavender); }
.button:disabled { cursor: not-allowed; opacity: 0.5; transform: none; }

.score-form { padding: 24px; }

.score-form label {
  display: block;
  margin-bottom: 10px;
  color: #e9e3ff;
  font-size: 0.88rem;
  font-weight: 700;
}

.search-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.search-row input {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(210, 198, 255, 0.2);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: rgba(8, 7, 20, 0.46);
}

.search-row input:focus { border-color: var(--lavender); box-shadow: 0 0 0 3px rgba(198, 169, 255, 0.12); }
.search-row input::placeholder { color: #777291; }
.field-note, .form-status, .result-note { color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.field-note { margin: 10px 0 0; }
.form-status { min-height: 1.2em; margin: 6px 0 0; }
.form-status[data-kind="error"] { color: #ffacbd; }
.form-status[data-kind="success"] { color: var(--mint); }

.result-panel { padding: 26px 24px 24px; background: var(--surface-strong); }
.result-heading h2 { margin: 0; font-size: clamp(1.25rem, 3vw, 1.8rem); letter-spacing: -0.04em; }
.score-line { display: flex; align-items: baseline; gap: 8px; margin-top: 26px; }
.score-line strong { font-size: clamp(4.8rem, 15vw, 8.8rem); font-weight: 760; letter-spacing: -0.1em; line-height: 0.88; }
.score-line span { color: var(--muted); font-size: 1rem; }
.score-track { height: 8px; margin: 24px 0 12px; overflow: hidden; border-radius: 99px; background: rgba(255,255,255,0.08); }
.score-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--lavender-strong), #e4bcff); transition: width 420ms cubic-bezier(.22,.8,.26,1); }
.result-meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.8rem; }
.result-meta strong { color: var(--text); }
.trait-results { display: grid; gap: 12px; margin-top: 28px; padding-top: 17px; border-top: 1px solid var(--line); }
.trait-result { display: flex; align-items: center; gap: 9px; color: #dfd8f9; font-size: 0.92rem; font-weight: 700; }
.trait-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: #777291; }
.trait-result[data-present="true"] .trait-dot { background: #ff9dc5; box-shadow: 0 0 0 5px rgba(255, 157, 197, 0.12); }
.trait-result[data-present="false"] .trait-dot { background: var(--mint); box-shadow: 0 0 0 5px rgba(143, 225, 213, 0.12); }
.result-note { margin: 16px 0 0; }
.page-footer { margin-top: 28px; color: #6e6987; font-size: 0.68rem; letter-spacing: 0.12em; }

body[data-busy="true"] .score-form { opacity: 0.78; }

@media (max-width: 560px) {
  .story-page { width: min(100% - 24px, 860px); }
  .topbar { margin-bottom: 52px; }
  .auth-panel { grid-template-columns: auto 1fr; }
  .auth-panel .button { grid-column: 1 / -1; width: 100%; }
  .score-form, .result-panel { padding: 20px 17px; border-radius: 20px; }
  .search-row { grid-template-columns: 1fr; }
  .search-row .button { width: 100%; }
  .desktop-break { display: none; }
}
