:root {
  --bg: #f6f1e7;
  --paper: #fffdf8;
  --ink: #2b2620;
  --muted: #7a6f62;
  --line: #e4dccd;
  --accent: #8c2f23;
  --accent-ink: #fff;
  --wood: #3f7d4e;
  --fire: #c2412d;
  --earth: #b8862b;
  --metal: #8a8f98;
  --water: #2c4a6e;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
.serif, h1, h2, h3 { font-family: "Noto Serif KR", serif; }
a { color: var(--accent); }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }
header.top { padding: 20px 0 8px; display: flex; align-items: center; justify-content: space-between; }
header.top a.logo { text-decoration: none; color: var(--ink); font-family: "Noto Serif KR", serif; font-weight: 700; font-size: 20px; letter-spacing: .02em; }
header.top a.logo span { color: var(--accent); }

.hero { text-align: center; padding: 40px 0 28px; }
.hero h1 { font-size: clamp(28px, 6vw, 40px); margin: 0 0 12px; line-height: 1.3; }
.hero p { color: var(--muted); margin: 0; }

.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin: 16px 0; }
.card h2 { margin: 0 0 16px; font-size: 20px; }

form .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
form .row.two { grid-template-columns: 1fr 1fr; }
label { display: block; font-size: 14px; color: var(--muted); margin: 14px 0 6px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg label { flex: 1; margin: 0; text-align: center; padding: 10px; cursor: pointer; color: var(--ink); background: #fff; }
.seg input { display: none; }
.seg label:has(input:checked) { background: var(--ink); color: #fff; }
.check { display: flex; gap: 8px; align-items: center; color: var(--ink); font-size: 14px; margin-top: 10px; }
.check input { width: auto; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

button.primary {
  width: 100%; margin-top: 22px; padding: 15px; font: inherit; font-weight: 700; font-size: 17px;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 12px; cursor: pointer;
}
button.primary:disabled { opacity: .55; cursor: default; }
.error { color: var(--fire); font-size: 14px; margin-top: 10px; min-height: 1em; }

/* 사주 원국 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; text-align: center; }
.pillar .lbl { font-size: 13px; color: var(--muted); }
.pillar .god { font-size: 12px; color: var(--muted); min-height: 1.5em; }
.char {
  font-family: "Noto Serif KR", serif; font-size: clamp(26px, 7vw, 38px); font-weight: 700; color: #fff;
  border-radius: 12px; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
}
.char small { font-size: 12px; font-weight: 400; opacity: .9; font-family: "Noto Sans KR", sans-serif; }
.char.unknown { background: #e9e2d4; color: var(--muted); font-size: 18px; }
.el-목 { background: var(--wood); } .el-화 { background: var(--fire); } .el-토 { background: var(--earth); }
.el-금 { background: var(--metal); } .el-수 { background: var(--water); }
.pillar .sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.pillar.day .char { box-shadow: 0 0 0 3px var(--paper), 0 0 0 5px var(--accent); }

.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 44px 1fr 24px; align-items: center; gap: 8px; font-size: 14px; }
.bar .track { background: #efe8da; border-radius: 99px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 99px; }

.daewoon { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.dw { flex: 0 0 64px; text-align: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 4px; font-size: 13px; }
.dw b { display: block; font-family: "Noto Serif KR", serif; font-size: 17px; }
.dw.now { border-color: var(--accent); background: #fbf1ee; }
.meta { font-size: 14px; color: var(--muted); }
.notes { font-size: 13px; color: var(--muted); margin: 12px 0 0; padding-left: 18px; }

.preview p { margin: 0 0 10px; }
.paywall { text-align: center; }
.paywall .price { font-size: 30px; font-weight: 700; font-family: "Noto Serif KR", serif; }
.paywall ul { text-align: left; display: inline-block; margin: 12px 0 0; padding-left: 20px; }
.badge { display: inline-block; font-size: 12px; background: #fbf1ee; color: var(--accent); border-radius: 99px; padding: 2px 10px; }

.report h2 { font-size: 19px; margin: 28px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.report h2:first-child { margin-top: 0; }
.report h3 { font-size: 16px; margin: 18px 0 6px; }
.report p { margin: 0 0 12px; }
.cursor::after { content: "▍"; animation: blink 1s steps(1) infinite; color: var(--accent); }
@keyframes blink { 50% { opacity: 0; } }

.chat .msg { margin: 12px 0; padding: 12px 14px; border-radius: 12px; }
.chat .msg.user { background: #2b2620; color: #fff; margin-left: 15%; }
.chat .msg.assistant { background: #f3ede1; margin-right: 6%; }
.chat .msg p { margin: 0 0 8px; } .chat .msg p:last-child { margin: 0; }
.chat form { display: flex; gap: 8px; margin-top: 12px; }
.chat textarea { resize: vertical; min-height: 48px; }
.chat button { flex: 0 0 auto; padding: 0 18px; font: inherit; font-weight: 700; background: var(--accent); color: #fff; border: 0; border-radius: 10px; cursor: pointer; }
.chat button:disabled { opacity: .5; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.suggest button { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 13px; font-weight: 400; }

footer { color: var(--muted); font-size: 12px; text-align: center; padding: 24px 16px 40px; }
.hidden { display: none !important; }

/* 약관·방침 문서 */
.doc h1 { font-size: 26px; margin: 0 0 4px; }
.doc h2 { font-size: 17px; margin: 28px 0 8px; }
.doc h3 { font-size: 15px; margin: 18px 0 6px; }
.doc p, .doc li { font-size: 15px; }
.doc ol, .doc ul { padding-left: 22px; }
.doc li { margin: 4px 0; }
.table-wrap { overflow-x: auto; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.doc th, .doc td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.doc thead th, .doc tbody th { background: var(--bg); white-space: nowrap; }
.todo { color: var(--fire); }
footer .legal-links { margin-bottom: 8px; font-size: 13px; }
footer .legal-links a { color: var(--muted); }
footer p { margin: 6px 0; }
.notice { text-align: left; background: var(--bg); border-radius: 10px; padding: 12px 16px; margin-top: 18px; font-size: 14px; }
.notice p { margin: 0 0 4px; }
.notice ul { margin: 0 0 8px; padding-left: 18px; }
.notice .check { align-items: flex-start; }
.notice .check input { margin-top: 5px; }

@media (max-width: 520px) {
  .card { padding: 18px; }
  form .row { grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1c1915; --paper: #25211c; --ink: #ece4d6; --muted: #a59a8a; --line: #3a342c; --accent: #d8644f;
  }
  :root:not([data-theme="light"]) input, :root:not([data-theme="light"]) select, :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) .seg label, :root:not([data-theme="light"]) .suggest button { background: #1c1915; color: var(--ink); }
  :root:not([data-theme="light"]) .seg label:has(input:checked) { background: var(--ink); color: #1c1915; }
  :root:not([data-theme="light"]) .chat .msg.assistant { background: #2f2a23; }
  :root:not([data-theme="light"]) .chat .msg.user { background: #3d362d; }
  :root:not([data-theme="light"]) .bar .track { background: #332e27; }
  :root:not([data-theme="light"]) .dw.now, :root:not([data-theme="light"]) .badge { background: #3a2622; }
  :root:not([data-theme="light"]) .char.unknown { background: #332e27; }
}
