/* 셀프 호스팅 폰트 (static/fonts/) — Pretendard·D2Coding: OFL, SDChildfundkorea: 무료 배포 */
@font-face {
  font-family: "Pretendard Variable";
  src: url("../fonts/PretendardVariable.725564d324fc.woff2") format("woff2-variations");
  font-weight: 45 920;
  font-display: swap;
}
@font-face {
  font-family: "D2Coding";
  src: url("../fonts/D2Coding.988b2589dbb0.ttf") format("truetype");
  font-display: swap;
}
@font-face {
  font-family: "SDChildfundkorea";
  src: url("../fonts/SDChildfundkorea.23b9c31fcfe4.otf") format("opentype");
  font-display: swap;
}

:root {
  --bg: #f7f7f5; --panel: #ffffff; --fg: #1f2328; --muted: #6b7280;
  --accent: #a903fc; --accent-soft: #f4e6fe; --border: #e5e7eb;
  --accent-typing: #c77dff;   /* 타이핑 진행 = 연보라 (읽기 보라와 구분) */
  --kakao: #fee500; --heart: #e05666;
  /* 잔디 히트맵 — 메인 보라 파생 스케일 */
  --grass-0: #ebedf0; --grass-1: #e3c8fb; --grass-2: #cc95f6; --grass-3: #b64ef9; --grass-4: #8a02cf;
  --ok: #2f7a4c; --bad: #d64545;  /* 타이핑 채점(맞음/틀림)은 의미색 유지 */
  /* 성경 읽기·타이핑 화면 전용 톤 — 라이트에서 고정값이던 것을 변수화(다크 오버라이드용) */
  --done-ink: #7355a0;       /* 읽음/완료 표시한 절 = 진한 보라 */
  --faint-ink: #c9c3cf;      /* 아직 안 온 절·입력 전 글자 = 흐리게 */
  --correct-ink: #241a2e;    /* 타이핑 중 맞게 입력한 글자 */
  --composing-ink: #6e6180;  /* 한글 조합 중인 글자 */
  --mark-off: #d8d2c4;       /* 읽음 체크·하트의 미선택 상태 */
  --mode-typing-bg: #f5ecd8; --mode-typing-fg: #8a6d2f;  /* 통계 기록의 "타이핑" 모드 뱃지 */
  --warn: #b8860b;          /* 관리 페이지 대기중 상태 표시 */
  --sidebar-w: 220px;
}
/* 다크 팔레트 — 고정(theme-dark)과 시스템 추종(theme-system + OS 다크) 두 블록.
   값은 항상 같아야 한다: 한쪽만 고치고 다른 쪽을 잊지 말 것. */
body.theme-dark {
  --bg: #121216; --panel: #1c1c22; --fg: #e6e4df; --muted: #9299a3;
  --accent: #c77dff; --accent-soft: #2c1642; --border: #2e2e36;
  --accent-typing: #d9a5ff;
  --heart: #ff7a8a;
  --grass-0: #24242b; --grass-1: #3d2a52; --grass-2: #6a3f9e; --grass-3: #9a5ce0; --grass-4: #c77dff;
  --ok: #4caf7d; --bad: #ef6b6b;
  --done-ink: #b79bdb; --faint-ink: #55505f; --correct-ink: #f2eef8; --composing-ink: #b3a6c9;
  --mark-off: #423d4a; --mode-typing-bg: #3a2f16; --mode-typing-fg: #e0b972;
  --warn: #e0b972;
}
@media (prefers-color-scheme: dark) {
  body.theme-system {
    --bg: #121216; --panel: #1c1c22; --fg: #e6e4df; --muted: #9299a3;
    --accent: #c77dff; --accent-soft: #2c1642; --border: #2e2e36;
    --accent-typing: #d9a5ff;
    --heart: #ff7a8a;
    --grass-0: #24242b; --grass-1: #3d2a52; --grass-2: #6a3f9e; --grass-3: #9a5ce0; --grass-4: #c77dff;
    --ok: #4caf7d; --bad: #ef6b6b;
    --done-ink: #b79bdb; --faint-ink: #55505f; --correct-ink: #f2eef8; --composing-ink: #b3a6c9;
    --mark-off: #423d4a; --mode-typing-bg: #3a2f16; --mode-typing-fg: #e0b972;
    --warn: #e0b972;
  }
}
/* Quill 에디터(일기) 다크 오버라이드 — 벤더 quill.snow.css는 그대로 두고 여기서 덮어쓴다.
   theme-dark / theme-system(미디어) 쌍은 항상 함께 갱신할 것. */
body.theme-dark .ql-toolbar.ql-snow,
body.theme-dark .ql-container.ql-snow { background: var(--panel); border-color: var(--border); }
body.theme-dark .ql-snow .ql-stroke { stroke: var(--muted); }
body.theme-dark .ql-snow .ql-fill { fill: var(--muted); }
body.theme-dark .ql-snow .ql-picker-label { color: var(--muted); }
body.theme-dark .ql-snow .ql-toolbar button:hover .ql-stroke,
body.theme-dark .ql-snow .ql-toolbar button:focus .ql-stroke,
body.theme-dark .ql-snow .ql-toolbar button.ql-active .ql-stroke,
body.theme-dark .ql-snow .ql-picker-label:hover .ql-stroke,
body.theme-dark .ql-snow .ql-picker-label.ql-active .ql-stroke,
body.theme-dark .ql-snow .ql-picker-item:hover .ql-stroke,
body.theme-dark .ql-snow .ql-picker-item.ql-selected .ql-stroke { stroke: var(--accent); }
body.theme-dark .ql-snow .ql-toolbar button:hover .ql-fill,
body.theme-dark .ql-snow .ql-toolbar button:focus .ql-fill,
body.theme-dark .ql-snow .ql-toolbar button.ql-active .ql-fill,
body.theme-dark .ql-snow .ql-picker-label:hover .ql-fill,
body.theme-dark .ql-snow .ql-picker-label.ql-active .ql-fill,
body.theme-dark .ql-snow .ql-picker-item:hover .ql-fill,
body.theme-dark .ql-snow .ql-picker-item.ql-selected .ql-fill { fill: var(--accent); }
body.theme-dark .ql-snow .ql-toolbar button:hover,
body.theme-dark .ql-snow .ql-toolbar button:focus,
body.theme-dark .ql-snow .ql-toolbar button.ql-active,
body.theme-dark .ql-snow .ql-picker-label:hover,
body.theme-dark .ql-snow .ql-picker-label.ql-active,
body.theme-dark .ql-snow .ql-picker-item:hover,
body.theme-dark .ql-snow .ql-picker-item.ql-selected { color: var(--accent); }
body.theme-dark .ql-editor.ql-blank::before { color: var(--muted); }
body.theme-dark .ql-snow .ql-picker-options { background: var(--panel); border-color: var(--border); }
@media (prefers-color-scheme: dark) {
  body.theme-system .ql-toolbar.ql-snow,
  body.theme-system .ql-container.ql-snow { background: var(--panel); border-color: var(--border); }
  body.theme-system .ql-snow .ql-stroke { stroke: var(--muted); }
  body.theme-system .ql-snow .ql-fill { fill: var(--muted); }
  body.theme-system .ql-snow .ql-picker-label { color: var(--muted); }
  body.theme-system .ql-snow .ql-toolbar button:hover .ql-stroke,
  body.theme-system .ql-snow .ql-toolbar button:focus .ql-stroke,
  body.theme-system .ql-snow .ql-toolbar button.ql-active .ql-stroke,
  body.theme-system .ql-snow .ql-picker-label:hover .ql-stroke,
  body.theme-system .ql-snow .ql-picker-label.ql-active .ql-stroke,
  body.theme-system .ql-snow .ql-picker-item:hover .ql-stroke,
  body.theme-system .ql-snow .ql-picker-item.ql-selected .ql-stroke { stroke: var(--accent); }
  body.theme-system .ql-snow .ql-toolbar button:hover .ql-fill,
  body.theme-system .ql-snow .ql-toolbar button:focus .ql-fill,
  body.theme-system .ql-snow .ql-toolbar button.ql-active .ql-fill,
  body.theme-system .ql-snow .ql-picker-label:hover .ql-fill,
  body.theme-system .ql-snow .ql-picker-label.ql-active .ql-fill,
  body.theme-system .ql-snow .ql-picker-item:hover .ql-fill,
  body.theme-system .ql-snow .ql-picker-item.ql-selected .ql-fill { fill: var(--accent); }
  body.theme-system .ql-snow .ql-toolbar button:hover,
  body.theme-system .ql-snow .ql-toolbar button:focus,
  body.theme-system .ql-snow .ql-toolbar button.ql-active,
  body.theme-system .ql-snow .ql-picker-label:hover,
  body.theme-system .ql-snow .ql-picker-label.ql-active,
  body.theme-system .ql-snow .ql-picker-item:hover,
  body.theme-system .ql-snow .ql-picker-item.ql-selected { color: var(--accent); }
  body.theme-system .ql-editor.ql-blank::before { color: var(--muted); }
  body.theme-system .ql-snow .ql-picker-options { background: var(--panel); border-color: var(--border); }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  /* 앱 글꼴 — 설정 페이지에서 선택(app-font-* 클래스), 기본 프리텐다드 */
  font-family: var(--font-app, "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", "Noto Sans KR", sans-serif);
  background: var(--bg); color: var(--fg); line-height: 1.6;
}
body { --verse-mark-raise: .22em; }  /* 하트·절 번호 올림량 — 글꼴별 시각 중앙 보정 */
/* 본문 글자 크기 — 설정·읽기·타이핑에서 선택 */
body { --verse-scale: 1; }
body.font-scale-small { --verse-scale: .88; }
body.font-scale-large { --verse-scale: 1.18; }
body.font-scale-xlarge { --verse-scale: 1.38; }
body.font-scale-xxlarge { --verse-scale: 1.62; }
body.app-font-pretendard { --font-app: "Pretendard Variable", Pretendard, "Apple SD Gothic Neo", sans-serif; }
body.app-font-gowun { --font-app: "Gowun Batang", "Apple SD Gothic Neo", serif; }
body.app-font-d2coding { --font-app: "D2Coding", "Apple SD Gothic Neo", monospace; }
body.app-font-childfund { --font-app: "SDChildfundkorea", "Apple SD Gothic Neo", sans-serif; --verse-mark-raise: .14em; }
a { color: var(--accent); }

/* 레이아웃 + 사이드바 */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: var(--panel); border-right: 1px solid var(--border); display: flex; flex-direction: column; padding: 1rem 0; }
.brand { font-weight: 800; font-size: 1.1rem; padding: 0 1.25rem 1rem; }
.brand a { color: var(--fg); text-decoration: none; }
.nav-list { list-style: none; margin: 0; padding: 0; flex: 1; }
.nav-link { display: block; padding: .55rem 1.25rem; color: var(--fg); text-decoration: none; }
.nav-link:hover { background: var(--accent-soft); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; border-right: 3px solid var(--accent); }
.nav-link.disabled { color: var(--muted); cursor: default; }
.badge { font-size: .7rem; background: var(--border); border-radius: 6px; padding: 0 .4rem; vertical-align: middle; }
.badge-bad { background: var(--bad); color: #fff; }
/* 사이드바 테마 스위처 — 알약형 3버튼 세그먼트 */
.theme-switch {
  display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden;
  margin: .5rem 1.25rem;
}
.theme-switch form { flex: 1; }
.theme-switch form + form { border-left: 1px solid var(--border); }
.theme-btn {
  width: 100%; background: transparent; border: 0; padding: .35rem 0; cursor: pointer;
  color: var(--muted); font: inherit;
}
.theme-btn:hover { background: var(--accent-soft); }
.theme-btn.active { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

.sidebar-footer { padding: 1rem 1.25rem 0; border-top: 1px solid var(--border); font-size: .9rem; }
.footer-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .3rem; }
.user-name { font-weight: 700; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; padding: .3rem; border-radius: 8px; color: var(--muted); }
.icon-btn:hover { color: var(--accent); background: var(--accent-soft); }
.footer-link { color: var(--muted); text-decoration: none; }
.footer-link.as-button { background: none; border: none; padding: 0; cursor: pointer; font: inherit; }
.content { flex: 1; padding: 2rem 2.5rem; min-width: 0; }  /* 넓은 화면 전체 활용 */
/* 본문형(긴 글) 컨텐츠만 읽기 좋은 폭 유지 — 그리드·통계·홈은 전체 폭 사용 */
#typing-app, .verse, .content > .next-preview { max-width: 62rem; }
.hamburger { display: none; position: fixed; top: .75rem; left: .75rem; z-index: 20; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .3rem .6rem; cursor: pointer; }

/* 좁은 화면: 사이드바 → 햄버거 */
@media (max-width: 768px) {
  .hamburger { display: block; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .nav-toggle:checked ~ .layout .sidebar { transform: translateX(0); }
  .content { padding: 3.5rem 1rem 1rem; }
}

/* 공통 컴포넌트 */
.centered-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; }
.centered-page .card { padding: 2rem 2.5rem; text-align: center; box-shadow: 0 2px 12px rgba(0,0,0,.08); border: none; }
.btn { display: inline-block; padding: .6rem 1.2rem; border-radius: 8px; border: 1px solid var(--border); background: var(--panel); cursor: pointer; text-decoration: none; color: inherit; font: inherit; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700; }
/* 카카오 노란 배경에는 검은 글씨 — 브랜드 가이드이자 대비 문제.
   color를 지정하지 않으면 .btn의 color:inherit이 다크 테마의 밝은 글자색을
   물려받아 노랑 위 흰 글씨가 된다. */
.btn-kakao { background: var(--kakao); border-color: var(--kakao); color: rgba(0,0,0,.85); font-weight: 700; }
.btn-kakao:hover { background: #f6dd00; border-color: #f6dd00; color: rgba(0,0,0,.85); }

/* 로그인 폼 (아이디/비밀번호) */
.login-divider { color: var(--muted); font-size: .85rem; margin: 1rem 0 .6rem; display: flex; align-items: center; gap: .6rem; }
.login-divider::before, .login-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.login-form { display: flex; flex-direction: column; gap: .5rem; }
.login-form input { padding: .55rem .8rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.form-error { color: var(--bad); font-size: .85rem; margin: 0; }

/* ---- 인증 화면 (로그인·승인 대기) — 장정 초록 배경 + 본문지 카드 + 금박 포인트 ----
   base.html 미상속 독립 템플릿이라 다크 대응도 .auth-page 스코프 안에서 별도로 한다.
   겉 배경(장정 그라데이션)은 원래도 짙은 톤이라 테마 불문 고정, 안쪽 본문지 카드만 다크에서 톤을 바꾼다. */
.auth-page {
  --auth-ink: #2B2130;        /* 장정 보라 잉크 */
  --auth-paper: #FAF7F0;      /* 성경 본문지 */
  --auth-gold: #C4A15A;       /* 금박 단면 */
  --auth-pending: #A099A6;    /* 아직 입력 전 본문 */
  --auth-verse-bg: #F3EEE3;   /* 말씀 인용구 배경 */
  --auth-line: #D8D2C4;       /* 테두리(조용한 버튼·입력창) */
  --auth-line-soft: #E2DCCE;  /* 구분선(더 연하게) */
  --auth-input-bg: #fff;      /* 아이디/비밀번호 입력창 배경 */
  background: radial-gradient(120% 130% at 50% -10%, #451A63 0%, #301245 55%, #200B30 100%);
  padding: 1rem;
}
/* 다크 컨텍스트 — theme-dark / theme-system(미디어) 쌍은 항상 함께 갱신할 것 */
body.theme-dark.auth-page {
  --auth-ink: #ece7f0; --auth-paper: #241b30; --auth-gold: #d9b673; --auth-pending: #8b8298;
  --auth-verse-bg: #2f2440; --auth-line: #443658; --auth-line-soft: #3a2e4a; --auth-input-bg: #2a2136;
}
@media (prefers-color-scheme: dark) {
  body.theme-system.auth-page {
    --auth-ink: #ece7f0; --auth-paper: #241b30; --auth-gold: #d9b673; --auth-pending: #8b8298;
    --auth-verse-bg: #2f2440; --auth-line: #443658; --auth-line-soft: #3a2e4a; --auth-input-bg: #2a2136;
  }
}
.auth-card {
  width: min(100%, 380px);
  background: var(--auth-paper);
  border-radius: 18px;
  padding: 2.4rem 2.2rem 2.2rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45), 0 2px 8px rgba(0, 0, 0, .3);
}
.auth-brand {
  font-family: "Gowun Batang", "Apple SD Gothic Neo", serif;
  font-weight: 700;
  font-size: 1.65rem;
  color: var(--auth-ink);
  margin: 0;
  letter-spacing: .01em;
}
.auth-tagline { color: var(--muted); font-size: .85rem; margin: .2rem 0 1.6rem; }
.auth-verse {
  margin: 0 0 1.6rem;
  padding: 1rem 1.1rem 1.1rem;
  background: var(--auth-verse-bg);
  border-radius: 12px;
  border-left: 3px solid var(--auth-gold);
}
.verse-ref {
  font-size: .68rem;
  letter-spacing: .12em;
  color: var(--auth-gold);
  margin-bottom: .35rem;
}
.verse-line {
  font-family: "Gowun Batang", serif;
  font-size: 1rem;
  line-height: 1.7;
  margin: 0;
  color: var(--auth-pending);
  word-break: keep-all;
}
.verse-line .typed { color: var(--accent); }
.verse-line .pending { color: var(--auth-pending); }
.verse-line .caret {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin: 0 1px -0.15em;
  background: var(--auth-gold);
  animation: caret-blink 1.1s steps(1) infinite;
}
@keyframes caret-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .verse-line .caret, .typing-flow .caret-here::before, .typing-flow .caret-end::after { animation: none; }
}
.auth-btn { display: block; width: 100%; text-align: center; padding: .7rem 1rem; border-radius: 10px; }
.auth-btn-quiet { background: transparent; border: 1px solid var(--auth-line); color: var(--auth-ink); }
.auth-btn-quiet:hover { border-color: var(--accent); color: var(--accent); }
.auth-page .login-divider::before, .auth-page .login-divider::after { border-color: var(--auth-line-soft); }
/* color를 안 주면 브라우저 기본값(검정)이 다크 배경 위에 얹혀 안 보인다 */
.auth-page .login-form input { background: var(--auth-input-bg); border-color: var(--auth-line); color: var(--auth-ink); }
.auth-page .login-form input::placeholder { color: var(--auth-pending); }
/* 브랜드 3연타로 비밀번호 폼을 여는 장치 — 연타 시 글자가 선택되지 않게 한다 */
.auth-brand { user-select: none; -webkit-user-select: none; }
.auth-page .login-form input:focus, .auth-page .auth-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.muted { color: var(--muted); }
.progress { background: var(--grass-0); border-radius: 6px; height: 8px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); }

/* 페이지 헤더 — 제목 왼쪽, 바로가기 칩 오른쪽 (좁으면 줄바꿈) */
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .6rem 1rem; margin: 0 0 1.2rem; }
.page-head h1 { margin: 0; }
.toc-actions { display: flex; gap: .55rem; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .48rem 1.05rem; border: 1px solid var(--border); border-radius: 999px;
  background: var(--panel); text-decoration: none; color: var(--fg);
  font-size: .92rem; font-weight: 500;
  transition: border-color .12s, box-shadow .12s;
}
.chip:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 1px 6px rgba(169, 3, 252, .12); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chip-heart { color: var(--heart); font-size: .95em; }
.chip-grass { display: inline-flex; gap: 2px; }
.chip-grass i { width: 7px; height: 7px; border-radius: 2px; }
.chip-grass i:nth-child(1) { background: var(--grass-2); }
.chip-grass i:nth-child(2) { background: var(--grass-3); }
.chip-grass i:nth-child(3) { background: var(--grass-4); }

/* 목차 그리드 — 모드별 진행률 두 줄 */
.mode-progress { display: flex; align-items: center; gap: .35rem; margin-top: .25rem; }
.mp-label { font-size: .66rem; color: var(--muted); width: 2.4em; flex-shrink: 0; }
.mp-pct { font-size: .66rem; color: var(--muted); width: 2.6em; text-align: right; flex-shrink: 0; }
.mode-progress .progress { flex: 1; height: 6px; }
.mp-typing .progress > span { background: var(--accent-typing); }  /* 타이핑 = 연보라, 읽기 = 보라 */

/* 통계 책별 진행률 — 촘촘한 카드 그리드 */
.stats-book-grid { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); gap: .45rem; }
.stats-book-grid .book-cell { padding: .45rem .65rem; }
.stats-book-name { font-size: .88rem; font-weight: 600; }

/* 통계 상세 기록 */
.session-table td, .session-table th { white-space: nowrap; }
.session-table td:nth-child(3) { white-space: normal; }
.mode-tag { font-size: .75rem; border-radius: 6px; padding: .1rem .5rem; background: var(--accent-soft); color: var(--accent); }
.mode-tag.mode-타이핑 { background: var(--mode-typing-bg); color: var(--mode-typing-fg); }

/* 목차 그리드 */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; margin: .5rem 0 1.5rem; }
.book-cell {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: .6rem .8rem; text-decoration: none; color: var(--fg);
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.book-cell.started { border-color: var(--accent); }  /* 진행률이 조금이라도 있는 책 */
.book-cell:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(169, 3, 252, .14);
}
@media (prefers-reduced-motion: reduce) {
  .book-cell { transition: none; }
  .book-cell:hover { transform: none; }
}
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: .5rem; }
.chapter-cell { padding: .4rem .5rem .5rem; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; text-decoration: none; color: var(--fg); }
.chapter-cell:hover { border-color: var(--accent); }
.chapter-cell.done { background: var(--accent-soft); border-color: var(--accent); }
.ch-top { display: flex; align-items: center; justify-content: center; gap: .2rem; line-height: 1.3; }
.ch-no { font-weight: 600; }
.ch-bm { font-size: .5rem; line-height: 1; }
.ch-bm-read, .legend-read { color: var(--accent); }
.ch-bm-typing, .legend-typing { color: var(--accent-typing); }
.ch-bar { height: 4px; background: var(--grass-0); border-radius: 2px; margin-top: 3px; overflow: hidden; }
.ch-bar > span { display: block; height: 100%; background: var(--accent); }
.ch-bar-typing > span { background: var(--accent-typing); }
.ch-legend { font-size: .85rem; }

/* 읽기 모드 — 하트·절 번호는 타이핑 화면과 동일 배치 */
.verse { margin: 0 0 .55rem; line-height: 1.9; word-break: keep-all; font-size: calc(1.02rem * var(--verse-scale)); }
/* 절 = 마커(하트·번호) 거터 + 본문 컬럼 → 줄바꿈된 본문이 마커 아래가 아니라 본문 첫 줄 아래로 정렬(행잉 인덴트). 읽기·타이핑 동일 */
.verse, .flow-verse, .next-preview { display: flex; align-items: baseline; }
.verse-gutter { flex-shrink: 0; }
.verse-body { flex: 1 1 auto; min-width: 0; }
.verse .heart-form { display: inline; }
.verse.read-done { color: var(--done-ink); }  /* 읽음 표시한 절 = 타이핑 완료와 같은 진한 보라 */
.verse-check {
  background: none; border: none; cursor: pointer; padding: 0;
  margin-right: .12em;
  font-size: .66em; line-height: 1; vertical-align: var(--verse-mark-raise);
  color: var(--mark-off);
  font-family: "Pretendard Variable", Pretendard, sans-serif;
}
.verse-check.on { color: var(--accent); }
.verse-check:hover { color: var(--accent); }

/* 번역본 전환 칩 */
.trans-switch { display: inline-flex; gap: .4rem; flex-wrap: wrap; }  /* 간격은 page-tools gap이 담당 */
.trans-chip {
  border: 1px solid var(--border); background: var(--panel); border-radius: 999px;
  padding: .3rem .85rem; cursor: pointer; font: inherit; font-size: .85rem; color: var(--muted);
  text-decoration: none;  /* <a>로 쓰이는 경우(설정 탭) 밑줄 방지 */
}
.trans-chip:hover { border-color: var(--accent); color: var(--accent); }
.trans-chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }

/* 페이지 도구 줄 (번역본·글자 크기 칩) */
.page-tools { display: flex; flex-wrap: wrap; gap: .2rem 1.2rem; align-items: center; }
.font-scale-switch .trans-chip { line-height: 1; }
.font-scale-switch .scale-small { font-size: .75rem; }
.font-scale-switch .scale-normal { font-size: .9rem; }
.font-scale-switch .scale-large { font-size: 1.05rem; }
.font-scale-switch .scale-xlarge { font-size: 1.2rem; }
.font-scale-switch .scale-xxlarge { font-size: 1.38rem; }

/* 타이핑 모드 — 원문 위 오버레이 타이핑 (typing.works 스타일) */
.batch-picker { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.batch-picker button { border: none; background: var(--panel); padding: .35rem .95rem; cursor: pointer; font: inherit; font-size: .85rem; color: var(--muted); }
.batch-picker button + button { border-left: 1px solid var(--border); }
.batch-picker button.active { background: var(--accent); color: #fff; }
.typing-flow {
  font-family: inherit;  /* 앱 글꼴 설정을 따른다 */
  font-size: calc(1.45rem * var(--verse-scale)); line-height: 2;
  word-break: keep-all; overflow-wrap: anywhere;
  background: var(--panel); border: 1px solid var(--border); border-radius: 14px;
  padding: 1.6rem 1.8rem; cursor: text;
}
.flow-verse { margin: 0 0 .7rem; }
.flow-verse:last-child { margin-bottom: 0; }
/* 절 번호·하트 — 한글 본문의 시각적 세로 중앙에 오도록 기준선에서 살짝 올림 */
.flow-verse sup, .verse sup { color: var(--muted); font-size: .66em; margin-right: .4em; font-family: "Pretendard Variable", Pretendard, sans-serif; vertical-align: var(--verse-mark-raise); line-height: 1; }
.flow-verse.done { color: var(--done-ink); }         /* 완료한 절 = 진한 보라 — 현재 절과 구분 */
.flow-verse.future { color: var(--faint-ink); }      /* 아직 안 온 절 = 흐리게 */
.typing-flow .pending { color: var(--faint-ink); }   /* 입력 전 글자 = 흐리게 */
.typing-flow .correct { color: var(--correct-ink); } /* 맞게 입력 = 진해짐 */
.typing-flow .wrong { color: var(--bad); background: rgba(214, 69, 69, .13); border-radius: 3px; }
.typing-flow .composing { color: var(--composing-ink); border-bottom: 2px solid var(--accent); }
/* 조합 중 글자 오버레이 — 원문 글자(투명)가 칸 폭을 고정하고, 조합 글자를 위에 그린다.
   line-height(2)를 그대로 두면 오버레이 글자가 아래로 처지므로 글자 영역 중앙에 정렬한다 */
.typing-flow .composing-host { position: relative; color: transparent; border-bottom: 2px solid var(--accent); }
.typing-flow .composing-host::before {
  content: attr(data-composing);
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  line-height: 1; white-space: pre; color: var(--composing-ink);
}
/* 캐럿 — 글자 위에 겹쳐 그리는 절대배치 (레이아웃·줄바꿈에 영향 없음) */
.typing-flow .caret-here, .typing-flow .caret-end { position: relative; }
.typing-flow .caret-here::before, .typing-flow .caret-end::after {
  content: ""; position: absolute; width: 2px; top: .12em; bottom: .12em;
  background: var(--accent); animation: caret-blink 1.1s steps(1) infinite;
}
.typing-flow .caret-here::before { left: -1px; }
.typing-flow .caret-end::after { right: -2px; }
.next-preview { margin: 1rem .4rem 0; color: var(--muted); font-size: calc(.95rem * var(--verse-scale)); word-break: keep-all; }
.next-preview sup { font-size: .7em; margin-right: .35em; }
/* fixed로 뷰포트에 고정 — absolute(카드 하단)면 타이핑 때마다 크롬이 입력창을 화면 안으로 끌어와 페이지가 점프한다 */
.typing-hidden-input { position: fixed; top: 0; left: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; }
.typing-hud { display: flex; gap: 1.5rem; color: var(--muted); margin: .6rem 0 .45rem; font-size: .95rem; }
.typing-progress { height: 6px; margin-bottom: 1rem; }  /* 채움 색은 .progress 기본(보라) */
#hud-speed { color: var(--accent); font-weight: 700; }
.verse-heart {
  /* 절 번호(sup)와 같은 크기·같은 기준선으로 정렬 — 어긋남 방지 */
  background: none; border: none; cursor: pointer; padding: 0;
  margin-right: .12em;
  font-size: .66em; line-height: 1; vertical-align: var(--verse-mark-raise);
  color: var(--mark-off);
  font-family: "Pretendard Variable", Pretendard, sans-serif;
}
.verse-heart.on { color: var(--heart); }
.verse-heart:hover { color: var(--heart); }
.summary-card { text-align: center; margin-top: 1rem; }  /* 완료 화면엔 HUD가 없어 도구 줄과 붙는 것 방지 */
.summary-card .big { font-size: 2rem; font-weight: 800; color: var(--accent); }

/* 설정 — 본문 글꼴 선택 */
.settings-card { max-width: 42rem; margin-bottom: 1rem; }
.settings-card h2 { margin-top: 0; }
/* 탭 바와 첫 카드가 붙지 않도록 — page-head와 같은 1.2rem */
.settings-tabs { margin-bottom: 1.2rem; }
.font-options { display: flex; flex-direction: column; gap: .6rem; margin: 1rem 0 1.2rem; }
.font-option {
  display: flex; align-items: center; gap: .85rem;
  padding: .9rem 1.1rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer;
}
/* 하이라이트는 실제 체크 상태만 따라간다 — 저장 전 이중 표시 방지 */
.font-option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.font-option input { accent-color: var(--accent); }
.font-sample { flex: 1; font-size: 1.08rem; word-break: keep-all; }
.font-sample-gowun { font-family: "Gowun Batang", serif; }
.font-sample-pretendard { font-family: "Pretendard Variable", Pretendard, sans-serif; }
.font-sample-d2coding { font-family: "D2Coding", monospace; }
.font-sample-childfund { font-family: "SDChildfundkorea", sans-serif; }
.font-name { color: var(--muted); font-size: .85rem; white-space: nowrap; }

/* 관리 페이지 */
.manage-card { max-width: 52rem; margin-bottom: 1rem; }
.manage-card h2 { margin-top: 0; }
/* 사용자 표는 열이 10개라 좁은 화면에서 페이지 전체를 밀어낸다.
   표만 가로로 스크롤시키고 페이지는 고정한다 (.hh-matrix-wrap과 같은 방식). */
.manage-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 셀이 세로로 쪼개져 "승 인 대 기"처럼 보이는 것을 막는다 */
.manage-card table.plain th, .manage-card table.plain td { white-space: nowrap; }
.btn-sm { padding: .3rem .8rem; font-size: .85rem; }
.status-ok { color: var(--ok); font-weight: 600; }
.status-pending { color: var(--warn); font-weight: 600; }
.create-form { display: flex; gap: .5rem; flex-wrap: wrap; }
.create-form input { padding: .5rem .8rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; flex: 1 1 160px; }

/* 잔디 히트맵 */
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-auto-columns: max-content; justify-content: start; gap: 3px; padding: .3rem 0 .5rem; }
/* 홈 최근 30일 — 한 줄 배치 (칸 조금 크게) */
.heatmap-mini { display: flex; flex-wrap: wrap; }
.heatmap-mini .d { width: 15px; height: 15px; border-radius: 3px; }
/* 잔디 말풍선 툴팁 — 호버한 칸 위에 즉시 표시. 데스크톱은 overflow 없음(클리핑 방지),
   모바일은 터치(호버 없음)라 스크롤만 유지 */
.heatmap .d { position: relative; }
.heatmap .d:hover { outline: 2px solid var(--accent); outline-offset: 1px; z-index: 6; }
.heatmap .d[data-tip]:hover::after {
  content: attr(data-tip);
  /* 오른쪽 끝(최근 날짜) 칸에서도 화면 안에 들어오도록 칸 오른쪽에 정렬해 왼쪽으로 펼친다 */
  position: absolute; bottom: calc(100% + 9px); right: -6px;
  white-space: pre-line; width: max-content; max-width: 260px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: .5rem .85rem; font-size: .84rem; line-height: 1.55; color: var(--fg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12); pointer-events: none; z-index: 7;
}
/* 구조화 말풍선 (통계 잔디): 날짜 / 읽기·타이핑 2단 */
.heatmap .d .tip { display: none; }
.heatmap .d:hover .tip {
  display: block; position: absolute; bottom: calc(100% + 9px); right: -6px;
  width: max-content; max-width: 300px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: .55rem .9rem .6rem; font-size: .84rem; line-height: 1.5; color: var(--fg);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .12); pointer-events: none; z-index: 7;
}
.tip-date { text-align: center; font-weight: 700; margin-bottom: .3rem; }
/* 두 열은 항상 동일 폭, 전체 너비는 내용(가장 넓은 열)에 따라 동적 */
.tip-cols { display: grid; grid-template-columns: 1fr 1fr; column-gap: .9rem; }
.tip-col { min-width: 3.2em; }
.tip-col + .tip-col { border-left: 1px solid var(--border); padding-left: .9rem; }
.tip-head { color: var(--muted); font-size: .76rem; margin-bottom: .1rem; }
.tip-none { color: var(--muted); }
.heatmap .d:hover::before {
  content: ""; position: absolute; bottom: calc(100% + 3px); left: 50%; transform: translateX(-50%);
  border: 6px solid transparent; border-top-color: var(--panel);
  filter: drop-shadow(0 1px 0 var(--border)); pointer-events: none; z-index: 7;
}
@media (max-width: 768px) {
  .heatmap { overflow-x: auto; }
}
.heatmap .d { width: 12px; height: 12px; border-radius: 2px; background: var(--grass-0); }
.heatmap .l1 { background: var(--grass-1); } .heatmap .l2 { background: var(--grass-2); }
.heatmap .l3 { background: var(--grass-3); } .heatmap .l4 { background: var(--grass-4); }

/* 통계 */
.stat-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.stat-tile { flex: 1 1 140px; }
.stat-tile .num { font-size: 1.6rem; font-weight: 800; }
table.plain { border-collapse: collapse; width: 100%; }
table.plain th, table.plain td { text-align: left; padding: .4rem .6rem; border-bottom: 1px solid var(--border); }

/* 캘린더 연결 관리 */
.cal-account-card { max-width: 44rem; margin-bottom: 1rem; }
.cal-account-card h2 { margin-top: 0; }
.cal-account-head { display: flex; align-items: center; gap: .6rem; }
.cal-account-head .cal-account-actions { margin-left: auto; display: inline-flex; align-items: center; gap: .9rem; }
.cal-reconnect:hover { color: var(--accent); }
.cal-inline-form { display: inline; }
.cal-error { color: var(--bad); font-size: .85rem; }
.cal-list { list-style: none; margin: .6rem 0 0; padding: 0; }
.cal-list li { display: flex; align-items: center; gap: .5rem; padding: .25rem 0; }
.cal-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }

/* 월간 캘린더 그리드 */
.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; background: var(--panel); border-radius: 12px; overflow: hidden; }
.cal-grid th { padding: .5rem 0; font-size: .8rem; color: var(--muted); border-bottom: 1px solid var(--border); font-weight: 600; }
.cal-grid th:first-child, .cal-cell:first-child .cal-date { color: var(--bad); }   /* 일요일 */
.cal-cell { position: relative; vertical-align: top; border: 1px solid var(--border); min-height: 96px; height: 96px; padding: .3rem .35rem; }
.cal-cell.out { background: var(--bg); opacity: .55; }
.cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.cal-date { display: inline-block; font-size: .8rem; font-weight: 600; text-decoration: none; color: var(--fg); margin-bottom: .15rem; }
.cal-ev { font-size: .72rem; line-height: 1.35; border-left: 3px solid var(--accent); padding-left: .3rem; margin-bottom: .15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-ev-time { color: var(--muted); margin-right: .2rem; }
.cal-more { font-size: .72rem; color: var(--accent); text-decoration: none; }
/* 멀티데이 연속 밴드 — 셀 패딩·테두리 위로 확장해 이웃 셀과 끊김 없이 이어진다 */
.cal-band {
  display: block; height: 1.15rem; line-height: 1.15rem; font-size: .72rem; color: #fff;
  margin: 0 calc(-.35rem - 1px) .15rem; padding: 0 .35rem;
  white-space: nowrap; overflow: hidden;
}
.cal-band.bs { margin-left: 0; border-radius: 5px 0 0 5px; }
.cal-band.be { margin-right: 0; border-radius: 0 5px 5px 0; }
.cal-band.bs.be { border-radius: 5px; }
.cal-band.empty { background: transparent; }
.as-chip-button { border: 1px solid var(--border); background: var(--panel); border-radius: 999px; padding: .48rem 1.05rem; cursor: pointer; font: inherit; font-size: .92rem; }
.as-chip-button:hover { border-color: var(--accent); color: var(--accent); }
.cal-toggles { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .8rem; }
.cal-toggle-row { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; }
.cal-acc-label { font-size: .82rem; font-weight: 600; opacity: .75; min-width: 5.5rem; }
.cal-toggle { display: inline-flex; align-items: center; gap: .4rem; opacity: .45; }
.cal-toggle.active { opacity: 1; }

/* 일별 목록 */
.day-event { display: flex; gap: .7rem; align-items: flex-start; max-width: 44rem; margin-bottom: .6rem; padding: .9rem 1.1rem; }
.day-event .cal-dot { margin-top: .45rem; }
.day-event-title { font-weight: 600; }
.day-event-meta { font-size: .85rem; }
.day-event-desc { margin: .3rem 0 0; font-size: .9rem; white-space: pre-line; }

/* 캘린더 색 선택 (연결 관리) — 원형 스와치 모양의 네이티브 컬러 피커 */
.cal-color-form { display: inline-flex; align-items: center; gap: .35rem; }
.cal-color-input {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; padding: 0; border: 1px solid var(--border); border-radius: 50%;
  background: none; cursor: pointer; flex-shrink: 0; overflow: hidden;
}
.cal-color-input::-webkit-color-swatch-wrapper { padding: 0; }
.cal-color-input::-webkit-color-swatch { border: none; border-radius: 50%; }
.cal-color-input::-moz-color-swatch { border: none; border-radius: 50%; }

/* 일정 폼 + 월간 셀 추가 버튼 */
.event-form { display: flex; flex-direction: column; gap: .6rem; max-width: 480px; }
.event-field { display: flex; flex-direction: column; gap: .2rem; }
.event-field label { font-size: .85rem; color: var(--muted); }
.event-field input, .event-field select, .event-field textarea {
  padding: .5rem .7rem; border: 1px solid var(--border); border-radius: 8px; font: inherit;
}
.event-delete-form { margin-top: 1rem; border-top: 1px solid var(--border); padding-top: .8rem; }
.event-delete-form .danger { color: var(--bad); }
.cal-add { display: none; font-weight: 700; color: var(--accent); text-decoration: none;
           margin-left: .2rem; font-size: .8rem; }
.cal-cell:hover .cal-add { display: inline; }
.event-edit-link { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--border); }
.event-edit-link:hover { color: var(--accent); }

/* 홈 — 오늘 일정 + 성경통독 2단 요약 */
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; max-width: 68rem; }
.home-section-head { display: flex; align-items: center; justify-content: space-between; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.home-section-head h2 { margin: 0; }
.home-subhead { margin: 1.1rem 0 .4rem; font-size: .95rem; color: var(--muted); }
.home-event { display: flex; align-items: center; gap: .5rem; padding: .28rem 0; min-width: 0; }
.home-event-time { color: var(--muted); font-size: .85rem; flex-shrink: 0; min-width: 3.4rem; }
.home-event-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.home-continue { display: flex; flex-direction: column; gap: .7rem; margin-bottom: .9rem; }
.home-continue-item { display: flex; align-items: center; justify-content: space-between; gap: .8rem; }
.home-bible-stats { display: flex; gap: 1.6rem; margin-bottom: .4rem; }
.home-bible-stats .num { font-size: 1.3rem; font-weight: 800; color: var(--accent); }

/* ---------- 일기 ---------- */
/* 일기 쓰기/수정 — '기록 시트' */
.diary-sheet { max-width: 46rem; margin: 0 auto; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px; padding: 2rem 2.2rem 1.5rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.04); color-scheme: light; }
body.theme-dark .diary-sheet { color-scheme: dark; }
.diary-eyebrow { margin: 0 0 1.4rem; font-size: .82rem; font-weight: 800;
  letter-spacing: .16em; text-transform: uppercase; color: var(--accent); }
.diary-sheet ::placeholder { color: var(--muted); opacity: 1; }

.field { margin-bottom: 1.3rem; }
.diary-field-last { margin-bottom: 1.6rem; }
.field-label { display: block; margin-bottom: .5rem; font-size: .72rem; font-weight: 700;
  letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }

.diary-input { width: 100%; padding: .6rem .8rem; font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  transition: border-color .12s, box-shadow .12s; }
.diary-input:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft); }
.diary-input.diary-date { width: auto; min-width: 12rem; }

.diary-title-input { width: 100%; padding: .35rem 0; font: inherit; font-size: 1.55rem;
  font-weight: 700; color: var(--fg); background: transparent; border: 0;
  border-bottom: 2px solid var(--border); border-radius: 0;
  transition: border-color .12s; }
.diary-title-input:focus { outline: none; border-bottom-color: var(--accent); }

/* 날짜 + 기분 머리글 행 */
.diary-meta { display: flex; flex-wrap: wrap; gap: 1rem 2rem; align-items: flex-start; }
.diary-meta .field { margin-bottom: 1.3rem; }

/* 기분 이모지 스탬프 피커 (시그니처) */
.mood-picker { display: flex; gap: .4rem; flex-wrap: wrap; }
.mood-opt { position: relative; cursor: pointer; }
.mood-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.mood-glyph { display: grid; place-items: center; width: 2.7rem; height: 2.7rem;
  font-size: 1.4rem; line-height: 1; background: var(--bg); border: 1px solid var(--border);
  border-radius: 13px; transition: transform .12s, border-color .12s, box-shadow .12s, background .12s; }
.mood-none .mood-glyph { font-size: .8rem; color: var(--muted); }
.mood-opt:hover .mood-glyph { transform: translateY(-2px); border-color: var(--accent); }
.mood-opt:has(input:checked) .mood-glyph { background: var(--accent-soft); border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft), 0 4px 12px rgba(169,3,252,.18); }
.mood-opt input:focus-visible + .mood-glyph { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Quill 에디터 = 하나의 매끈한 쓰기 상자 */
.diary-sheet .ql-toolbar.ql-snow { border-color: var(--border);
  border-top-left-radius: 12px; border-top-right-radius: 12px; }
.diary-sheet .ql-container.ql-snow { border-color: var(--border); font: inherit;
  border-bottom-left-radius: 12px; border-bottom-right-radius: 12px; }
.diary-sheet .ql-editor { min-height: 20rem; font-size: 1.02rem; line-height: 1.75; }

.diary-actions { display: flex; justify-content: flex-end; gap: .6rem; align-items: center;
  padding-top: 1.2rem; border-top: 1px solid var(--border); }

.diary-sheet .errorlist { list-style: none; margin: .4rem 0 0; padding: 0;
  color: var(--bad); font-size: .85rem; }

@media (prefers-color-scheme: dark) { body.theme-system .diary-sheet { color-scheme: dark; } }
@media (prefers-reduced-motion: reduce) {
  .mood-glyph, .diary-input, .diary-title-input { transition: none; }
  .mood-opt:hover .mood-glyph { transform: none; }
}
@media (max-width: 640px) {
  .diary-sheet { padding: 1.4rem 1.2rem 1.2rem; border-radius: 12px; }
  .diary-input.diary-date { width: 100%; }
}
.diary-body { line-height: 1.7; }
.diary-body img { max-width: 100%; border-radius: 8px; }
.diary-tags { margin-top: .6rem; }
.diary-cell { background-size: cover; background-position: center; }
.diary-cell.has-photo, .diary-cell.has-photo .cal-date { color: #fff; }
.diary-ev { display: block; font-size: .78rem; line-height: 1.35; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; text-decoration: none; color: inherit; }
.cal-diary { position: absolute; top: .2rem; right: 1.6rem; font-size: .8rem; text-decoration: none; }
.diary-ev:hover { text-decoration: underline; }
.diary-day-item h3 { margin: 0 0 .3rem; }
.diary-day-item h3 a { text-decoration: none; }
.diary-search-form input, .diary-search-card input { padding: .35rem .6rem; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; color: inherit; }
.diary-search-card { display: flex; gap: .5rem; }

/* ---------- API랩: 기업 검색 ---------- */
.apilab-notice { padding: .7rem .95rem; margin-bottom: 1.3rem; font-size: .9rem;
  background: var(--accent-soft); color: var(--fg); border: 1px solid var(--border); border-radius: 10px; }
.apilab-notice code { background: var(--bg); padding: .1rem .35rem; border-radius: 5px; }

.apilab-search { max-width: 40rem; margin: 1.5rem auto 2rem; }
.apilab-search-form { display: flex; gap: .6rem; }
.apilab-search-input { flex: 1; min-width: 0; padding: .85rem 1.1rem; font: inherit; font-size: 1.05rem;
  color: var(--fg); background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  transition: border-color .12s, box-shadow .12s; }
.apilab-search-input::placeholder { color: var(--muted); }
.apilab-search-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.apilab-search-btn { padding: .85rem 1.6rem; border-radius: 12px; font-size: 1.02rem; white-space: nowrap; }
.apilab-search-hint { margin: .9rem 0 0; text-align: center; color: var(--muted); font-size: .9rem; }

.apilab-result-count { max-width: 40rem; margin: 0 auto .7rem; color: var(--muted); font-size: .9rem; }
.apilab-results { list-style: none; margin: 0 auto; padding: 0; max-width: 40rem;
  display: flex; flex-direction: column; gap: .5rem; }
.apilab-result { display: flex; align-items: center; gap: .7rem; padding: .9rem 1.1rem;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  text-decoration: none; color: var(--fg);
  transition: border-color .12s, transform .12s, box-shadow .12s; }
.apilab-result:hover { border-color: var(--accent); transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(169, 3, 252, .12); }
.apilab-result-name { font-weight: 700; font-size: 1.05rem; }
.apilab-stock { font-size: .74rem; font-weight: 700; letter-spacing: .03em;
  padding: .14rem .5rem; border-radius: 6px; background: var(--accent-soft); color: var(--accent); }
.apilab-unlisted { font-size: .74rem; padding: .14rem .5rem; border-radius: 6px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.apilab-result-go { margin-left: auto; font-size: .85rem; color: var(--muted);
  opacity: 0; transition: opacity .12s; white-space: nowrap; }
.apilab-result:hover .apilab-result-go { opacity: 1; color: var(--accent); }

.apilab-empty { max-width: 40rem; margin: 1.5rem auto; padding: 2rem 1rem; text-align: center; }
.apilab-empty-title { font-weight: 700; margin: 0 0 .4rem; }

@media (prefers-reduced-motion: reduce) {
  .apilab-search-input, .apilab-result, .apilab-result-go { transition: none; }
  .apilab-result:hover { transform: none; }
}
@media (max-width: 640px) {
  .apilab-search-form { flex-direction: column; }
  .apilab-result-go { display: none; }
}

/* ── 가계관리 ── */
.hh-summary { display: flex; gap: 1.5rem; flex-wrap: wrap; padding: .8rem 1.1rem; margin: 0 0 1.2rem; }
.hh-summary strong { color: var(--accent); }
.hh-summary .hh-expected { color: var(--muted); }  /* 예정액은 muted — 실제 합계(보라)와 구분 */
.hh-cell { text-align: left; }
/* 날짜 줄: 날짜 왼쪽 · 총 합계 오른쪽(보라) */
.hh-cell-head { display: flex; align-items: baseline; justify-content: space-between; gap: .3rem; }
.hh-amt { font-size: .82rem; font-weight: 700; color: var(--accent); white-space: nowrap; }
/* 칸 안 항목 칩 — 카테고리 색 왼쪽 띠, 이름(왼쪽)+금액(오른쪽) */
.hh-ev { display: flex; align-items: baseline; gap: .3rem; margin-top: .2rem; padding: .1rem .35rem;
  font-size: .72rem; border-left: 3px solid var(--border); border-radius: 3px; background: var(--bg);
  color: var(--fg); text-decoration: none; }
.hh-ev:hover { border-color: var(--accent); }
.hh-ev-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hh-ev-amt { flex-shrink: 0; color: var(--muted); font-variant-numeric: tabular-nums; }
.hh-ev-paid { opacity: .5; }
.hh-ev-paid .hh-ev-name { text-decoration: line-through; }
.hh-ev.hh-cat-loan { border-left-color: #e06666; }
.hh-ev.hh-cat-insurance { border-left-color: #6fa8dc; }
.hh-ev.hh-cat-telecom { border-left-color: #93c47d; }
.hh-ev.hh-cat-maintenance { border-left-color: #ffd966; }
.hh-ev.hh-cat-card { border-left-color: #c27ba0; }
.hh-ev.hh-cat-subscription { border-left-color: #b4a7d6; }
.hh-ev.hh-cat-etc { border-left-color: var(--border); }
/* 날짜 모달 */
dialog.hh-modal { border: 1px solid var(--border); border-radius: 14px; padding: 1.2rem;
  background: var(--panel); color: var(--fg); max-width: 460px; width: 92%;
  box-shadow: 0 14px 44px rgba(0,0,0,.3); }
dialog.hh-modal::backdrop { background: rgba(0,0,0,.5); }
.hh-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.hh-modal-head h3 { margin: 0; }
.hh-modal-close { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; padding: .2rem .4rem; }
.hh-modal-close:hover { color: var(--fg); }
dialog.hh-modal .hh-day-item { border-bottom: 1px solid var(--border); }
dialog.hh-modal .btn-primary { margin-top: 1rem; }
.hh-day-item.hh-track { opacity: .82; }
.hh-day-item { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .6rem; padding: .7rem 1rem; }
.hh-check { display: flex; align-items: center; gap: .6rem; cursor: pointer; }
.hh-check input { width: 18px; height: 18px; accent-color: var(--accent); }
.hh-name { font-weight: 600; }
.hh-fixed { font-weight: 600; }
.hh-amt-input, .hh-input { padding: .4rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg); }
.hh-amt-input { width: 120px; text-align: right; }

/* 매트릭스 */
.hh-matrix-head { margin-top: 2rem; }
.hh-matrix-head h2 { margin: 0; }
.hh-matrix-wrap { overflow-x: auto; margin-bottom: 1rem; }

/* 색상 범례 */
.hh-legend { display: flex; flex-wrap: wrap; gap: .5rem 1rem; margin: 0 0 .7rem;
  padding: .55rem .8rem; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.hh-legend-item { display: inline-flex; align-items: center; gap: .4rem; font-size: .82rem; color: var(--muted); }
.hh-legend-dot { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.hh-legend-dot.hh-cat-loan { background: #e06666; }
.hh-legend-dot.hh-cat-insurance { background: #6fa8dc; }
.hh-legend-dot.hh-cat-telecom { background: #93c47d; }
.hh-legend-dot.hh-cat-maintenance { background: #ffd966; }
.hh-legend-dot.hh-cat-card { background: #c27ba0; }
.hh-legend-dot.hh-cat-subscription { background: #b4a7d6; }
.hh-legend-dot.hh-cat-etc { background: var(--border); }

/* 드래그 재정렬 */
.hh-matrix tr[draggable="true"] { cursor: grab; }
.hh-matrix tr.hh-dragging { opacity: .5; background: var(--accent-soft); cursor: grabbing; }
.hh-drag { color: var(--muted); margin-right: .4rem; letter-spacing: -2px; cursor: grab; user-select: none; }
.hh-matrix.hh-reorder-error { outline: 2px solid var(--bad); }
.hh-matrix { border-collapse: collapse; width: 100%; font-size: .85rem; }
.hh-matrix th, .hh-matrix td { border: 1px solid var(--border); padding: .35rem .5rem; text-align: center; }
.hh-matrix th { background: var(--panel); color: var(--muted); font-weight: 600; }
.hh-matrix .sticky-col { position: sticky; left: 0; background: var(--panel); text-align: left; z-index: 1; }
.hh-matrix .hh-name { font-weight: 600; }
.hh-matrix .hh-amt-col, .hh-matrix .hh-due { color: var(--muted); white-space: nowrap; }
.hh-mcell input { width: 16px; height: 16px; accent-color: var(--accent); }
.hh-cat-loan .sticky-col { border-left: 3px solid #e06666; }
.hh-cat-insurance .sticky-col { border-left: 3px solid #6fa8dc; }
.hh-cat-telecom .sticky-col { border-left: 3px solid #93c47d; }
.hh-cat-maintenance .sticky-col { border-left: 3px solid #ffd966; }
.hh-cat-card .sticky-col { border-left: 3px solid #c27ba0; }
.hh-cat-subscription .sticky-col { border-left: 3px solid #b4a7d6; }
.hh-cat-etc .sticky-col { border-left: 3px solid var(--border); }

/* 항목 목록·폼 */
.hh-items { width: 100%; border-collapse: collapse; }
.hh-items th, .hh-items td { border-bottom: 1px solid var(--border); padding: .5rem .6rem; text-align: left; }
.hh-items th { color: var(--muted); font-weight: 600; }
.hh-inactive { opacity: .5; }
.hh-form .hh-form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; }
.hh-danger { color: var(--bad); border-color: var(--bad); }

/* ── 자동차 관리(car) ── */
.car-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .9rem; }
.car-card { display: block; padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: 12px;
  background: var(--panel); text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s; }
.car-card:hover { border-color: var(--accent); box-shadow: 0 1px 8px rgba(169, 3, 252, .12); }
.car-card-name { font-weight: 700; font-size: 1.05rem; }
.car-card-meta { color: var(--muted); font-size: .85rem; margin-top: .2rem; }
.car-card-econ { margin-top: .5rem; color: var(--accent); font-weight: 600; }
.car-empty { color: var(--muted); }

.car-summary { display: flex; flex-wrap: wrap; gap: 1.2rem; margin: 0 0 1.4rem;
  padding: 1rem 1.2rem; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.car-summary div { display: flex; flex-direction: column; gap: .2rem; }
.car-summary span { font-size: .8rem; color: var(--muted); }
.car-summary strong { font-size: 1.1rem; }

.car-section { margin: 1.6rem 0 .8rem; font-size: 1.05rem; }
.car-form.card { display: block; }
.car-form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; }

.car-logs-wrap { overflow-x: auto; }
.car-logs { width: 100%; border-collapse: collapse; white-space: nowrap; }
.car-logs th, .car-logs td { border-bottom: 1px solid var(--border); padding: .5rem .6rem; text-align: left; }
.car-logs th { color: var(--muted); font-weight: 600; }
.car-log-actions { display: flex; gap: .6rem; align-items: center; }
.car-log-actions form { display: inline; }
.car-link-danger { background: none; border: none; color: var(--bad); cursor: pointer; font: inherit; padding: 0; }
.car-danger-form { margin-top: 1rem; }
.car-danger { color: var(--bad); border-color: var(--bad); }

/* ── 자동차 추가/수정 폼 ── */
.car-form { max-width: 660px; }
.car-form .card { margin-bottom: 1.1rem; padding: 1.4rem 1.5rem; border-radius: 16px; }

/* 섹션 헤더 — 아이콘 + 제목 */
.car-sec-head { display: flex; align-items: center; gap: .55rem; margin: 0 0 1.1rem; }
.car-sec-head svg { color: var(--accent); flex: none; }
.car-sec-head h2 { margin: 0; font-size: .98rem; font-weight: 700; letter-spacing: -.01em; }

/* 필드 */
.car-field { display: flex; flex-direction: column; margin-bottom: 1rem; }
.car-field:last-child { margin-bottom: 0; }
.car-field label { font-size: .78rem; color: var(--muted); font-weight: 700;
  letter-spacing: .01em; margin-bottom: .4rem; }
.car-form input[type="text"], .car-form input[type="number"], .car-form input[type="date"],
.car-form select, .car-form textarea {
  width: 100%; box-sizing: border-box; padding: .62rem .75rem; font: inherit;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--panel); color: var(--fg);
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.car-form input::placeholder, .car-form textarea::placeholder { color: var(--muted); opacity: .6; }
.car-form input:hover, .car-form select:hover, .car-form textarea:hover { border-color: var(--muted); }
.car-form input:focus, .car-form select:focus, .car-form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.car-field-note { color: var(--muted); font-size: .76rem; margin-top: .35rem; }
.car-field ul.errorlist { list-style: none; margin: .35rem 0 0; padding: 0; color: var(--bad); font-size: .8rem; }
.car-form-errors { margin-bottom: 1rem; }
.car-form-errors ul.errorlist { list-style: none; margin: 0; padding: .7rem .9rem;
  border: 1.5px solid var(--bad); border-radius: 10px; color: var(--bad); font-size: .85rem; }
.car-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.1rem; }

/* 활성 체크 — 알약 토글 */
.car-toggle { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer;
  padding: .5rem .8rem; border: 1.5px solid var(--border); border-radius: 999px;
  font-size: .85rem; color: var(--fg); user-select: none; }
.car-toggle input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }
.car-toggle:hover { border-color: var(--muted); }

/* ── 시그니처: 번호판 — 앱 테마와 무관하게 실제 번호판처럼 고정 톤 ── */
.car-plate-field label { text-align: center; }
.car-form .car-plate-field input[type="text"] {
  width: 190px; padding: .55rem .6rem; text-align: center;
  font-family: "D2Coding", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.6rem; font-weight: 700; letter-spacing: .12em;
  color: #16161a; background: #f4f4ee;
  border: 2.5px solid #23252b; border-radius: 12px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.7);
}
.car-form .car-plate-field input[type="text"]::placeholder { color: #9a9a92; opacity: 1; letter-spacing: .12em; }
.car-form .car-plate-field input[type="text"]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,.7);
}

/* 하단 액션 */
.car-form-actions { display: flex; align-items: center; gap: .7rem; margin-top: .3rem; }
.car-form-actions .btn { padding: .6rem 1.4rem; }

@media (max-width: 560px) {
  .car-grid-2 { grid-template-columns: 1fr; }
  .car-plate-field { justify-self: center; }
  .car-form .car-plate-field input[type="text"] { width: 100%; max-width: 240px; }
}

/* ── 소모품 교체주기 ── */
.car-section-head { display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; margin: 1.6rem 0 .8rem; }
.car-section-head .car-section { margin: 0; }
.car-maint-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.car-maint { display: flex; align-items: center; gap: .8rem; padding: .7rem .9rem;
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
.car-maint-badge { flex: none; min-width: 3.2em; text-align: center; padding: .25rem .5rem;
  border-radius: 999px; font-size: .78rem; font-weight: 700; }
.car-maint-overdue { border-color: var(--bad); }
.car-maint-overdue .car-maint-badge { background: var(--bad); color: #fff; }
.car-maint-due_soon { border-color: var(--warn); }
.car-maint-due_soon .car-maint-badge { background: #c17d0f; color: #fff; }
.car-maint-ok .car-maint-badge { background: var(--accent-soft); color: var(--accent); }
.car-maint-unset .car-maint-badge { background: var(--border); color: var(--muted); }
.car-maint-body { flex: 1; min-width: 0; }
.car-maint-name { font-weight: 700; }
.car-maint-phrase { font-size: .84rem; color: var(--muted); margin-top: .1rem; }
.car-maint-actions { display: flex; align-items: center; gap: .55rem; flex-wrap: wrap; }
.car-maint-actions form { display: inline; }
.car-maint-link { font-size: .85rem; color: var(--muted); text-decoration: none; }
.car-maint-link:hover { color: var(--accent); }

/* 홈 요약 — 차량 소모품 알림 */
.home-maint-item { display: flex; align-items: center; gap: .6rem; padding: .4rem 0;
  border-bottom: 1px solid var(--border); }
.home-maint-item:last-child { border-bottom: none; }
.home-maint-badge { flex: none; min-width: 3em; text-align: center; padding: .15rem .45rem;
  border-radius: 999px; font-size: .72rem; font-weight: 700; }
.home-maint-overdue .home-maint-badge { background: var(--bad); color: #fff; }
.home-maint-due_soon .home-maint-badge { background: #c17d0f; color: #fff; }
.home-maint-text { font-size: .88rem; }
.home-maint-text a { color: inherit; text-decoration: none; font-weight: 600; }
.home-maint-text a:hover { color: var(--accent); }

/* ── 정비 이력 분류 배지 ── */
.car-cat { display: inline-block; padding: .12rem .5rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; white-space: nowrap; }
.car-cat-inspection { background: var(--accent-soft); color: var(--accent); }
.car-cat-accident { background: #fde2e2; color: #b02a2a; }
.car-cat-consumable { background: #e2eefd; color: #1f5fb0; }
.car-cat-etc { background: var(--border); color: var(--muted); }
body.theme-dark .car-cat-accident { background: #4a1f1f; color: #ff9c9c; }
body.theme-dark .car-cat-consumable { background: #1c2f4a; color: #8fbaf0; }
@media (prefers-color-scheme: dark) {
  body.theme-system .car-cat-accident { background: #4a1f1f; color: #ff9c9c; }
  body.theme-system .car-cat-consumable { background: #1c2f4a; color: #8fbaf0; }
}

/* 반복지출 — 연간 결제 배지 */
.hh-badge-yearly {
  display: inline-block; margin-left: 6px; padding: 1px 7px;
  border-radius: 999px; font-size: 12px; font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}

/* 가계 — 실제 지출(현금·체크카드) */
.hh-card-chip { display:inline-block; padding:1px 8px; border-radius:999px;
  font-size:12px; font-weight:600; color:#fff; text-decoration:none; }
.hh-card-blue{background:#2f6fed} .hh-card-green{background:#1f9d55}
.hh-card-red{background:#d64545} .hh-card-amber{background:#c17d0f}
.hh-card-purple{background:#7c3aed} .hh-card-teal{background:#0d9488}
.hh-card-gray{background:#6b7280}
.hh-amt-spend { color: var(--bad); }
.hh-spend-summary { margin-top: 8px; }
.hh-spend-catsum { color: var(--muted); font-size: 13px; }
.hh-spend-list { list-style:none; padding:0; margin:0 0 12px; }
.hh-spend-item { display:flex; gap:10px; align-items:center; padding:8px 0;
  border-bottom:1px solid var(--border); flex-wrap:wrap; }
.hh-spend-amt { margin-left:auto; font-weight:600; }
.hh-spend-actions { display:flex; gap:6px; align-items:center; }
.hh-spend-actions form { display:inline; }

/* ── 토글 스위치 — 실제 checkbox를 감추고 트랙·손잡이를 그린다 (JS 없음) ── */
.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input[type="checkbox"] {
  position: absolute; opacity: 0; width: 0; height: 0;  /* 접근성·form= 연결은 유지 */
}
.switch-track {
  display: block; width: 34px; height: 20px; border-radius: 999px;
  background: var(--border); position: relative;
  transition: background .15s ease;
}
.switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--panel); box-shadow: 0 1px 2px rgba(0,0,0,.35);
  transition: transform .15s ease;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch:hover .switch-track { filter: brightness(1.08); }
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ── 프로필 아바타 ── */
.avatar { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; }
.avatar-sm { width: 22px; height: 22px; }
.avatar-lg { width: 96px; height: 96px; font-size: 2.2rem; }
.avatar-initial { display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.user-link { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; color: inherit; }
.profile-photo { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.profile-field { display: flex; flex-direction: column; gap: .3rem; max-width: 320px; }
.profile-field input { padding: .5rem .6rem; }
.manage-name { display: flex; align-items: center; gap: .45rem; }

@media (max-width: 640px) {
  /* 관리 화면 — 계정 생성 폼을 세로로 쌓고 버튼을 전체 폭으로 */
  .create-form { flex-direction: column; }
  .create-form input, .create-form .btn { width: 100%; flex: none; }
  /* 표가 잘려 보이지 않도록 카드 안쪽 여백을 줄인다 */
  .manage-card { padding: 1.1rem; }
}

/* 넓은 표는 표만 가로로 스크롤시키고 페이지는 고정한다.
   (.manage-table-wrap·.car-logs-wrap·.hh-matrix-wrap과 같은 방식) */
.hh-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* 셀이 세로로 쪼개져 글자가 한 자씩 끊기는 것을 막는다 */
.hh-table-wrap .hh-items th, .hh-table-wrap .hh-items td { white-space: nowrap; }
