/* 레이아웃: 조선 판본 한 장(사주쌍변 광곽) 안에 세로쓰기 제목과 먹선 얼굴 — 한 단짜리 첩(帖) */
:root {
  --hanji: #d9cfb8;        /* 바랜 한지 */
  --hanji-deep: #c8bb9d;   /* 그늘진 한지 */
  --meok: #1d1915;         /* 먹 */
  --meok-soft: #50473c;    /* 옅은 먹 */
  --inju: #a3271c;         /* 인주(낙관) */
  --nureun: #85704b;       /* 누런 괘선 */
  --f-brush: "Nanum Brush Script", "Song Myung", serif;
  --f-display: "Song Myung", "Noto Serif KR", "Batang", serif;
  --f-body: "Gowun Batang", "Noto Serif KR", "Batang", serif;
  --f-seal: "Noto Serif KR", "Batang", serif;
  color-scheme: light;
}
html { background: var(--hanji-deep); }
body {
  background-color: var(--hanji);
  background-image:
    radial-gradient(120% 90% at 50% 40%, transparent 55%, rgba(60, 40, 15, .22) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .32 0 0 0 0 .25 0 0 0 0 .14 0 0 0 .16 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color: var(--meok);
  font-family: var(--f-body);
  font-size: 16px;
  line-height: 1.7;
  padding-inline: 16px;
  padding-block: 20px 40px;
  min-height: 100%;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--inju); outline-offset: 3px; }

/* 광곽: 바깥 굵은 선 + 안쪽 가는 선 */
.leaf {
  max-width: 460px; margin-inline: auto;
  border: 3px solid var(--meok);
  outline: 1px solid var(--meok); outline-offset: -8px;
  padding: 22px 22px 26px;
  position: relative;
  display: grid; gap: 22px;
}
.panshim { display: flex; align-items: center; gap: 10px; color: var(--meok-soft); font-family: var(--f-display); font-size: 13px; letter-spacing: .18em; }
.panshim::before, .panshim::after { content: ""; height: 1px; background: var(--nureun); flex: 1; }
.eomi { width: 0; height: 0; border-left: 7px solid transparent; border-right: 7px solid transparent; border-top: 8px solid var(--meok); }

/* 시작 화면 */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; }
.hero canvas { width: 100%; max-width: 100%; aspect-ratio: 1 / 1.08; display: block; }
.vcol { display: flex; gap: 6px; align-items: flex-start; border-left: 1px solid var(--nureun); padding-left: 8px; }
.vtitle {
  display: flex; flex-direction: column; align-items: center;
  font-family: var(--f-brush); font-size: clamp(64px, 19vw, 92px); line-height: 1;
  letter-spacing: -.02em; color: var(--meok); margin: 0;
}
.vsub { display: flex; flex-direction: column; align-items: center; gap: 2px; font-family: var(--f-seal); font-weight: 600; font-size: 14px; line-height: 1.15; color: var(--inju); border: 1.5px solid var(--inju); padding: 6px 4px; margin-top: 6px; }
.hook { font-family: var(--f-display); font-size: 22px; line-height: 1.45; margin: 0; text-wrap: balance; }
.lede { margin: 0; color: var(--meok-soft); font-size: 15px; }
.friend { border: 1px solid var(--inju); padding: 12px 14px; display: grid; gap: 2px; color: var(--meok); }
.friend b { font-family: var(--f-display); font-weight: 400; color: var(--inju); font-size: 19px; }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 10px 14px; cursor: pointer;
  border: 1.5px solid var(--meok); background: transparent;
  font-family: var(--f-display); font-size: 17px; letter-spacing: .02em; text-align: center;
  transition: background .15s, color .15s;
}
.btn:hover { background: rgba(29, 25, 21, .07); }
.btn.ink { background: var(--meok); color: var(--hanji); }
.btn.ink:hover { background: #3a332b; }
.btn input { display: none; }
.btn.wide { grid-column: 1 / -1; }

.privacy { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: start; font-size: 14px; color: var(--meok-soft); }
.privacy .seal-mini { width: 34px; height: 34px; border: 2px solid var(--inju); color: var(--inju); display: grid; place-items: center; font-family: var(--f-seal); font-weight: 900; font-size: 15px; transform: rotate(-4deg); }
.privacy p { margin: 0; }
.privacy strong { color: var(--meok); font-weight: 700; }

.howto { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; font-size: 14px; }
.howto li { display: flex; gap: 8px; align-items: baseline; }
.howto li::before { content: "·"; color: var(--inju); font-weight: 700; }

.five { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--nureun); border-bottom: 1px solid var(--nureun); }
.five div { padding: 10px 4px; text-align: center; border-left: 1px solid var(--nureun); display: grid; gap: 2px; }
.five div:first-child { border-left: 0; }
.five b { font-family: var(--f-seal); font-weight: 600; font-size: 17px; letter-spacing: .08em; }
.five span { font-size: 11.5px; color: var(--meok-soft); line-height: 1.35; }

.ad { border: 1px dashed var(--nureun); color: var(--nureun); font-size: 12px; letter-spacing: .12em; text-align: center; padding: 18px 8px; }
.foot { font-size: 12.5px; color: var(--meok-soft); text-align: center; display: grid; gap: 4px; }
.foot p { margin: 0; }
.foot a { color: var(--meok-soft); }
.site-foot { max-width: 460px; margin: 14px auto 0; }
.cta { text-decoration: none; }

/* 분석 화면 */
.scan { position: relative; display: grid; gap: 16px; justify-items: center; }
.scan canvas { width: 100%; max-width: 360px; aspect-ratio: 3 / 4; display: block; border: 1px solid var(--meok); background: var(--hanji-deep); }
.scan .msg { font-family: var(--f-display); font-size: 19px; min-height: 1.6em; text-align: center; }
.bar { width: 100%; max-width: 360px; height: 3px; background: rgba(29, 25, 21, .15); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--inju); transition: width .4s ease; }

/* 오류 */
.oops { display: grid; gap: 14px; text-align: center; }
.oops h2 { font-family: var(--f-display); font-weight: 400; font-size: 24px; margin: 0; }
.oops p { margin: 0; color: var(--meok-soft); }

/* 결과 */
.res-head { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "eye seal" "name name" "hanja hanja"; column-gap: 14px; align-items: start; }
.res-head .eyebrow { grid-area: eye; align-self: end; }
.res-head .seal { grid-area: seal; }
.res-head .res-name { grid-area: name; }
.res-head .res-hanja { grid-area: hanja; }
.res-head .eyebrow { font-family: var(--f-display); color: var(--meok-soft); font-size: 15px; letter-spacing: .1em; margin: 0; }
.res-name { font-family: var(--f-brush); font-size: clamp(44px, 13vw, 66px); line-height: 1; margin: 2px 0 0; font-weight: 400; white-space: nowrap; }
.res-hanja { font-family: var(--f-seal); font-weight: 600; letter-spacing: .4em; color: var(--meok-soft); font-size: 14px; margin-top: 6px; }
.seal {
  width: 76px; height: 76px; border: 3px solid var(--inju); color: var(--inju);
  display: grid; place-items: center; text-align: center; transform: rotate(5deg);
  font-family: var(--f-seal); font-weight: 900; line-height: 1.05; font-size: 21px;
  box-shadow: inset 0 0 0 2px var(--hanji), inset 0 0 0 3px var(--inju);
  font-variant-numeric: tabular-nums;
  animation: stamp .45s cubic-bezier(.2, 1.6, .4, 1) both;
}
.seal small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .05em; }
@keyframes stamp { from { transform: rotate(5deg) scale(1.6); opacity: 0; } to { transform: rotate(5deg) scale(1); opacity: 1; } }
.summary { font-family: var(--f-display); font-size: 21px; line-height: 1.5; margin: 0; text-wrap: balance; }
.traits { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.traits li { border: 1px solid var(--meok); padding: 4px 12px; font-size: 14.5px; }

.sec-t { font-family: var(--f-display); font-size: 17px; letter-spacing: .14em; margin: 0 0 10px; display: flex; align-items: center; gap: 10px; }
.sec-t::after { content: ""; flex: 1; height: 1px; background: var(--nureun); }

.facebox canvas { width: 100%; max-width: 100%; aspect-ratio: 1 / 1.05; display: block; }
.facebox .note { font-size: 12.5px; color: var(--meok-soft); margin: 4px 0 0; text-align: center; }

.axes { display: grid; gap: 18px; }
.axis { display: grid; gap: 6px; }
.axis-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.axis-top b { font-family: var(--f-seal); font-weight: 600; font-size: 16px; }
.axis-top em { font-style: normal; font-size: 13px; color: var(--inju); }
.gauge { position: relative; height: 22px; }
.gauge::before { content: ""; position: absolute; left: 0; right: 0; top: 10px; height: 2px; background: var(--meok); }
.gauge::after { content: ""; position: absolute; left: 50%; top: 4px; width: 1px; height: 14px; background: var(--meok-soft); }
.gauge i { position: absolute; top: 3px; width: 16px; height: 16px; margin-left: -8px; border-radius: 50%; background: var(--inju); box-shadow: 0 0 0 3px var(--hanji); transition: left .8s cubic-bezier(.2, .8, .2, 1); }
.gauge-l { display: flex; justify-content: space-between; font-size: 13px; color: var(--meok-soft); }
.gauge-l .on { color: var(--meok); font-weight: 700; }
.axis p { margin: 0; font-size: 14.5px; }

.tips { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.tips li { padding-left: 20px; position: relative; }
.tips li::before { content: "◆"; position: absolute; left: 0; top: .1em; font-size: 11px; color: var(--inju); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair div { border: 1px solid var(--nureun); padding: 10px 12px; display: grid; gap: 2px; }
.pair span { font-size: 12.5px; color: var(--meok-soft); }
.pair b { font-family: var(--f-display); font-weight: 400; font-size: 17px; }

.vs { border: 1.5px solid var(--inju); padding: 14px; display: grid; gap: 6px; text-align: center; }
.vs .pct { font-family: var(--f-brush); font-size: 56px; line-height: 1; color: var(--inju); font-variant-numeric: tabular-nums; }
.vs p { margin: 0; }

.next { display: grid; gap: 8px; }
.next a, .next span { display: flex; justify-content: space-between; gap: 10px; padding: 10px 2px; border-bottom: 1px solid var(--nureun); color: var(--meok); text-decoration: none; font-size: 15px; }
.next a:hover { color: var(--inju); }
.next span { color: var(--meok-soft); }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--meok); color: var(--hanji); padding: 10px 18px; font-size: 14px; max-width: calc(100% - 32px); }
.copybox { width: 100%; font: inherit; font-size: 13px; padding: 8px; border: 1px solid var(--nureun); background: transparent; color: var(--meok); resize: none; }

@media (max-width: 380px) {
  .leaf { padding: 18px 16px 22px; }
  .howto { grid-template-columns: 1fr; }
  .actions { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .seal { animation: none; }
  .gauge i, .bar i { transition: none; }
}

/* 테스트 고르기로 돌아가기 */
.tohub { justify-self: start; font-family: var(--f-display); font-size: 15px; color: var(--meok-soft); text-decoration: none; letter-spacing: .04em; }
.tohub:hover { color: var(--inju); }
a.btn { text-decoration: none; }
