/* 냥냥사주 — 다크 + 한지 포인트 (Claude Design 시안 기준) */
:root {
  --ink: #110F13;          /* 바탕 먹빛 */
  --ink-2: #161318;        /* 탭바 */
  --surface: #1B181E;      /* 카드 */
  --surface-2: #2A252E;    /* 칸·구분 */
  --line: #3A343F;
  --hanji: #EFE6D2;        /* 본문 한지색 */
  --hanji-2: #E6DCC7;
  --soft: #B9AF9C;         /* 보조 글씨 */
  --muted: #8E8578;
  --gold: #D8B46A;
  --gold-2: #EBCB86;
  --seal: #B23A24;         /* 주홍 낙관 */
  --seal-text: #9A2F1C;
  --el-0: #4E8A5C; --el-1: #B8402F; --el-2: #B8892E; --el-3: #A7A9AC; --el-4: #2E3A55;
  --font-title: 'Song Myung', 'Gowun Batang', serif;
  --font-serif: 'Gowun Batang', serif;
  --font-body: 'Gowun Dodum', system-ui, sans-serif;
  --tabbar: 68px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--ink); color: var(--hanji); font-family: var(--font-body); font-size: 16px; line-height: 1.7; word-break: keep-all; }
a { color: var(--gold); }
a:hover { color: var(--gold-2); }
button, input, select { font: inherit; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.app { max-width: 480px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); position: relative; }
.hint { font-size: 13px; color: var(--soft); margin: 4px 0 0; line-height: 1.5; font-weight: 400; }
.center { text-align: center; }

/* 로고·낙관 */
.seal { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 6px; background: var(--seal); color: var(--hanji); font-family: var(--font-serif); font-weight: 700; font-size: 17px; transform: rotate(-4deg); flex: 0 0 auto; }
.seal.big { width: 44px; height: 44px; font-family: var(--font-title); font-size: 22px; font-weight: 400; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--hanji); text-decoration: none; font-family: var(--font-serif); font-weight: 700; font-size: 21px; }
.brand:hover { color: var(--hanji); }

/* 카테고리 탭 */
.cats { display: flex; gap: 22px; padding: 4px 20px 0; border-bottom: 1px solid var(--surface-2); overflow-x: auto; scrollbar-width: none; }
.cats::-webkit-scrollbar { display: none; }
.cats button { background: none; border: 0; padding: 10px 0 12px; min-height: 44px; color: var(--muted); border-bottom: 2px solid transparent; cursor: pointer; white-space: nowrap; font-size: 15px; }
.cats button.on { color: var(--hanji); font-weight: 700; border-bottom-color: var(--gold); }

/* 사주명리/자미두수 전환 */
.sysseg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 16px 20px 4px; }
.sysseg button { text-align: center; padding: 12px 8px; border-radius: 14px; cursor: pointer; min-height: 44px; background: var(--surface); color: var(--hanji); border: 1px solid var(--line); }
.sysseg button b { display: block; font-family: var(--font-serif); font-size: 16px; }
.sysseg button span { display: block; font-size: 12px; opacity: .8; margin-top: 2px; }
.sysseg button.on { background: var(--hanji); color: #1A1618; border-color: var(--hanji); }

/* 포스터 */
.poster { position: relative; width: 300px; height: 450px; overflow: hidden; background: var(--ink); color: var(--hanji); border-radius: 18px; }
.poster img { position: absolute; left: 0; width: 300px; height: 450px; object-fit: cover; }
.poster .shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(10,8,12,.25) 0%, rgba(10,8,12,0) 16%, rgba(10,8,12,0) 54%, rgba(10,8,12,.92) 68%, #0A080C 74%, #0A080C 100%); }
.poster.compact .shade { background: linear-gradient(180deg, rgba(10,8,12,0) 70%, rgba(10,8,12,.7) 100%); }
.poster .badge { position: absolute; top: 0; right: 18px; padding: 8px 8px 13px; background: var(--seal); color: #F5EDDC; font-family: var(--font-serif); font-weight: 700; font-size: 13px; line-height: 1; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 82%, 0 100%); }
.poster .txt { position: absolute; left: 18px; right: 18px; bottom: 22px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.chip { display: inline-block; padding: 5px 13px; border-radius: 999px; background: var(--seal); font-size: 13px; font-weight: 700; color: #F5EDDC; }
.poster h3 { margin: 0; font-family: var(--font-title); font-weight: 400; font-size: 36px; line-height: 1.14; color: #F5EDDC; white-space: pre-line; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.poster .hook { margin: 0; font-size: 14px; line-height: 1.5; color: #EDE3CF; }
.poster .promise { margin: 2px 0 0; font-size: 12px; line-height: 1.45; color: var(--gold-2); }

.hero { padding: 18px 0 6px; }
.hero-btn { display: block; margin: 0 auto; width: 300px; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 18px; box-shadow: 0 18px 40px rgba(0,0,0,.55); }
.dots { display: flex; justify-content: center; gap: 6px; margin-top: 14px; }
.dots span { width: 6px; height: 6px; border-radius: 3px; background: #4A4350; }
.dots span.on { width: 18px; background: var(--gold); }

.row-head { padding: 26px 20px 0; }
.row-head p { margin: 0; font-size: 13px; color: var(--soft); }
.row-head h2 { margin: 4px 0 14px; font-family: var(--font-serif); font-size: 21px; font-weight: 700; }
.rail { display: flex; gap: 12px; overflow-x: auto; padding: 0 20px 6px; scrollbar-width: none; scroll-snap-type: x mandatory; }
.rail::-webkit-scrollbar { display: none; }
.mini { flex: 0 0 150px; padding: 0; border: 0; background: none; color: var(--hanji); text-align: left; cursor: pointer; scroll-snap-align: start; }
.mini .frame { width: 150px; height: 225px; border-radius: 12px; overflow: hidden; }
.mini .frame .poster { transform: scale(.5); transform-origin: top left; border-radius: 0; }
.mini .g { display: block; margin-top: 8px; font-size: 12px; color: var(--gold); }
.mini .t { display: block; font-family: var(--font-serif); font-weight: 700; font-size: 15px; line-height: 1.35; }
.mini .s { display: block; font-size: 12px; color: var(--muted); }

.cta { display: flex; align-items: center; gap: 14px; margin: 28px 20px 0; padding: 18px; border-radius: 16px; background: var(--hanji); color: #1A1618; text-decoration: none; border: 0; width: calc(100% - 40px); text-align: left; cursor: pointer; }
.cta:hover { color: #1A1618; }
.cta b { display: block; font-family: var(--font-serif); font-size: 17px; }
.cta span.sub { display: block; font-size: 13px; color: #5A5047; }
.cta .grow { flex: 1; }
.foot { margin: 26px 20px 0; font-size: 12px; line-height: 1.6; color: var(--muted); text-align: center; }

/* 하단 탭바 */
.tabbar { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--ink-2); border-top: 1px solid var(--surface-2); z-index: 20; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; min-height: 48px; color: var(--soft); text-decoration: none; font-size: 12px; }
.tabbar a.on { color: var(--gold); }

/* 입력창 */
.sheet-backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(5,4,6,.72); display: flex; align-items: flex-end; justify-content: center; }
.sheet { position: relative; width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; padding: 26px 22px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; background: var(--surface); border-radius: 26px 26px 0 0; border-top: 1px solid var(--line); }
.sheet-close { position: absolute; top: 14px; right: 14px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; border: 0; background: var(--surface-2); color: var(--hanji); cursor: pointer; }
.sheet-head { display: flex; align-items: center; gap: 12px; padding-right: 48px; }
.sheet-head h2 { margin: 0; font-family: var(--font-serif); font-size: 20px; }
.field { margin: 0; padding: 0; border: 0; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > legend, .field > .label { font-size: 13px; color: var(--soft); padding: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 8px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
input[type=number], input[type=text], select { width: 100%; min-width: 0; height: 46px; padding: 0 12px; color: var(--hanji); background: var(--ink); border: 1px solid var(--line); border-radius: 12px; font-size: 15px; appearance: none; }
select { background-image: linear-gradient(45deg, transparent 50%, var(--soft) 50%), linear-gradient(135deg, var(--soft) 50%, transparent 50%); background-position: calc(100% - 15px) 20px, calc(100% - 10px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 24px; }
select:disabled { opacity: .45; }
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg label { text-align: center; padding: 11px 0; cursor: pointer; color: var(--soft); background: var(--ink); font-size: 15px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { background: var(--hanji); color: #1A1618; font-weight: 700; }
.seg label:has(input:focus-visible) { outline: 2px solid var(--gold); outline-offset: -2px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--hanji-2); min-height: 32px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--gold); }
details.opts { border-top: 1px dashed var(--line); padding-top: 12px; }
details.opts summary { cursor: pointer; color: var(--soft); font-size: 14px; }
details.opts[open] summary { margin-bottom: 12px; }
details.opts .field + .field { margin-top: 14px; }
.error { color: #F08A73; font-weight: 700; margin: 0; min-height: 1em; font-size: 14px; }
.btn { display: grid; place-items: center; width: 100%; height: 54px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); color: var(--hanji); cursor: pointer; text-decoration: none; font-size: 15px; }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #1A1618; font-family: var(--font-serif); font-weight: 700; font-size: 17px; }
.btn.seal-btn { background: var(--seal); border-color: var(--seal); color: #F5EDDC; font-family: var(--font-serif); font-weight: 700; font-size: 16px; }
.btn:disabled { opacity: .6; }

/* 리더 */
.reader-bar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: rgba(17,15,19,.94); border-bottom: 1px solid var(--surface-2); }
.iconbtn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--hanji); background: none; border: 0; cursor: pointer; border-radius: 12px; flex: 0 0 auto; text-decoration: none; }
.reader-bar .meta { flex: 1; min-width: 0; }
.reader-bar .meta p { margin: 0; line-height: 1.35; }
.reader-bar .meta .c { font-size: 12px; color: var(--gold); }
.reader-bar .meta .t { font-family: var(--font-serif); font-weight: 700; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.progress { position: sticky; top: 65px; z-index: 10; height: 3px; background: var(--surface-2); }
.progress i { display: block; height: 3px; width: 0; background: var(--gold); }
.banner { position: relative; height: 230px; overflow: hidden; }
.banner img { position: absolute; left: 0; width: 100%; height: auto; }
.banner::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(17,15,19,0) 40%, var(--ink) 100%); }
.reader-head { padding: 4px 22px 0; }
.reader-head h1 { margin: 6px 0 2px; font-family: var(--font-title); font-weight: 400; font-size: 32px; line-height: 1.25; }
.reader-head p { margin: 0; color: var(--soft); font-size: 14px; }
.story { padding: 6px 22px 0; font-size: 17px; line-height: 1.95; }
.story .ep { margin: 44px 0 16px; font-family: var(--font-title); font-weight: 400; font-size: 25px; line-height: 1.35; color: var(--hanji); }
.story .ep::before { content: '✦'; display: block; font-size: 13px; color: var(--gold); margin-bottom: 8px; }
.story .ep:first-child { margin-top: 22px; }
.story .narr { margin: 0 0 18px; font-family: var(--font-serif); color: var(--hanji-2); }
.say { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 16px; }
.say .avatar { flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%; background: var(--surface-2); overflow: hidden; }
.say .avatar svg { width: 100%; height: 100%; }
.say .bubble { flex: 1; background: var(--hanji); color: #1F1A1C; border-radius: 4px 18px 18px 18px; padding: 10px 16px 12px; }
.say .who { display: block; font-size: 12px; font-weight: 700; color: var(--seal-text); }
.say .bubble p { margin: 0; font-size: 16px; line-height: 1.75; }
/* 운명서 본문: 한지 종이에 먹 글씨 (왼쪽 주홍 괘선은 책 여백선) */
.page { position: relative; margin: 6px 0 24px; padding: 26px 20px 10px 26px; background-color: var(--hanji); background-image: radial-gradient(ellipse at 15% 0%, rgba(255,255,255,.4), transparent 60%), radial-gradient(ellipse at 100% 100%, rgba(150,120,80,.16), transparent 55%); border-radius: 3px; box-shadow: 0 10px 28px rgba(0,0,0,.45), inset 0 0 0 1px rgba(120,95,60,.2), inset 0 0 40px rgba(150,120,80,.12); }
.page::before { content: ''; position: absolute; left: 12px; top: 14px; bottom: 14px; width: 1px; background: rgba(178,58,36,.35); }
.page p { margin: 0 0 16px; font-family: var(--font-serif); font-size: 17px; line-height: 1.95; color: #2A2320; text-indent: .6em; }
.sys { margin: 0 0 14px; padding: 10px 14px; border-radius: 8px; background: #0E1A2E; color: #5CE1E6; font-family: ui-monospace, monospace; font-size: 14px; line-height: 1.6; }
.status { margin: 0 0 18px; padding: 14px; border-radius: 12px; background: #0A1626; border: 1px solid #5CE1E6; color: #E6F6F7; font-size: 14px; }
.status-title { font-family: ui-monospace, monospace; color: #5CE1E6; font-weight: 700; margin-bottom: 8px; letter-spacing: .1em; }
.status-row { display: grid; grid-template-columns: 96px 1fr; gap: 8px; padding: 5px 0; border-top: 1px solid rgba(92,225,230,.2); }
.status-row span { color: #8FB7C9; }
.figure { margin: 6px 0 20px; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.figure.art { padding: 0; overflow: hidden; }
.figure.art svg { display: block; width: 100%; height: auto; }
.figcap { font-size: 13px; color: var(--soft); margin: 12px 0 0; line-height: 1.6; }
.figure.art .figcap { margin: 0; padding: 10px 14px; }
.end { margin: 40px 22px 0; display: grid; gap: 8px; }
.end .label { margin: 0; color: var(--soft); font-size: 13px; }
.listbtn { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--surface-2); color: var(--hanji); text-decoration: none; text-align: left; cursor: pointer; width: 100%; }
.listbtn:hover { color: var(--hanji); border-color: var(--line); }
.listbtn .l { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.listbtn .l small { font-size: 12px; color: var(--gold); }
.listbtn .l b { font-family: var(--font-serif); font-size: 15px; }
.listbtn .r { font-size: 12px; color: var(--soft); }

/* 원국표·오행·대운·명반 */
.chart { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.chart .col-head { font-size: 12px; color: var(--soft); }
.chart .tg { font-size: 12px; color: var(--soft); line-height: 1.3; }
.chart .tg.me { color: var(--gold); font-weight: 700; }
.tile { aspect-ratio: 1; border-radius: 10px; display: grid; place-items: center; align-content: center; color: #fff; font-family: var(--font-title); line-height: 1.1; }
.tile b { font-size: clamp(24px, 7vw, 32px); font-weight: 400; }
.tile span { font-family: var(--font-body); font-size: 11px; opacity: .9; margin-top: 2px; }
.tile.el-3 { color: #1F1A1C; }
.tile.empty { background: transparent; border: 1px dashed var(--line); color: var(--soft); }
.tile.day { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--gold); }
.el-0 { background: var(--el-0); } .el-1 { background: var(--el-1); } .el-2 { background: var(--el-2); } .el-3 { background: var(--el-3); } .el-4 { background: var(--el-4); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 58px 1fr 24px; align-items: center; gap: 8px; font-size: 14px; }
.bar .track { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; }
.bar .n { text-align: right; }
.dw { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.dw .item { flex: 0 0 60px; text-align: center; }
.dw .item .tile { aspect-ratio: auto; height: 44px; border-radius: 8px; }
.dw .item .tile b { font-size: 21px; }
.dw .stack { display: grid; gap: 3px; }
.dw .age { font-size: 12px; color: var(--soft); }
.dw .yr { font-size: 11px; color: var(--muted); }
.dw .now .age { color: var(--gold); font-weight: 700; }
.dw .now .stack { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 9px; }
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th { text-align: left; color: var(--soft); font-weight: 400; border-bottom: 1px solid var(--line); padding: 6px 8px; white-space: nowrap; }
.tbl td { border-bottom: 1px solid var(--surface-2); padding: 7px 8px; }
.tbl tr.now td { background: rgba(216,180,106,.1); }
.tbl td:first-child { white-space: nowrap; }

/* 서재·내 정보 */
.page-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 6px; }
.page-head h1 { margin: 0; font-family: var(--font-serif); font-size: 22px; }
.page-head a, .page-head button { font-size: 14px; color: var(--gold); background: none; border: 0; cursor: pointer; min-height: 44px; }
.book-card { position: relative; margin: 10px 20px 0; padding: 22px 20px 20px; border-radius: 20px; background: var(--hanji); color: #1F1A1C; overflow: hidden; }
.book-card .stamp { position: absolute; top: 18px; right: 18px; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 8px; background: var(--seal); color: var(--hanji); font-family: var(--font-title); font-size: 20px; transform: rotate(6deg); }
.book-card .who { margin: 0; font-size: 13px; color: #5A5047; }
.book-card .gz { margin: 6px 0 0; font-family: var(--font-title); font-size: 54px; line-height: 1.1; letter-spacing: .08em; }
.book-card .img { margin: 4px 0 14px; font-family: var(--font-serif); font-weight: 700; font-size: 16px; }
.book-card .pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; text-align: center; }
.book-card .pillars small { font-size: 11px; color: #5A5047; display: block; margin-bottom: 4px; }
.book-card .pillars .tile { aspect-ratio: auto; height: 54px; margin-bottom: 4px; }
.book-card .pillars .tile.day { box-shadow: 0 0 0 2px var(--hanji), 0 0 0 4px var(--seal); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.tags span { padding: 3px 10px; border-radius: 999px; border: 1px solid #9A7A3A; color: #6E5520; font-size: 13px; }
.section { padding: 22px 20px 0; }
.section > .label { margin: 0 0 10px; font-size: 13px; color: var(--soft); }
.stack-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.continue { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--hanji); text-decoration: none; width: 100%; text-align: left; cursor: pointer; }
.continue:hover { color: var(--hanji); }
.continue .thumb { flex: 0 0 72px; height: 108px; border-radius: 10px; overflow: hidden; }
.continue .thumb .poster { transform: scale(.24); transform-origin: top left; border-radius: 0; }
.continue .l { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.continue .l small { font-size: 12px; color: var(--gold); }
.continue .l b { font-family: var(--font-serif); font-size: 17px; }
.empty-card { margin: 16px 20px 0; padding: 26px 20px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.empty-card p { margin: 0 0 16px; color: var(--hanji-2); }
.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 0; padding: 16px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; }
.kv dt { color: var(--soft); }
.kv dd { margin: 0; }
.btn-col { display: grid; gap: 8px; padding: 18px 20px 0; }
.note { margin: 18px 20px 0; font-size: 13px; line-height: 1.7; color: var(--muted); }
.notice { margin: 16px 20px 0; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); color: var(--hanji-2); font-size: 15px; }
