/* 사주본색 2판. 얼굴(첫 화면·결론)은 늘 밤하늘 남색의 절기 원판, 본문은 밝은 종이(어두운 화면에서는 먹색)와 또렷한 표.
   오행 다섯 색은 정보에만 쓴다. 글자는 16px 아래로 내리지 않는다. */
:root {
  --bg: #F6F6F2; --paper: #FFFFFF; --ink: #151716; --muted: #5A5E5B; --line: #E0E1DB;
  --accent: #1E5C72; --on-accent: #FFFFFF; --accent-soft: #E3EDF0;
  --sky: #0F1D2A; --sky-2: #16283A; --sky-ink: #E8EEF2; --sky-muted: #AEBBC6; --sky-line: rgba(232, 238, 242, 0.22); --gold: #F2C25C; --on-gold: #0F1D2A;
  --e0: #2B7849; --e1: #B3352B; --e2: #8E6210; --e3: #5A6168; --e4: #1F4E96; --on-e: #FFFFFF;
  --good: #2B7849; --warn: #8E6210;
  --display: "Hahmlet Variable", "Noto Serif KR", "AppleMyungjo", "Batang", serif;
  --body: "Pretendard Variable", "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "Consolas", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1115; --paper: #151A1F; --ink: #E7ECEF; --muted: #A3AEB6; --line: #2A323A;
    --accent: #86C0D3; --on-accent: #0D1115; --accent-soft: #18282E;
    --sky: #0A1520; --sky-2: #112232;
    --e0: #73CB97; --e1: #FF8E83; --e2: #E3BD69; --e3: #C3C9CF; --e4: #93B9F6; --on-e: #0D1115;
    --good: #73CB97; --warn: #E3BD69;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 17px/1.7 var(--body); word-break: keep-all; overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; text-wrap: balance; margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }
button, input, select, textarea { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted, .small, .hint { color: var(--muted); }
.small, .hint { font-size: 16px; }

/* 윗줄 */
.bar { position: sticky; top: 0; z-index: 5; background: var(--sky); color: var(--sky-ink); }
.bar-in { max-width: 640px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); display: flex; justify-content: space-between; align-items: center; min-height: 52px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 600 21px/1 var(--display); letter-spacing: 0.01em; color: inherit; text-decoration: none; }
.brand .seal { width: 30px; height: 30px; flex: none; display: block; }

/* 버튼 */
.primary, .ghost, .gold, .line { border-radius: 14px; min-height: 52px; padding: 12px 18px; font-weight: 700; cursor: pointer; border: 0; }
.primary { background: var(--accent); color: var(--on-accent); width: 100%; }
.ghost { background: transparent; color: inherit; border: 1px solid currentColor; min-height: 44px; padding: 8px 14px; }
.gold { background: var(--gold); color: var(--on-gold); }
.line { background: transparent; color: var(--sky-ink); border: 1px solid var(--sky-line); }

/* 밤하늘 띠 */
.sky { background: var(--sky) radial-gradient(120% 80% at 50% 0%, var(--sky-2) 0%, var(--sky) 60%); color: var(--sky-ink); }
.sky-in { max-width: 640px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.intake { padding-block: 28px 40px; display: grid; gap: 18px; }
.intro { display: grid; gap: 10px; justify-items: start; }
.dial-sm { width: 92px; height: 92px; }
.intro h1 { font-size: clamp(30px, 8vw, 40px); line-height: 1.25; }
.lede { color: var(--sky-muted); }
.friend { background: rgba(242, 194, 92, 0.14); border: 1px solid rgba(242, 194, 92, 0.5); border-radius: 12px; padding: 12px 14px; }
.promise { color: var(--sky-muted); font-size: 16px; }
.more-links { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.more-links a { color: var(--sky-ink); font-size: 16px; text-underline-offset: 3px; }
.recent { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.recent span { color: var(--sky-muted); }
.recent button { min-height: 44px; }

/* 입력 카드 (밝은 종이) */
.card { background: var(--paper); color: var(--ink); border-radius: 20px; padding: 20px 18px; }
.form { display: grid; gap: 14px; }
.dots { display: flex; gap: 6px; list-style: none; margin: 0; padding: 0; }
.dots li { width: 28px; height: 4px; border-radius: 2px; background: var(--line); }
.dots li.on { background: var(--accent); }
.step { border: 0; margin: 0; padding: 0; display: grid; gap: 14px; min-width: 0; }
.step legend { font: 800 22px/1.35 var(--display); padding: 0; margin-bottom: 6px; }
label { display: grid; gap: 4px; color: var(--muted); font-size: 16px; }
input[type=number], input[type=date], select, .saverow input { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; background: var(--bg); color: var(--ink); font-size: 18px; }
.row3 { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.nav2 { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; }
.nav2 .ghost { min-height: 52px; color: var(--ink); border-color: var(--line); }
.check { display: flex; gap: 10px; align-items: center; color: var(--ink); min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); margin: 0; flex: none; }
.seg { display: flex; gap: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.seg label { flex: 1; display: block; color: inherit; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; min-height: 46px; padding: 0 10px; color: var(--muted); font-weight: 700; }
.seg input:checked + span { background: var(--accent); color: var(--on-accent); }
.seg input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: -3px; }
.seg.small span { min-height: 44px; font-size: 16px; }
.more summary { cursor: pointer; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.err { color: var(--e1); font-weight: 700; }
.err:empty { display: none; }

/* 세우는 중 */
.building { position: fixed; inset: 0; z-index: 20; background: var(--sky); color: var(--sky-ink); display: grid; place-content: center; gap: 18px; justify-items: center; }
.spin { width: 120px; height: 120px; border-radius: 50%; border: 1px solid var(--sky-line); position: relative; }
.spin::after { content: ""; position: absolute; top: -7px; left: calc(50% - 7px); width: 14px; height: 14px; border-radius: 50%; background: var(--gold); }
@media (prefers-reduced-motion: no-preference) { .spin { animation: turn 1.1s cubic-bezier(.4, 0, .2, 1) infinite; } }
@keyframes turn { to { transform: rotate(360deg); } }

/* 결론 */
.hero-in { padding-block: 22px 30px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.dial { width: min(78vw, 300px); aspect-ratio: 1; }
.dial svg, .dial-sm svg { width: 100%; height: 100%; display: block; }
.dial text { fill: var(--sky-muted); font: 500 9.5px var(--body); }
.moment { color: var(--sky-muted); font-size: 16px; }
.hero h2 { font-size: clamp(34px, 10vw, 46px); line-height: 1.15; }
.hero .title { font: 400 20px/1.5 var(--display); color: var(--sky-ink); }
.three { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 8px; width: 100%; text-align: left; }
.three li { border-top: 1px solid var(--sky-line); padding-top: 8px; display: grid; gap: 2px; }
.three b { color: var(--gold); font-size: 16px; }
.three span { color: var(--sky-ink); }
.stripe { display: flex; width: 100%; height: 44px; border-radius: 10px; overflow: hidden; }
.stripe i { display: grid; place-items: center; font: 700 16px/1 var(--body); font-style: normal; color: var(--on-e); min-width: 0; }
.hero .stripe i { color: #0F1D2A; }
.hero .stripe .s0 { background: #73CB97; } .hero .stripe .s1 { background: #FF8E83; } .hero .stripe .s2 { background: #E3BD69; } .hero .stripe .s3 { background: #C3C9CF; } .hero .stripe .s4 { background: #93B9F6; }
.acts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
.acts .wide { grid-column: 1 / -1; min-height: 44px; }
.sky-note { color: var(--sky-muted); font-size: 16px; min-height: 1em; }

/* 차례 */
.chips { position: sticky; top: 52px; z-index: 4; background: var(--bg); border-bottom: 1px solid var(--line); }
.chips-in { max-width: 640px; margin: 0 auto; display: flex; gap: 6px; overflow-x: auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 10px max(16px, env(safe-area-inset-left, 0px)); scrollbar-width: none; }
.chips a { flex: none; display: inline-flex; align-items: center; min-height: 44px; color: var(--ink); text-decoration: none; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font-size: 16px; background: var(--paper); }

/* 본문 */
.body { max-width: 640px; margin: 0 auto; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); display: grid; gap: 14px; }
.sec { background: var(--paper); border: 1px solid var(--line); border-radius: 18px; padding: 20px 18px; display: grid; gap: 14px; scroll-margin-top: 110px; min-width: 0; }
.sec > *, .hero-in > *, .intake > * { min-width: 0; max-width: 100%; }
.sec h2 { font-size: 24px; line-height: 1.35; }
.sec h3 { font-size: 19px; margin-top: 6px; }
.sec-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.lead { font-size: 18px; }
.note { background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }
.note:empty { display: none; }
.stack { display: grid; gap: 10px; }
.stack p b { color: var(--accent); }

/* 여덟 글자 판 */
.boardwrap { overflow-x: auto; }
.board { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.board th { font-size: 16px; color: var(--muted); font-weight: 700; }
.board th[scope=row] { text-align: left; width: 4.6em; font-weight: 500; }
.board td { padding: 0; }
.board td button, .board td span.cell { width: 100%; min-height: 44px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 10px; padding: 6px 2px; display: grid; place-items: center; gap: 0; cursor: pointer; line-height: 1.25; font-size: 16px; }
.board td button.g { font: 800 26px/1.1 var(--display); padding: 8px 2px; }
.board td button.g small { font: 500 16px/1.2 var(--body); color: var(--muted); }
.board tr.deep { display: none; }
#r-board.deep .board tr.deep { display: table-row; }
#r-board.deep .board .void { box-shadow: inset 0 0 0 2px var(--warn); }
#r-board:not(.deep) .rel-deep, #r-board:not(.deep) .void-legend { display: none; }
.rel-sum { width: 100%; }
.offask { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 10px; }
.board span.cell { cursor: default; color: var(--muted); }
.e0 { color: var(--e0); } .e1 { color: var(--e1); } .e2 { color: var(--e2); } .e3 { color: var(--e3); } .e4 { color: var(--e4); }
.rels { display: flex; flex-wrap: wrap; gap: 8px; }
.rels button { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 6px 14px; min-height: 44px; cursor: pointer; font-size: 16px; }

/* 다섯 기운 */
.counts { display: grid; gap: 8px; }
.counts .stripe i { color: var(--on-e); }
.counts .stripe .s0 { background: var(--e0); } .counts .stripe .s1 { background: var(--e1); } .counts .stripe .s2 { background: var(--e2); } .counts .stripe .s3 { background: var(--e3); } .counts .stripe .s4 { background: var(--e4); }
.gauge-box { display: grid; gap: 6px; }
.gauge-top { display: flex; justify-content: space-between; align-items: baseline; }
.gauge-top b { font: 800 20px/1.3 var(--display); }
.gauge { position: relative; height: 12px; border-radius: 6px; background: var(--line); }
.gauge i { position: absolute; top: -5px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--accent); border: 3px solid var(--paper); }
.gauge .tick { position: absolute; top: -3px; width: 2px; height: 18px; background: var(--muted); }
.gauge .t45 { left: 45%; } .gauge .t55 { left: 55%; }
.gauge-scale { display: flex; justify-content: space-between; color: var(--muted); font-size: 16px; }
.yong { border: 2px solid var(--accent); border-radius: 14px; padding: 14px; display: grid; gap: 6px; }
.yong b { font: 800 20px/1.3 var(--display); }

/* 나 */
.tiles { display: grid; grid-template-columns: 1fr; gap: 10px; }
.tiles div { border-top: 2px solid var(--ink); padding-top: 8px; display: grid; gap: 4px; }
.tiles b { font: 800 18px/1.3 var(--display); }

/* 시기 */
.daeun { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.daeun button { flex: none; width: 74px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 12px; padding: 8px 4px; display: grid; gap: 2px; justify-items: center; cursor: pointer; }
.daeun button b { font: 800 22px/1.2 var(--display); }
.daeun button small { font-size: 16px; color: var(--muted); }
.daeun button.now { border: 2px solid var(--accent); background: var(--accent-soft); }
.daeun-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.years { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.years div { border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 4px; align-content: start; }
.years b { font: 800 20px/1.3 var(--display); }
.score { letter-spacing: 3px; color: var(--accent); font-size: 16px; }
.months { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; align-items: end; height: 150px; }
.months button { height: 100%; display: grid; grid-template-rows: 1fr auto; gap: 2px; border: 0; background: none; padding: 0; cursor: pointer; color: var(--ink); min-width: 0; }
.months i { align-self: end; display: block; border-radius: 6px 6px 2px 2px; background: var(--accent); opacity: .85; }
.months button.sel i { opacity: 1; box-shadow: 0 0 0 2px var(--gold); }
.months span { font-size: 16px; line-height: 1.1; text-align: center; }
.date-pick input { max-width: 260px; }

/* 오늘 */
.dodont { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.dodont div { border-radius: 14px; padding: 12px; display: grid; gap: 4px; }
.dodont .do { background: var(--accent-soft); }
.dodont .dont { border: 1px solid var(--line); }
.dodont b { font-size: 16px; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.week div { border-radius: 10px; padding: 6px 0; display: grid; gap: 0; font-size: 16px; }
.week .today { background: var(--accent); color: var(--on-accent); }
.week small { font-size: 16px; }

/* 궁합 */
.chemi-total { display: flex; align-items: baseline; gap: 8px; }
.chemi-total b { font: 800 44px/1 var(--display); color: var(--accent); }
.axes { display: grid; gap: 12px; }
.axis { display: grid; gap: 4px; }
.axis-top { display: flex; justify-content: space-between; }
.axis-bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.axis-bar i { display: block; height: 100%; background: var(--accent); }

/* AI */
textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.55; resize: vertical; }

/* 근거 */
.facts, .nots { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }

/* 보관함 */
.saverow { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; }
.saverow .primary { width: auto; }
.boxlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.boxlist li { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.boxlist button { min-height: 44px; }

/* 아래에서 열리는 뜻풀이 */
.sheet { border: 0; border-radius: 20px 20px 0 0; margin: auto auto 0; width: min(640px, 100%); max-width: 100%; background: var(--paper); color: var(--ink); padding: 22px max(18px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(18px, env(safe-area-inset-left, 0px)); display: grid; gap: 12px; }
.sheet:not([open]) { display: none; }
.sheet::backdrop { background: rgba(5, 10, 15, 0.55); }
.sheet h3 { font-size: 22px; }

.notice { color: var(--muted); font-size: 16px; text-align: center; padding-top: 8px; }
.ad { border: 1px dashed var(--line); border-radius: 12px; padding: 16px; text-align: center; color: var(--muted); }

@media (min-width: 560px) {
  .tiles { grid-template-columns: 1fr 1fr; }
  .three { grid-template-columns: repeat(3, 1fr); }
}
