:root {
  --bg: #f7f3ec; --card: #fffdf9; --ink: #221d17; --muted: #6f655a; --line: #e6ddcf;
  --accent: #b23a2b; --accent-soft: #f6e4df; --gold: #8a6d3b; --warn-bg: #fdf3dc; --warn-ink: #7a5a12;
  --serif: "Noto Serif KR", "AppleMyungjo", serif; --sans: "Noto Sans KR", -apple-system, "Apple SD Gothic Neo", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120e; --card: #1f1b16; --ink: #ece4d6; --muted: #a89c8c; --line: #352e26;
    --accent: #e0644f; --accent-soft: #3a211b; --gold: #c9a86a; --warn-bg: #352a12; --warn-ink: #f0d58f;
  }
}
:root[data-theme="dark"] {
  --bg: #15120e; --card: #1f1b16; --ink: #ece4d6; --muted: #a89c8c; --line: #352e26;
  --accent: #e0644f; --accent-soft: #3a211b; --gold: #c9a86a; --warn-bg: #352a12; --warn-ink: #f0d58f;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 17px/1.75 var(--sans); word-break: keep-all; overflow-wrap: anywhere; }
main { max-width: 640px; margin: 0 auto; padding: 32px 16px 48px; }
[hidden] { display: none !important; }

.hero { text-align: center; margin: 12px 0 28px; }
.eyebrow { margin: 0; letter-spacing: .18em; text-transform: uppercase; font-size: 13px; color: var(--accent); font-weight: 700; }
h1 { font-family: var(--serif); font-size: clamp(30px, 8vw, 42px); line-height: 1.25; margin: 6px 0 8px; }
.lede { color: var(--muted); margin: 0; }

/* 사진 고르기 */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 44px 16px;
  background: var(--card); border: 2px dashed var(--line); border-radius: 20px; cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.drop-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 30px; line-height: 56px; margin-bottom: 8px; }
.drop-main { font-size: 20px; font-weight: 700; }
.drop-sub { color: var(--muted); font-size: 14px; }

.url-row { display: flex; gap: 8px; margin-top: 14px; }
.url-row input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.url-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.btn {
  font: inherit; font-weight: 700; font-size: 16px; padding: 12px 20px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--accent); color: #fff;
}
.btn:hover { filter: brightness(1.08); }
.btn.wide { display: block; width: 100%; margin: 28px 0 8px; padding: 15px; }
.fine { color: var(--muted); font-size: 14px; text-align: center; margin: 18px 0 0; line-height: 1.7; }

/* 진행 · 오류 */
#busy { text-align: center; padding: 56px 0; color: var(--muted); }
.spinner { width: 44px; height: 44px; margin: 0 auto 16px; border: 4px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.alert { margin: 16px 0; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); color: var(--ink); border-left: 4px solid var(--accent); }
.warn { margin: 10px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; }

/* 결과 */
.photo { background: var(--card); border-radius: 20px; overflow: hidden; border: 1px solid var(--line); }
.photo canvas { display: block; width: 100%; height: auto; }
.headline { text-align: center; margin: 26px 0 8px; }
.headline h2 { font-family: var(--serif); font-size: clamp(24px, 6.5vw, 32px); line-height: 1.35; margin: 0 0 10px; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0 0 14px; }
.chip { background: var(--accent-soft); color: var(--accent); border-radius: 999px; padding: 2px 12px; font-size: 14px; font-weight: 700; }
.intro { color: var(--muted); margin: 0; text-align: left; }

.sec { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px; margin-top: 16px; }
.sec h3 { font-family: var(--serif); font-size: 21px; margin: 0; line-height: 1.4; }
.sec .sub { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.sec .age { color: var(--gold); font-weight: 700; }
.p { margin: 12px 0 0; }
.p b { display: block; font-size: 15px; color: var(--accent); margin-bottom: 1px; }
.p.indent { padding-left: 12px; border-left: 2px solid var(--line); }
.p.muted { color: var(--muted); font-size: 15px; }
.p.combo { background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; }
.p.combo b { color: var(--accent); }
.p.warn-p { color: var(--warn-ink); background: var(--warn-bg); border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.edge { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }

.block { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px 18px; margin-top: 16px; }
.block summary { cursor: pointer; font-weight: 700; font-family: var(--serif); font-size: 19px; }
.palaces { list-style: none; padding: 0; margin: 12px 0 0; }
.palaces li { padding: 10px 0; border-top: 1px solid var(--line); }
.palaces li:first-child { border-top: 0; }
.palaces .pn { font-weight: 700; }
.palaces .pw { color: var(--muted); font-size: 14px; }
.palaces .pt { display: block; font-size: 15px; }
.palaces li.none .pt { color: var(--muted); }

.closing { margin-top: 16px; padding: 22px 18px; border-radius: 18px; background: var(--ink); color: var(--bg); }
.closing h3 { font-family: var(--serif); margin: 0 0 8px; font-size: 21px; }
.closing p { margin: 0 0 12px; opacity: .9; }
.closing ul { margin: 0; padding-left: 20px; }
.closing li { margin: 4px 0; }

footer { margin-top: 40px; color: var(--muted); font-size: 13px; text-align: center; line-height: 1.8; }

#debug { margin-top: 24px; font-size: 13px; }
.table-wrap { overflow-x: auto; }
#mtable { border-collapse: collapse; width: 100%; }
#mtable td, #mtable th { border-bottom: 1px solid var(--line); padding: 4px 6px; text-align: left; white-space: nowrap; }
#debug-json { width: 100%; font: 12px/1.4 ui-monospace, monospace; margin-top: 8px; background: var(--card); color: var(--ink); border: 1px solid var(--line); }

/* 재미로 보기 안내 */
.fun { display: inline-block; margin: 14px 0 0; padding: 6px 14px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 14px; }
.disclaimer { margin: 0 0 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; text-align: left; }

/* 예시 얼굴 */
.examples { margin-top: 28px; }
.ex-title { text-align: center; font-weight: 700; margin: 0 0 12px; }
.ex-title small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.ex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 560px) { .ex-grid { grid-template-columns: repeat(6, 1fr); } }
.ex {
  position: relative; display: flex; flex-direction: column; align-items: center; padding: 0 0 8px; overflow: hidden;
  background: var(--card); border: 2px solid var(--line); border-radius: 14px; cursor: pointer; font: inherit; color: var(--ink);
  transition: border-color .15s, transform .15s;
}
.ex:hover { transform: translateY(-2px); }
.ex img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: 50% 30%; display: block; margin-bottom: 6px; }
.ex-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.ex-type { font-size: 12px; color: var(--muted); line-height: 1.3; }
.ex[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ex[aria-checked="true"]::after {
  content: "✓"; position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 14px; line-height: 24px; text-align: center; font-weight: 700;
}
.ex:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.ex-go { margin-top: 14px; }
.ex-go:disabled { background: var(--line); color: var(--muted); cursor: default; filter: none; }
footer a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
footer a:hover { filter: brightness(1.15); }

/* 처음으로 버튼 */
.home-btn {
  display: inline-block; margin: 10px 0 2px; font: inherit; font-size: 15px; font-weight: 700; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 16px; cursor: pointer;
}
.home-btn:hover { border-color: var(--accent); color: var(--accent); }
.home-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.drop-privacy { margin-top: 10px; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--ink); font-size: 13px; font-weight: 500; }
#pick .alert { margin: 10px 0 0; font-size: 15px; }
.url-tip { margin: 10px 2px 0; color: var(--muted); font-size: 13.5px; line-height: 1.7; }
.url-tip b { color: var(--ink); font-weight: 600; }

/* 주소 칸 지우기 버튼 */
.url-field { position: relative; flex: 1; min-width: 0; display: flex; }
.url-field input { flex: 1; min-width: 0; padding-right: 44px; }
.url-clear {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--line); color: var(--ink); font-size: 18px; line-height: 28px; padding: 0;
}
.url-clear:hover { background: var(--accent); color: #fff; }
.url-clear:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.movie { text-align: center; font-size: 14px; color: var(--muted, inherit); margin: 0 0 8px; line-height: 1.6; }
.movie b { color: var(--accent); }
.animal { display: flex; gap: 14px; align-items: flex-start; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 18px; margin-top: 16px; }
.animal-emoji { font-size: 44px; line-height: 1; flex: none; }
.animal-body { min-width: 0; }
.animal-body p { margin: 0 0 6px; }
.animal-label { color: var(--muted); font-size: 13px; }
.animal h3 { font-family: var(--serif); font-size: 22px; margin: 0 0 6px; color: var(--accent); }
.animal-why { font-weight: 700; }
.animal-next { color: var(--muted); font-size: 14px; margin-bottom: 0 !important; }
.year-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 14px; }
.year-row label { font-weight: 700; }
.year-row label small { color: var(--muted); font-weight: 400; }
.year-row input { width: 7.5em; font: inherit; font-size: 16px; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.year-row input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.year-note { color: var(--muted); font-size: 13.5px; }
.animal-zodiac { margin-top: 10px !important; padding-top: 10px; border-top: 1px solid var(--line); }
.animal-zodiac b { color: var(--accent); }
.animal-zodiac small { display: block; color: var(--muted); font-size: 13px; margin-top: 4px; }
.reset-btn { font: inherit; font-size: 14px; font-weight: 600; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); color: var(--muted); cursor: pointer; }
.reset-btn:hover { color: var(--accent); border-color: var(--accent); }
.reset-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
