/* 마음 상담소 — 흰 배경, 얇은 테두리, 보라색 강조 */
:root {
  --bg: #f5f6fa;
  --bg-grad: none;
  --surface: #ffffff;
  --surface-2: #f9f9fb;
  --ink: #222222;
  --muted: #666b7c;
  --line: #e1e1e1;
  --brand: #6a4bd6;
  --accent: #6a4bd6;
  --accent-soft: #efeafd;
  --seal: #e5484d;
  --on-accent: #ffffff;
  --shadow: 0 1px 2px rgba(20, 20, 50, .05), 0 6px 20px rgba(20, 20, 50, .06);
  --star-off: #e1e1e1;
  --star-on: #ff9000;

  --el0: #3f8a5a; --el1: #c8452f; --el2: #a9791c; --el3: #6f7888; --el4: #2f4f8f;
  --el0-bg: #e4f1e8; --el1-bg: #fbe6df; --el2-bg: #f6ecd0; --el3-bg: #e8eaee; --el4-bg: #e0e8f6;

  --h1: #3f6fd0; --h2: #a9c4f2; --h3: #f5e6b8; --h4: #f4a27a; --h5: #cc2f2f;
  --h1-t: #ffffff; --h2-t: #10264d; --h3-t: #4a3a0c; --h4-t: #4a1a08; --h5-t: #ffffff;

  --serif: "Noto Serif KR", "Nanum Myeongjo", "Batang", serif;
  --sans: "Noto Sans KR", "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif;
  --r: 16px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { color-scheme: dark; --bg: #11121a; --surface: #1b1d2b; --surface-2: #222437; --ink: #eceef6; --muted: #a3a8bf; --line: #2f3248; --brand: #7c5ce6; --accent: #b7a4ff; --accent-soft: #2b2650; --seal: #ff7b80; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .25); --star-off: #3a3e58; --star-on: #ffa726;
    --el0: #6fcf8f; --el1: #ff8a72; --el2: #e6bd5a; --el3: #b6bfd0; --el4: #7fa6ff; --el0-bg: #1c3428; --el1-bg: #3b2222; --el2-bg: #383016; --el3-bg: #2a2f45; --el4-bg: #1e2c52;
    --h1: #2a4f9e; --h2: #5b86c8; --h3: #c9b36a; --h4: #e2803f; --h5: #f05a5a; --h1-t: #ffffff; --h2-t: #0c1a33; --h3-t: #2a2108; --h4-t: #2a0f04; --h5-t: #2b0606; }
}
:root[data-theme="dark"] { color-scheme: dark; --bg: #11121a; --surface: #1b1d2b; --surface-2: #222437; --ink: #eceef6; --muted: #a3a8bf; --line: #2f3248; --brand: #7c5ce6; --accent: #b7a4ff; --accent-soft: #2b2650; --seal: #ff7b80; --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 28px rgba(0, 0, 0, .25); --star-off: #3a3e58; --star-on: #ffa726;
  --el0: #6fcf8f; --el1: #ff8a72; --el2: #e6bd5a; --el3: #b6bfd0; --el4: #7fa6ff; --el0-bg: #1c3428; --el1-bg: #3b2222; --el2-bg: #383016; --el3-bg: #2a2f45; --el4-bg: #1e2c52;
  --h1: #2a4f9e; --h2: #5b86c8; --h3: #c9b36a; --h4: #e2803f; --h5: #f05a5a; --h1-t: #ffffff; --h2-t: #0c1a33; --h3-t: #2a2108; --h4-t: #2a0f04; --h5-t: #2b0606; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg) var(--bg-grad) no-repeat; color: var(--ink);
  font: 400 16px/1.7 var(--sans); word-break: keep-all; overflow-wrap: break-word;
  min-height: 100vh;
}
.wrap { width: min(760px, 100% - 32px); margin-inline: auto; }
h1, h2, h3 { font-family: var(--sans); font-weight: 700; line-height: 1.35; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 .8em; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* 헤더 */
.top { position: relative; padding: 14px 0 6px; }
.top-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit; }
.brand-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--brand); color: #fff; font: 700 24px/1 var(--serif); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25); transform: rotate(-3deg); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font: 700 18px/1.25 var(--serif); }
.brand-text small { color: var(--muted); font-size: 12.5px; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 20px; }
.icon-btn:hover { background: var(--surface-2); }

/* 카드 · 공통 */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 24px; margin: 14px 0; }
.eyebrow { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: .06em; margin-bottom: 10px; }
.lead { color: var(--muted); margin-top: 14px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.error { color: var(--seal); font-weight: 500; margin: 12px 0 0; }
.sec-title { font-size: 20px; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; }
.sec-title .num { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); font: 700 14px/1 var(--sans); }

/* 입력 폼 */
.intro-head h1 { font-size: clamp(26px, 5.6vw, 38px); }
form { margin-top: 26px; display: grid; gap: 22px; }
.field { border: 0; padding: 0; margin: 0; min-width: 0; }
.field > label:first-child, legend { display: block; font-weight: 700; margin-bottom: 8px; padding: 0; }
label.sub { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
input[type="text"], input[type="number"], input[type="time"], input[type="date"], select {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); appearance: none; -webkit-appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 55%, calc(100% - 14px) 55%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.row3 { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.row-time { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.row-time input[type="time"] { width: 170px; }
.row-time input:disabled { opacity: .45; }
.seg { display: inline-flex; flex-wrap: wrap; gap: 6px; padding: 4px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg span { display: block; padding: 9px 18px; border-radius: 10px; font-weight: 500; min-height: 40px; }
.seg input:checked + span { background: var(--brand); color: #fff; font-weight: 700; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; margin-top: 10px; }
.check input { width: 20px; height: 20px; margin-top: 3px; accent-color: var(--accent); flex: none; }
.check.small { font-size: 14px; color: var(--muted); }
.check em { font-style: normal; color: var(--muted); font-size: 13px; }
.row-time .check { margin: 0; }

.btn { border: 1.5px solid var(--line); background: var(--surface); border-radius: 12px; padding: 10px 18px; cursor: pointer; font-weight: 500; min-height: 44px; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.15); }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn.ghost { background: transparent; }

/* 입력 확인 배너 */
.confirm { display: flex; gap: 14px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; margin-top: 4px; background: linear-gradient(135deg, var(--surface), var(--surface-2)); }
.confirm p { margin: 0; }
.confirm b { color: var(--accent); }
.confirm .pills { margin-top: 6px; color: var(--muted); font-size: 14px; }

/* 탭 */
.tabbar { position: sticky; top: 0; z-index: 10; display: flex; gap: 4px; padding: 8px 0; margin: 6px 0 0; overflow-x: auto; scrollbar-width: none; background: linear-gradient(var(--bg) 75%, transparent); }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar button { flex: 1 0 auto; white-space: nowrap; border: 1.5px solid transparent; background: transparent; padding: 10px 16px; border-radius: 999px; cursor: pointer; font-weight: 500; color: var(--muted); min-height: 44px; }
.tabbar button:hover { color: var(--ink); background: var(--surface-2); }
.tabbar button[aria-selected="true"] { background: var(--ink); color: var(--bg); font-weight: 700; }
#panel:focus { outline: none; }

/* 별점 */
.stars { --v: 3; display: inline-block; font-size: 22px; letter-spacing: 3px; line-height: 1; white-space: nowrap; vertical-align: middle; }
.stars::before { content: "★★★★★"; background: linear-gradient(90deg, var(--star-on) calc(var(--v) * 20%), var(--star-off) calc(var(--v) * 20%)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.stars.sm { font-size: 16px; letter-spacing: 2px; }
.score-num { font-weight: 700; margin-left: 8px; color: var(--muted); font-size: 14px; }

/* 결과 - 헤드 */
.day-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.day-head h2 { font-size: clamp(21px, 4.6vw, 28px); }
.nav-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-btns .btn { padding: 8px 14px; min-height: 40px; font-size: 14px; }
.total { display: grid; gap: 14px; }
.total-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.label { display: inline-block; min-width: 88px; color: var(--muted); font-weight: 500; font-size: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.chip.plain { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
.oneline { margin: 0; padding: 16px 18px; border-radius: 14px; background: var(--accent-soft); border-left: 5px solid var(--accent); font: 500 clamp(17px, 3.8vw, 21px)/1.6 var(--serif); }

.grid2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.mini { background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 16px; }
.mini h3 { font: 700 16px/1.4 var(--sans); display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 8px; }
.mini h3 span:first-child { display: flex; gap: 8px; align-items: center; }
.mini p { margin: 0; font-size: 15px; color: var(--ink); }

.note-box { margin-top: 14px; padding: 14px 16px; border: 1px dashed var(--line); border-radius: 12px; background: var(--surface-2); font-size: 15px; }
.note-box summary { cursor: pointer; font-weight: 700; }
.note-box ul { margin: 10px 0 0; padding-left: 20px; }
.note-box li { margin: 4px 0; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 6px; margin-right: 6px; background: var(--accent-soft); color: var(--accent); }
.tag.bad { background: var(--el1-bg); color: var(--el1); }

.lucky { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.lucky .mini .k { color: var(--muted); font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.lucky .mini .v { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); flex: none; }
.ball { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; font-weight: 700; font-size: 15px; }

.advice p { text-align: left; }
.advice p:last-child { margin-bottom: 0; }
.advice .closing { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); font-family: var(--serif); color: var(--accent); font-size: 17px; }

/* 원국 */
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pillar { text-align: center; border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 12px 6px; }
.pillar .plabel { font-weight: 700; font-size: 14px; }
.pillar .hint { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.pillar .tgs { font-size: 12.5px; color: var(--muted); min-height: 20px; }
.glyph { margin: 6px auto; width: 64px; height: 64px; border-radius: 12px; display: grid; place-items: center; font: 700 34px/1 var(--serif); }
.glyph small { display: block; font: 500 12px/1 var(--sans); margin-top: 2px; opacity: .85; }
.glyph.day { box-shadow: 0 0 0 2.5px var(--accent); }
.e0 { color: var(--el0); background: var(--el0-bg); } .e1 { color: var(--el1); background: var(--el1-bg); } .e2 { color: var(--el2); background: var(--el2-bg); } .e3 { color: var(--el3); background: var(--el3-bg); } .e4 { color: var(--el4); background: var(--el4-bg); }
.pillar.unknown { opacity: .55; display: grid; place-content: center; }

.bars { display: grid; gap: 10px; margin-top: 4px; }
.bar-row { display: grid; grid-template-columns: 64px 1fr 84px; align-items: center; gap: 10px; font-size: 15px; }
.bar-row .track { height: 14px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.bar-row .fill { height: 100%; border-radius: 999px; }
.bar-row .state { font-size: 12.5px; color: var(--muted); text-align: right; }
.f0 { background: var(--el0); } .f1 { background: var(--el1); } .f2 { background: var(--el2); } .f3 { background: var(--el3); } .f4 { background: var(--el4); }
.gauge { margin: 6px 0 4px; position: relative; height: 12px; border-radius: 999px; background: linear-gradient(90deg, var(--el4), var(--star-off) 50%, var(--el1)); }
.gauge i { position: absolute; top: 50%; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 4px solid var(--ink); transform: translate(-50%, -50%); }
.gauge-labels { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); }
.yong { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.yong .mini { text-align: center; padding: 12px 8px; }
.yong .mini .k { font-size: 12.5px; color: var(--muted); }
.yong .mini .v { font: 700 20px/1.4 var(--serif); }

/* 주간 */
.week-chart { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; margin: 8px 0 4px; }
.wcol { display: grid; gap: 6px; justify-items: center; background: none; border: 0; padding: 4px 0; cursor: pointer; border-radius: 12px; }
.wcol:hover { background: var(--surface-2); }
.wcol .bar-wrap { height: 120px; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.wcol .bar { width: min(34px, 70%); border-radius: 10px 10px 4px 4px; min-height: 12px; }
.wcol .dw { font-weight: 700; font-size: 15px; }
.wcol .dd { font-size: 12.5px; color: var(--muted); }
.wcol .tgn { font-size: 12px; color: var(--muted); }
.wcol.today .dw::after { content: " ●"; color: var(--seal); font-size: 10px; }
.wcol[aria-pressed="true"] { background: var(--accent-soft); }
.b1 { background: var(--h1); } .b2 { background: var(--h2); } .b3 { background: var(--h3); } .b4 { background: var(--h4); } .b5 { background: var(--h5); }

.detail { margin-top: 14px; border-top: 1px dashed var(--line); padding-top: 16px; }
.detail h3 { font-size: 18px; margin-bottom: 6px; }
.detail .meta { color: var(--muted); font-size: 14px; margin-bottom: 10px; }
.detail .grid2 { margin-top: 12px; }

.kv { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.kv .mini { text-align: center; padding: 12px 8px; }
.kv .mini .k { font-size: 13px; color: var(--muted); font-weight: 500; }
.kv .mini .stars { margin-top: 4px; }
.tips { margin: 0; padding-left: 22px; }
.tips li { margin: 6px 0; }

/* 월간 캘린더 */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal .dow { text-align: center; font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal .dow:first-child { color: var(--seal); }
.cell { aspect-ratio: 1 / 1.05; border: 1.5px solid transparent; border-radius: 12px; padding: 6px 2px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; min-height: 52px; font-weight: 500; }
.cell .n { font-weight: 700; font-size: 16px; }
.cell .g { font-size: 11px; opacity: .8; }
.cell.s1 { background: var(--h1); color: var(--h1-t); } .cell.s2 { background: var(--h2); color: var(--h2-t); } .cell.s3 { background: var(--h3); color: var(--h3-t); } .cell.s4 { background: var(--h4); color: var(--h4-t); } .cell.s5 { background: var(--h5); color: var(--h5-t); }
.cell:hover { border-color: var(--ink); }
.cell.today { box-shadow: 0 0 0 2px var(--surface), 0 0 0 5px var(--brand); }
.cell[aria-pressed="true"] { border-color: var(--ink); border-width: 2.5px; }
.cell.empty { visibility: hidden; cursor: default; }
.legend { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.legend i { width: 22px; height: 14px; border-radius: 4px; display: inline-block; }
.seglist { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.seglist li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.dayp { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.dayp span { padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); font-weight: 700; font-size: 14px; }
.dayp.care span { background: var(--el4-bg); color: var(--el4); }
.wk-rows { display: grid; gap: 8px; }
.wk-row { display: grid; grid-template-columns: 96px 1fr auto; gap: 10px; align-items: center; font-size: 14.5px; }
.wk-row .track { height: 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.wk-row .fill { height: 100%; background: var(--star-on); border-radius: 999px; }

/* 상담 */
.chat { display: grid; gap: 14px; }
.chat-log { display: grid; gap: 14px; min-height: 120px; }
.msg { max-width: 92%; padding: 14px 16px; border-radius: 18px; }
.msg.me { justify-self: end; background: var(--brand); color: #fff; border-bottom-right-radius: 6px; }
.msg.bot { background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.bot p:last-child { margin-bottom: 0; }
.msg .who { font-size: 12.5px; color: var(--accent); font-weight: 700; margin-bottom: 4px; }
.msg .stars-line { margin: 4px 0 10px; }
.msg .closing { font-family: var(--serif); color: var(--accent); margin-top: 10px; }
.msg.typing span { display: inline-block; width: 8px; height: 8px; margin: 0 2px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .2s; } .msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.topic-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-chips button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; cursor: pointer; font-weight: 500; min-height: 44px; }
.topic-chips button:hover { border-color: var(--accent); }
.topic-chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.span-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.foot { padding: 22px 0 56px; color: var(--muted); font-size: 13.5px; }
.foot p { margin-bottom: .5em; }

/* 반응형 */
@media (max-width: 620px) {
  .card { padding: 18px 16px; }
  .grid2, .lucky { grid-template-columns: 1fr; }
  .kv { grid-template-columns: repeat(2, 1fr); }
  .yong { grid-template-columns: 1fr; }
  .yong .mini { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
  .pillars { gap: 6px; }
  .glyph { width: 54px; height: 54px; font-size: 28px; }
  .bar-row { grid-template-columns: 52px 1fr 64px; }
  .cal { gap: 4px; }
  .cell .g { display: none; }
  .cell { min-height: 46px; }
  .wcol .bar-wrap { height: 96px; }
  .wcol .tgn { display: none; }
  .wk-row { grid-template-columns: 80px 1fr auto; }
  .chat-form { grid-template-columns: 1fr; }
  .msg { max-width: 100%; }
  .brand-text small { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .tabbar, .top, form, .nav-btns, .chat-form { display: none !important; } body { background: #fff; } }
