/*
 * 잇다 스타일
 * 모서리 규칙: 버튼과 선택 칸은 알약 모양(999px), 카드와 타일은 20px, 입력 칸은 12px.
 * 강조색은 붉은 실 한 가지만 씁니다.
 * 겹침 순서: 내비게이션 10. 그 밖에는 z-index를 쓰지 않습니다.
 */

:root {
  --bg: #f2f5f3;
  --surface: #fbfcfb;
  --tint: #e6ecea;
  --ink: #14201c;
  --muted: #53625c;
  --line: #d5dcd9;
  --accent: #c2362c;
  --accent-ink: #fff8f6;
  --accent-soft: #f3dfdb;
  --shadow: 0 18px 40px -24px rgb(20 50 40 / .35);
  --radius-card: 20px;
  --radius-input: 12px;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --page: 1160px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1614;
    --surface: #161f1c;
    --tint: #1b2622;
    --ink: #e7eeea;
    --muted: #9daba5;
    --line: #2a3632;
    --accent: #ea5d50;
    --accent-ink: #1c0a08;
    --accent-soft: #3a1c18;
    --shadow: 0 18px 40px -24px rgb(0 0 0 / .7);
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  font-size: 17px;
  line-height: 1.7;
  word-break: keep-all;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol, dl, dd, figure, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 6px; }

.wrap { width: min(100% - 40px, var(--page)); margin-inline: auto; }

/* ---------- 내비게이션 ---------- */

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.nav-inner {
  width: min(100% - 40px, var(--page));
  margin-inline: auto;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.brand {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -.04em;
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 3px solid var(--accent);
  line-height: 1.2;
}
.nav nav { display: flex; align-items: center; gap: 24px; font-size: 15px; white-space: nowrap; }
.nav nav a { text-decoration: none; color: var(--muted); transition: color .2s var(--ease); }
.nav nav a:hover { color: var(--ink); }
.nav nav a.btn { color: var(--accent-ink); }
.nav nav a[aria-current="page"] { color: var(--ink); font-weight: 700; }
@media (max-width: 720px) {
  /* 홈은 좁은 화면에서 AI 상담과 시작 버튼만 남기고, 읽기와 상담 화면은 메뉴를 모두 보여 줍니다. */
  body:not(.page-reading) .nav nav a:not(.btn):not(.nav-keep) { display: none; }
  .nav nav { gap: 16px; }
  .page-reading .nav nav { font-size: 14px; }
}

/* ---------- 버튼 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 24px;
  border: 1px solid transparent;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s var(--ease), background-color .2s var(--ease), border-color .2s var(--ease);
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn-ghost { border-color: var(--line); color: var(--ink); background: transparent; }
.btn-ghost:hover { border-color: var(--ink); }
.btn-small { min-height: 40px; padding: 0 18px; font-size: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { background: var(--surface); border-color: var(--line); color: var(--muted); cursor: not-allowed; }

/* ---------- 홈: 첫 화면 ---------- */

.hero { padding: 56px 0 72px; }
.hero-grid { display: grid; gap: 40px; align-items: center; }
.hero h1 {
  font-size: clamp(38px, 6.2vw, 68px);
  font-weight: 800;
  letter-spacing: -.045em;
  line-height: 1.14;
}
.hero-sub { margin-top: 22px; max-width: 30em; font-size: 19px; color: var(--muted); }
.hero-cta { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; }
.hero-art { justify-self: center; width: min(100%, 440px); }
.hero-art .thread { fill: none; stroke: var(--accent); stroke-width: 3.5; stroke-linecap: round; }
.hero-art .node { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }
.hero-art text { fill: var(--ink); font-size: 19px; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
@media (min-width: 900px) {
  .hero { padding: 72px 0 104px; }
  .hero-grid { grid-template-columns: 1.15fr .85fr; gap: 56px; }
  .hero-art { justify-self: end; }
}

/* 실을 따라 흐르는 빛 한 점. 움직임을 줄인 화면에서는 보이지 않습니다. */
.hero-art .thread-glint {
  fill: none; stroke: color-mix(in srgb, var(--accent) 30%, white); stroke-width: 3.5; stroke-linecap: round;
  stroke-dasharray: .07 3; stroke-dashoffset: .08; opacity: 0;
}

@media (prefers-reduced-motion: no-preference) {
  .hero-art .thread { stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 2.6s var(--ease) .3s forwards; }
  .hero-art .thread-glint { opacity: 1; animation: glint 5.5s linear 3.4s infinite; }
  .hero-art .node-b, .hero-art .label-b { opacity: 0; animation: appear .8s var(--ease) 2.2s forwards; }
  .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s var(--ease), transform .7s var(--ease); }
  .reveal.is-in { opacity: 1; transform: none; }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes appear { to { opacity: 1; } }
@keyframes glint { 0% { stroke-dashoffset: .08; } 42%, 100% { stroke-dashoffset: -1.02; } }

/* ---------- 붉은 실 ---------- */

/* 홈: 스크롤을 따라 이어지는 실. 가장자리와 섹션 사이 빈 자리로만 지나갑니다. (site.js가 그립니다) */
main.has-spine { position: relative; }
.spine { position: absolute; top: 0; left: 0; width: 100%; pointer-events: none; }
.spine path { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 900px) { .spine path { stroke-width: 3; } }
@media (prefers-reduced-motion: no-preference) { .spine path { transition: stroke-dashoffset .4s linear; } }

/* 실 모양 무늬. 색은 쓰는 자리에서 정합니다. */
:root {
  --wave: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 8' preserveAspectRatio='none'%3E%3Cpath d='M0 4 Q6 0 12 4 T24 4' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  --glyph-center: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40'%3E%3Cg fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M4 8 C40 8 48 20 68 20 L116 20 M4 32 C40 32 48 20 68 20'/%3E%3C/g%3E%3Ccircle cx='68' cy='20' r='5'/%3E%3C/svg%3E");
  --glyph-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40'%3E%3Cpath d='M4 26 C28 26 40 6 54 12 C68 18 56 36 46 27 C38 18 60 6 78 20 C90 30 102 24 116 20' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
  --glyph-work: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40'%3E%3Cg fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M4 20 Q18 2 32 20 T60 20 T88 20 T116 20'/%3E%3Cpath d='M4 20 Q18 38 32 20 T60 20 T88 20 T116 20'/%3E%3C/g%3E%3C/svg%3E");
  --glyph-root: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 120 40'%3E%3Cpath d='M4 12 L48 12 C72 12 86 10 116 5 M48 12 C72 12 88 22 116 20 M48 12 C66 12 84 34 116 35' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* 잇다 이야기: "다시 묶다" 아래로 실이 그어집니다. */
.story-quote span { position: relative; white-space: nowrap; }
.story-quote span::after {
  content: ""; position: absolute; left: 0; bottom: -.16em; width: 100%; height: .24em;
  background: var(--accent);
  -webkit-mask: var(--wave) repeat-x 0 50% / auto 100%;
  mask: var(--wave) repeat-x 0 50% / auto 100%;
}

/* 네 가닥의 실: 타일마다 그 실의 모양이 그려집니다. */
.tile::before {
  content: ""; width: 120px; height: 40px; margin-bottom: auto; flex: none;
  background: var(--accent);
  -webkit-mask: var(--glyph) no-repeat 0 0 / contain;
  mask: var(--glyph) no-repeat 0 0 / contain;
}
.tile-center { --glyph: var(--glyph-center); }
.tile-center::before { background: currentColor; }
.tile-heart { --glyph: var(--glyph-heart); }
.tile-work { --glyph: var(--glyph-work); }
.tile-root { --glyph: var(--glyph-root); }

/* 로고 아래의 실 */
.brand { position: relative; border-bottom: 0; padding-bottom: 8px; }
.brand::after {
  content: ""; position: absolute; left: 0; bottom: 0; width: 100%; height: 7px;
  background: var(--accent);
  -webkit-mask: var(--wave) repeat-x 0 50% / 50% 100%;
  mask: var(--wave) repeat-x 0 50% / 50% 100%;
}

/* 누르는 버튼 안쪽의 바느질 땀 */
.btn-primary:not([disabled]) { position: relative; }
.btn-primary:not([disabled])::after {
  content: ""; position: absolute; inset: 4px; border-radius: 999px; pointer-events: none;
  border: 1.5px dashed color-mix(in srgb, var(--accent-ink) 60%, transparent);
  opacity: .45; transition: opacity .25s var(--ease), inset .25s var(--ease);
}
.btn-primary:not([disabled]):hover::after,
.btn-primary:not([disabled]):focus-visible::after,
.btn-primary:not([disabled]):active::after { opacity: 1; inset: 5px; }

/* 결과 첫 화면: 마음 구조 그림과 버튼 세 개. 긴 풀이는 그 아래에 접어 둡니다. */
.mind { margin-top: 20px; padding: 20px 16px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.mind-art { display: block; width: min(100%, 380px); height: auto; margin-inline: auto; overflow: visible; }
.mind-art text { font-family: inherit; letter-spacing: -.02em; }
.mind-legend { margin-top: 14px; display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.mind-legend li { display: inline-flex; align-items: center; gap: 6px; }
.mind-legend i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.mind-legend .dot-top { background: var(--accent); }
.mind-legend .dot-want { width: 14px; height: 14px; background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent-soft), inset 0 0 0 3.5px var(--ink); }
.mind-legend .dot-empty { border: 1.2px dashed var(--muted); }
.mind figcaption { margin-top: 10px; font-size: 14px; color: var(--muted); text-align: center; }
.mind-actions { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mind-actions .btn { padding: 0 12px; }
.mind-actions .btn-primary { grid-column: 1 / -1; min-height: 56px; font-size: 18px; }
.mind-actions .btn-ghost:nth-child(2):last-child { grid-column: 1 / -1; }
.mind-actions + .help { margin-top: 10px; text-align: center; }
.mind-actions + .help:empty { display: none; }
#result-detail, #chat-slot { scroll-margin-top: 84px; }
#result-detail:focus { outline: none; }

/* 결과와 상담: 묶음 제목 위의 짧은 실 */
.result .block > h2::before, .consult-reading::before {
  content: ""; display: block; width: 36px; height: 9px; margin-bottom: 12px;
  background: var(--accent);
  -webkit-mask: var(--wave) repeat-x 0 50% / 18px 100%;
  mask: var(--wave) repeat-x 0 50% / 18px 100%;
}

/* 실의 상태 그림 */
.strand-state { display: inline-flex; align-items: center; gap: 8px; }
.strand-glyph { width: 44px; height: 20px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.strand-glyph circle { fill: var(--accent); stroke: none; }

/* 잠긴 묶음과 추가 상담 안내는 꿰매 둔 조각처럼 */
.deep-locked, .chat-paywall { border: 1.5px dashed color-mix(in srgb, var(--accent) 55%, transparent); }

@media (prefers-reduced-motion: no-preference) {
  .story-quote.reveal span::after { width: 0; transition: width 1s var(--ease) .5s; }
  .story-quote.reveal.is-in span::after { width: 100%; }
  .tile.reveal::before { clip-path: inset(0 100% 0 0); transition: clip-path 1.3s var(--ease) .35s; }
  .tile.reveal.is-in::before { clip-path: inset(0); }
}

/* ---------- 홈: 공통 섹션 ---------- */

.section { padding: 80px 0; }
.section h2 { font-size: clamp(28px, 4vw, 42px); font-weight: 800; letter-spacing: -.04em; line-height: 1.22; }
.section-lede { margin-top: 14px; max-width: 34em; color: var(--muted); }

/* 세 가지 인연: 큰 글씨 행 */
.relations-list { margin-top: 40px; border-top: 1px solid var(--line); }
.relation-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 24px;
  align-items: center;
  padding: 28px 4px;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
  transition: padding .3s var(--ease), background-color .3s var(--ease);
}
.relation-row h3 { font-size: clamp(26px, 4.4vw, 46px); font-weight: 800; letter-spacing: -.04em; line-height: 1.2; }
.relation-row p { grid-column: 1; color: var(--muted); max-width: 30em; }
.relation-row i { grid-row: 1 / span 2; grid-column: 2; font-size: 30px; color: var(--accent); transition: transform .3s var(--ease); }
.relation-row:hover { padding-left: 16px; background: var(--surface); }
.relation-row:hover i { transform: translateX(6px); }
@media (min-width: 900px) {
  .relation-row { grid-template-columns: minmax(280px, .9fr) 1.1fr auto; }
  .relation-row p { grid-column: 2; }
  .relation-row i { grid-row: 1; grid-column: 3; }
}

/* 잇다 이야기: 가운데 정렬 선언문 */
.story { background: var(--tint); text-align: center; }
.story .eyebrow { font-size: 14px; font-weight: 700; letter-spacing: .08em; color: var(--accent); }
.story-quote {
  margin: 18px auto 0;
  max-width: 21em;
  font-size: clamp(26px, 3.8vw, 40px);
  font-weight: 750;
  letter-spacing: -.04em;
  line-height: 1.36;
}
.story-quote span { color: var(--accent); }
.story-body { margin: 28px auto 0; max-width: 33em; color: var(--muted); }
.story-body + .story-body { margin-top: 16px; }

/* 네 가닥의 실: 크기가 다른 타일 */
.strand-grid { margin-top: 40px; display: grid; gap: 16px; }
.tile { border-radius: var(--radius-card); padding: 28px; min-height: 200px; display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; }
.tile h3 { font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.tile small { font-size: 14px; font-weight: 600; opacity: .8; }
.tile p { max-width: 26em; }
.tile-center { background: var(--accent); color: var(--accent-ink); }
.tile-heart {
  background-color: var(--surface);
  background-image: repeating-linear-gradient(118deg, transparent 0 22px, color-mix(in srgb, var(--accent) 16%, transparent) 22px 23px);
  border: 1px solid var(--line);
}
.tile-work { background: var(--ink); color: var(--bg); }
.tile-root { background: var(--tint); }
@media (min-width: 820px) {
  .strand-grid { grid-template-columns: repeat(3, 1fr); }
  .tile-center { grid-column: span 2; min-height: 260px; }
  .tile-root { grid-column: span 2; }
}

/* 받아 보는 내용: 두 단 비교 */
.report-grid { margin-top: 40px; display: grid; gap: 16px; }
.report-col { border: 1px solid var(--line); border-radius: var(--radius-card); padding: 28px; background: var(--surface); }
.report-col.is-deep { border-color: var(--accent); box-shadow: var(--shadow); }
.report-col h3 { font-size: 22px; font-weight: 800; letter-spacing: -.03em; }
.report-col ul { margin-top: 16px; display: grid; gap: 10px; }
.report-col li { display: grid; grid-template-columns: 22px 1fr; gap: 10px; align-items: start; }
.report-col li i { margin-top: 5px; font-size: 18px; color: var(--accent); }
.report-note { margin-top: 18px; font-size: 15px; color: var(--muted); }
@media (min-width: 820px) { .report-grid { grid-template-columns: 1fr 1fr; } }

/* 자주 묻는 질문 */
.faq-list { margin-top: 32px; max-width: 760px; border-top: 1px solid var(--line); }
.faq-list details { border-bottom: 1px solid var(--line); }
.faq-list summary {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 20px 4px; font-size: 18px; font-weight: 700; cursor: pointer; list-style: none;
}
.faq-list summary::-webkit-details-marker { display: none; }
.faq-list summary i { font-size: 20px; color: var(--muted); transition: transform .3s var(--ease); }
.faq-list details[open] summary i { transform: rotate(180deg); }
.faq-list details p { padding: 0 4px 22px; max-width: 38em; color: var(--muted); }

/* 마지막 안내 */
.closing { text-align: center; padding: 96px 0; }
.closing h2 { max-width: 15em; margin-inline: auto; }
.closing .btn { margin-top: 28px; }

/* 바닥글 */
.footer { border-top: 1px solid var(--line); padding: 36px 0 48px; font-size: 14px; color: var(--muted); }
.footer-grid { display: grid; gap: 14px; }
.footer .brand { font-size: 18px; color: var(--ink); justify-self: start; }
.footer-slim { text-align: center; padding: 28px 20px 40px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 2px 18px; }
.footer-links a { padding: 6px 0; text-decoration: none; }
.footer-links a:hover { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.footer-links strong { font-weight: 700; color: var(--ink); }
.footer-biz { display: flex; flex-wrap: wrap; gap: 2px 14px; font-size: 13px; }
.footer-slim .footer-links, .footer-slim .footer-biz { justify-content: center; margin-top: 8px; }
@media (min-width: 820px) {
  .footer-grid { grid-template-columns: auto 1fr auto; align-items: center; gap: 14px 32px; }
  .footer-grid .footer-biz { grid-column: 1 / -1; }
}

/* ---------- 약관과 정책 ---------- */

.policy-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 24px; }
.policy-tabs a {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px;
  font-size: 14px; font-weight: 650; color: var(--muted); text-decoration: none;
  transition: color .2s var(--ease), border-color .2s var(--ease);
}
.policy-tabs a:hover { color: var(--ink); border-color: var(--ink); }
.policy-tabs a[aria-current="page"] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.policy-note {
  margin-top: 20px; padding: 14px 18px; border-radius: var(--radius-card);
  background: var(--accent-soft); font-size: 15px;
}
.policy section { margin-top: 40px; }
.policy h2 { font-size: 20px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 12px; }
.policy section > * + p, .policy section > * + ul, .policy section > * + dl { margin-top: 12px; }
.policy section > h2 + * { margin-top: 0; }
.policy ul { list-style: disc; padding-left: 20px; display: grid; gap: 8px; }
.policy li::marker { color: var(--accent); }
.policy section a { text-underline-offset: 3px; }
.policy-list { border-top: 1px solid var(--line); }
.policy-list dt { padding-top: 16px; font-weight: 750; }
.policy-list dd { padding-bottom: 16px; border-bottom: 1px solid var(--line); color: var(--muted); }
.policy-list dd strong { display: block; color: var(--accent); font-weight: 750; }
.policy-biz { display: grid; grid-template-columns: auto 1fr; gap: 0 20px; }
.policy-biz dt, .policy-biz dd { padding: 12px 0; border-bottom: 1px solid var(--line); }
.policy-biz dt { font-weight: 650; color: var(--muted); font-size: 15px; }
.policy-biz dd { color: var(--ink); }
.policy-date { font-size: 14px; color: var(--muted); }

/* ---------- 관계 읽기: 입력 ---------- */

.reading { width: min(100% - 32px, 620px); margin-inline: auto; padding: 36px 0 72px; }
.reading-head h1 { font-size: clamp(28px, 6vw, 38px); font-weight: 800; letter-spacing: -.04em; line-height: 1.25; }
.reading-head p { margin-top: 12px; color: var(--muted); font-size: 16px; }

.field-group {
  margin-top: 24px;
  padding: 24px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  display: grid;
  gap: 20px;
}
.field-group legend { float: left; width: 100%; font-size: 20px; font-weight: 800; letter-spacing: -.03em; }
.field-group legend + * { clear: both; }
.field { display: grid; gap: 8px; }
.field label, .field-label, .sub-label { font-size: 15px; font-weight: 650; }
.optional { font-weight: 500; color: var(--muted); font-size: 13px; }
.sub-field { display: grid; gap: 8px; }

.field input[type="text"] {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font: inherit;
  font-size: 17px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-input);
  transition: border-color .2s var(--ease);
}
.field input[type="text"]:focus { border-color: var(--ink); outline: none; }
.field input[type="text"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.field input[type="text"]:disabled { opacity: .5; }
.field input[aria-invalid="true"] { border-color: var(--accent); }
.help { font-size: 14px; color: var(--muted); }
.error { font-size: 14px; font-weight: 600; color: var(--accent); }

.segmented { display: grid; gap: 8px; }
.segmented-2 { grid-template-columns: repeat(2, 1fr); }
.segmented-3 { grid-template-columns: repeat(3, 1fr); }
.segmented-4 { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 520px) { .segmented-4 { grid-template-columns: repeat(4, 1fr); } }
.segmented label { position: relative; display: block; cursor: pointer; }
.segmented input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.segmented span {
  display: flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg);
  font-size: 15px; font-weight: 650; text-align: center; white-space: nowrap;
  transition: background-color .2s var(--ease), border-color .2s var(--ease), color .2s var(--ease);
}
.segmented input:checked + span { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.check { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; cursor: pointer; min-height: 32px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.reading form > .btn { margin-top: 24px; min-height: 56px; font-size: 18px; }

/* ---------- 관계 읽기: 결과 ---------- */

.result:focus { outline: none; }
.result-head { padding: 12px 0 8px; }
.result-type { font-size: 15px; font-weight: 700; color: var(--accent); }
.result-head h1 { margin-top: 10px; font-size: clamp(26px, 6vw, 36px); font-weight: 800; letter-spacing: -.04em; line-height: 1.3; }
.thread-word { font-size: 1.5em; color: var(--accent); line-height: 1.25; }
.result-line { margin-top: 10px; color: var(--muted); }

.block { margin-top: 44px; }
.block > h2, .care > h2 { font-size: 22px; font-weight: 800; letter-spacing: -.03em; margin-bottom: 16px; }
.block p + p { margin-top: 12px; }
.lede { font-size: 19px; line-height: 1.65; font-weight: 500; }

.charts { display: grid; gap: 16px; }
.chart { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 20px; }
.chart-head h3 { font-size: 19px; font-weight: 800; }
.chart-head p { font-size: 14px; color: var(--muted); }
.pillars { margin-top: 16px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pillar {
  display: grid; justify-items: center; gap: 2px;
  padding: 12px 4px 14px;
  background: var(--bg);
  border: 1px solid transparent;
  border-radius: 14px;
}
.pillar-day { border-color: var(--accent); background: var(--accent-soft); }
.pillar-label { font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.pillar-char { font-size: 30px; font-weight: 700; line-height: 1.2; font-family: "Noto Serif KR", "Nanum Myeongjo", "Batang", serif; }
.pillar-read { font-size: 12px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.pillar-empty { align-content: center; }
.pillar-unknown { font-size: 14px; color: var(--muted); }
.chart-master { margin-top: 16px; font-size: 15px; }
.chart-master b { display: block; }
.elements { margin-top: 14px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.elements li { display: flex; justify-content: center; align-items: baseline; gap: 6px; padding: 8px 0; background: var(--bg); border-radius: 10px; font-size: 14px; }
.elements li b { font-size: 17px; }
.elements li.is-zero { color: var(--muted); border: 1px dashed var(--line); background: transparent; }
.chart-note { margin-top: 12px; font-size: 14px; color: var(--muted); }

.daewoon { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.daewoon h4 { font-size: 15px; font-weight: 800; }
.daewoon h4 small { margin-left: 4px; font-size: 13px; font-weight: 500; color: var(--muted); }
.daewoon ol { margin-top: 10px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.daewoon li { display: grid; justify-items: center; gap: 1px; padding: 8px 2px; background: var(--bg); border: 1px solid transparent; border-radius: 10px; }
.daewoon li span { font-size: 12px; color: var(--muted); white-space: nowrap; }
.daewoon li b { font-size: 17px; font-weight: 700; line-height: 1.3; font-family: "Noto Serif KR", "Nanum Myeongjo", "Batang", serif; }
.daewoon li.is-current { background: var(--accent-soft); border-color: var(--accent); }
.daewoon li.is-current span { color: var(--ink); }

.roles { margin-top: 20px; display: grid; gap: 12px; }
.roles div { padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.roles dt { font-weight: 600; }
.roles dt b { color: var(--accent); font-weight: 800; }
.roles dd { margin-top: 4px; color: var(--muted); font-size: 16px; }

.strands { display: grid; gap: 12px; }
.strand { padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.strand-lead { border-color: var(--accent); }
.strand-top { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.strand-top h3 { font-size: 18px; font-weight: 800; }
.strand-state { font-size: 15px; font-weight: 800; color: var(--accent); white-space: nowrap; }
.strand-basis { font-size: 14px; color: var(--muted); margin: 2px 0 8px; }
.strand .strand-flag { margin-top: 8px; font-size: 14px; font-weight: 700; color: var(--accent); }

.way { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.way + .way { margin-top: 12px; }
.way h3 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.way-first { border-color: var(--accent); }

.deep { padding: 24px 20px; background: var(--tint); border-radius: var(--radius-card); }
.deep .sub { margin: 28px 0 12px; font-size: 18px; font-weight: 800; }
.lines { display: grid; gap: 10px; }
.lines li { padding: 16px 18px; background: var(--surface); border-radius: var(--radius-card); font-weight: 550; }
.complements { display: grid; gap: 10px; }
.complements li { padding-left: 16px; border-left: 3px solid var(--accent); }
.plan { display: grid; gap: 10px; }
.plan li { display: grid; grid-template-columns: 76px 1fr; gap: 2px 12px; padding: 14px 16px; background: var(--surface); border-radius: var(--radius-card); }
.plan-week { grid-row: span 2; font-size: 14px; font-weight: 700; color: var(--accent); padding-top: 3px; }
.plan p { color: var(--muted); font-size: 16px; }
.locked-list { margin: 16px 0 20px; display: grid; gap: 10px; }
.locked-list li { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.locked-list i { color: var(--muted); font-size: 18px; }

.care { margin-top: 44px; padding: 22px 20px; border: 1px solid var(--line); border-radius: var(--radius-card); font-size: 15px; color: var(--muted); }
.care > h2 { font-size: 17px; color: var(--ink); margin-bottom: 8px; }
.care p + p { margin-top: 10px; }

.result-actions { margin-top: 32px; display: grid; gap: 10px; }
@media (min-width: 520px) { .result-actions { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); } }

/* ---------- 인연 읽기: 단계 ---------- */

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* 단계마다 매듭이 하나씩 있고, 지나온 만큼 붉은 실이 이어집니다. */
.steps { display: flex; margin-bottom: 28px; counter-reset: step; }
.steps li {
  --knot: var(--line);
  --fill: 0%;
  flex: 1; counter-increment: step; position: relative;
  padding-top: 22px;
  font-size: 13px; font-weight: 650; color: var(--muted); white-space: nowrap;
  background:
    radial-gradient(circle at 6px 6px, var(--knot) 0 5px, transparent 5.6px) no-repeat,
    linear-gradient(var(--accent), var(--accent)) 0 5px / var(--fill) 2px no-repeat,
    linear-gradient(var(--line), var(--line)) 0 5px / 100% 2px no-repeat;
  transition: background-size .8s var(--ease), color .3s var(--ease);
}
.steps li::before { content: counter(step) " "; }
.steps li.is-done { --knot: var(--accent); --fill: 100%; color: var(--ink); }
.steps li.is-current { --knot: var(--accent); --fill: 45%; color: var(--accent); }
.steps li.is-current::after {
  content: ""; position: absolute; left: 0; top: 0; width: 12px; height: 12px;
  border: 1.5px solid var(--accent); border-radius: 999px; opacity: 0;
}
@media (prefers-reduced-motion: no-preference) {
  .steps li.is-current::after { animation: knot-ring 2s var(--ease) infinite; }
}
@keyframes knot-ring { 0% { opacity: .7; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(2.4); } }

.step:focus, .step:focus-visible { outline: none; }
.step-nav { margin-top: 24px; display: grid; grid-template-columns: auto 1fr; gap: 10px; }
.step-nav .btn { min-height: 56px; font-size: 18px; }
.step-nav .btn:only-child { grid-column: 1 / -1; }
.block-tight { margin-top: 24px; }

/* 고르는 카드 (하나 고르기, 여러 개 고르기 공통) */
.choices, .want-list, .trait-list { display: grid; gap: 10px; }
.choices { margin-top: 24px; }
@media (min-width: 520px) {
  .choices, .trait-list { grid-template-columns: 1fr 1fr; }
  .choices > .choice:last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.choice > span {
  display: grid; gap: 2px; height: 100%;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  transition: border-color .2s var(--ease), background-color .2s var(--ease);
}
.choice b { font-size: 17px; font-weight: 750; line-height: 1.45; }
.choice small { font-size: 14px; color: var(--muted); }
.choice input:checked + span { border-color: var(--accent); background: var(--accent-soft); }
.choice input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.field-group .choice > span { background: var(--bg); }
.field-group .choice input:checked + span { background: var(--accent-soft); }
.choice-check b { font-size: 15px; font-weight: 650; }

.tips { margin-top: 24px; padding: 20px; background: var(--tint); border-radius: var(--radius-card); }
.tips h2 { font-size: 16px; font-weight: 800; margin-bottom: 10px; }
.tips ul { display: grid; gap: 8px; }
.tips li { padding-left: 14px; border-left: 3px solid var(--accent); font-size: 15px; color: var(--muted); }

.field select {
  width: 100%; height: 52px; padding: 0 14px;
  font: inherit; font-size: 17px; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-input);
}
.field select[aria-invalid="true"] { border-color: var(--accent); }

.picked { margin-top: 12px; display: grid; gap: 6px; }
.picked li { padding: 8px 12px; background: var(--bg); border-radius: 10px; font-size: 14px; }

/* ---------- AI 상담 채팅 ---------- */

.chat-intro { color: var(--muted); }
.chat-log { display: grid; gap: 10px; margin-top: 16px; }
.chat-log:empty { display: none; }
.chat-bubble { max-width: 88%; padding: 14px 16px; border-radius: var(--radius-card); white-space: pre-wrap; font-size: 16px; line-height: 1.65; }
.chat-user { justify-self: end; background: var(--ink); color: var(--bg); }
.chat-assistant { justify-self: start; background: var(--surface); border: 1px solid var(--line); }
.chat-assistant.is-waiting { color: var(--muted); }
.chat-assistant.is-error { border-color: var(--accent); color: var(--accent); font-weight: 600; }
/* 답을 기다리는 동안 실이 흘러갑니다. */
.chat-assistant.is-waiting::after {
  content: ""; display: block; width: 54px; height: 9px; margin-top: 8px;
  background: var(--accent);
  -webkit-mask: var(--wave) repeat-x 0 50% / 18px 100%;
  mask: var(--wave) repeat-x 0 50% / 18px 100%;
}
@media (prefers-reduced-motion: no-preference) {
  .chat-assistant.is-waiting::after { animation: thread-flow .9s linear infinite; }
}
@keyframes thread-flow { to { -webkit-mask-position: -18px 50%; mask-position: -18px 50%; } }

.chat-starters { margin-top: 16px; display: grid; gap: 8px; }
.chat-starter {
  padding: 14px 16px; text-align: left;
  font: inherit; font-size: 15px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card);
  cursor: pointer; transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.chat-starter:hover { border-color: var(--ink); }
.chat-starter:active { transform: scale(.99); }
.chat-starter:disabled { opacity: .5; cursor: default; }

.chat-form { margin-top: 16px; display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.chat-form textarea {
  width: 100%; min-height: 56px; padding: 14px 16px; resize: vertical;
  font: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-input);
}
.chat-form textarea::placeholder { color: var(--muted); }
.chat-form textarea:focus { border-color: var(--ink); outline: none; }
.chat-form textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-form .btn { min-height: 56px; }
.chat-form + .help { margin-top: 10px; }
.chat-quota { margin-top: 10px; font-size: 14px; font-weight: 650; color: var(--accent); }
.chat-quota + .chat-paywall + .help { margin-top: 6px; }
.chat-paywall { margin-top: 16px; padding: 20px; background: var(--accent-soft); border-radius: var(--radius-card); display: grid; gap: 10px; justify-items: start; }
.chat-paywall h3 { font-size: 18px; font-weight: 800; }
.chat-paywall p { font-size: 15px; }
.chat-event { font-weight: 650; }
.event-badge {
  display: inline-block; margin-right: 8px; padding: 2px 12px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 13px; font-weight: 800; white-space: nowrap;
}
@media (max-width: 519px) { .chat-paywall .btn { width: 100%; } }
.chat-more { margin-top: 20px; display: grid; gap: 10px; }
.result-actions + .help { margin-top: 10px; }

/* ---------- AI 상담 탭 ---------- */

.consult-reading { margin-top: 24px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); }
.consult-reading .result-type { font-size: 14px; }
.consult-reading h2 { margin-top: 4px; font-size: 22px; font-weight: 800; letter-spacing: -.03em; color: var(--accent); }
.consult-reading h2 + p { color: var(--muted); font-size: 16px; }
.consult-reading details { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.consult-reading summary { font-size: 14px; font-weight: 650; color: var(--muted); cursor: pointer; }
.consult-context { margin-top: 10px; font-size: 14px; color: var(--muted); white-space: pre-wrap; }
.consult-chat { margin-top: 28px; }

.empty { margin-top: 24px; padding: 28px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-card); display: grid; gap: 12px; justify-items: start; }
.empty > i { font-size: 32px; color: var(--accent); }
.empty h2 { font-size: 22px; font-weight: 800; letter-spacing: -.03em; line-height: 1.35; }
.empty p { color: var(--muted); }
.empty ol { display: grid; gap: 8px; counter-reset: empty; width: 100%; }
.empty ol li { counter-increment: empty; display: grid; grid-template-columns: 28px 1fr; gap: 10px; align-items: start; font-size: 16px; }
.empty ol li::before {
  content: counter(empty);
  display: grid; place-items: center; width: 28px; height: 28px; margin-top: 1px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 800;
}
.empty .btn { margin-top: 8px; }
@media (max-width: 519px) { .empty .btn { width: 100%; } }
