/* 하루결 — 스타일
 * 모바일 우선. 밤에 기록하는 일이 많으므로 다크 모드를 기본 지원한다. */

:root {
  --bg: #F6F4EF;
  --surface: #FFFFFF;
  --surface-2: #EFECE5;
  --line: #E2DED5;
  --text: #1F2A2C;
  --muted: #5E6B6D;
  --faint: #687375;
  --primary: #2F6F6A;
  --primary-ink: #FFFFFF;
  --primary-soft: #DCEBE8;
  --warn: #B4582F;
  --warn-soft: #F7E4D9;
  --safe: #3D6FB0;
  --safe-soft: #E1EAF6;
  --safe-ink: #FFFFFF;

  --c-up: #D9952E;       /* 들뜸 */
  --c-down: #4F74B3;     /* 우울 */
  --c-mixed: #8E5CB0;    /* 혼재 */
  --c-anx: #C25E4A;      /* 불안 */
  --c-irr: #B0783A;      /* 짜증 */
  --c-ok: #4E9A7C;
  --c-energy: #2F6F6A;
  --c-focus: #7A6BB8;
  --c-sleep: #4F74B3;
  --c-bed: #CBD5E6;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 30, .06), 0 2px 10px rgba(20, 30, 30, .04);
  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111716;
    --surface: #1A2120;
    --surface-2: #222B2A;
    --line: #2E3938;
    --text: #E4EBE9;
    --muted: #A3B0AE;
    --faint: #909D9B;
    --primary: #74B8AE;
    --primary-ink: #0E1514;
    --primary-soft: #22403D;
    --warn: #E59B78;
    --warn-soft: #3D2A21;
    --safe: #8DB3E8;
    --safe-soft: #1F2C3F;
    --safe-ink: #0E1514;
    --c-bed: #34405A;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111716;
  --surface: #1A2120;
  --surface-2: #222B2A;
  --line: #2E3938;
  --text: #E4EBE9;
  --muted: #A3B0AE;
  --faint: #909D9B;
  --primary: #74B8AE;
  --primary-ink: #0E1514;
  --primary-soft: #22403D;
  --warn: #E59B78;
  --warn-soft: #3D2A21;
  --safe: #8DB3E8;
  --safe-soft: #1F2C3F;
  --safe-ink: #0E1514;
  --c-bed: #34405A;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- 레이아웃 ---------- */
#app {
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px calc(84px + env(safe-area-inset-bottom));
}
.view { padding-top: 8px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  margin: 0 -16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid transparent;
}
.topbar h1 { font-size: 19px; font-weight: 700; flex: 1; }
.topbar .sub { font-size: 13px; color: var(--muted); font-weight: 400; }

.datenav { display: flex; align-items: center; gap: 4px; flex: 1; justify-content: center; }
.datenav .date { font-weight: 700; font-size: 17px; min-width: 9.5em; text-align: center; background: none; border: 0; padding: 6px 4px; border-radius: 8px; }
.datenav .date small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 50%;
  border: 0; background: transparent; color: var(--muted);
  display: inline-grid; place-items: center; font-size: 20px;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn:disabled { opacity: .3; cursor: default; background: none; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar nav { max-width: 600px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 0 8px; text-decoration: none; color: var(--faint); font-size: 12px; font-weight: 600;
}
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--primary); }

/* ---------- 카드 ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 16px;
  margin: 12px 0;
}
.card > h2, .section-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card > h2 .right, .section-title .right { margin-left: auto; font-weight: 500; font-size: 13px; color: var(--muted); }
.card-sub { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.card.notice { background: var(--primary-soft); border-color: transparent; }
.card.warn { background: var(--warn-soft); border-color: transparent; }
.card.safe { background: var(--safe-soft); border-color: transparent; }

.emoji { font-size: 18px; line-height: 1; }

/* ---------- 오늘 화면: 단계 버튼 ---------- */
.stagebar { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0 4px; }
.stage {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 10px 6px; text-align: center; font-weight: 600; font-size: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 64px; justify-content: center;
}
.stage small { font-weight: 500; color: var(--muted); font-size: 12px; }
.stage.done { background: var(--primary-soft); border-color: transparent; }
.stage.done small { color: var(--primary); }

/* ---------- 질문 ---------- */
.q { padding: 12px 0; border-top: 1px solid var(--line); }
.q:first-of-type { border-top: 0; }
.q-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.q-label { font-weight: 650; font-size: 15px; }
.q-help { font-size: 13px; color: var(--muted); margin: -4px 0 8px; }
.q-clear { margin-left: auto; font-size: 12px; color: var(--muted); background: none; border: 0; padding: 10px 8px; margin-top: -10px; margin-bottom: -10px; }
.q-clear:hover { color: var(--text); }

.card[id], h2[id] { scroll-margin-top: 76px; }
.q-divider { display: flex; align-items: center; gap: 8px; margin: 14px 0 2px; color: var(--faint); font-size: 12px; font-weight: 600; }
.q-divider::before, .q-divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.q-divider + .q { border-top: 0; }
.sheet-foot { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; margin-top: 12px; }
.sheet-info { font-size: 13px; color: var(--text); background: var(--primary-soft); border-radius: var(--radius-sm); padding: 8px 10px; margin: 6px 0; }
.group-action { margin-left: auto; }

/* 척도 버튼 */
.scale { display: grid; gap: 6px; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); }
.scale button {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 8px 2px; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font-size: 13px; line-height: 1.2; color: var(--text);
  transition: background .12s, border-color .12s;
}
.scale button b { font-size: 16px; font-weight: 700; }
.scale button span { color: var(--muted); font-size: 12px; word-break: keep-all; }
.scale button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.scale button[aria-pressed="true"] span { color: var(--primary-ink); opacity: .9; }
.scale.tone-up button[aria-pressed="true"] { background: var(--c-up); border-color: var(--c-up); color: #1F2A2C; }
.scale.tone-down button[aria-pressed="true"] { background: var(--c-down); border-color: var(--c-down); color: #fff; }
.scale.tone-up button[aria-pressed="true"] span { color: #1F2A2C; }
.scale.tone-down button[aria-pressed="true"] span { color: #fff; }
.scale-ends { display: flex; justify-content: space-between; font-size: 12px; color: var(--faint); margin-top: 4px; }

/* 칩 (다중 선택) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 7px 12px; font-size: 14px; min-height: 36px;
}
.chip[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); color: var(--text); font-weight: 600; }
.chip.add { border-style: dashed; color: var(--muted); }

/* 예/아니오 */
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-width: 280px; }
.yn button { border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); min-height: 44px; font-weight: 600; }
.yn button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* 입력 */
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.field > span { font-size: 13px; color: var(--muted); font-weight: 600; }
input[type="text"], input[type="number"], input[type="time"], input[type="date"], select, textarea {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 84px; resize: vertical; line-height: 1.5; }
input[type="time"] { max-width: 150px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; }
.timebox { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.timebox input { flex: 0 0 132px; }
.pill-now { border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; min-height: 36px; font-variant-numeric: tabular-nums; }
.pill-now[aria-pressed="true"] { background: var(--primary-soft); border-color: var(--primary); }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--surface-2); font-size: 20px; }
.stepper output { min-width: 64px; text-align: center; font-weight: 700; padding: 0 4px; }
.stepper .unit { font-weight: 500; color: var(--muted); font-size: 13px; }

/* 버튼 */
.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  padding: 10px 16px; min-height: 44px; font-weight: 650; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--primary); }
.btn.danger { color: var(--warn); }
.btn.block { width: 100%; }
.btn.sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: .5; cursor: default; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.btnrow .btn { flex: 1; }

/* 모드 토글 */
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 650; color: var(--muted); min-height: 32px; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

/* ---------- 약 ---------- */
.dose {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line);
}
.dose:first-of-type { border-top: 0; }
.dose .time { font-variant-numeric: tabular-nums; font-weight: 700; width: 48px; color: var(--muted); font-size: 14px; }
.dose .name { flex: 1; min-width: 0; }
.dose .name b { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dose .name small { color: var(--muted); font-size: 12px; }
.dose .take {
  min-width: 92px; min-height: 44px; border-radius: 999px; border: 1.5px solid var(--primary);
  background: transparent; color: var(--primary); font-weight: 700; font-size: 14px; padding: 0 12px;
}
.dose .take.taken { background: var(--primary); color: var(--primary-ink); }
.dose .take.skipped { border-color: var(--faint); color: var(--faint); }
.dose .more { width: 36px; height: 36px; }

/* ---------- 사건 목록 ---------- */
.evlist { list-style: none; margin: 0; padding: 0; }
.evlist li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.evlist li:first-child { border-top: 0; }
.evlist .at { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); width: 48px; flex: none; }
.evlist .body { flex: 1; min-width: 0; }
.evlist .body b { font-weight: 650; }
.evlist .body p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); margin: 2px 4px 0 0; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }

.quickadd { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quickadd button {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-weight: 650; font-size: 14px;
}
.quickadd button .emoji { font-size: 20px; }

/* ---------- 시트 (하단 모달) ---------- */
.sheet-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 16, .42);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease-out;
}
.sheet {
  background: var(--bg); width: 100%; max-width: 600px; max-height: 92vh; overflow-y: auto;
  border-radius: 20px 20px 0 0; padding: 8px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 4px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font-size: 18px; margin-bottom: 4px; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-back { animation: none; } }

/* ---------- 토스트 ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(10px);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; max-width: calc(100% - 32px); text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 알림 ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); margin: 8px 0; font-size: 14px; }
.alert .emoji { margin-top: 1px; }
.alert.warn { background: var(--warn-soft); }
.alert.safe { background: var(--safe-soft); }
.alert b { display: block; margin-bottom: 2px; }
.alert .act { margin-top: 6px; }

.crisis { line-height: 1.7; }
.crisis a { font-weight: 700; text-decoration: none; }
.crisis .num { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.crisis .num:first-of-type { border-top: 0; }
.crisis .num a { background: var(--safe); color: var(--safe-ink); border-radius: 999px; padding: 6px 14px; font-size: 15px; }

/* ---------- 달력 ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .wd { text-align: center; font-size: 12px; color: var(--faint); font-weight: 600; padding: 4px 0; }
.cal button {
  min-width: 0; min-height: 58px; border: 1px solid transparent; background: var(--surface); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 0 2px; gap: 2px; font-size: 13px; font-weight: 600;
  position: relative;
}
.cal button.out { visibility: hidden; }
.cal button.today { border-color: var(--primary); }
.cal button.empty { background: transparent; color: var(--faint); font-weight: 500; }
.cal button:disabled { opacity: .35; }
.cal .bar { width: 6px; border-radius: 3px; }
.cal .mini { display: flex; gap: 2px; align-items: flex-end; height: 22px; }
.cal .mood-up { background: var(--c-up); }
.cal .mood-down { background: var(--c-down); }
.cal .mood-mixed { background: var(--c-mixed); }
.cal .mood-mixed-soft { background: var(--c-mixed); opacity: .45; }
.cal .mood-ok { background: var(--c-ok); height: 4px !important; }
.cal .dotrow { display: flex; gap: 2px; }
.cal .dotrow i { width: 5px; height: 5px; border-radius: 50%; display: block; }
.cal .i-panic { background: var(--c-anx); }
.cal .i-visit { background: var(--primary); }
.cal .i-chg { background: var(--c-mixed); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------- 요약 수치 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; margin: 8px 0; }
.stat { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .d { font-size: 12px; color: var(--faint); }

/* ---------- 리스트/설정 ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 48px; height: 28px; flex: none; }
.switch input { opacity: 0; width: 100%; height: 100%; position: absolute; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ''; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }

details.more { margin-top: 8px; }
details.more > summary { cursor: pointer; color: var(--primary); font-weight: 650; font-size: 14px; padding: 8px 0; list-style: none; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '＋ '; }
details.more[open] > summary::before { content: '－ '; }

/* ---------- 차트 ---------- */
.chart { display: block; overflow: visible; font-family: var(--font); }
.chart .ax { font-size: 10px; fill: var(--faint); }
.chart .lbl { font-size: 11px; fill: var(--muted); font-weight: 600; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--faint); stroke-width: 1; }
.chart .ref { stroke: var(--c-ok); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .wkend { fill: var(--surface-2); opacity: .7; }
.chart .mark { stroke: var(--primary); stroke-width: 1.5; stroke-dasharray: 3 2; }
.chart .mark.chg { stroke: var(--c-mixed); }
.chart .b-up { fill: var(--c-up); }
.chart .b-down { fill: var(--c-down); }
.chart .b-mixed { fill: var(--c-mixed); }
.chart .b-mixed-soft { fill: var(--c-mixed); opacity: .4; }
.chart .dot-ok { fill: var(--c-ok); }
.chart .ln { stroke-width: 2; stroke: var(--primary); stroke-linejoin: round; stroke-linecap: round; }
.chart .pt { fill: var(--primary); }
.chart .ln.c-energy { stroke: var(--c-energy); } .chart .pt.c-energy { fill: var(--c-energy); }
.chart .ln.c-focus { stroke: var(--c-focus); } .chart .pt.c-focus { fill: var(--c-focus); }
.chart .ln.c-anx { stroke: var(--c-anx); } .chart .pt.c-anx { fill: var(--c-anx); }
.chart .ln.c-irr { stroke: var(--c-irr); } .chart .pt.c-irr { fill: var(--c-irr); }
.chart .ln.c-sleep { stroke: var(--c-sleep); } .chart .pt.c-sleep { fill: var(--c-sleep); }
.chart .ln.c-up { stroke: var(--c-up); } .chart .pt.c-up { fill: var(--c-up); }
.chart .ln.c-down { stroke: var(--c-down); } .chart .pt.c-down { fill: var(--c-down); }
.chart .s-bed { fill: var(--c-bed); }
.chart .s-sleep { fill: var(--c-sleep); }
.chart .s-med { fill: var(--c-up); stroke: var(--surface); stroke-width: 1; }
.chart .g-taken { fill: var(--c-ok); }
.chart .g-late { fill: var(--c-up); }
.chart .g-skip { stroke: var(--warn); stroke-width: 2; stroke-linecap: round; }
.chart .g-none { fill: var(--faint); }
.chart .g-yes { fill: var(--c-anx); }
.chart .g-int { fill: var(--c-anx); }
.chart .b-count { fill: var(--c-anx); }
.chart .b-prn { fill: var(--c-mixed); }
.chart-block { margin: 10px 0 4px; }
.chart-block h3 { font-size: 14px; font-weight: 700; margin-bottom: 2px; }
.chart-block .cap { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12px; color: var(--muted); margin: 2px 0 4px; }
.chart-legend i { display: inline-block; width: 12px; height: 4px; border-radius: 2px; vertical-align: 3px; margin-right: 4px; }
.chart-legend i.sw { height: 0; border-top: 4px solid currentColor; border-radius: 0; background: none; }
.legend i { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

/* ---------- 리포트 ---------- */
.report h2 { font-size: 16px; margin: 0 0 6px; padding-bottom: 4px; border-bottom: 2px solid var(--text); }
.report section { margin: 18px 0; }
.report h2, .report h3 { break-after: avoid; }
.report .chart-block, .report .stats, .report .flagbox, .report table, .report .head { break-inside: avoid; }
.report table { width: 100%; border-collapse: collapse; font-size: 13px; }
.report th, .report td { text-align: left; padding: 5px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.report th { font-weight: 700; color: var(--muted); font-size: 12px; }
.report td.num, .report th.num { text-align: right; font-variant-numeric: tabular-nums; }
.report .head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 3px solid var(--primary); padding-bottom: 8px; margin-bottom: 8px; }
.report .head h1 { font-size: 21px; }
.report .flagbox { border: 1.5px solid var(--warn); border-radius: var(--radius-sm); padding: 8px 12px; margin: 8px 0; }
.report .flagbox li { margin: 2px 0; }
.report ul { padding-left: 20px; margin: 4px 0; }
.report-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.report .head-meta { text-align: right; }
@media (max-width: 480px) { .report .head-meta { text-align: left; } }
.report-controls select, .report-controls input { width: auto; }

.empty-state { text-align: center; padding: 28px 12px; color: var(--muted); }
.empty-state .emoji { font-size: 32px; display: block; margin-bottom: 8px; }

.onboard h2 { font-size: 22px; margin: 8px 0; }
.onboard p { color: var(--muted); }

/* ---------- 인쇄 ---------- */
@media print {
  :root, :root:not([data-theme="light"]), :root[data-theme="dark"] {
    --bg: #fff; --surface: #fff; --surface-2: #F3F3F1; --line: #D8D8D4; --text: #111; --muted: #444; --faint: #777;
    --primary: #2F6F6A; --primary-soft: #E6F0EE; --warn: #A3461F; --warn-soft: #FBEDE6; --c-bed: #CBD5E6;
    color-scheme: light;
  }
  @page { size: A4; margin: 12mm; }
  body { background: #fff; font-size: 12px; }
  #app { max-width: none; padding: 0; }
  .tabbar, .topbar, .no-print, #toast { display: none !important; }
  .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
  .report section { margin: 10px 0; }
  .report .pagebreak { break-before: page; }
  .chart .wkend { fill: #F1F1EE; }
  a { color: inherit; text-decoration: none; }
}

@media screen and (max-width: 640px) {
  .report .chart-block { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .report .chart-block .chart { min-width: 560px; }
  .report .chart-block .cap, .report .chart-block h3, .report .chart-block .chart-legend { position: sticky; left: 0; }
}
.chart, .chart * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
