:root {
  --ink: #18312f;
  --muted: #647b78;
  --line: #dce9e6;
  --paper: #fffdfa;
  --canvas: #f4f7f4;
  --primary: #0f766e;
  --primary-dark: #0a5953;
  --primary-soft: #dff4ef;
  --accent: #f2b84b;
  --good: #16835e;
  --bad: #c65b4b;
  --wood: #3c9361;
  --fire: #df6a50;
  --earth: #b58644;
  --metal: #6e7884;
  --water: #4384b7;
  --shadow: 0 12px 30px rgba(23, 64, 59, .08);
}

* { box-sizing: border-box; }
html { background: var(--canvas); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--canvas);
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  word-break: keep-all;
}
button, input { font: inherit; }
button { color: inherit; }
.app-shell { width: min(100%, 620px); min-height: 100vh; margin: 0 auto; background: var(--paper); box-shadow: 0 0 40px rgba(0,0,0,.05); }
.app-header {
  position: sticky; top: 0; z-index: 20;
  height: 62px; padding: 9px 18px;
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,253,250,.94); backdrop-filter: blur(12px); border-bottom: 1px solid rgba(220,233,230,.8);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: var(--primary); color: white; font-family: serif; font-size: 22px; }
.brand b { display: block; font-size: 17px; letter-spacing: -.3px; }
.brand small { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; }
.xp-pill { padding: 7px 11px; border-radius: 999px; background: #fff4d8; color: #8a5a00; font-size: 12px; font-weight: 800; }
main { min-height: calc(100vh - 130px); padding: 20px 18px 104px; outline: none; }
.bottom-nav {
  position: fixed; bottom: 0; z-index: 30; width: min(100%, 620px); height: calc(72px + env(safe-area-inset-bottom));
  padding: 8px 6px env(safe-area-inset-bottom); display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(255,253,250,.96); backdrop-filter: blur(16px); border-top: 1px solid var(--line);
}
.bottom-nav button { border: 0; background: none; color: #7a8e8b; font-size: 11px; font-weight: 700; cursor: pointer; }
.bottom-nav span { display: block; height: 26px; font-size: 21px; line-height: 24px; font-family: serif; }
.bottom-nav button.active { color: var(--primary); }
.page-title { margin: 0 0 4px; font-size: 24px; letter-spacing: -.7px; }
.page-desc { margin: 0 0 20px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-size: 12px; font-weight: 800; letter-spacing: .5px; }
.card { padding: 18px; background: white; border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.hero { padding: 21px; background: linear-gradient(145deg, #0d6d66, #159486); color: white; border: 0; overflow: hidden; position: relative; }
.hero::after { content: "命"; position: absolute; right: -7px; bottom: -35px; color: rgba(255,255,255,.09); font: 120px/1 serif; }
.hero-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.hero h1 { margin: 2px 0 6px; font-size: 24px; }
.hero p { margin: 0; color: rgba(255,255,255,.78); font-size: 13px; }
.level-badge { flex: none; padding: 7px 10px; background: rgba(255,255,255,.17); border: 1px solid rgba(255,255,255,.28); border-radius: 999px; font-size: 12px; font-weight: 800; }
.progress { height: 8px; margin-top: 19px; background: rgba(255,255,255,.22); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: #f4ce75; border-radius: inherit; }
.hero-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.hero-metrics div { padding: 10px 8px; border-radius: 13px; background: rgba(255,255,255,.1); }
.hero-metrics b { display: block; font-size: 17px; }
.hero-metrics span { font-size: 10px; color: rgba(255,255,255,.72); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 24px 2px 11px; }
.section-head h2 { margin: 0; font-size: 17px; }
.section-head span { color: var(--muted); font-size: 12px; }
.lesson-card h3 { margin: 3px 0 7px; font-size: 20px; }
.lesson-card p { margin: 0 0 16px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.btn { width: 100%; min-height: 50px; padding: 13px 18px; border: 0; border-radius: 15px; font-weight: 800; cursor: pointer; }
.btn-primary { background: var(--primary); color: white; box-shadow: 0 8px 18px rgba(15,118,110,.22); }
.btn-primary:active { background: var(--primary-dark); transform: translateY(1px); }
.btn-secondary { background: var(--primary-soft); color: var(--primary-dark); }
.shortcut-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.shortcut { min-height: 92px; padding: 14px 9px; border: 1px solid var(--line); border-radius: 17px; background: white; cursor: pointer; }
.shortcut span { display: block; margin-bottom: 8px; font-size: 25px; }
.shortcut b { display: block; font-size: 12px; }
.shortcut small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.path-list { display: grid; gap: 10px; }
.path-item { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.path-num { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 13px; background: var(--primary-soft); color: var(--primary); font-weight: 900; }
.path-item b { display: block; font-size: 14px; }
.path-item small { color: var(--muted); font-size: 11px; }
.path-state { color: var(--primary); font-size: 11px; font-weight: 800; }
.study-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.icon-btn { flex: none; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 12px; background: white; cursor: pointer; }
.icon-btn:disabled { color: #aebdb9; background: #f6f8f6; cursor: default; }
.study-back { color: var(--primary); font-size: 20px; }
.study-progress { flex: 1; height: 7px; border-radius: 99px; background: var(--line); overflow: hidden; }
.study-progress i { display: block; height: 100%; background: var(--primary); transition: width .25s; }
.study-count { color: var(--muted); font-size: 12px; font-weight: 800; }
.question-type { display: inline-flex; align-items: center; gap: 5px; padding: 6px 9px; border-radius: 8px; background: var(--primary-soft); color: var(--primary-dark); font-size: 11px; font-weight: 800; }
.question h2 { margin: 16px 0 8px; font-size: 22px; line-height: 1.45; letter-spacing: -.5px; }
.question-context { margin: 12px 0 0; padding: 15px; border-radius: 15px; background: #f7f3eb; color: #4e4b43; font-size: 14px; line-height: 1.65; white-space: pre-line; }
.context-pillar-line { display: grid; grid-template-columns: 42px 1fr 1fr; align-items: center; gap: 10px; min-height: 32px; }
.context-pillar-line b { font: 20px/1.2 serif; }.context-pillar-line small { color: var(--muted); font-size: 11px; font-weight: 700; }
.options { display: grid; gap: 10px; margin-top: 24px; }
.option { width: 100%; min-height: 58px; padding: 15px 16px; display: flex; align-items: center; gap: 12px; text-align: left; border: 1.5px solid var(--line); border-radius: 16px; background: white; cursor: pointer; }
.option-letter { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: #f0f5f3; color: var(--muted); font-size: 12px; font-weight: 900; }
.option:not(:disabled):active { border-color: var(--primary); }
.option.correct { border-color: var(--good); background: #effaf5; color: #0d6247; }
.option.wrong { border-color: var(--bad); background: #fff1ee; color: #994235; }
.option:disabled { cursor: default; }
.explanation { margin-top: 18px; padding: 18px; border-radius: 18px; background: #f5f8f6; border: 1px solid var(--line); }
.result-title { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; font-size: 16px; }
.ex-section + .ex-section { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.ex-section b { display: block; margin-bottom: 5px; color: var(--primary-dark); font-size: 12px; }
.ex-section p { margin: 0; color: #405754; font-size: 13px; line-height: 1.65; }
.feedback-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 14px; }
.feedback-row span { color: var(--muted); font-size: 11px; }
.feedback-buttons { display: flex; gap: 8px; }
.feedback-buttons button { min-width: 42px; height: 36px; border: 1px solid var(--line); border-radius: 11px; background: white; cursor: pointer; }
.next-wrap { margin-top: 14px; }
.next-wrap.with-previous { display: grid; grid-template-columns: 1fr 1.3fr; gap: 10px; }
.complete { text-align: center; padding-top: 30px; }
.complete-icon { width: 86px; height: 86px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 30px; background: var(--primary-soft); color: var(--primary); font-size: 42px; }
.complete h2 { margin: 0 0 8px; }
.complete p { color: var(--muted); }
.complete-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 22px 0; }
.complete-stats div { padding: 14px 7px; background: white; border: 1px solid var(--line); border-radius: 15px; }
.complete-stats b { display: block; font-size: 20px; }
.complete-stats span { color: var(--muted); font-size: 10px; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chip { flex: none; padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: white; color: var(--muted); font-size: 12px; font-weight: 800; cursor: pointer; }
.chip.active { background: var(--primary); border-color: var(--primary); color: white; }
.concept-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.concept-card { min-height: 135px; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: white; text-align: left; cursor: pointer; }
.concept-char { display: block; font: 34px/1.2 serif; }
.concept-card b { display: block; margin-top: 8px; font-size: 14px; }
.concept-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.mastery-mini { height: 4px; margin-top: 13px; border-radius: 9px; background: var(--line); overflow: hidden; }
.mastery-mini i { display: block; height: 100%; background: var(--primary); }
.element-목 { color: var(--wood); }.element-화 { color: var(--fire); }.element-토 { color: var(--earth); }.element-금 { color: var(--metal); }.element-수 { color: var(--water); }
.wheel-mode-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 2px 0 8px; }
.wheel-mode-row > span { color: var(--muted); font-size: 12px; font-weight: 800; }
.wheel-mode-row > div { display: flex; gap: 5px; }
.wheel-mode { min-width: 38px; height: 34px; padding: 0 9px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--muted); font-size: 11px; font-weight: 800; cursor: pointer; }
.wheel-mode.active { border-color: var(--primary); background: var(--primary); color: white; }
.concept-wheel { position: relative; width: min(100%, 410px); aspect-ratio: 1; margin: 3px auto 0; }
.concept-wheel svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.concept-wheel svg circle { fill: none; stroke: #bec8c6; stroke-width: 1.2; }
.concept-wheel svg marker path { fill: #39a993; }
.wheel-lines { stroke: #39a993; stroke-width: .45; opacity: .88; }
.wheel-node { position: absolute; z-index: 2; width: 58px; height: 58px; padding: 4px 2px; transform: translate(-50%,-50%); border: 3px solid var(--paper); border-radius: 50%; color: white; box-shadow: 0 4px 13px rgba(24,49,47,.14); cursor: pointer; }
.wheel-node b { display: block; font: 22px/1.1 serif; }
.wheel-node small { display: block; margin-top: 2px; color: inherit; font-size: 9px; font-weight: 800; }
.element-bg-목 { background: var(--wood); }.element-bg-화 { background: var(--fire); }.element-bg-토 { background: var(--earth); }.element-bg-금 { background: var(--metal); }.element-bg-수 { background: var(--water); }
.wheel-center { position: absolute; left: 50%; top: 50%; width: 76px; height: 76px; display: grid; place-content: center; transform: translate(-50%,-50%); border: 1px solid var(--line); border-radius: 50%; background: rgba(255,253,250,.95); text-align: center; box-shadow: 0 5px 18px rgba(23,64,59,.08); pointer-events: none; }
.wheel-center b { color: var(--primary); font-size: 19px; }.wheel-center small { margin-top: 2px; color: var(--muted); font-size: 9px; }
.wheel-help { margin: 2px 4px 0; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: center; }
.detail-hero { text-align: center; padding: 24px 18px; background: linear-gradient(145deg, #edf8f4, #fffaf0); border-radius: 21px; }
.detail-char { font: 66px/1.1 serif; }
.detail-hero h2 { margin: 7px 0 4px; }
.detail-hero p { margin: 0; color: var(--muted); }
.detail-section { margin-top: 20px; }
.detail-section h3 { margin: 0 0 9px; font-size: 15px; }
.detail-section p, .detail-section li { color: #405754; font-size: 13px; line-height: 1.7; }
.detail-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat-card { padding: 16px; border: 1px solid var(--line); border-radius: 17px; background: white; }
.stat-card span { color: var(--muted); font-size: 11px; }
.stat-card b { display: block; margin-top: 5px; font-size: 23px; }
.bar-list { display: grid; gap: 14px; }
.bar-label { display: flex; justify-content: space-between; margin-bottom: 7px; font-size: 12px; }
.bar { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.empty { padding: 30px 15px; text-align: center; color: var(--muted); font-size: 13px; }
.list-card { padding: 0 16px; background: white; border: 1px solid var(--line); border-radius: 18px; }
.list-row { width: 100%; min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; }
.list-row:last-child { border-bottom: 0; }
.list-row b { font-size: 13px; }.list-row small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.profile-card { margin-bottom: 16px; }
.profile-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.profile-head h2 { margin: 2px 0 4px; font-size: 19px; }
.profile-head p { margin: 0; color: var(--muted); font-size: 12px; }
.text-btn { flex: none; padding: 7px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--primary); font-size: 11px; font-weight: 800; cursor: pointer; }
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 16px; }
.pillar { padding: 10px 4px; border-radius: 13px; background: #f6f8f6; text-align: center; }
.pillar small { display: block; color: var(--muted); font-size: 9px; }
.pillar b { display: block; margin-top: 4px; font: 21px/1.2 serif; }
.pillar em { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; font-style: normal; font-weight: 700; }
.form-stack { display: grid; gap: 15px; }
.field-group { display: grid; gap: 7px; color: var(--ink); font-size: 12px; font-weight: 700; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-control { width: 100%; height: 48px; padding: 0 13px; border: 1px solid var(--line); border-radius: 13px; background: white; color: var(--ink); font-size: 16px; outline: none; }
.field-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(15,118,110,.1); }
.field-control:disabled { background: #f1f4f3; color: #9aaba8; }
.check-row { min-height: 44px; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; font-weight: 500; }
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-note { padding: 12px 13px; border-radius: 13px; background: #f4f7f4; color: var(--muted); font-size: 11px; line-height: 1.55; }
.map-wrap { position: relative; aspect-ratio: 1/1; margin: 15px 0 12px; overflow: hidden; border-radius: 23px; background: radial-gradient(circle at center, transparent 0 23%, rgba(15,118,110,.1) 23.5% 24%, transparent 24.5% 43%, rgba(15,118,110,.08) 43.5% 44%, transparent 44.5%), #f4f7f4; }
.map-axis { position: absolute; background: rgba(15,118,110,.1); pointer-events: none; }
.map-axis-x { left: 8%; right: 8%; top: 50%; height: 1px; }
.map-axis-y { top: 8%; bottom: 8%; left: 50%; width: 1px; }
.person-node { position: absolute; transform: translate(-50%,-50%); min-width: 62px; min-height: 62px; padding: 7px; border: 0; border-radius: 20px; background: var(--primary-soft); color: var(--ink); box-shadow: 0 7px 18px rgba(23,64,59,.12); cursor: pointer; }
.person-node b { display: block; max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.person-node small { display: block; margin-top: 2px; color: var(--muted); font-size: 9px; }
.person-node.me { left: 50%; top: 50%; min-width: 78px; min-height: 78px; background: var(--primary); color: white; }
.person-node.me small { color: rgba(255,255,255,.75); }
.person-node.energy { background: #fff1cf; }
.person-node.tension { background: #ffeae5; }
.map-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 15px; color: var(--muted); font-size: 10px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: var(--primary-soft); }
.legend-dot.energy { background: #fff1cf; }.legend-dot.tension { background: #ffe0d8; }
.person-list { display: grid; gap: 9px; margin-top: 14px; }
.person-list-item { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 8px; padding: 12px 13px; border: 1px solid var(--line); border-radius: 14px; background: white; }
.person-list-item button:first-child { padding: 0; border: 0; background: none; text-align: left; cursor: pointer; }
.person-list-item b { display: block; font-size: 13px; }.person-list-item small { color: var(--muted); font-size: 10px; }
.delete-btn { width: 36px; height: 36px; border: 0; border-radius: 10px; background: #fff1ee; color: var(--bad); cursor: pointer; }
.edit-btn { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: white; color: var(--primary); font-size: 12px; font-weight: 800; white-space: nowrap; cursor: pointer; }
.relation-top { display: flex; align-items: center; justify-content: space-between; margin: 0 0 12px; }
.relation-charts, .relation-stems { display: grid; gap: 10px; margin: 10px 0; }
.relation-chart, .relation-stems > div { padding: 12px; border-radius: 14px; background: white; border: 1px solid var(--line); }
.relation-chart > b { display: block; margin-bottom: 9px; font-size: 13px; }
.relation-pillars { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 5px; }
.relation-pillars > div { display: grid; justify-items: center; gap: 2px; padding: 7px 2px; border-radius: 9px; background: var(--primary-soft); }
.relation-pillars small { font-size: 10px; color: var(--muted); }
.relation-pillars strong { font: 20px/1.25 serif; }
.relation-pillars em { font-size: 10px; color: var(--primary); font-style: normal; }
.relation-section .relation-note { margin-top: 9px; color: var(--muted); font-size: 12px; }
.relation-section .relation-stems p { margin-top: 5px; }
.relation-tag { display: inline-block; margin-right: 4px; padding: 2px 7px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); }
.relation-found { margin-top: 11px; padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: white; }
.relation-found-title { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px; margin-bottom: 6px; }
.relation-found-title b { font-size: 13px; }.relation-found-title b small { color: var(--primary); }
.relation-found-title span { font-size: 11px; color: var(--muted); }
.relation-found .relation-question { margin-top: 6px; color: var(--primary); font-weight: 700; }
.relation-hero { padding: 18px; border-radius: 20px; background: linear-gradient(145deg, var(--primary-soft), #fff8e9); text-align: center; }
.relation-hero strong { display: block; font: 38px/1.25 serif; }.relation-hero h2 { margin: 5px 0 3px; font-size: 19px; }.relation-hero p { margin: 0; color: var(--muted); font-size: 11px; }
.ganji-reading { display: block; margin-top: -3px; color: var(--primary); font-size: 12px; font-weight: 800; }
.relation-section { padding: 16px 2px; border-bottom: 1px solid var(--line); }
.relation-section h3 { margin: 0 0 6px; font-size: 14px; }.relation-section p { margin: 0; color: #405754; font-size: 12px; line-height: 1.65; }
.empty-illustration { width: 70px; height: 70px; margin: 16px auto; display: grid; place-items: center; border-radius: 24px; background: var(--primary-soft); color: var(--primary); font: 30px serif; }
.notice { margin-bottom: 16px; padding: 13px 14px; border-radius: 14px; background: #fff6df; color: #73551d; font-size: 12px; line-height: 1.55; }
.admin-table { display: grid; gap: 10px; }
.admin-item { padding: 15px; border: 1px solid var(--line); border-radius: 15px; background: white; }
.admin-item p { margin: 6px 0; font-size: 13px; line-height: 1.5; }
.admin-meta { display: flex; flex-wrap: wrap; gap: 6px; color: var(--muted); font-size: 10px; }
.search { width: 100%; height: 46px; margin-bottom: 15px; padding: 0 14px; border: 1px solid var(--line); border-radius: 13px; background: white; outline: none; }
.search:focus { border-color: var(--primary); }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 92px; transform: translate(-50%, 16px); padding: 11px 16px; border-radius: 12px; background: #173936; color: white; font-size: 12px; opacity: 0; pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.hidden { display: none !important; }

@media (min-width: 621px) {
  body { padding: 18px 0; }
  .app-shell { min-height: calc(100vh - 36px); border-radius: 24px; overflow: hidden; }
  .app-header { top: 18px; }
  .bottom-nav { bottom: 18px; border-radius: 0 0 24px 24px; }
}
@media (max-width: 360px) {
  main { padding-left: 14px; padding-right: 14px; }
  .hero-metrics { gap: 5px; }
  .shortcut-grid { gap: 7px; }
  .field-row { grid-template-columns: 1fr; }
  .person-node { min-width: 56px; min-height: 56px; }
  .wheel-node { width: 51px; height: 51px; border-width: 2px; }
  .wheel-node b { font-size: 19px; }.wheel-node small { font-size: 8px; }
  .wheel-mode-row { align-items: flex-start; flex-direction: column; }
}
