/* 만세력 · 파스텔 미니멀 (봄꽃 색감 + 고운돋움).
   색은 오행 글자판에만 쓰고, 나머지는 흰 바탕에 글자만 줄 맞춰 둔다.
   글자판은 연한 파스텔 바탕에 같은 색 계열의 진한 글자: 흰 글자보다 잘 읽힌다. */
@font-face { font-family: "Gowun Dodum"; font-display: swap; src: url(fonts/GowunDodum-Regular.woff2) format("woff2"); }
/* 간지 22자와 로고 글자만 남긴 Noto Serif KR. 본문 글꼴에 없는 한자도 이 글꼴로 채운다. */
/* unicode-range keeps the browser from waiting on this file for hangul or digits. */
@font-face { font-family: "Ganji Serif"; font-weight: 200 900; font-display: swap; src: url(fonts/NotoSerifKR-ganji.woff2) format("woff2");
  unicode-range: U+7532, U+4E59, U+4E19, U+4E01, U+620A, U+5DF1, U+5E9A, U+8F9B, U+58EC, U+7678, U+5B50, U+4E11, U+5BC5, U+536F, U+8FB0, U+5DF3, U+5348, U+672A, U+7533, U+9149, U+620C, U+4EA5, U+842C; }

:root {
  --bg: #fdfbf8; --card: #ffffff; --ink: #3d3a40; --muted: #736e78; --line: #eee8e4; --soft: #f6f1ee;
  --accent: #e07d97; --accent-ink: #b4466a; --accent-soft: #fdeef2;
  --wood: #c4e6d2; --wood-ink: #2d5c45;
  --fire: #f9c9d3; --fire-ink: #8a3148;
  --earth: #fae3ad; --earth-ink: #77580f;
  --metal: #e7e3ea; --metal-ink: #55505e;
  --water: #c8d7f3; --water-ink: #2c4577;
  --hanja: "Ganji Serif", "Noto Serif KR", "Batang", serif;
  font-family: "Gowun Dodum", "Ganji Serif", "Malgun Gothic", sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.app { max-width: 440px; margin: 0 auto; padding: 20px 18px 40px; }
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.top h1 { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 1.25rem; font-weight: 400; }
.logo { width: 18px; height: 18px; border-radius: 50%; background: conic-gradient(var(--wood) 0 20%, var(--fire) 0 40%, var(--earth) 0 60%, var(--metal) 0 80%, var(--water) 0); }
.icon-button { min-width: 44px; height: 44px; border: 0; background: none; color: var(--accent-ink); font-size: 1.5rem; cursor: pointer; }

h2 { margin: 0 0 10px; font-size: 1rem; font-weight: 400; }
h2 span { margin-left: 6px; color: var(--muted); font-size: .8rem; }

.summary { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 10px 0 12px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.summary strong { color: var(--ink); font-size: 1.15rem; font-weight: 400; }
.bar { width: 1px; height: 10px; background: var(--line); }
.note { margin: 12px 0 0; color: var(--muted); font-size: .82rem; text-align: center; }
.error { padding: 14px; border-radius: 12px; background: #fff0f0; color: #b3261e; }

/* 네 기둥 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.column { display: flex; flex-direction: column; gap: 4px; text-align: center; }
.pill { color: var(--muted); font-size: .95rem; }
.column:nth-child(2) .pill { color: var(--accent-ink); }
.column:nth-child(2) .pill::after { content: " · 나"; }
.sub { min-height: 1.3em; font-size: .9rem; }
.tile { display: grid; place-items: center; font-family: var(--hanja); font-weight: 500; }
.tile-big { aspect-ratio: 1; border-radius: 26%; font-size: clamp(2rem, 10vw, 2.9rem); }
.tile-small { height: 34px; border-radius: 26%; font-size: 1rem; }
.tile-empty { background: var(--soft); color: var(--muted); }
/* 일주는 천간·지지 두 칸을 테두리 하나로 묶는다. 칸마다 두르면 사이 간격보다 테두리가 커서 서로 겹친다. */
.stack { display: flex; flex-direction: column; gap: 4px; border-radius: 26cqw; }
.column { container-type: inline-size; }
.column:nth-child(2) .stack { box-shadow: 0 0 0 3px var(--card), 0 0 0 5px var(--accent); }
.el-wood { background: var(--wood); color: var(--wood-ink); }
.el-fire { background: var(--fire); color: var(--fire-ink); }
.el-earth { background: var(--earth); color: var(--earth-ink); }
.el-metal { background: var(--metal); color: var(--metal-ink); }
.el-water { background: var(--water); color: var(--water-ink); }

/* 대운 */
.dayun { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.cycles { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; scroll-snap-type: x mandatory; }
.cycle { flex: 0 0 46px; display: flex; flex-direction: column; gap: 3px; padding: 4px 0; border-radius: 10px; text-align: center; scroll-snap-align: start; }
.cycle.current { background: var(--accent-soft); }
.age, .cycle-god { color: var(--muted); font-size: .72rem; }
.cycle.current .age { color: var(--accent-ink); }

/* 지장간 · 십이운성 · 납음: 글자만, 일주 칸만 강조색 */
.row { display: grid; grid-template-columns: 80px 1fr; align-items: center; gap: 8px; padding: 6px 0; }
.row:first-of-type { margin-top: 10px; padding-top: 14px; border-top: 1px solid var(--line); }
.row-title { color: var(--muted); font-size: .85rem; }
.row-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.chip { text-align: center; font-size: .9rem; }
.row-cells .chip:nth-child(2) { color: var(--accent-ink); }

.warnings { margin: 12px 0; color: var(--muted); font-size: .8rem; }
.warnings summary { padding: 6px 0; cursor: pointer; }
.warnings ul { padding-left: 18px; }
.primary { width: 100%; margin-top: 8px; padding: 14px; border: 0; border-radius: 8px; background: var(--accent-ink); color: #fff; font-size: 1rem; cursor: pointer; }
.link-button { padding: 10px 0; border: 0; background: none; color: var(--accent-ink); text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }

/* 저장한 명식 */
.saved-box { margin-top: 24px; padding-top: 14px; border-top: 1px solid var(--line); }
#saved { list-style: none; margin: 0; padding: 0; }
#saved li { display: flex; align-items: center; }
#saved .empty { color: var(--muted); font-size: .9rem; }
.saved-open { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.saved-open span { color: var(--muted); font-size: .85rem; }
.saved-remove { width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }

/* 입력: 늘 보이는 한 줄 입력 (이름 · 생년월일시 숫자 · 글자로 고르는 성별과 달력) */
.entry { display: grid; gap: 8px; margin-bottom: 18px; }
.entry input:not([type="radio"]), .entry select { width: 100%; padding: 13px 14px; border: 0; border-radius: 6px; background: var(--soft); color: var(--ink); font-size: 16px; }
.entry input::placeholder { color: var(--muted); }
.entry input[aria-invalid="true"] { outline: 2px solid var(--accent-ink); }
.toggles { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; }
.segmented { display: flex; gap: 14px; }
.segmented label { display: block; padding: 8px 0; color: var(--muted); font-size: .95rem; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { color: var(--ink); text-decoration: underline; text-underline-offset: 6px; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.more summary { padding: 4px 0; color: var(--muted); font-size: .85rem; cursor: pointer; }
.more select { margin-top: 6px; }
.help { margin: 0; color: var(--muted); font-size: .8rem; }
.field-error { margin: 0; color: var(--accent-ink); font-size: .85rem; }
.field-error:empty { display: none; }
.entry .primary { margin-top: 2px; }

/* 넓은 화면: 명식은 왼쪽 흰 판, 입력과 저장 목록은 오른쪽 */
@media (min-width: 960px) {
  .app { max-width: 920px; display: grid; grid-template-columns: minmax(0, 1fr) 300px; grid-template-rows: auto auto 1fr; column-gap: 40px; padding-top: 36px; }
  .top { grid-column: 1 / -1; }
  #chart { grid-column: 1; grid-row: 2 / 4; align-self: start; padding: 18px 22px 22px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
  .entry { grid-column: 2; grid-row: 2; }
  .saved-box { grid-column: 2; grid-row: 3; align-self: start; margin-top: 6px; }
  .pillars { max-width: 420px; margin-inline: auto; }
  .tile-big { font-size: 2.6rem; }
  .cycles { overflow: visible; }
}
