:root {
  color-scheme: light;
  --bg: #f4f2ee;
  --surface: #fcfcfb;
  --surface-2: #efede8;
  --line: #e2dfd8;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7873;
  --brand: #fee500;
  --brand-ink: #191600;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --bar: #2a78d6;
  --bar-hl: #eb6834;
  --warm: #fff4e8;
  --cool: #eaf2fc;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 6px 24px rgb(0 0 0 / 0.05);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111110;
    --surface: #1a1a19;
    --surface-2: #262624;
    --line: #33322f;
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #8f8d86;
    --series-1: #3987e5;
    --series-2: #d95926;
    --bar: #3987e5;
    --bar-hl: #d95926;
    --warm: #2a2118;
    --cool: #172230;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111110; --surface: #1a1a19; --surface-2: #262624; --line: #33322f;
  --text: #ffffff; --text-2: #c3c2b7; --muted: #8f8d86;
  --series-1: #3987e5; --series-2: #d95926; --bar: #3987e5; --bar-hl: #d95926;
  --warm: #2a2118; --cool: #172230; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.55 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  word-break: keep-all; overflow-wrap: anywhere;
}
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.logo { font-weight: 900; font-size: 18px; color: var(--text); text-decoration: none; letter-spacing: -0.02em; }
.logo::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--brand); margin-right: 6px; vertical-align: 1px; }
.lock { font-size: 12px; color: var(--muted); text-align: right; }

main { max-width: 520px; margin: 0 auto; padding: 20px 16px 64px; }
.title { font-size: 30px; line-height: 1.25; font-weight: 900; letter-spacing: -0.03em; margin: 20px 0 8px; }
.title-sm { font-size: 20px; font-weight: 800; margin: 8px 0 16px; }
.lead { color: var(--text-2); margin: 0 0 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.modes { display: grid; gap: 12px; }
.mode {
  display: grid; grid-template-columns: 48px 1fr; grid-template-rows: auto auto; column-gap: 12px;
  text-align: left; padding: 18px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer; transition: transform .12s;
}
.mode:hover { transform: translateY(-2px); }
.mode-emoji { grid-row: span 2; font-size: 32px; line-height: 48px; text-align: center; background: var(--surface-2); border-radius: 14px; }
.mode-name { font-weight: 800; font-size: 17px; }
.mode-desc { color: var(--text-2); font-size: 13.5px; }

.back { background: none; border: 0; color: var(--text-2); padding: 6px 0; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; padding: 14px 18px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 16px; text-decoration: none;
}
.btn.ghost { background: var(--surface); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .6; }

.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 36px 16px; margin-bottom: 12px;
  border: 2px dashed var(--line); border-radius: 18px; background: var(--surface); cursor: pointer; text-align: center;
}
.drop.over { border-color: var(--series-1); background: var(--cool); }
.drop input { display: none; }
.drop-icon { font-size: 36px; }
.error { color: #d03b3b; font-size: 14px; }
.howto { margin-top: 20px; padding: 14px 16px; border-radius: 14px; background: var(--surface-2); }
.howto summary { font-weight: 700; cursor: pointer; }
.howto ol { padding-left: 20px; margin: 10px 0 4px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 4px 0 16px; padding-bottom: 2px; }
.tab { flex: none; padding: 8px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; }
.tab.on { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 700; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-weight: 700; margin-bottom: 6px; }
.field input, .person-name {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
}
.people { display: grid; gap: 8px; }
.person { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; }
.person-name { min-width: 0; }
.person-count { font-size: 12px; color: var(--muted); }
.pick { position: relative; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; cursor: pointer; }
.pick input { position: absolute; opacity: 0; pointer-events: none; }
.pick.on { background: var(--series-1); color: #fff; border-color: var(--series-1); font-weight: 700; }
.pick.b.on { background: var(--series-2); border-color: var(--series-2); }
.toggle { display: flex; align-items: center; gap: 8px; margin: 4px 0 20px; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.toolbar-actions { display: flex; gap: 6px; }

/* 리포트 카드 */
.report { display: grid; gap: 14px; padding: 2px; }
.card { background: var(--surface); border-radius: 22px; padding: 22px 20px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.card h1 { font-size: 26px; line-height: 1.25; margin: 4px 0 4px; font-weight: 900; letter-spacing: -0.03em; }
.card h2 { font-size: 20px; line-height: 1.35; margin: 4px 0 10px; font-weight: 800; letter-spacing: -0.02em; }
.card h2 em { font-style: normal; color: var(--series-2); }
.card p { margin: 0 0 8px; }
.eyebrow { font-size: 13px; font-weight: 700; color: var(--text-2); margin-bottom: 8px; }
.hero { background: linear-gradient(160deg, var(--brand) 0%, #ffd000 100%); color: var(--brand-ink); border: 0; }
.hero .muted, .hero .eyebrow { color: rgb(25 22 0 / 0.65); }
.hero.warm { background: linear-gradient(160deg, #ffe3c7, #ffc9a8); }
.hero.cool { background: linear-gradient(160deg, #d9e8ff, #c3d6ff); }
.big-stat { margin: 18px 0 14px; }
.big-stat b { display: block; font-size: 52px; font-weight: 900; line-height: 1.15; letter-spacing: -0.04em; margin-bottom: 2px; }
.big-stat span { font-weight: 600; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-row div, .facts div, .care-item { background: rgb(255 255 255 / 0.55); border-radius: 14px; padding: 10px; }
.stat-row b, .facts b, .care-item b { display: block; font-size: 20px; font-weight: 900; }
.stat-row span, .facts span, .care-item span { font-size: 12px; }
.facts, .care { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.facts div, .care-item { background: var(--surface-2); }

.awards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.award { background: var(--surface-2); border-radius: 16px; padding: 12px; }
.award-emoji { font-size: 26px; }
.award-title { font-size: 12px; font-weight: 700; color: var(--text-2); }
.award-winner { font-size: 16px; font-weight: 900; line-height: 1.3; }
.award-value { font-size: 12px; color: var(--muted); }

.chat { display: grid; gap: 8px; margin-top: 10px; }
.bubble { background: var(--surface-2); border-radius: 4px 16px 16px 16px; padding: 9px 12px; max-width: 92%; font-size: 14.5px; }
.bubble.me { justify-self: end; background: var(--brand); color: var(--brand-ink); border-radius: 16px 4px 16px 16px; }
.bubble .who { display: block; font-size: 11.5px; font-weight: 700; opacity: .65; margin-bottom: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { padding: 6px 11px; border-radius: 999px; background: var(--surface-2); font-size: 14px; }
.chip.strong { background: var(--text); color: var(--bg); font-weight: 700; }

/* 차트 */
.cols { margin: 8px 0 4px; }
.cols svg { display: block; width: 100%; overflow: visible; }
.cols .bar { fill: var(--bar); opacity: .45; }
.cols .col.hl .bar { fill: var(--bar-hl); opacity: 1; }
.cols .hit { fill: transparent; }
.cols .col:hover .bar { opacity: 1; }
.ticks { position: relative; height: 18px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--line); }
.ticks span { position: absolute; top: 2px; transform: translateX(-50%); white-space: nowrap; }

.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: minmax(0, 7.5em) 1fr 3.2em; gap: 8px; align-items: center; }
.hbar-label { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-label small { display: block; font-weight: 400; color: var(--muted); }
.hbar-track { height: 14px; }
.hbar-fill { height: 100%; background: var(--bar); opacity: .55; border-radius: 0 4px 4px 0; }
.hbar-fill.me { opacity: 1; }
.hbar-val { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.versus { display: grid; gap: 12px; }
.versus-legend { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); flex-wrap: wrap; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.a { background: var(--series-1); }
.sw.b { background: var(--series-2); margin-left: 10px; }
.vs-label { font-size: 13.5px; font-weight: 700; margin-bottom: 4px; }
.vs-bar { position: relative; display: flex; gap: 2px; height: 14px; }
.vs-a { background: var(--series-1); border-radius: 4px 0 0 4px; }
.vs-b { background: var(--series-2); border-radius: 0 4px 4px 0; }
.vs-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--text); opacity: .35; }
.vs-vals { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-2); margin-top: 3px; font-variant-numeric: tabular-nums; }
.lean { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 12px; }
.lean b { font-size: 28px; font-weight: 900; }

.gauges { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { background: var(--surface-2); border-radius: 16px; padding: 12px 10px; }
.gauge-num { font-size: 28px; font-weight: 900; line-height: 1.1; }
.gauge-num small { font-size: 13px; font-weight: 600; margin-left: 1px; }
.gauge-track { height: 6px; background: var(--line); border-radius: 3px; margin: 8px 0 6px; overflow: hidden; }
.gauge-fill { height: 100%; background: var(--series-2); border-radius: 3px; }
.gauge-label { font-size: 12px; font-weight: 700; color: var(--text-2); }

.type { margin-top: 18px; background: rgb(255 255 255 / 0.6); border-radius: 16px; padding: 14px; }
.type-title { font-size: 22px; font-weight: 900; margin-bottom: 4px; }
.type p { margin: 0; font-size: 14px; }

.year-table { display: flex; gap: 6px; margin-top: 14px; flex-wrap: wrap; }
.year-table div { flex: 1; min-width: 64px; background: var(--surface-2); border-radius: 12px; padding: 8px; text-align: center; }
.year-table b { display: block; font-size: 12px; color: var(--muted); }
.year-table span { font-weight: 900; font-size: 18px; }

.tips { list-style: none; padding: 0; margin: 0; counter-reset: t; display: grid; gap: 10px; }
.tips li { counter-increment: t; display: grid; grid-template-columns: 28px 1fr; column-gap: 8px; }
.tips li::before { content: counter(t); grid-row: span 2; width: 26px; height: 26px; border-radius: 50%; background: var(--series-1); color: #fff; font-weight: 800; display: grid; place-items: center; font-size: 13px; }
.tips span { color: var(--text-2); font-size: 14px; }
.cta { text-align: center; background: var(--warm); }
.cta .btn { margin-top: 8px; }
.disclaimer { text-align: center; font-size: 12px; color: var(--muted); margin: 4px 0 0; }

.tooltip {
  position: fixed; left: 0; top: 0; z-index: 50; pointer-events: none; opacity: 0; transition: opacity .1s;
  background: var(--text); color: var(--bg); font-size: 12.5px; padding: 6px 9px; border-radius: 8px; max-width: 260px;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; width: max-content; max-width: calc(100% - 32px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  .hero, .hero.warm, .hero.cool { color: var(--brand-ink); }
}

/* 내보내기 안내 */
.guide { margin-top: 20px; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.guide h3 { margin: 0 0 10px; font-size: 16px; }
.guide-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); margin-bottom: 12px; }
.gtab { border: 0; background: none; padding: 8px; border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text-2); }
.gtab.on { background: var(--surface); color: var(--text); font-weight: 800; box-shadow: 0 1px 3px rgb(0 0 0 / .08); }
.gsteps { list-style: none; counter-reset: g; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.gsteps li { counter-increment: g; position: relative; padding-left: 32px; font-size: 14.5px; }
.gsteps li::before { content: counter(g); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 800; font-size: 12px; display: grid; place-items: center; }
.gsteps small { display: block; color: var(--muted); font-size: 12.5px; }
.gmove { padding: 10px 12px; border-radius: 12px; background: var(--surface-2); font-size: 13.5px; margin-bottom: 10px; }
.gmove b { display: block; margin-bottom: 2px; }

/* 공유 시트 */
.sheet { position: fixed; inset: 0; z-index: 70; background: rgb(0 0 0 / .45); display: flex; align-items: flex-end; justify-content: center; }
.sheet-card { width: 100%; max-width: 520px; background: var(--surface); border-radius: 22px 22px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }
.sheet-card h3 { margin: 0; font-size: 19px; }
.sheet-card p { margin: 0; }
.sheet-notes { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); }
.sheet-card .toggle { margin: 4px 0; }
.sheet-card .back { justify-self: center; }
.warn { padding: 10px 12px; border-radius: 12px; background: #fff1e0; color: #8a4b00; font-size: 13px; }

/* 사진 올리기 */
.avatar-pick { position: relative; width: 38px; height: 38px; border-radius: 50%; border: 1.5px dashed var(--line); background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; font-size: 15px; cursor: pointer; flex: none; }
.avatar-pick.has { border: 2px solid var(--brand); }
.avatar-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.person.with-photo { grid-template-columns: auto 1fr auto auto; }

/* 사진 편집 */
.avatar-pick.loading { animation: pulse .6s infinite alternate; }
.crop-sheet { position: fixed; inset: 0; z-index: 80; background: rgb(0 0 0 / .6); display: grid; place-items: center; padding: 16px; }
.crop-card { width: min(100%, 400px); background: var(--surface); border-radius: 22px; padding: 18px; display: grid; gap: 12px; }
.crop-card h3 { margin: 0; font-size: 18px; }
.crop-help { margin: -6px 0 0; font-size: 13px; color: var(--muted); }
.crop-area { position: relative; width: 100%; aspect-ratio: 1; overflow: hidden; border-radius: 16px; background: #111; touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.crop-area:active { cursor: grabbing; }
.crop-area img { position: absolute; left: 0; top: 0; max-width: none; transform-origin: 0 0; pointer-events: none; }
.crop-mask { position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgb(0 0 0 / .55); outline: 2px solid rgb(255 255 255 / .9); outline-offset: -2px; pointer-events: none; }
.crop-zoom { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; color: var(--muted); font-weight: 700; }
.crop-zoom input { width: 100%; accent-color: #e5b800; }
.crop-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 8px; }

/* 공유 링크로 들어왔을 때: 업로드 화면 대신 로딩 커튼 */
.boot-loader { display: none; }
.shared-boot .boot-loader { display: block; }
.shared-boot #step-upload { display: none !important; }
.boot-curtain {
  aspect-ratio: 4 / 5; border-radius: 22px; display: grid; place-content: center; gap: 10px; text-align: center; color: #fff;
  background: repeating-linear-gradient(90deg, #8f0d1f 0 16px, #b3172b 16px 28px, #7a0a1a 28px 36px);
  box-shadow: 0 10px 40px rgb(30 10 60 / .35);
}
.boot-curtain span { font-size: 56px; animation: pulse .7s infinite alternate; }
.boot-curtain b { font-size: 18px; text-shadow: 0 2px 0 #3a0010; }
@keyframes pulse { to { transform: scale(1.08); } }
