:root {
  --paper: #f4f4ef;
  --surface: #ffffff;
  --sunk: #ebebe4;
  --ink: #1c2126;
  --muted: #5d666e;
  --line: #d9d8cf;
  --accent: #2e6b64;
  --accent-soft: #dbe9e5;
  --seal: #b0362a;
  --card-back: #1f3b45;
  --card-back-2: #2e5560;
  --card-face: #fbfaf5;
  --wood: #4b8757; --fire: #c4533c; --earth: #a88434; --metal: #7f858d; --water: #2f4f7a;
  --serif: "Noto Serif KR", "Nanum Myeongjo", "Batang", serif;
  --sans: "IBM Plex Sans KR", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #121518; --surface: #1a1e22; --sunk: #0e1113; --ink: #e6e3da; --muted: #9aa2a9;
    --line: #2c3238; --accent: #7cb9ae; --accent-soft: #1f3431; --seal: #e0715f;
    --card-back: #183038; --card-back-2: #27505a; --card-face: #f3f0e6;
    --wood: #72b07e; --fire: #e27a63; --earth: #d0ad5b; --metal: #a9afb7; --water: #6f95c9;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #121518; --surface: #1a1e22; --sunk: #0e1113; --ink: #e6e3da; --muted: #9aa2a9;
  --line: #2c3238; --accent: #7cb9ae; --accent-soft: #1f3431; --seal: #e0715f;
  --card-back: #183038; --card-back-2: #27505a; --card-face: #f3f0e6;
  --wood: #72b07e; --fire: #e27a63; --earth: #d0ad5b; --metal: #a9afb7; --water: #6f95c9;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.75 var(--sans);
  word-break: keep-all;
  overflow-wrap: break-word;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 600; line-height: 1.35; margin: 0; text-wrap: balance; }
p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.wrap { max-width: 1080px; margin: 0 auto; padding-inline: 20px; }
@media (max-width: 480px) { .wrap { padding-inline: 16px; } }

/* 헤더 */
.top {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.top .wrap { display: flex; align-items: center; gap: 24px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; }
.seal {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--seal); color: #fff; border-radius: 3px;
  font-family: var(--serif); font-size: 17px; font-weight: 700; line-height: 1;
}
.brand b { font-family: var(--serif); font-size: 18px; letter-spacing: .04em; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted);
  white-space: nowrap; font-size: 14px;
}
.nav a:hover { color: var(--ink); }
.nav a[aria-current="page"] { background: var(--ink); color: var(--paper); }
.theme-btn { border: 1px solid var(--line); background: transparent; border-radius: 999px; width: 34px; height: 34px; cursor: pointer; flex-shrink: 0; }
@media (max-width: 720px) {
  .top .wrap { flex-wrap: wrap; gap: 8px 12px; padding-block: 10px; }
  .nav { order: 3; width: 100%; margin-left: 0; }
  .theme-btn { margin-left: auto; }
}

main { padding-block: 40px 80px; }
section.page > .wrap { display: grid; gap: 48px; }

.eyebrow { font-size: 12px; letter-spacing: .14em; color: var(--accent); font-weight: 600; text-transform: uppercase; }
.page-head { display: grid; gap: 10px; max-width: 680px; }
.page-head h1 { font-size: clamp(28px, 4.2vw, 40px); }
.page-head p { color: var(--muted); }
.block { display: grid; gap: 18px; }
.block > h2 { font-size: 22px; display: flex; align-items: baseline; gap: 10px; }
.block > h2 small { font-family: var(--sans); font-size: 13px; font-weight: 400; color: var(--muted); }
.prose { max-width: 68ch; display: grid; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--paper); cursor: pointer; font-weight: 500; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn:hover { opacity: .88; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-size: 14px;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--paper); }

.form { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: flex-end; }
.field { display: grid; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); letter-spacing: .04em; }
.field input, .field select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper);
  min-width: 0;
}
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

table.t { border-collapse: collapse; width: 100%; font-size: 14px; }
.t th, .t td { border-bottom: 1px solid var(--line); padding: 9px 10px; text-align: left; vertical-align: top; }
.t th { font-weight: 600; color: var(--muted); font-size: 12px; letter-spacing: .06em; }
.scroll-x { overflow-x: auto; }

/* 오행 색 */
.el-0 { --el: var(--wood); } .el-1 { --el: var(--fire); } .el-2 { --el: var(--earth); }
.el-3 { --el: var(--metal); } .el-4 { --el: var(--water); }
.el-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--el); }

/* 홈 */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; }
.hero h1 { font-size: clamp(34px, 5.5vw, 56px); line-height: 1.2; letter-spacing: -.01em; }
.hero h1 em { font-style: normal; color: var(--seal); }
.hero-lead { color: var(--muted); max-width: 46ch; margin-top: 16px; font-size: 16px; }
.hero .chips { margin-top: 24px; }
.today { display: grid; gap: 14px; }
.today-row { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; }
.pillar-mini { font-family: var(--serif); font-size: 40px; line-height: 1.05; display: grid; text-align: center; font-weight: 700; }
.pillar-mini span { color: var(--el); }
@media (max-width: 800px) { .hero { grid-template-columns: 1fr; } }

.links { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.links a { background: var(--surface); padding: 20px; text-decoration: none; color: var(--ink); display: grid; gap: 6px; }
.links a:hover { background: var(--accent-soft); }
.links .hz { font-family: var(--serif); font-size: 30px; color: var(--accent); line-height: 1; }
.links b { font-family: var(--serif); font-size: 17px; }
.links span { font-size: 13px; color: var(--muted); }

/* 타로 카드 */
.spread { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.spread.one { grid-template-columns: minmax(160px, 220px); justify-content: center; }
.slot { display: grid; gap: 8px; justify-items: center; text-align: center; }
.slot .pos { font-size: 12px; color: var(--muted); letter-spacing: .06em; }
.tcard {
  width: 100%; max-width: 200px; aspect-ratio: 5 / 8; perspective: 900px; cursor: pointer;
  border: 0; padding: 0; background: none;
}
.tcard .inner { position: relative; width: 100%; height: 100%; transition: transform .6s cubic-bezier(.3,.7,.3,1); transform-style: preserve-3d; }
.tcard.open .inner { transform: rotateY(180deg); }
.tcard .face, .tcard .back { position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden; }
.tcard .back {
  background:
    radial-gradient(circle at 50% 50%, transparent 22%, var(--card-back) 23%, var(--card-back) 26%, transparent 27%),
    repeating-linear-gradient(45deg, var(--card-back) 0 6px, var(--card-back-2) 6px 7px),
    var(--card-back);
  border: 5px solid var(--card-face);
  box-shadow: 0 0 0 1px var(--line), 0 6px 16px rgb(0 0 0 / .12);
}
.tcard .face {
  transform: rotateY(180deg); background: var(--card-face); color: #1c2126;
  border: 1px solid #cfccbf; box-shadow: 0 6px 16px rgb(0 0 0 / .12);
  display: grid; grid-template-rows: auto 1fr auto; padding: 10px; text-align: center;
}
.tcard.rev .face .art { transform: rotate(180deg); }
.face .num { font-family: var(--serif); font-size: 13px; letter-spacing: .1em; color: #6b6554; }
.face .art { display: grid; place-items: center; }
.face .art svg { width: 62%; height: auto; }
.face .nm { font-family: var(--serif); font-size: 14px; font-weight: 600; line-height: 1.3; }
.face .en { font-size: 10px; color: #6b6554; letter-spacing: .06em; }
.rev-tag { font-size: 11px; color: var(--seal); font-weight: 600; }
.reading { display: grid; gap: 14px; }
.reading article { display: grid; gap: 4px; padding-block: 14px; border-top: 1px solid var(--line); }
.reading h4 { font-size: 17px; }
.kw { font-size: 13px; color: var(--accent); }

.lib { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.lib .tcard { max-width: none; }
.lib .tcard .inner { transform: rotateY(180deg); }

dialog {
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
  max-width: min(560px, calc(100vw - 32px)); padding: 28px; width: 100%;
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
.dlg-grid { display: grid; grid-template-columns: 130px 1fr; gap: 22px; }
@media (max-width: 480px) { .dlg-grid { grid-template-columns: 1fr; } .dlg-grid .tcard { max-width: 140px; margin: 0 auto; } }
.dlg-close { float: right; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }

/* 사주 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; max-width: 560px; }
.pillar { display: grid; gap: 6px; text-align: center; }
.pillar .lbl { font-size: 12px; color: var(--muted); letter-spacing: .08em; }
.pillar .god { font-size: 12px; color: var(--muted); min-height: 1.4em; }
.gz {
  aspect-ratio: 1; display: grid; place-items: center; border-radius: var(--radius);
  background: color-mix(in srgb, var(--el) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--el) 40%, transparent);
  font-family: var(--serif); font-weight: 700; font-size: clamp(26px, 6vw, 40px); color: var(--el); line-height: 1;
}
.gz small { display: block; font-family: var(--sans); font-size: 11px; font-weight: 500; margin-top: 4px; }
.gz.empty { --el: var(--muted); opacity: .5; }
.pillar.day .gz { box-shadow: 0 0 0 2px var(--ink); }
.bars { display: grid; gap: 10px; }
.bar { display: grid; grid-template-columns: 56px 1fr 30px; align-items: center; gap: 10px; font-size: 14px; }
.bar .track { height: 10px; background: var(--sunk); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--el); border-radius: 999px; transition: width .5s; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 760px) { .result-grid { grid-template-columns: 1fr; } }

/* 주역 */
.hex { display: grid; gap: 6px; width: 96px; }
.hex i { display: block; height: 10px; background: var(--ink); border-radius: 2px; }
.hex i.yin { background: linear-gradient(90deg, var(--ink) 0 42%, transparent 42% 58%, var(--ink) 58%); }
.hex i.chg { background-color: var(--seal); }
.hex i.yin.chg { background: linear-gradient(90deg, var(--seal) 0 42%, transparent 42% 58%, var(--seal) 58%); }
.hex.sm { width: 40px; gap: 3px; }
.hex.sm i { height: 4px; }
.cast { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.cast-col { display: grid; gap: 10px; justify-items: start; }
.cast-log { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.hexlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.hexlist button { background: var(--surface); border: 0; padding: 14px; display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; text-align: left; cursor: pointer; }
.hexlist button:hover { background: var(--accent-soft); }
.hexlist .n { font-size: 11px; color: var(--muted); }
.hexlist b { font-family: var(--serif); font-size: 15px; display: block; }
.tri { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 12px; }
.tri div { text-align: center; padding: 14px 8px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.tri .s { font-size: 34px; line-height: 1.1; }
.tri b { font-family: var(--serif); display: block; }

/* 풍수 / 철학 */
.compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; max-width: 380px; aspect-ratio: 1; }
.compass div {
  border-radius: 4px; display: grid; place-items: center; text-align: center; padding: 4px;
  font-size: 12px; line-height: 1.35; background: var(--sunk);
}
.compass div b { display: block; font-size: 14px; font-family: var(--serif); }
.compass .good { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.compass .best { background: var(--accent); color: var(--paper); }
.compass .bad { background: color-mix(in srgb, var(--seal) 14%, var(--surface)); }
.compass .worst { background: var(--seal); color: #fff; }
.compass .center { background: var(--surface); border: 1px solid var(--line); font-family: var(--serif); font-size: 26px; }
.term { display: grid; gap: 4px; padding: 16px 0; border-top: 1px solid var(--line); }
.term h3 { font-size: 18px; }
.term h3 span { font-size: 14px; color: var(--muted); font-weight: 400; margin-left: 6px; }
.cycle-svg { width: 100%; max-width: 420px; height: auto; }
.gz60 { display: grid; grid-template-columns: repeat(10, minmax(42px, 1fr)); gap: 4px; min-width: 460px; }
.gz60 div { text-align: center; font-family: var(--serif); padding: 6px 0; border-radius: 4px; background: var(--surface); border: 1px solid var(--line); font-size: 15px; line-height: 1.2; }
.gz60 small { display: block; font-family: var(--sans); font-size: 10px; color: var(--muted); }

footer { border-top: 1px solid var(--line); padding-block: 28px; color: var(--muted); font-size: 13px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
