:root {
  --paper: #f6efdd;
  --paper-2: #efe5cb;
  --card: #fffaf0;
  --ink: #2a2520;
  --ink-2: #5a5148;
  --line: #d9ccae;
  --accent: #8a3b2a;        /* 인주색(도장) */
  --accent-ink: #fffaf0;
  --gold: #b88a2e;
  /* 오방색 = 오행 */
  --wood: #2f7a52;  --wood-bg: #dcebdd;
  --fire: #c1432d;  --fire-bg: #f7ddd5;
  --earth: #a9781a; --earth-bg: #f3e5bd;
  --metal: #66707a; --metal-bg: #e6e8ea;
  --water: #27384f; --water-bg: #d8dfe9;
  --radius: 14px;
  --base: 18px;
  --serif: "Noto Serif KR", "Batang", "Nanum Myeongjo", serif;
  --sans: "Noto Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
html[data-size="1"] { --base: 20px; }
html[data-size="2"] { --base: 23px; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: var(--base); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--sans); line-height: 1.7;
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(255,255,255,.55), transparent 60%),
    repeating-linear-gradient(0deg, rgba(120,90,40,.018) 0 2px, transparent 2px 5px),
    var(--paper);
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  min-height: 100vh;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: var(--ink); color: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 8px; top: 8px; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* 상단 */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  padding: calc(.55rem + env(safe-area-inset-top)) 16px .55rem; background: rgba(246,239,221,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 2.1rem; height: 2.1rem; border-radius: 6px; background: var(--accent); color: var(--accent-ink);
  font-family: var(--serif); font-weight: 700; font-size: 1.15rem; transform: rotate(-4deg); }
.brand-name { font-family: var(--serif); font-weight: 700; font-size: 1.1rem; }
.icon-btn { min-width: 48px; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; }

main { max-width: 680px; margin: 0 auto; padding: 16px 16px 24px; outline: none; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.35; margin: 0 0 .6rem; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .8rem; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* 카드 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: 0 1px 0 rgba(120,90,40,.08); }
.card.hero { background: linear-gradient(180deg, #fff8e8, #f9efd3); text-align: center; padding: 24px 16px; }
.hero .big { font-family: var(--serif); font-size: 1.7rem; font-weight: 700; margin-bottom: .4rem; }
.notice { border-left: 5px solid var(--gold); background: #fbf2d6; padding: 12px 14px; border-radius: 8px; margin: 0 0 14px; }
.notice.warn { border-color: var(--fire); background: #fbe7e0; }
.disclaimer { font-size: .8rem; color: var(--ink-2); text-align: center; margin: 22px 0 0; }

/* 버튼 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 52px; padding: 0 22px; border-radius: 12px; border: 2px solid var(--ink);
  background: var(--card); color: var(--ink); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.block { display: flex; width: 100%; }
.btn.ghost { border-color: var(--line); font-weight: 500; }
.btn:active { transform: translateY(1px); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }
.links { display: grid; gap: 10px; grid-template-columns: 1fr; }
.linkcard { display: flex; align-items: center; gap: 14px; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-height: 64px; }
.linkcard .ico { font-family: var(--serif); font-weight: 700; font-size: 1.5rem; width: 2.4rem; text-align: center; color: var(--accent); }
.linkcard b { display: block; } .linkcard span { color: var(--ink-2); font-size: .88rem; }

/* 폼 */
.field { margin: 0 0 18px; }
.field > label, .field > .lbl, legend { display: block; font-weight: 700; margin: 0 0 6px; }
fieldset { border: 0; padding: 0; margin: 0 0 18px; }
input[type=text], input[type=number], input[type=time], select {
  width: 100%; min-height: 52px; padding: 8px 12px; font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 12px; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 22px) 50%, calc(100% - 16px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
input:disabled { background: var(--paper-2); color: #8b8478; }
.trio { display: grid; grid-template-columns: 1.55fr 1.1fr 1.15fr; gap: 8px; }
.trio select { padding-left: 10px; padding-right: 30px; background-position: calc(100% - 17px) 50%, calc(100% - 11px) 50%; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: grid; place-items: center; min-height: 52px; padding: 6px 8px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font-weight: 700; cursor: pointer; text-align: center; margin: 0; }
.seg input:checked + label { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.seg input:focus-visible + label { outline: 3px solid var(--gold); outline-offset: 2px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 48px; font-weight: 500; }
.check input { width: 26px; height: 26px; accent-color: var(--accent); }
details.adv { border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 14px; margin: 0 0 18px; background: rgba(255,255,255,.5); }
details.adv summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.err { color: #a2261a; font-weight: 700; margin: 0 0 12px; }

/* 명식 표 */
.saju { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 4px; }
.col { text-align: center; }
.col .head { font-weight: 700; font-size: .95rem; }
.col .role { font-size: .72rem; color: var(--ink-2); margin-bottom: 6px; line-height: 1.35; }
.gz { display: block; width: 100%; border: 2px solid var(--line); border-radius: 12px; padding: 8px 2px 6px; margin: 0 0 8px; cursor: pointer; font: inherit; color: var(--ink); min-height: 96px; }
.gz .ko { display: block; font-family: var(--serif); font-weight: 700; font-size: 2rem; line-height: 1.1; }
.gz .han { display: block; font-size: .8rem; opacity: .8; }
.gz .tag { display: block; font-size: .75rem; margin-top: 4px; font-weight: 700; }
.gz.empty { border-style: dashed; background: transparent; color: var(--ink-2); font-size: .85rem; cursor: default; }
.gz.me { outline: 3px solid var(--gold); outline-offset: 2px; }
.el-목 { background: var(--wood-bg); border-color: var(--wood); } .el-목 .ko { color: var(--wood); }
.el-화 { background: var(--fire-bg); border-color: var(--fire); } .el-화 .ko { color: var(--fire); }
.el-토 { background: var(--earth-bg); border-color: var(--earth); } .el-토 .ko { color: var(--earth); }
.el-금 { background: var(--metal-bg); border-color: var(--metal); } .el-금 .ko { color: var(--metal); }
.el-수 { background: var(--water-bg); border-color: var(--water); } .el-수 .ko { color: var(--water); }
.legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: .8rem; margin: 6px 0 0; }
.legend i { display: inline-block; width: .9rem; height: .9rem; border-radius: 4px; vertical-align: -2px; margin-right: 4px; border: 1px solid rgba(0,0,0,.15); }

/* 오행 막대 */
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 4.6rem 1fr 2.4rem; gap: 10px; align-items: center; }
.bar .nm { font-weight: 700; } .bar .nm small { display: block; font-weight: 400; font-size: .72rem; color: var(--ink-2); }
.bar .track { height: 18px; border-radius: 9px; background: var(--paper-2); overflow: hidden; }
.bar .fill { display: block; height: 100%; border-radius: 9px; }
.bar .n { text-align: right; font-weight: 700; }

/* 정보 목록 */
dl.info { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; }
dl.info dt { color: var(--ink-2); } dl.info dd { margin: 0; font-weight: 500; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.chip { display: inline-block; padding: 2px 12px; border-radius: 999px; background: var(--paper-2); font-size: .85rem; font-weight: 700; }
.timeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.timeline .gz { min-height: 78px; cursor: default; }
.timeline .gz .ko { font-size: 1.35rem; }
.timeline .age { font-size: .75rem; font-weight: 700; }

/* 64괘 */
.search { margin: 0 0 12px; }
.guagrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.guabtn { display: block; text-align: center; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 6px; min-height: 108px; }
.guabtn .sym { display: block; font-size: 2.4rem; line-height: 1.1; font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", var(--sans); }
.guabtn .nm { display: block; font-family: var(--serif); font-weight: 700; }
.guabtn .sub { display: block; font-size: .78rem; color: var(--ink-2); }
.bigsym { font-size: 5rem; line-height: 1; text-align: center; font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", var(--sans); margin: 4px 0 6px; }
.tri { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 12px; }
.tri .t { background: var(--paper-2); border-radius: 12px; padding: 10px; text-align: center; }
.tri .t b { display: block; font-size: 1.6rem; font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", var(--sans); }
.orig { font-family: var(--serif); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.orig ol { margin: .4rem 0 0; padding-left: 1.4rem; } .orig li { margin: 0 0 .3rem; }
details.fold { margin: 0 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
details.fold > summary { cursor: pointer; padding: 12px 16px; font-weight: 700; min-height: 52px; display: flex; align-items: center; }
details.fold > div { padding: 0 16px 14px; }
.tipbox { background: #e9f1e1; border-left: 5px solid var(--wood); padding: 12px 14px; border-radius: 8px; margin: 0 0 12px; }
.cautionbox { background: #fbf2d6; border-left: 5px solid var(--gold); padding: 12px 14px; border-radius: 8px; margin: 0 0 12px; }
.pager { display: flex; justify-content: space-between; gap: 10px; margin: 8px 0 0; }

/* 용어 */
.filter { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.filter button { min-height: 44px; padding: 0 14px; border-radius: 999px; border: 2px solid var(--line); background: #fff; font: inherit; font-weight: 700; cursor: pointer; }
.filter button[aria-pressed=true] { background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* 하단 탭 */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr); background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 64px; text-decoration: none; color: var(--ink-2); font-size: .78rem; font-weight: 700; gap: 2px; }
.tabs a .ti { font-family: var(--serif); font-size: 1.25rem; line-height: 1; }
.tabs a[aria-current=page] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* 바텀시트 */
.backdrop { position: fixed; inset: 0; background: rgba(30,20,10,.45); z-index: 50; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-width: 680px; margin: 0 auto; background: var(--card); border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 82vh; overflow: auto; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: -6px auto 12px; }
.sheet .x { float: right; }
.sheet .glyph { font-family: var(--serif); font-weight: 700; font-size: 3rem; line-height: 1; }

@media (min-width: 560px) { .links { grid-template-columns: repeat(3, 1fr); } .guagrid { grid-template-columns: repeat(4, 1fr); } .timeline { grid-template-columns: repeat(10, 1fr); } .timeline .gz .ko { font-size: 1.1rem; } }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: up .18s ease-out; } @keyframes up { from { transform: translateY(30px); opacity: .6; } } }

/* ── 운명설계소(질문 풀이) ── */
.tabs { grid-template-columns: repeat(5, 1fr); }
.primary-link { background: linear-gradient(180deg, #fff3d6, #f8e6b8); border-color: var(--gold); margin: 0 0 4px; }
.steps { display: flex; gap: 4px; list-style: none; padding: 0; margin: 0 0 14px; flex-wrap: wrap; }
.steps li { font-size: .78rem; padding: 3px 10px; border-radius: 999px; background: var(--paper-2); color: var(--ink-2); font-weight: 700; }
.steps li[aria-current=step] { background: var(--ink); color: var(--paper); }
.steps li.done { background: #dcebdd; color: var(--wood); }
.topics { display: grid; gap: 10px; }
.topic-btn, .persona-btn { display: block; width: 100%; text-align: left; padding: 14px 16px; min-height: 64px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--card); font: inherit; color: var(--ink); cursor: pointer; }
.topic-btn b, .persona-btn b { display: block; font-family: var(--serif); font-size: 1.1rem; }
.topic-btn span, .persona-btn span { color: var(--ink-2); font-size: .88rem; }
.persona-btn[aria-pressed=true], .chip-btn[aria-pressed=true] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.persona-btn[aria-pressed=true] span { color: #e8dfc8; }
.personas { display: grid; gap: 10px; margin: 0 0 12px; }
.ta { width: 100%; padding: 12px; font: inherit; color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 12px; resize: vertical; line-height: 1.6; }
.right { text-align: right; }
.chip-btn { display: inline-block; min-height: 44px; padding: 8px 14px; margin: 0 6px 8px 0; border: 2px solid var(--line); border-radius: 999px; background: #fff; font: inherit; color: var(--ink); cursor: pointer; text-align: left; }
.opts { display: flex; flex-wrap: wrap; }
.envq { border: 0; padding: 0; margin: 0 0 14px; }
.envq legend { font-weight: 700; margin-bottom: 6px; }
.consent { align-items: flex-start; margin: 10px 0; }
.consent input { margin-top: 4px; flex: none; }
.hx { width: 150px; margin: 10px auto; display: grid; gap: 8px; }
.hx-line { display: flex; gap: 10px; align-items: center; height: 14px; position: relative; }
.hx-line .hx-bar { flex: 1; height: 14px; border-radius: 3px; background: var(--ink); }
.hx-line.empty .bar { background: var(--paper-2); border: 1px dashed var(--line); }
.hx-line.chg .bar { background: var(--accent); }
.hx-line .mark { position: absolute; right: -26px; font-weight: 700; color: var(--accent); }
.hex-result { margin-top: 8px; }
.bigsym.sm { font-size: 3rem; margin: 0; }
.reading-gua { display: flex; gap: 16px; align-items: center; justify-content: center; flex-wrap: wrap; }
.reading-gua .hx { margin: 0; width: 110px; }
.spinner { width: 54px; height: 54px; margin: 8px auto 14px; border: 6px solid var(--paper-2); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.pick { border: 0; padding: 0; margin: 0; }
.act { display: flex; gap: 10px; align-items: flex-start; padding: 12px; margin: 0 0 8px; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; }
.act input { margin-top: 5px; width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.act.picked { border-color: var(--wood); background: #e9f1e1; }
.coach { font-family: var(--serif); line-height: 1.8; }
.fq { border-left: 4px solid var(--line); padding-left: 12px; margin: 0 0 12px; }
.care { border-color: var(--accent); }
.carelist { padding-left: 1.2rem; font-size: 1.1rem; }
.boxlist { display: grid; gap: 10px; }
.boxrow { display: flex; gap: 8px; align-items: stretch; }
.boxitem { flex: 1; display: flex; gap: 12px; align-items: center; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; min-height: 76px; }
.boxitem .sym { font-size: 2rem; font-family: "Noto Sans Symbols 2", "Segoe UI Symbol", var(--sans); }
.del { flex: none; min-height: auto; padding: 0 12px; }

/* 풀이 말풍선(같이 이야기하는 느낌) */
.bubble { max-width: 92%; background: #fbf2d6; border: 1px solid var(--gold); border-radius: 4px 18px 18px 18px; padding: 10px 14px; margin: 0 0 10px; line-height: 1.7; }
.bubble p { margin: 0; }
.bubble.me { margin-left: auto; background: #fff; border-radius: 18px 4px 18px 18px; font-weight: 700; }

/* 오늘 마음에 둘 한 줄 카드 */
.quote { text-align: center; background: #fff8e1; border: 1px solid var(--gold); }
.quote .qline { font-family: var(--serif); font-size: 1.3rem; line-height: 1.7; margin: .3rem 0 0; }

.steps li .crumb { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.kakao-bar { position: sticky; top: 0; z-index: 50; background: #fee500; color: #2a2520; padding: 8px 12px; font-size: .85rem; line-height: 1.5; display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.kakao-bar .btn { white-space: nowrap; }
