/* =============================================
   자평진전 원문읽기 - 전체 스타일 v6.0
   하루한장 명리 — 이미지 팔레트 기반 (파스텔핑크 + 크림베이지)
   ============================================= */

/* --- CSS 변수 --- */
:root {
  /* ── 핑크 계열 (배너·헤더·포인트) ── */
  --pink:        #E59AAE;   /* 배너 롤 핑크 — 헤더 배경 */
  --pink-dark:   #C87A90;   /* 진핑크 — hover, 강조 */
  --pink-light:  #F0B5C4;   /* 파스텔핑크 — 탭 활성, 배지 */
  --pink-pale:   #FDF0F4;   /* 극연핑크 — 패널 배경 */
  --pink-border: #EFC8D4;   /* 핑크 보더 */

  /* ── 베이지 계열 (본문·카드·배경) ── */
  --beige:       #F7F0E0;   /* 전체 배경 베이지 */
  --beige-mid:   #EEDFC0;   /* 책 표지 베이지 — 카드 헤더 */
  --beige-warm:  #E8D5C5;   /* 따뜻한 베이지 — 섹션 구분 */
  --beige-deep:  #D9C2B0;   /* 강조 베이지 — 구절 헤더 배경 */
  --beige-border:#E1D0B8;   /* 베이지 보더 */

  /* ── 크림 (카드·모달 배경) ── */
  --cream:       #FFFDF8;   /* 카드 배경 */
  --cream-warm:  #FFF8EE;   /* 본문 내용 배경 */

  /* ── 텍스트 ── */
  --text:        #1A1A1A;   /* 기본 — 라인과 동일한 진한 검정 */
  --text2:       #5A4040;   /* 보조 텍스트 — 갈색계 */
  --text3:       #A08878;   /* 연한 보조 */

  /* ── 포인트 별색 ── */
  --star-yellow: #F0C88A;   /* 노란 별 */
  --star-blue:   #A8C7E8;   /* 파란 별 */
  --success:     #85C9A0;
  --red:         #E87090;

  --shadow:    0 2px 10px rgba(180,140,120,0.12);
  --shadow-lg: 0 6px 24px rgba(180,140,120,0.18);
  --radius:    16px;
  --radius-sm: 10px;
  --header-h:  120px;
  --chap-h:    56px;
  font-size: 16px;

  /* ── 하위호환 alias ── */
  --primary:      var(--pink);
  --primary-dark: var(--pink-dark);
  --primary-light:var(--pink-light);
  --primary-pale: var(--pink-pale);
  --accent:       var(--pink-dark);
  --accent-light: var(--pink-light);
  --accent-pale:  var(--pink-pale);
  --bg:           var(--beige);
  --bg2:          var(--beige-warm);
  --card:         var(--cream);
  --border:       var(--pink-border);
  --border-b:     var(--beige-border);
}

/* --- 리셋 & 기본 --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  font-family: 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}
button { cursor: pointer; border: none; background: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }
ul, ol { list-style: none; }
input, textarea { font-family: inherit; }

/* =============================================
   앱 레이아웃
   ============================================= */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  background: var(--bg);
}

/* --- 뷰 전환 --- */
.view {
  display: none;
  min-height: 100vh;
  animation: fadeIn 0.25s ease;
}
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* =============================================
   메인 헤더 (고정)
   ============================================= */
#main-header {
  position: fixed;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  z-index: 100;
  background: var(--pink);          /* 배너 롤과 동일한 핑크 */
  box-shadow: 0 2px 10px rgba(180,120,130,0.18);
  overflow: hidden;
}

.header-inner {
  display: flex;
  align-items: center;
  padding: 14px 16px 8px;
  gap: 14px;
  position: relative;
}
.header-title {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.header-char-img {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid rgba(255,255,255,0.90);
  box-shadow: 0 2px 10px rgba(160,80,110,0.20), 0 0 0 3px rgba(240,210,220,0.50);
  flex-shrink: 0;
}
.header-title-text {
  text-align: left;
}
.title-kr {
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.3;
}
.title-cn {
  font-family: 'Noto Serif KR', serif;
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 4px;
  line-height: 1.25;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: rgba(255,255,255,0.75);
  font-size: 10px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  min-width: 52px;
  position: relative;
}
.nav-btn i { font-size: 20px; }
.nav-btn.active, .nav-btn:hover {
  color: #fff;
  background: rgba(255,255,255,0.22);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.30);
}

/* 진도바 */
#progress-bar-wrap {
  height: 8px;
  background: rgba(0,0,0,0.08);
  position: relative;
  overflow: hidden;
}
#progress-bar-fill {
  height: 100%;
  background: var(--cream);   /* 헤더 핑크 위 흰크림 바 */
  transition: width 0.6s ease;
  width: 0%;
}
#progress-text {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

/* =============================================
   홈 화면
   ============================================= */
#view-home {
  padding-top: var(--header-h);
  padding-bottom: 40px;
  background: var(--pink-pale);  /* 헤더~6버튼 사이 여백 핑크 통일 */
}

.home-hero {
  background: var(--pink-pale);  /* 원래 연핑크 유지 */
  padding: 20px 24px 28px;
  text-align: center;
  color: var(--pink-dark);
  position: relative;
  overflow: hidden;
}
.hero-char-img { display: none; }  /* 헤더로 통합 — 히어로에서 제거 */
.hero-badge { display: none; }      /* 헤더 타이틀로 통합 */
.hero-title { display: none; }      /* 헤더 타이틀로 통합 */
.hero-sub {
  font-size: 12px;
  color: var(--text2);
  opacity: 0.85;
  margin-bottom: 16px;
  font-weight: 500;
  letter-spacing: 0.5px;
}

/* 원형 진도 */
.progress-ring-wrap {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 20px;
}
.progress-ring {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}
.ring-bg {
  fill: none !important;
  stroke: #E1D0B8 !important;
  stroke-width: 10;
}
.ring-fill {
  fill: none !important;
  stroke: #E59AAE !important;
  stroke-width: 10;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.9s ease;
  filter: drop-shadow(0 0 3px rgba(220,150,170,0.45));
}
.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#home-pct {
  font-size: 24px;
  font-weight: 700;
  line-height: 1;
  color: var(--pink-dark);
}
.ring-sub {
  font-size: 11px;
  opacity: 0.65;
  margin-top: 2px;
}

.hero-stats {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}
.stat-item { text-align: center; }
.stat-item span {
  display: block;
  font-size: 21px;
  font-weight: 700;
}
.stat-item small {
  font-size: 11px;
  opacity: 0.65;
}
.stat-sep { font-size: 16px; opacity: 0.25; }

/* 홈 안내 문구 */
.home-notice {
  margin: 4px 16px 8px;
  padding: 10px 14px;
  background: var(--bg2, #f5f0e8);
  border-left: 3px solid var(--accent, #8b6914);
  border-radius: 6px;
  font-size: 12.5px;
  color: var(--text2, #6b5c3e);
  line-height: 1.6;
}
.home-notice .fa-info-circle {
  margin-right: 5px;
  opacity: 0.7;
}

/* ── 홈 하단 인사말 ── */
.home-footer-msg {
  margin: 10px 16px 32px;
  padding: 18px 20px;
  background: var(--pink-pale);
  border-radius: var(--radius);
  border: 1px solid var(--pink-border);
  text-align: center;
}
.home-footer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--pink-dark);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}
.home-footer-sub {
  font-size: 12.5px;
  color: var(--text2);
  margin-bottom: 10px;
  line-height: 1.6;
}
.home-footer-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.9;
  border-top: 1px solid var(--pink-border);
  padding-top: 10px;
}

/* ── 홈 빠른 링크 그리드 ── */
.quick-links-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  padding: 12px 14px;
  background: var(--pink-pale);
  border-bottom: 1px solid var(--pink-border);
}
.ql-card {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 12px;
  background: var(--cream);
  border: 1px solid var(--beige-border);
  border-radius: 12px;
  text-decoration: none;
  box-shadow: 0 1px 4px rgba(180,140,120,0.08);
  transition: transform 0.14s, box-shadow 0.14s;
}
.ql-card:active { transform: scale(0.96); box-shadow: none; }
.ql-card-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}
.ql-card-texts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.ql-card-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ql-card-sub {
  font-size: 10px;
  color: var(--text3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 섹션 공통 */
.card-section { padding: 14px 16px; }
.section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  text-transform: uppercase;
}

/* 이어보기 카드 */
.resume-btn {
  width: 100%;
  background: var(--cream);
  border: 1.5px solid var(--pink-border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: all 0.2s;
}
.resume-btn:hover { background: var(--pink-pale); transform: translateY(-2px); }
.resume-info { text-align: left; }
#resume-chap-title {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
}
#resume-para-label {
  display: block;
  font-size: 12px;
  color: var(--text3);
  margin-top: 2px;
}
.resume-btn > i { color: var(--accent); font-size: 18px; flex-shrink: 0; }
.hidden { display: none !important; }

/* 목차 리스트 */
.toc-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toc-item {
  background: var(--cream);
  border-radius: var(--radius);
  border: 1px solid var(--beige-border);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.toc-item:hover { border-color: var(--pink); box-shadow: var(--shadow-lg); }
.toc-item.completed { border-left: 4px solid var(--success); }
.toc-header {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toc-num {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}
.toc-item.completed .toc-num { background: var(--success); }
.toc-info { flex: 1; min-width: 0; }
.toc-title-kr {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: block;
}
.toc-title-cn {
  font-family: 'Noto Serif KR', serif;
  font-size: 11px;
  color: var(--text3);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toc-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.toc-progress-mini {
  font-size: 11px;
  color: var(--text3);
}
.toc-check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  font-size: 10px;
  transition: all 0.3s;
}
.toc-item.completed .toc-check {
  background: var(--success);
  border-color: var(--success);
  color: #fff;
}
.toc-btn-read {
  display: block;
  width: calc(100% - 28px);
  margin: 0 14px 12px;
  padding: 9px;
  background: var(--pink);
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.2s;
}
.toc-btn-read:hover { opacity: 0.85; }

/* =============================================
   읽기 화면
   ============================================= */
#view-read {
  padding-top: calc(var(--header-h) + var(--chap-h) + 8px);
  padding-bottom: 40px;
}

/* 챕터 서브헤더 (고정) */
#chapter-header {
  position: fixed;
  top: var(--header-h);
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: var(--chap-h);
  background: var(--cream);
  border-bottom: 1px solid var(--beige-border);
  padding: 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 90;
  box-shadow: 0 2px 8px rgba(180,140,100,0.08);
}
.back-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 15px;
  background: var(--primary-pale);
  flex-shrink: 0;
  transition: background 0.2s;
}
.back-btn:hover { background: var(--bg2); }
#chapter-header-info { flex: 1; min-width: 0; }
#chapter-num-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#chapter-title-label {
  font-family: 'Noto Serif KR', serif;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--primary);
  background: var(--primary-pale);
  transition: all 0.2s;
  flex-shrink: 0;
}
.icon-btn.active { background: var(--accent); color: #fff; }
.icon-btn:hover { background: var(--bg2); }

/* 장 해설팁 */
.tip-bar {
  margin: 10px 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--pink-border);
  background: var(--pink-pale);    /* 아주 연한 핑크 */
}
.tip-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: none;
}
.tip-toggle-btn i:first-child { color: var(--pink-dark); }
.tip-arrow { margin-left: auto; transition: transform 0.3s; font-size: 11px; }
.tip-toggle-btn.open .tip-arrow { transform: rotate(180deg); }
.tip-content {
  padding: 0 14px 12px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.75;
}

/* 강설요약 */
.gangsul-bar {
  margin: 8px 16px 0;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--pink-border);
  background: var(--pink-pale);    /* 연핑크 배경 */
}
.gangsul-toggle-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-dark);
  background: none;
}
.gangsul-arrow { margin-left: auto; transition: transform 0.3s; font-size: 11px; }
.gangsul-toggle-btn.open .gangsul-arrow { transform: rotate(180deg); }
.gangsul-content {
  padding: 0 14px 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.75;
}
.gangsul-content p { margin-bottom: 8px; }
.gangsul-content p:last-child { margin-bottom: 0; }

/* 문단 영역 */
#para-list {
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* 문단 카드 */
.para-card {
  background: var(--cream);
  border-radius: var(--radius);
  border: 1.5px solid var(--beige-border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.para-card.completed { border-left: 4px solid var(--success); }
.para-card-header {
  display: flex;
  align-items: center;
  padding: 11px 12px;
  gap: 10px;
  cursor: pointer;
  background: var(--pink-pale);    /* 아주 연한 핑크 */
  border-bottom: 1px solid transparent;
  user-select: none;
  transition: background 0.2s;
}
.para-card.open .para-card-header {
  border-bottom-color: var(--beige-border);
}
.para-card-header:hover { background: #FAE4EC; }
.para-num {
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  min-width: 52px;
  text-align: center;
}
.para-card.completed .para-num { background: var(--success); }
.para-preview {
  flex: 1;
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.para-check-icon {
  font-size: 15px;
  color: var(--border);
  flex-shrink: 0;
  transition: color 0.3s;
}
.para-card.completed .para-check-icon { color: var(--success); }
.para-accordion-arrow {
  font-size: 11px;
  color: var(--text3);
  flex-shrink: 0;
  transition: transform 0.3s;
}
.para-card.open .para-accordion-arrow { transform: rotate(180deg); }

/* 문단 내용 영역 */
.para-body {
  display: none;
  padding: 14px 12px;
}
.para-card.open .para-body { display: block; }

/* === 탭 UI === */
.tab-bar {
  display: flex;
  border-radius: var(--radius-sm);
  background: var(--beige-warm);   /* 베이지 탭 트랙 */
  padding: 3px;
  gap: 2px;
  margin-bottom: 14px;
}
.tab-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text2);
  background: none;
  transition: all 0.18s;
  text-align: center;
  white-space: nowrap;
}
.tab-btn.active {
  background: var(--pink);         /* 활성 탭 — 핑크 */
  color: #fff;
  box-shadow: 0 1px 5px rgba(200,120,140,0.22);
}

/* 탭 콘텐츠 */
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* 한자 원문 */
.text-hanja {
  font-family: 'Noto Serif KR', serif;
  font-size: 17px;
  line-height: 2.1;
  color: var(--text);
  letter-spacing: 1px;
  word-break: break-all;
}

/* 구절 단위 래퍼 */
.clauses-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.clause-row {
  background: var(--cream-warm);   /* 따뜻한 크림 배경 */
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  border: 1px solid var(--beige-border);
}
.clause-hanja {
  font-family: 'Noto Serif KR', serif;
  font-size: 16px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 5px;
  letter-spacing: 1px;
  line-height: 1.8;
}
.clause-reading {
  font-size: 13px;
  color: var(--accent);
  line-height: 1.65;
  font-weight: 500;
}

/* === 뜻풀이 탭 (새 스타일) === */
.meaning-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.meaning-clause {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.meaning-header {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--beige-deep);   /* 구절 헤더 — 진한 베이지 */
  padding: 9px 13px 8px;
  flex-wrap: wrap;
  border-bottom: 2px solid var(--beige-border);
}
.meaning-clause-text {
  font-family: 'Noto Serif KR', serif;
  font-size: 17px;
  color: var(--text);              /* 밝은 배경이므로 진한 텍스트 */
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.5;
  flex-shrink: 0;
}
.meaning-reading {
  font-size: 11px;
  color: var(--text2);
  font-weight: 400;
  line-height: 1.5;
}
.meaning-body {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: var(--cream-warm);
  border-top: 1px solid var(--beige-border);
}
.meaning-item {
  display: flex;
  align-items: center;
  gap: 5px;
  background: var(--cream);
  border: 1px solid var(--beige-border);
  border-radius: 5px;
  padding: 4px 9px 4px 7px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.meaning-item:hover {
  background: var(--pink-pale, #fff0f0);
  border-color: var(--pink, #c97b7b);
  transform: translateY(-1px);
}
.meaning-item:active {
  transform: translateY(0);
}
.meaning-hanja {
  font-family: 'Noto Serif KR', serif;
  font-size: 16px;
  color: var(--pink-dark);
  font-weight: 700;
  line-height: 1;
}
.meaning-def {
  font-size: 12px;
  color: var(--text2);
  line-height: 1.3;
}

/* 해석 */
.text-interp {
  font-size: 14px;
  line-height: 1.95;
  color: var(--text);
  border-left: 3px solid var(--pink);
  background: var(--pink-pale);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px 12px 16px;
}

/* === 구간해석 탭 === */
.seg-interp-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* 구간해석 카드 */
.seg-row {
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--beige-border);
  margin-bottom: 10px;
}
.seg-row:last-child {
  margin-bottom: 0;
}

/* 한자 절 1개짜리 (단독 매칭) */
.seg-row-single .seg-hanja-block {
  background: var(--beige-deep);
  padding: 10px 14px 8px;
  border-bottom: 1px solid var(--beige-border);
}

/* 한자 절 여러 개 묶인 그룹 */
.seg-row-grouped .seg-hanja-block {
  background: var(--beige-deep);
  border-bottom: 1px solid var(--beige-border);
}
.seg-sub-clause,
.seg-single-clause {
  padding: 8px 14px 7px;
}
/* 묶인 절들 사이 구분선 */
.seg-row-grouped .seg-sub-clause + .seg-sub-clause {
  border-top: 1px dashed var(--beige-border);
}

.seg-clause-text {
  font-family: 'Noto Serif KR', serif;
  font-size: 17px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: 2px;
  line-height: 1.7;
  word-break: break-all;
}
.seg-reading {
  font-size: 12px;
  color: var(--text2);
  font-weight: 400;
  letter-spacing: 1.5px;
  line-height: 1.6;
  margin-top: 3px;
  word-break: break-all;
}

/* 해석 영역 */
.seg-kr {
  font-size: 14px;
  line-height: 1.9;
  color: var(--text);
  background: var(--cream-warm);
  padding: 11px 14px;
}
.seg-kr-empty {
  background: var(--bg2);
}
.seg-no-interp {
  color: var(--text3);
  font-style: italic;
  font-size: 12px;
}

/* 전체 해석 박스 */
.seg-full-interp {
  margin-top: 10px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1.5px solid var(--pink-border);
  box-shadow: var(--shadow);
}
.seg-full-interp-label {
  background: var(--pink);         /* 전체해석 배너 — 핑크 */
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  padding: 7px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  letter-spacing: 0.3px;
}
.seg-full-interp-body {
  font-size: 14px;
  line-height: 2.0;
  color: var(--text);
  background: var(--pink-pale);
  padding: 13px 15px;
}

/* 해석 없음 안내 */
.seg-no-interp-box {
  margin-top: 10px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text2);
  line-height: 1.8;
  text-align: center;
}

/* 핵심어휘 & 궁리안내 */
.vocab-section, .ponder-section {
  margin-top: 14px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.vocab-title, .ponder-title {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.vocab-title { background: var(--pink-pale); color: var(--text2); border-bottom: 1px solid var(--pink-border); }  /* 어휘 — 아주 연한 핑크 */
.ponder-title { background: var(--pink-pale); color: var(--pink-dark); border-bottom: 1px solid var(--pink-border); }  /* 궁리 — 연핑크 */
.vocab-body { padding: 10px 12px; background: var(--cream-warm); }
.ponder-body {
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.8;
  color: var(--text);
  background: var(--pink-pale);
}
.vocab-item {
  display: flex;
  gap: 8px;
  margin-bottom: 7px;
  align-items: flex-start;
}
.vocab-item:last-child { margin-bottom: 0; }
.vocab-hanja {
  font-family: 'Noto Serif KR', serif;
  font-weight: 700;
  color: var(--pink-dark);
  min-width: 80px;
  flex-shrink: 0;
  font-size: 14px;
}
.vocab-def { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* 완독 체크 버튼 */
.para-check-btn {
  margin-top: 14px;
  width: 100%;
  padding: 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: 2px solid var(--border);
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  background: #fff;
}
.para-check-btn.done {
  border-color: var(--success);
  color: var(--success);
  background: #F0FFF4;
}
.para-check-btn:hover { background: var(--accent-pale); }

/* AI 참고 버튼 */
.ai-ref-btn {
  margin-top: 8px;
  width: 100%;
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: opacity 0.2s, transform 0.2s;
}
.ai-ref-btn:hover { opacity: 0.88; transform: translateY(-1px); }

/* 장 이동 */
#chapter-nav {
  display: flex;
  gap: 10px;
  padding: 14px 16px;
  margin-top: 4px;
}
.chap-nav-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  border: 2px solid var(--border);
  color: var(--text2);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
  background: var(--card);
}
.chap-nav-btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.chap-nav-btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: var(--shadow); }
.chap-nav-btn:disabled { opacity: 0.38; cursor: not-allowed; }

/* =============================================
   책갈피 화면
   ============================================= */
#view-bookmark {
  padding-top: var(--header-h);
  padding-bottom: 40px;
}
.sub-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}
.sub-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}
.bookmark-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bookmark-section-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  padding: 6px 4px 2px;
  border-bottom: 1px solid var(--border);
  margin-top: 6px;
}

/* 문단 책갈피 버튼 */
.para-bk-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--text3);
  font-size: 15px;
  flex-shrink: 0;
  transition: color 0.2s, transform 0.15s;
  line-height: 1;
}
.para-bk-btn:hover { color: var(--pink-dark); transform: scale(1.2); }
.para-bk-btn.marked { color: var(--pink-dark); }
.para-bk-btn.marked i { font-weight: 900; }
.bookmark-item {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: all 0.2s;
}
.bookmark-item:hover { border-color: var(--accent); transform: translateY(-2px); }
.bookmark-icon { color: var(--accent); font-size: 20px; flex-shrink: 0; }
.bookmark-info { flex: 1; min-width: 0; }
.bookmark-chap { font-size: 11px; color: var(--text3); font-weight: 500; }
.bookmark-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bookmark-del {
  color: var(--text3);
  font-size: 16px;
  padding: 4px;
  transition: color 0.2s;
}
.bookmark-del:hover { color: var(--red); }
.bookmark-empty {
  text-align: center;
  padding: 60px 0;
  color: var(--text3);
  font-size: 14px;
  line-height: 1.7;
}
.bookmark-empty i { font-size: 40px; display: block; margin-bottom: 12px; opacity: 0.3; }

/* =============================================
   AI 모달
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-box {
  background: var(--card);
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.28s ease;
}
@keyframes slideUp { from { transform: translateY(60px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--card);
  z-index: 1;
}
.modal-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-header h3 i { color: var(--blue); }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 14px;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--border); }
.modal-body { padding: 14px 20px 28px; }
.modal-para-preview {
  background: var(--primary-pale);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-family: 'Noto Serif KR', serif;
  font-size: 13px;
  color: var(--primary);
  line-height: 1.75;
  margin-bottom: 14px;
  max-height: 80px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.prompt-select-label, .prompt-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.prompt-label { margin-top: 14px; }
.prompt-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.prompt-opt {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  font-size: 13px;
  color: var(--text);
  text-align: left;
  background: #fff;
  transition: all 0.18s;
  cursor: pointer;
}
.prompt-opt.selected {
  border-color: var(--primary);
  background: var(--primary-pale);
  color: var(--primary-dark);
  font-weight: 600;
}
.prompt-textarea {
  width: 100%;
  min-height: 120px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
  resize: vertical;
  background: var(--bg);
  margin-top: 6px;
}
.modal-actions {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.action-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: opacity 0.2s, transform 0.2s;
  cursor: pointer;
}
.copy-btn {
  background: var(--pink);
  color: #fff;
  border: none;
}
.copy-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.ai-links {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.ai-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.ai-link:hover { opacity: 0.88; transform: translateY(-1px); }
.ai-link.chatgpt {
  background: #19C37D;
  color: #fff;
}
.ai-link.claude {
  background: #A0714F;
  color: #fff;
}
.ai-link img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

/* =============================================
   토스트
   ============================================= */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(100,60,60,0.92);
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 500;
  z-index: 300;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: toastIn 0.25s ease;
  max-width: 90vw;
  text-align: center;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* =============================================
   반응형 (데스크탑)
   ============================================= */

/* 태블릿 (640px~) */
@media (min-width: 640px) {
  #app {
    max-width: 640px;
  }
  #main-header,
  #chapter-header,
  .gangsul-bar,
  .tip-bar {
    max-width: 640px;
  }
  :root {
    --header-h: 126px;
    font-size: 17px;
  }
  .seg-clause-text  { font-size: 19px; }
  .seg-reading      { font-size: 13px; }
  .seg-kr           { font-size: 15px; line-height: 2.0; }
  .para-hanja       { font-size: 20px; }
  .toc-title        { font-size: 15px; }
  .modal-box        { max-width: 600px; }
}

/* PC (900px~) */
@media (min-width: 900px) {
  #app {
    max-width: 820px;
  }
  #main-header,
  #chapter-header,
  .gangsul-bar,
  .tip-bar {
    max-width: 820px;
  }
  :root {
    --header-h: 130px;
    font-size: 18px;
  }

  /* 헤더 */
  .header-inner       { padding: 16px 28px 10px; }
  .title-kr           { font-size: 18px; }
  .title-cn           { font-size: 13px; }
  .header-char-img    { width: 52px; height: 52px; }

  /* 홈 히어로 */
  .home-hero          { padding: 28px 40px 34px; }
  .progress-ring-wrap { width: 140px; height: 140px; }
  .progress-ring      { width: 140px; height: 140px; }
  #home-pct           { font-size: 28px; }
  .stat-item span     { font-size: 24px; }

  /* 빠른링크 그리드 */
  .quick-links-grid   { padding: 14px 28px 4px; gap: 10px; }
  .ql-card            { padding: 13px 14px; gap: 11px; }
  .ql-card-icon       { font-size: 20px; }
  .ql-card-title      { font-size: 13px; }
  .ql-card-sub        { font-size: 11px; }

  /* 목차 */
  .card-section       { padding: 18px 28px; }
  .toc-list           { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toc-item           { margin-bottom: 0; }
  .toc-title          { font-size: 15px; }

  /* 본문 읽기 */
  #para-list          { padding: 0 28px 28px; }
  .para-card          { padding: 22px 24px; }
  .para-hanja         { font-size: 22px; letter-spacing: 3px; line-height: 2.0; }

  /* 구간해석 */
  .seg-clause-text    { font-size: 20px; letter-spacing: 3px; }
  .seg-reading        { font-size: 14px; }
  .seg-kr             { font-size: 16px; line-height: 2.1; padding: 14px 18px; }

  /* 탭 */
  .tab-bar            { padding: 0 28px; }

  /* 모달 */
  .modal-box          { max-width: 700px; }

  /* 안내 문구 */
  .home-notice        { margin: 6px 28px 10px; font-size: 13px; }
}

/* =============================================
   스크롤바 스타일
   ============================================= */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
