/* ============================================================
   만세력 감명지 — 흰 종이 · 검은 붓글씨
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nanum+Myeongjo:wght@400;700;800&family=Nanum+Brush+Script&display=swap');

.manse,
#saju-result-page.manse {
  --paper:      #FFFDF7;
  --paper-2:    #FBF8F0;
  --ink:        #14130F;
  --ink-2:      #3A362D;
  --ink-3:      #6E685C;
  --ink-faint:  #9B958A;
  --rule:       #CFC8B6;
  --rule-2:     #E3DDCD;
  --seal:       #A3352A;

  --brush: 'Nanum Myeongjo', 'Noto Serif KR', serif;
  --hand:  'Nanum Brush Script', 'Nanum Myeongjo', serif;

  background: var(--paper);
  color: var(--ink);
  font-family: var(--brush);
  padding: 3rem 1.25rem 4.5rem;
  position: relative;
}

/* 한지 결 */
#saju-result-page.manse::before, .manse::before {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23p)'/%3E%3C/svg%3E");
}

#saju-result-page .manse-inner, .manse-inner { max-width: 940px; margin: 0 auto; position: relative; }

/* ── 머리글 ─────────────────────────────── */
.manse-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--ink);
  padding-bottom: .9rem; margin-bottom: .3rem;
}
.manse-head-title {
  font-family: var(--hand);
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  line-height: 1.15; color: var(--ink); letter-spacing: .02em;
}
.manse-head-sub {
  font-size: .82rem; color: var(--ink-3); margin-top: .4rem; line-height: 1.85;
}
.manse-head-sub b { color: var(--ink-2); font-weight: 700; }
.manse-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.manse-btn {
  font-family: var(--brush); font-size: .82rem; font-weight: 700;
  padding: .5rem 1.1rem; border: 1px solid var(--ink);
  background: transparent; color: var(--ink);
  cursor: pointer; text-decoration: none; transition: .18s;
}
.manse-btn:hover { background: var(--ink); color: var(--paper); }
.manse-btn.seal { border-color: var(--seal); color: var(--seal); }
.manse-btn.seal:hover { background: var(--seal); color: #fff; }

/* ── 블록 제목 ──────────────────────────── */
.manse-block { margin-top: 2.6rem; }
.manse-block-title {
  font-family: var(--hand);
  font-size: 1.5rem; color: var(--ink);
  border-bottom: 1px solid var(--ink);
  padding-bottom: .35rem; margin-bottom: .9rem;
  display: flex; align-items: baseline; gap: .6rem;
}
.manse-block-title small {
  font-family: var(--brush); font-size: .74rem;
  color: var(--ink-faint); font-weight: 400; letter-spacing: .06em;
}

/* ── 원국 표 ────────────────────────────── */
.wongook { width: 100%; border-collapse: collapse; table-layout: fixed; }
.wongook th, .wongook td {
  border: 1px solid var(--rule);
  text-align: center; vertical-align: middle;
  padding: .38rem .2rem;
}
.wongook .rowlabel {
  width: 62px; background: var(--paper-2);
  font-size: .7rem; color: var(--ink-3); font-weight: 700;
  letter-spacing: .04em; line-height: 1.4;
}
.wongook thead th {
  background: var(--paper-2); padding: .6rem .2rem;
  font-size: .95rem; font-weight: 800; color: var(--ink);
}
.wongook thead th .ganji {
  display: block; font-size: .74rem; font-weight: 400;
  color: var(--ink-3); margin-top: .15rem;
}
.wongook thead th.is-day { background: #F5EFE2; }
.wongook thead th.is-day::after {
  content: '日'; display: inline-block; margin-left: .3rem;
  font-size: .68rem; color: var(--seal); vertical-align: super;
}

/* 큰 붓글씨 한자 타일 */
.gz {
  font-family: var(--brush); font-weight: 800;
  font-size: clamp(2.1rem, 6.5vw, 3.1rem);
  line-height: 1.05; color: var(--ink);
  display: block; padding: .28rem 0 .1rem;
  text-shadow: 0 1px 0 rgba(0,0,0,.16);
}
.gz-ko {
  display: block; font-size: .66rem; font-weight: 400;
  color: var(--ink-faint); letter-spacing: .06em; margin-top: .1rem;
}
td.gz-cell { background: var(--paper); padding: .3rem .1rem .45rem; }
td.gz-cell.is-day { background: #FBF6EA; }
td.gz-cell.is-day .gz { color: var(--seal); }

/* 십성 · 12운성 · 납음 */
.sipseong { font-size: .8rem; font-weight: 700; color: var(--ink-2); }
.sipseong.me { color: var(--seal); font-weight: 800; }
.small-cell { font-size: .74rem; color: var(--ink-2); line-height: 1.6; }
.faint-cell { font-size: .72rem; color: var(--ink-3); }

/* 지장간 */
.jijang { font-size: .72rem; line-height: 1.75; color: var(--ink-2); }
.jijang i {
  font-style: normal; font-weight: 800; font-size: .82rem;
  color: var(--ink); margin-right: .18rem;
}
.jijang em { font-style: normal; color: var(--ink-3); font-size: .68rem; }

/* 형충회합 / 신살 */
.rel-cell, .ss-cell { font-size: .7rem; line-height: 1.7; color: var(--ink-2); }
.rel-cell span { display: block; }
.ss-cell span { display: block; }
.ss-cell .aux { color: var(--seal); }
.dash { color: var(--rule); }

/* ── 요약 줄 ────────────────────────────── */
.manse-summary {
  display: flex; flex-wrap: wrap; gap: .5rem 2rem;
  border: 1px solid var(--rule); border-top: none;
  padding: .8rem 1rem; font-size: .82rem; color: var(--ink-2);
  background: var(--paper-2);
}
.manse-summary b { font-weight: 800; color: var(--ink); }
.manse-summary .el-run { letter-spacing: .1em; font-size: .9rem; }
.manse-summary .zero { color: var(--seal); }

/* ── 띠 (공간 감명 연결) ────────────────── */
.manse-zodiac {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem 1.5rem; flex-wrap: wrap;
  border: 1px solid var(--rule); border-top: none;
  padding: .9rem 1rem; background: var(--paper);
}
.mz-main { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; }
.mz-emoji { font-size: 1.35rem; line-height: 1; }
.mz-name {
  font-family: var(--brush); font-weight: 800;
  font-size: 1.42rem; color: var(--seal); letter-spacing: .02em;
}
.mz-src { font-size: .72rem; color: var(--ink-faint); }
.mz-side { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.mz-group { font-size: .8rem; color: var(--ink-2); }
.mz-group b { font-weight: 800; color: var(--ink); }
.mz-go {
  font-size: .82rem; font-weight: 700; color: var(--seal);
  border-bottom: 1px solid var(--seal); padding-bottom: 1px;
  text-decoration: none; white-space: nowrap;
}
.mz-go:hover { opacity: .72; }

@media (max-width: 720px) {
  .manse-zodiac { flex-direction: column; align-items: flex-start; gap: .6rem; }
  .mz-side { flex-direction: column; align-items: flex-start; gap: .45rem; }
}

/* ── 가로 운(運) 표 ─────────────────────── */
.un-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: .3rem; }
.un-table { border-collapse: collapse; margin: 0 auto; min-width: 100%; }
.un-table td, .un-table th {
  border: 1px solid var(--rule); text-align: center;
  padding: .3rem .45rem; white-space: nowrap;
}
.un-table .un-rowlabel {
  position: sticky; left: 0; z-index: 2;
  background: var(--paper-2); width: 54px; min-width: 54px;
  font-size: .68rem; color: var(--ink-3); font-weight: 700;
}
.un-head { font-size: .82rem; font-weight: 800; color: var(--ink); background: var(--paper-2); }
.un-table td.is-now,
.un-table .un-head.now {
  background: #fff1f0;
  border-left: 2px solid #b13b3f;
  border-right: 2px solid #b13b3f;
}
.un-table tr:first-child .un-head.now { border-top: 2px solid #b13b3f; }
.un-table tr:last-child td.is-now { border-bottom: 2px solid #b13b3f; }
.un-current-badge {
  display: block;
  width: max-content;
  margin: 0 auto .2rem;
  padding: .1rem .4rem;
  border-radius: 3px;
  background: #b13b3f;
  color: #fff;
  font-size: .62rem;
  font-weight: 800;
  line-height: 1.35;
}
.un-current-value { display: block; }
.un-gz {
  font-family: var(--brush); font-weight: 800;
  font-size: 1.72rem; line-height: 1.1; color: var(--ink);
  text-shadow: 0 1px 0 rgba(0,0,0,.14);
}
.un-sm { font-size: .7rem; color: var(--ink-2); }
.un-xs { font-size: .66rem; color: var(--ink-3); line-height: 1.55; }
.un-col.now td { background: #FBF6EA; }
.un-col.now .un-head { color: var(--seal); }
.un-col.now .un-gz { color: var(--seal); }
.un-table col.now-col { background: #FBF6EA; }
.un-note { font-size: .72rem; color: var(--ink-faint); margin-top: .5rem; }

/* ── 꼬리말 ─────────────────────────────── */
.manse-foot {
  margin-top: 2.8rem; border-top: 2px solid var(--ink);
  padding-top: 1.1rem;
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1rem; flex-wrap: wrap;
}
.manse-foot p { font-size: .78rem; color: var(--ink-3); line-height: 1.9; max-width: 54ch; }
.manse-seal {
  font-family: var(--hand); font-size: 1.05rem; color: var(--seal);
  border: 1.5px solid var(--seal); padding: .55rem .8rem;
  line-height: 1.25; text-align: center; flex-shrink: 0;
}

/* ── 반응형 ─────────────────────────────── */
@media (max-width: 720px) {
  .manse { padding: 2rem .75rem 3rem; }
  .wongook .rowlabel { width: 46px; font-size: .62rem; }
  .wongook th, .wongook td { padding: .3rem .1rem; }
  .gz { font-size: clamp(1.7rem, 11vw, 2.4rem); }
  .jijang { font-size: .64rem; }
  .jijang i { font-size: .72rem; }
  .rel-cell, .ss-cell { font-size: .62rem; }
  .sipseong { font-size: .7rem; }
  .manse-block-title { font-size: 1.25rem; }
}

/* ── 인쇄 ───────────────────────────────── */
@media print {
  .manse { padding: 0; background: #fff; }
  #saju-result-page.manse::before, .manse::before { display: none; }
  .manse-actions { display: none; }
  .un-scroll { overflow: visible; }
  .manse-block { break-inside: avoid; }
}
