/* 사주 프로토타입 공용 컴포넌트 스타일 (tokens.css 필요). 개발자는 클래스명·구조 참고용으로 사용 */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: var(--font-sans); background: var(--bg); color: var(--text); line-height: var(--lh-body); word-break: keep-all; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hanja { font-family: var(--font-serif-ko); font-weight: 700; }

.app { max-width: var(--content-max); margin: 0 auto; padding: 0 var(--sp-4) 96px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 56px; border-bottom: 1px solid var(--line); margin: 0 calc(var(--sp-4) * -1) var(--sp-5); padding: 0 var(--sp-4); }
.brand { font-weight: 800; letter-spacing: .14em; font-size: var(--fs-sm); }
.brand small { font-family: var(--font-serif-en); font-style: italic; color: var(--accent); letter-spacing: .06em; margin-left: 6px; font-size: var(--fs-md); }
.icon-btn { min-width: var(--tap-min); min-height: var(--tap-min); border: 0; background: none; border-radius: var(--radius-pill); cursor: pointer; color: var(--text-muted); }

h1 { font-family: var(--font-serif-ko); font-size: var(--fs-2xl); line-height: var(--lh-tight); margin-bottom: var(--sp-2); }
h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }
.lead { color: var(--text-muted); font-size: var(--fs-sm); margin-bottom: var(--sp-5); }
.kicker { font-size: var(--fs-xs); letter-spacing: .3em; color: var(--accent); margin-bottom: var(--sp-2); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--sp-4); margin-bottom: var(--sp-4); }
.badge { display: inline-flex; align-items: center; min-height: 24px; padding: 0 10px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); font-size: var(--fs-xs); color: var(--accent); }
.notice { font-size: var(--fs-xs); color: var(--text-muted); border-left: 3px solid var(--line-strong); padding: var(--sp-2) var(--sp-3); margin: var(--sp-3) 0; }
.notice.banner { background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

/* 폼 */
.field { margin-bottom: var(--sp-5); border: 0; }
.field > legend, .field > label.lbl { display: block; font-size: var(--fs-sm); font-weight: 600; margin-bottom: var(--sp-2); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-pill); padding: 3px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 40px; border-radius: var(--radius-pill); font-size: var(--fs-sm); cursor: pointer; color: var(--text-muted); }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.row { display: grid; gap: var(--sp-2); }
.row.c3 { grid-template-columns: 1.4fr 1fr 1fr; }
.row.c2 { grid-template-columns: 1fr 1fr; }
.input { width: 100%; min-height: var(--tap-min); padding: 0 var(--sp-3); background: var(--surface); border: 1px solid var(--line-ui, var(--line-strong)); border-radius: var(--radius-sm); }
.input::placeholder { color: var(--text-muted); opacity: 1; }
.input:disabled { opacity: .5; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.err { color: var(--danger); font-size: var(--fs-xs); margin-top: var(--sp-2); }
.check { display: flex; align-items: center; gap: var(--sp-2); min-height: var(--tap-min); font-size: var(--fs-sm); }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.opt-summary { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-3); min-height: var(--tap-min); font-size: var(--fs-sm); color: var(--text-muted); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.opt-summary a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 10px 0; }

.btn { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); width: 100%; min-height: 52px; border-radius: var(--radius-pill); border: 1px solid transparent; font-weight: 700; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--accent-grad); color: var(--accent-ink); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--text); }
.privacy { display: flex; gap: var(--sp-2); font-size: var(--fs-xs); color: var(--text-muted); margin-top: var(--sp-4); }

/* 원국 표 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-2); }
.pillar { text-align: center; }
.pillar .col-h { font-size: var(--fs-xs); color: var(--text-muted); margin-bottom: var(--sp-1); }
.glyph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 92px; padding: var(--sp-2) 0; margin-bottom: var(--sp-2); border-radius: var(--radius-sm); background: var(--el-bg); border: 1px solid var(--el); color: var(--el); }
.glyph .hj { font-family: var(--font-serif-ko); font-weight: 700; font-size: var(--fs-hanja); line-height: 1.1; }
.glyph .ko { font-size: var(--fs-xs); color: var(--text); }
.glyph .el-tag { font-size: 11px; font-weight: 700; }
.glyph.day-master { outline: 2px solid var(--accent); outline-offset: 2px; }
.glyph.unknown { --el: var(--text-muted); --el-bg: transparent; border-style: dashed; color: var(--text-muted); }
.tengod { font-size: var(--fs-xs); color: var(--text-muted); min-height: 20px; }
.pillars .day-label { color: var(--accent); font-weight: 700; }

/* 오행 막대 */
.bars { display: grid; gap: var(--sp-3); }
.bar-row { display: grid; grid-template-columns: 56px 1fr 32px; align-items: center; gap: var(--sp-3); font-size: var(--fs-sm); }
.bar-row .name { color: var(--el); font-weight: 700; }
.bar-track { height: 14px; background: var(--surface-2); border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill { height: 100%; background: var(--el); border-radius: var(--radius-pill); min-width: 2px; }
.bar-row.zero .bar-fill { background: repeating-linear-gradient(45deg, var(--el) 0 3px, transparent 3px 7px); opacity: .5; }
.bar-row .n { text-align: right; font-variant-numeric: tabular-nums; }

/* 십신 칩, 일간 카드 */
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip { min-height: 32px; padding: 0 12px; display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface-2); font-size: var(--fs-sm); cursor: pointer; }
.chip b { color: var(--accent); }
.dm-card { display: grid; grid-template-columns: 72px 1fr; gap: var(--sp-4); align-items: center; }
.dm-card .glyph { min-height: 84px; margin: 0; }
.kw { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin: var(--sp-2) 0; }
.kw span { font-size: var(--fs-xs); padding: 2px 10px; border-radius: var(--radius-pill); background: var(--el-bg); color: var(--el); border: 1px solid var(--el); }

/* 대운 타임라인 */
.timeline { display: flex; gap: var(--sp-2); overflow-x: auto; padding: var(--sp-1) 2px var(--sp-3); scroll-snap-type: x proximity; }
.tl-item { flex: 0 0 68px; scroll-snap-align: start; text-align: center; padding: var(--sp-2) 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.tl-item .age { font-size: var(--fs-xs); color: var(--text-muted); }
.tl-item .hj { font-family: var(--font-serif-ko); font-weight: 700; font-size: 1.25rem; color: var(--el); line-height: 1.2; }
.tl-item .ko { font-size: 11px; }
.tl-item.current { border: 2px solid var(--accent); background: var(--surface-2); }
.tl-item.current .age { color: var(--accent); font-weight: 700; }
.yr-list { display: grid; gap: var(--sp-2); font-size: var(--fs-sm); }
.yr-list li { list-style: none; display: grid; grid-template-columns: 52px 72px 1fr; gap: var(--sp-2); align-items: baseline; }
.yr-list .hj { font-family: var(--font-serif-ko); font-weight: 700; color: var(--el); }
.yr-list .now { color: var(--accent); font-weight: 700; }

/* 고정 액션 바 */
.action-bar { position: fixed; inset: auto 0 0; z-index: 10; display: flex; justify-content: center; background: var(--bg); border-top: 1px solid var(--line); padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + env(safe-area-inset-bottom)); }
.action-bar .in { width: 100%; max-width: var(--content-max); display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--sp-2); }
.action-bar button, .action-bar a { min-height: var(--tap-min); border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface); font-size: var(--fs-sm); font-weight: 600; cursor: pointer; display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); }
.action-bar .primary { background: var(--accent-grad); color: var(--accent-ink); border-color: transparent; }
.footer { font-size: var(--fs-xs); color: var(--text-muted); border-top: 1px solid var(--line); padding-top: var(--sp-4); margin-top: var(--sp-5); }
.footer p + p { margin-top: var(--sp-2); }
.theme-toggle { font-size: var(--fs-xs); }
