:root {
  --obsidian: #0B0E1A;
  --layer-1: #131A2E;
  --layer-2: #171E33;
  --line-1: #1D2440;
  --line-2: #2A3149;
  --line-3: #3A4260;
  --gold: #E8C97A;
  --gold-deep: #C9A24B;
  --gold-dim: #8A7B4F;
  --rose: #D98A96;
  --sage: #A8BFA0;
  --ivory: #F2EFE6;
  --mist: #9BA0B5;
  --faint: #5E6479;
  --sans: 'Jost', 'Pretendard', 'Noto Sans KR', sans-serif;
  --serif: 'Cormorant Garamond', 'Gowun Batang', serif;
  --serif-kr: 'Gowun Batang', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #05070F;
  font-family: var(--sans);
  color: var(--ivory);
}

#frame {
  max-width: 420px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--obsidian);
  position: relative;
  overflow: hidden;
  border-left: 1px solid var(--line-1);
  border-right: 1px solid var(--line-1);
}

/* ───── 화면 공통 ───── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 28px 22px;
  overflow-y: auto;
}
.screen.active { display: flex; }

.center-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  margin: auto 0;
  padding-top: 8vh;
}

.bottom-area { margin-top: auto; padding-top: 20px; }

.wordmark {
  font-family: var(--serif);
  font-weight: 500;
  font-size: 30px;
  letter-spacing: 7px;
  color: var(--gold);
  margin-top: 14px;
}
.tagline {
  font-family: var(--serif);
  font-style: italic;
  font-size: 15px;
  color: var(--mist);
  margin-top: 8px;
}
.serif-copy {
  font-family: var(--serif-kr);
  font-size: 16px;
  line-height: 1.8;
  color: var(--ivory);
  margin-top: 20px;
}
.serif-title {
  font-family: var(--serif-kr);
  font-weight: 400;
  font-size: 21px;
  line-height: 1.55;
  color: var(--ivory);
  margin-bottom: 6px;
}
.hint { font-size: 12.5px; color: var(--faint); line-height: 1.6; }
.hint.center { text-align: center; }
.gold-text { color: var(--gold); font-size: 13px; }

.c-line { stroke: var(--line-3); stroke-width: 1; }
.c-star { fill: var(--gold-deep); }
.c-star.dim { fill: var(--gold-dim); }

.luna-hero { margin-top: 4px; animation: luna-bob 4s ease-in-out infinite alternate; }
@keyframes luna-bob { from { transform: translateY(0); } to { transform: translateY(-5px); } }
@media (prefers-reduced-motion: reduce) { .luna-hero { animation: none; } }
.luna-sleep-wrap { display: flex; align-items: center; gap: 12px; }

/* ───── 버튼 ───── */
.btn-gold {
  width: 100%;
  background: var(--gold);
  color: var(--obsidian);
  border: none;
  border-radius: 99px;
  padding: 14px 0;
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}
.btn-gold:disabled { background: var(--line-3); color: var(--faint); cursor: default; }
.btn-gold.sm { padding: 10px 0; font-size: 13.5px; }
.btn-outline {
  width: 100%;
  background: none;
  color: var(--mist);
  border: 1px solid var(--line-3);
  border-radius: 99px;
  padding: 14px 0;
  font-family: var(--sans);
  font-size: 14px;
  cursor: pointer;
}
.btn-outline.sm { padding: 10px 0; font-size: 13px; }
.btn-text {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 13px;
  margin-top: 12px;
  cursor: pointer;
}
.btn-mini {
  background: none;
  border: none;
  color: var(--faint);
  font-family: var(--sans);
  font-size: 12.5px;
  cursor: pointer;
}
.row-2 { display: flex; gap: 8px; margin-top: 12px; }

/* ───── 온보딩 ───── */
.ob-progress { display: flex; gap: 5px; justify-content: center; margin-bottom: 26px; }
.ob-progress span { width: 18px; height: 3px; border-radius: 2px; background: var(--line-2); }
.ob-progress span.on { background: var(--gold); }

.option-list { display: flex; flex-direction: column; gap: 9px; margin-top: 16px; }
.option {
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 14px;
  color: #C7CBDB;
  background: none;
  font-family: var(--sans);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.option.selected { border-color: var(--gold); color: var(--gold); }

.bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.avatar {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%;
  background: var(--layer-2);
  border: 1px solid var(--line-3);
  display: flex; align-items: center; justify-content: center;
}
.bubble {
  background: var(--layer-2);
  border-radius: 3px 14px 14px 14px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.65;
  color: var(--ivory);
}

textarea {
  width: 100%;
  margin-top: 16px;
  background: none;
  border: 1px dashed var(--line-3);
  border-radius: 12px;
  padding: 13px;
  font-family: var(--sans);
  font-size: 14px;
  color: var(--ivory);
  resize: none;
}
textarea:focus { outline: none; border-color: var(--gold-dim); }
textarea::placeholder { color: var(--faint); }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  border: 1px solid var(--line-2);
  border-radius: 99px;
  background: none;
  padding: 5px 12px;
  font-family: var(--sans);
  font-size: 12.5px;
  color: var(--mist);
  cursor: pointer;
}
#moon-fab {
  position: absolute; top: 14px; right: 16px; z-index: 15;
  width: 44px; height: 44px; border-radius: 50%;
  background: rgba(23, 30, 51, .85); border: 1px solid rgba(232, 201, 122, .35);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 0 14px rgba(232, 201, 122, .18);
}
#chat-log {
  max-height: 300px; overflow-y: auto; margin-top: 10px;
  display: flex; flex-direction: column; gap: 8px;
}
.msg { display: flex; align-items: flex-end; gap: 6px; }
.msg.user { justify-content: flex-end; }
.msg .msg-b {
  max-width: 78%; padding: 9px 13px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.6; background: #171E33; color: var(--ivory);
  border-bottom-left-radius: 4px;
}
.msg.user .msg-b {
  background: rgba(232, 201, 122, .16); border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}
.msg-moon { font-size: 15px; }

.seg { display: flex; gap: 6px; background: #131A2E; border-radius: 12px; padding: 4px; margin-bottom: 14px; }
.seg button { flex: 1; background: none; border: none; color: var(--mist); font-family: inherit; font-size: 13.5px; padding: 9px 0; border-radius: 9px; cursor: pointer; }
.seg button.on { background: #171E33; color: var(--gold); }

.chip.hinted {
  border-color: rgba(232, 201, 122, .55);
  color: var(--gold);
  border-style: dashed;
}
.chip.confirmed {
  border-color: rgba(168, 191, 160, .7);
  color: var(--sage);
}

/* 흥미 — 여덟 방향의 별 */
#interest-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
  margin-bottom: 10px;
}
.int-cell {
  background: var(--bubble, #171E33);
  border-radius: 9px;
  padding: 8px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.int-cell .int-star { color: #3A4260; font-size: 13px; }
.int-cell.lit .int-star { color: var(--goldDim, #C9A24B); }
.int-cell.bright .int-star { color: var(--gold, #E8C97A); text-shadow: 0 0 8px rgba(232, 201, 122, .5); }
.int-cell .int-name { font-size: 11.5px; color: var(--mist, #9BA0B5); }
.int-cell.bright .int-name { color: var(--ivory, #F2EFE6); }
.int-cell .int-n { font-size: 10px; color: var(--faint, #5E6479); }

.chip.selected { border-color: var(--gold); color: var(--gold); }

.quiz-top { display: flex; justify-content: space-between; align-items: center; }
.progress-track { height: 3px; background: var(--line-2); border-radius: 2px; margin-top: 8px; }
.progress-fill { height: 3px; background: var(--gold); border-radius: 2px; width: 0; transition: width 0.3s; }

/* ───── 결과 카드 ───── */
#reveal-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.reveal-card {
  background: var(--layer-1);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 14px;
}
.reveal-card.locked { background: none; border-style: dashed; border-color: var(--line-3); }
.reveal-card .rc-head { display: flex; justify-content: space-between; font-size: 13px; }
.reveal-card .rc-domain { color: var(--gold); }
.reveal-card.locked .rc-domain { color: var(--mist); }
.reveal-card .rc-state { color: var(--mist); font-size: 12px; }
.rc-state.sage { color: var(--sage); }
.rc-state.rose { color: var(--rose); }
.reveal-card .rc-text { font-size: 13.5px; color: var(--ivory); margin-top: 4px; line-height: 1.55; }

/* ───── 홈 ───── */
.home-scroll { flex: 1; overflow-y: auto; padding-bottom: 76px; display: flex; flex-direction: column; gap: 12px; }
.home-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.home-greet { font-family: var(--serif-kr); font-size: 19px; color: var(--ivory); line-height: 1.5; }

.card {
  background: var(--layer-1);
  border: 1px solid var(--line-2);
  border-radius: 14px;
  padding: 14px 16px;
}
.card.gold-border { border-color: var(--gold-dim); }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title { font-size: 14px; font-weight: 500; color: var(--ivory); }
.card-body-text { font-size: 13.5px; line-height: 1.65; color: #C7CBDB; }

.star-dots { display: flex; gap: 5px; }
.star-dots svg { display: block; }

.tag-sage { font-size: 11.5px; color: var(--sage); }
.tag-rose { font-size: 11.5px; color: var(--rose); }

.daily-q { font-size: 14px; line-height: 1.6; color: var(--ivory); margin-bottom: 10px; }
.mood-row { display: flex; align-items: center; gap: 10px; }
.mood-row input[type="range"] { flex: 1; }
.emotion-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.slider-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--mist); margin-bottom: 10px; }
.slider-row span { width: 64px; flex: none; }
.slider-row input { flex: 1; }
.slider-row b { width: 46px; text-align: right; color: var(--ivory); font-weight: 400; font-size: 12.5px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--mist); margin: 4px 0 12px; }

input[type="range"] { accent-color: var(--gold); }
input[type="checkbox"] { accent-color: var(--gold); width: 16px; height: 16px; }

.hidden { display: none !important; }

/* ───── 탭바 ───── */
.tabbar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-end;
  background: var(--layer-1);
  border-top: 1px solid var(--line-1);
  padding: 6px 0 10px;
}
.tab {
  flex: 1;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 12px;
  color: var(--faint);
  padding: 8px 0 2px;
  cursor: pointer;
}
.tab.on { color: var(--gold); }
.tab-fab {
  flex: none;
  width: 48px; height: 48px;
  margin: -24px 8px 0;
  border-radius: 50%;
  background: var(--gold);
  color: var(--obsidian);
  border: none;
  font-size: 26px;
  font-family: var(--sans);
  cursor: pointer;
  line-height: 1;
}

/* ───── 기록 시트 ───── */
#chat-input { flex: 1; min-width: 0; width: auto; margin-top: 0; }
#btn-chat-send { width: auto; flex: 0 0 auto; }
#moon-greet {
  position: absolute; top: 64px; right: 14px; z-index: 14;
  max-width: 210px; background: #171E33; border: 1px solid rgba(232, 201, 122, .3);
  border-radius: 14px 4px 14px 14px; padding: 9px 12px;
  font-size: 12.5px; color: var(--ivory); line-height: 1.55; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.cmoon { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: #F2DFA8; }

#interest-test-sheet, #value-link-sheet, #lab-sheet, #coach-sheet,
#record-sheet {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 15, 0.72);
  display: flex;
  align-items: flex-end;
  z-index: 20;
}
.sheet-inner {
  width: 100%;
  background: var(--layer-1);
  border-top: 1px solid var(--line-2);
  border-radius: 18px 18px 0 0;
  padding: 18px 20px 26px;
}
.sheet-inner input[type="text"] {
  width: 100%;
  margin-top: 10px;
  background: none;
  border: 1px dashed var(--line-3);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: var(--sans);
  font-size: 13.5px;
  color: var(--ivory);
}
.sheet-inner input[type="text"]:focus { outline: none; border-color: var(--gold-dim); }
.sheet-inner input::placeholder { color: var(--faint); }
.sheet-inner textarea { margin-top: 10px; }

/* ───── 달력 (월간 밤하늘) ───── */
.cal-week {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-size: 11px;
  color: var(--faint);
  text-align: center;
  margin-bottom: 5px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-cell {
  aspect-ratio: 0.86;
  background: var(--layer-2);
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 3px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-family: var(--sans);
  font-size: 10.5px;
  color: var(--faint);
  cursor: pointer;
}
.cal-cell.empty { background: none; cursor: default; }
.cal-cell.today { border-color: var(--gold); }
.cal-cell.selected { border-color: var(--gold-dim); background: var(--layer-1); }
.cal-cell .cd { line-height: 1.2; }
.cal-cell .cw { font-size: 13px; line-height: 1.35; }
.cal-cell .cw.clear { color: var(--gold); }
.cal-cell .cw.calm { color: var(--gold-dim); }
.cal-cell .cw.cloud { color: var(--mist); }
.cal-cell .cw.rain { color: #7E8DB5; }
.cal-cell .cmarks { display: flex; gap: 2px; margin-top: auto; align-items: center; }
.cal-cell .cstar { width: 4px; height: 4px; border-radius: 50%; background: var(--gold); }
.cal-cell .cperson {
  min-width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--layer-1);
  border: 1px solid var(--rose);
  color: var(--rose);
  font-size: 8.5px;
  line-height: 11px;
  padding: 0 1px;
}
.cal-cell .cring { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid var(--sage); }

/* ───── 별자리 탭 ───── */
.sky-ring { fill: none; stroke: var(--line-1); stroke-width: 1; }
#sky-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* ───── 설정 행 ───── */
.settings-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line-1);
  font-size: 13.5px;
  color: #C7CBDB;
  cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row.danger { color: var(--rose); }
.sr-arrow { color: var(--faint); font-size: 14px; }

/* ───── 약속 화면 · 달빛 ───── */
.promise-list { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.promise-row {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--layer-1);
  border: 1px solid var(--line-2);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.65;
  color: #C7CBDB;
}
.promise-row b { color: var(--ivory); font-weight: 500; }
.promise-star { color: var(--gold); flex: none; }
.moon-track { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.moon-track .progress-track { flex: 1; }

/* ───── 나의 사람들 ───── */
.person-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--line-1);
  cursor: pointer;
}
.person-row:last-child { border-bottom: none; }
.person-star {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  background: var(--layer-2);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  font-size: 12.5px;
  display: flex; align-items: center; justify-content: center;
}
.person-star.unreg { border-color: var(--line-3); color: var(--mist); }
.person-name { font-size: 14px; color: var(--ivory); }
.person-meta { font-size: 11.5px; color: var(--faint); }
.person-right { margin-left: auto; font-size: 11.5px; color: var(--faint); }

/* ───── 여정: 주간 스트립 · 플랜 · 성장 ───── */
.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.ws-cell {
  background: var(--layer-2);
  border-radius: 9px;
  padding: 6px 2px;
  text-align: center;
  font-size: 10.5px;
  color: var(--faint);
}
.ws-cell.today { border: 1px solid var(--gold); }
.ws-cell .cw { display: block; font-size: 14px; line-height: 1.4; }
.plan-progress { display: flex; gap: 4px; margin: 10px 0; }
.plan-progress span { flex: 1; height: 4px; border-radius: 2px; background: var(--line-2); }
.plan-progress span.done { background: var(--gold); }
.growth-row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13.5px; color: #C7CBDB;
  padding: 6px 0;
  border-bottom: 1px solid var(--line-1);
}
.growth-row:last-child { border-bottom: none; }
.growth-row b { color: var(--gold); font-weight: 500; font-size: 15px; }

/* ───── 토스트 ───── */
#toast {
  position: absolute;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--layer-2);
  border: 1px solid var(--line-3);
  color: var(--ivory);
  font-size: 13px;
  padding: 9px 18px;
  border-radius: 99px;
  white-space: nowrap;
  z-index: 10;
}
