/* ===================================================
   J-UP — Main Stylesheet
   Aesthetic: Refined editorial / Japanese minimalism
   =================================================== */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=Noto+Serif+JP:wght@300;400;700&family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

/* === VARIABLES === */
:root {
  --bg:         #f7f5f0;
  --bg2:        #eeebe3;
  --bg3:        #e5e0d5;
  --surface:    #ffffff;
  --border:     #d8d2c4;
  --border2:    #c8c0ad;

  --ink:        #1a1714;
  --ink2:       #4a4540;
  --ink3:       #8a837a;
  --ink4:       #b0a99f;

  --accent:     #c0392b;
  --accent2:    #e74c3c;
  --accent-bg:  #fdf1f0;

  --gold:       #c9a84c;
  --gold-bg:    #fdf8ee;

  --speaker-a:  #2d6a8f;
  --speaker-b:  #5c7a3e;
  --speaker-c:  #8b4a6b;
  --speaker-d:  #7a5c2e;

  --shadow-sm:  0 1px 3px rgba(26,23,20,0.08);
  --shadow-md:  0 4px 12px rgba(26,23,20,0.10);
  --shadow-lg:  0 8px 32px rgba(26,23,20,0.12);

  --radius-sm:  6px;
  --radius-md:  12px;
  --radius-lg:  20px;
  --radius-xl:  32px;

  --font-body:  'DM Sans', 'Noto Sans JP', sans-serif;
  --font-jp:    'Noto Sans JP', sans-serif;
  --font-serif: 'DM Serif Display', 'Noto Serif JP', serif;

  --trans:      0.2s cubic-bezier(0.4,0,0.2,1);
  --trans-slow: 0.4s cubic-bezier(0.4,0,0.2,1);

  --nav-h:      84px;
  --sidebar-w:  72px;
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
/* Ruby: 히라가나를 한자 위에 표시 */
ruby {
  ruby-position: over;
  ruby-align: center;
}
ruby rt {
  font-size: 0.55em;
  color: var(--ink3);
  ruby-position: over;
  ruby-align: center;
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink3); }

/* ===================================================
   HEADER / NAV
   =================================================== */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: rgba(247,245,240,0.97);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 0;
  /* height is controlled by rows */
  box-shadow: 0 1px 4px rgba(26,23,20,0.07);
}

.header-row {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 0 20px;
}

/* 상단 행: 로고 + 관리자 배지 + 검색 */
.header-row-top {
  height: 44px;
  gap: 10px;
  border-bottom: 1px solid var(--bg3);
}

/* 하단 행: 드롭다운 + 챕터 제목 */
.header-row-bottom {
  height: 40px;
  gap: 8px;
  background: var(--bg2);
}

.site-logo {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-shrink: 0;
}
.site-logo .jp {
  font-family: var(--font-jp);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--accent);
  letter-spacing: 0.05em;
}
.site-logo .en {
  font-family: var(--font-serif);
  font-size: 0.75rem;
  color: var(--ink3);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Chapter selectors */
.header-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.chapter-meta {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meta-select-wrap {
  position: relative;
}
.meta-select-wrap select {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 24px 4px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink2);
  cursor: pointer;
  transition: border-color var(--trans);
  max-width: 120px;
}
.meta-select-wrap select:hover,
.meta-select-wrap select:focus { border-color: var(--accent); outline: none; }
/* select는 클릭 시 브라우저가 그리는 네이티브 팝업 목록이 뜨는데, 여기에 press용 transform을
   걸면 팝업 위치 계산과 어긋나 목록이 떨리는 것처럼 보임 — 네이티브 폼 컨트롤에는 적용 금지 */
.meta-select-wrap::after {
  content: '▾';
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.65rem;
  color: var(--ink3);
  pointer-events: none;
}

/* PC 화면에서는 드롭다운이 좁고 글자가 작아 보이므로 넉넉하게 확대 */
@media (min-width: 1025px) {
  .meta-select-wrap select {
    max-width: 220px;
    font-size: 0.95rem;
    padding: 6px 30px 6px 14px;
  }
  .meta-select-wrap::after { font-size: 0.75rem; right: 12px; }
}

/* Chapter title — marquee wrapper */
.chapter-title-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  position: relative;
  /* 페이드는 .has-marquee 일 때만 (JS가 클래스 부여) */
}

/* 오버플로우 스크롤이 활성화된 경우에만 양끝 페이드 */
.chapter-title-wrap.has-marquee {
  -webkit-mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 7%,
    black 87%,
    transparent 100%
  );
  mask-image: linear-gradient(
    to right,
    transparent 0%,
    black 7%,
    black 87%,
    transparent 100%
  );
}

.chapter-title {
  font-family: var(--font-jp);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  display: inline-block;
  /* GPU 레이어 고정 — 스크롤 중 속도 변동 방지 */
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* 마퀴 활성 상태 */
.chapter-title.marquee {
  /* animation-fill-mode: none 이 기본이라 생략 */
  /* linear + infinite 로 일정 속도 유지 */
  animation: marqueeScroll var(--marquee-duration, 14s) linear infinite;
  padding-right: 60px; /* 반복 사이 간격 */
}

@keyframes marqueeScroll {
  0%   { transform: translateX(0)   translateZ(0); }
  100% { transform: translateX(-50%) translateZ(0); }
}

/* 호버·포커스 시 일시정지 (접근성) */
.chapter-title-wrap:hover       .chapter-title.marquee,
.chapter-title-wrap:focus-within .chapter-title.marquee {
  animation-play-state: paused;
}

/* 모션 최소화 설정 사용자 대응 — 완전히 없애는 게 아니라 부드러운 대체로 전환 */
@media (prefers-reduced-motion: reduce) {
  .chapter-title.marquee { animation: none; }
  .quiz-option:active,
  .lq-option:active,
  .search-result-item:active,
  .header-contact-btn > i:active {
    transform: none;
  }
  .contact-popup,
  .search-results-dropdown {
    transform: none;
    transition: opacity 120ms ease-out, visibility 120ms;
  }
}

/* Contact info button */
.header-contact-btn {
  margin-left: auto;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-size: 1.05rem;
  color: var(--ink3);
  cursor: pointer;
  transition: color var(--trans);
}
.header-contact-btn:hover { color: var(--accent); }
/* 컨테이너가 아니라 아이콘에만 press 피드백을 줌 — 컨테이너에 걸면 :active가 조상까지 전파되어
   말풍선 안에서 텍스트를 드래그로 선택(복사)할 때마다 팝업 전체가 같이 눌려서 흔들리고,
   그 동안 좌표가 바뀌어 드래그 선택이 끊기는 문제가 있었음 */
.header-contact-btn > i { display: inline-block; transition: transform 100ms ease-out; }
.header-contact-btn > i:active { transform: scale(0.92); }

/* JLPT 사이트 전환 버튼 — 어디로 가는지 알 수 있게 아이콘 + 라벨 pill 형태 */
.header-jlpt-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink3);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--trans), border-color var(--trans), background var(--trans);
}
.header-jlpt-btn i { font-size: 0.68rem; }
.header-jlpt-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
.header-jlpt-btn:active { transform: scale(0.94); }
.contact-popup {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 9px 14px;
  font-size: 0.8rem;
  color: var(--ink2);
  white-space: nowrap;
  z-index: 200;
  cursor: text;
  user-select: text;
  /* display:none 대신 visibility+opacity — 열릴 때 자연스럽게 페이드인 */
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease-out, transform 150ms ease-out, visibility 150ms;
}
.contact-popup.active { visibility: visible; opacity: 1; transform: translateY(0); }

/* Search */
.header-search {
  position: relative;
  flex-shrink: 0;
}
.header-search input {
  background: var(--bg3);
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  padding: 5px 12px 5px 30px;
  font-size: 0.82rem;
  width: 180px;
  transition: all var(--trans);
}
.header-search input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  width: 240px;
}
.header-search .search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--ink3);
  font-size: 0.78rem;
  pointer-events: none;
}

.search-results-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 150ms ease-out, transform 150ms ease-out, visibility 150ms;
}
.search-results-dropdown.active { visibility: visible; opacity: 1; transform: translateY(0); }
.search-result-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg2);
  cursor: pointer;
  transition: background var(--trans), transform 100ms ease-out;
}
.search-result-item:hover { background: var(--bg2); }
.search-result-item:active { background: var(--bg3); transform: scale(0.98); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item .sr-jp { font-family: var(--font-jp); font-size: 0.9rem; }
.search-result-item .sr-ko { font-size: 0.78rem; color: var(--ink3); }
.search-result-item .sr-meta { font-size: 0.7rem; color: var(--accent); margin-top: 2px; }

/* ===================================================
   LAYOUT
   =================================================== */
.page-wrap {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}

/* Sidebar tab nav */
.side-tabs {
  position: fixed;
  top: var(--nav-h);
  right: 0;
  width: var(--sidebar-w);
  height: calc(100vh - var(--nav-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 4px;
  z-index: 90;
}

.side-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink3);
  transition: all var(--trans);
  gap: 4px;
  text-align: center;
  position: relative;
}
.side-tab .tab-icon { font-size: 1.1rem; line-height: 1; }

/* 중급1/중급2의 '회화·독해'처럼 라벨이 길 때 52px 폭 안에 한 줄로 들어가도록 축소 */
.side-tab.label-compact { font-size: 0.5rem; letter-spacing: -0.01em; }

/* 메뉴 아이콘 — 기존 팔레트(포인트색·화자색)를 그대로 가져와 탭마다 다른 색을 입힘 */
.side-tab .tab-icon.ti-week     { color: var(--accent); }
.side-tab .tab-icon.ti-conv     { color: var(--speaker-a); }
.side-tab .tab-icon.ti-vocab    { color: var(--speaker-b); }
.side-tab .tab-icon.ti-grammar  { color: var(--speaker-c); }
.side-tab .tab-icon.ti-quiz     { color: var(--speaker-d); }
.side-tab .tab-icon.ti-etc      { color: var(--accent2); }
.side-tab .tab-icon.ti-speaking { color: var(--speaker-a); }
.side-tab .tab-icon.ti-note     { color: var(--speaker-c); }
.side-tab .tab-icon.ti-bookmark { color: var(--gold); }
/* 인쇄·관리자는 콘텐츠 카테고리가 아닌 기능이라 중립색 유지 — 색이 있는 탭과 자연스럽게 구분됨 */
.side-tab .tab-icon.ti-print,
.side-tab .tab-icon.ti-admin    { color: var(--ink3); }

.side-tab:hover:not(.disabled) {
  background: var(--bg2);
  color: var(--ink);
}
.side-tab.active {
  background: var(--accent);
  color: white;
}
/* hover·active일 때는 각 아이콘의 고유색 대신 라벨과 같은 색으로 통일 — 눌림/포커스 상태를 분명하게 */
.side-tab:hover:not(.disabled) .tab-icon,
.side-tab.active .tab-icon {
  color: inherit;
}
.side-tab.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  position: relative;
}
.side-tab.disabled::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-md);
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.04) 3px,
    rgba(0,0,0,0.04) 6px
  );
}

.side-tab-divider {
  width: 32px;
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.side-tab-bottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

/* Main content */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-w);
  padding: 32px 40px;
  max-width: calc(100% - var(--sidebar-w));
}

/* ===================================================
   SECTION PANELS
   =================================================== */
.content-section {
  display: none;
  animation: fadeIn 0.3s ease;
}
.content-section.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.section-title {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title .jp-title {
  font-family: var(--font-jp);
  font-size: 0.95rem;
  color: var(--ink3);
  font-weight: 400;
}

/* ===================================================
   CONVERSATION SECTION
   =================================================== */
.conversation-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.conv-block {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.conv-block.right { flex-direction: row-reverse; }

.conv-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-jp);
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  position: relative;
}
.conv-avatar::after {
  content: '';
  position: absolute;
  bottom: -1px; right: -1px;
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--surface);
}

.speaker-0 .conv-avatar { background: var(--speaker-a); }
.speaker-1 .conv-avatar { background: var(--speaker-b); }
.speaker-2 .conv-avatar { background: var(--speaker-c); }
.speaker-3 .conv-avatar { background: var(--speaker-d); }
.speaker-0 .conv-avatar::after { background: var(--speaker-a); }
.speaker-1 .conv-avatar::after { background: var(--speaker-b); }
.speaker-2 .conv-avatar::after { background: var(--speaker-c); }
.speaker-3 .conv-avatar::after { background: var(--speaker-d); }

.conv-bubble-wrap {
  max-width: 70%;
}
.conv-block.right .conv-bubble-wrap { text-align: right; }

.conv-speaker-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink3);
  margin-bottom: 4px;
  padding: 0 4px;
}

.conv-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.conv-block.right .conv-bubble {
  border-radius: var(--radius-lg);
}
.conv-block.speaker-0 .conv-bubble { border-top-left-radius: 4px; }
.conv-block.right.speaker-1 .conv-bubble { border-top-right-radius: 4px; }

.conv-jp {
  font-family: var(--font-jp);
  font-size: 1.05rem;
  line-height: 2.2;        /* 2 → 1.75: JP 자체 높이 축소 */
  color: var(--ink);
  margin-bottom: 1px;       /* JP↔KO 간격 최소화 */
}
.conv-jp .highlight {
  background: linear-gradient(180deg, transparent 55%, rgba(192,57,43,0.2) 55%);
  border-radius: 2px;
  padding: 0 2px;
}

/* 검색 결과를 클릭해 이동했을 때, 선택한 단어/문법/회화 항목임을 표시 */
.vocab-card.search-hit,
.grammar-card.search-hit {
  animation: searchHitPulse 3s ease-out 1;
}
.conv-line.search-hit {
  border-radius: 6px;
  animation: searchHitLineFlash 3s ease-out 1;
}
@keyframes searchHitPulse {
  0%, 15%   { box-shadow: 0 0 0 3px var(--accent2); border-color: var(--accent); }
  100%      { box-shadow: var(--shadow-sm); }
}
@keyframes searchHitLineFlash {
  0%, 15%   { background: var(--accent-bg); box-shadow: 0 0 0 2px var(--accent2); }
  100%      { background: transparent; box-shadow: none; }
}

.conv-ko {
  font-size: 0.8rem;
  color: var(--ink4);
  margin-top: 1px;          /* 8px → 1px: JP↔KO 간격 확 줄임 */
  padding-top: 0;           /* 패딩 제거 */
  border-top: none;         /* JP↔KO 사이 줄 제거 */
  line-height: 1.5;
  margin-bottom: 0;
}

/* 말풍선 안에서 줄(line) 여러 개일 때:
   두 번째 줄부터 위에 연한 구분선 + 여백 */
.conv-bubble > div + div {
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid rgba(180,170,155,0.2);  /* 연한 구분선 */
}

.conv-line { display: flex; align-items: flex-start; gap: 6px; }
.conv-line-body { flex: 1; min-width: 0; }

/* ===================================================
   청해 재생 버튼 (회화·독해 공용) — 녹음 있으면 재생, 없으면 TTS
   =================================================== */
.tts-btn {
  flex-shrink: 0;
  width: 22px; height: 22px;
  margin-top: 2px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--ink4);
  font-size: 0.8rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans);
}
.tts-btn:hover { background: var(--accent-bg); color: var(--accent); }
.tts-btn.speaking { color: var(--accent); animation: ttsPulse 0.9s ease-in-out infinite; }
@keyframes ttsPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ===================================================
   독해 지문 (중급1/중급2 전용)
   =================================================== */
.reading-title {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px dashed var(--border2);
}
.reading-passage {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.reading-sentence {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  transition: background var(--trans);
}
.reading-sentence:hover { background: var(--bg2); }
.reading-sentence-body { flex: 1; min-width: 0; }
.reading-jp {
  font-family: var(--font-jp);
  font-size: 1.05rem;
  line-height: 2;
  color: var(--ink);
}
.reading-ko {
  font-size: 0.82rem;
  color: var(--ink4);
  margin-top: 3px;
  line-height: 1.5;
}

/* ===================================================
   VOCABULARY SECTION
   =================================================== */
.vocab-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.vocab-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  position: relative;
  transition: box-shadow var(--trans), border-color var(--trans);
  box-shadow: var(--shadow-sm);
}
.vocab-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border2);
}

.vocab-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}
.vocab-word-wrap {}
.vocab-word {
  font-family: var(--font-jp);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}
.vocab-reading {
  font-family: var(--font-jp);
  font-size: 0.78rem;
  color: var(--ink3);
  margin-top: 2px;
}
.vocab-meaning {
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.vocab-type {
  display: inline-block;
  background: var(--bg2);
  color: var(--ink3);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.vocab-examples {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;          /* 예문 간격은 .vocab-example 자체가 제어 */
}
/* 예문 하나 = JP + KO 묶음 */
.vocab-example {
  padding: 6px 0;  /* JP↔KO 내부 간격 최소화 */
}
/* 예문과 예문 사이 구분선 (첫 번째 제외) */
.vocab-example + .vocab-example {
  border-top: 1px solid rgba(180,170,155,0.25);  /* 연한 구분선 */
  padding-top: 8px;
  margin-top: 2px;
}
.vocab-ex-jp {
  font-family: var(--font-jp);
  font-size: 0.88rem;
  line-height: 2.2;   /* 1.9→1.75: JP↔KO 간격 축소 */
  color: var(--ink2);
  margin-bottom: 1px;  /* JP와 KO 사이 최소 여백 */
}
.vocab-ex-ko {
  font-size: 0.75rem;
  color: var(--ink4);
  margin-top: 0;
}

.vocab-chapter-tag {
  font-size: 0.65rem;
  color: var(--ink4);
  margin-top: 8px;
  text-align: right;
}

/* Star bookmark button */
.btn-star {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--ink4);
  transition: all var(--trans);
  flex-shrink: 0;
}
.btn-star:hover { background: var(--gold-bg); color: var(--gold); }
.btn-star.starred { color: var(--gold); }
.btn-star.starred .star-icon { content: '★'; }

/* ===================================================
   GRAMMAR SECTION
   =================================================== */
.grammar-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.grammar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--trans);
}
.grammar-card:hover { box-shadow: var(--shadow-md); }

.grammar-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
}
.grammar-pattern {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}
.grammar-explanation {
  font-size: 0.875rem;
  color: var(--ink2);
  line-height: 2.2;
  margin-bottom: 14px;
}

.grammar-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: var(--gold-bg);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(201,168,76,0.2);
}
.grammar-ex-jp {
  font-family: var(--font-jp);
  font-size: 0.9rem;
  line-height: 2.4;
  color: var(--ink);
}
.grammar-ex-ko {
  font-size: 0.76rem;
  color: var(--ink3);
}
.grammar-ex-divider {
  height: 1px;
  background: rgba(180,170,155,0.2);  /* 더 연하게 */
  margin: 8px 0 6px;                  /* 위 여백 늘려서 예문 사이 간격 확보 */
}

.grammar-chapter-tag {
  font-size: 0.65rem;
  color: var(--ink4);
  margin-top: 10px;
  text-align: right;
}

/* ===================================================
   THIS WEEK SECTION (이번주)
   =================================================== */
.tw-intro {
  background: var(--accent-bg);
  border: 1px solid rgba(192,57,43,0.15);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  color: var(--ink2);
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.7;
  margin-bottom: 24px;
}

.tw-block { margin-bottom: 28px; }
.tw-block-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 12px;
}
.tw-count { font-weight: 500; color: var(--ink4); font-size: 0.8rem; }

.tw-word-row, .tw-grammar-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}

.tw-word-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.tw-word-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tw-word-jp { font-family: var(--font-jp); font-size: 1.3rem; font-weight: 700; color: var(--ink); }
.tw-word-reading { font-family: var(--font-jp); font-size: 0.76rem; color: var(--ink3); margin-top: 2px; }
.tw-word-meaning { font-size: 0.9rem; font-weight: 600; color: var(--accent); margin-top: 6px; }

.tw-grammar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--gold);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.tw-grammar-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tw-grammar-pattern { font-family: var(--font-jp); font-size: 1.05rem; font-weight: 700; color: var(--ink); }
.tw-grammar-exp { font-size: 0.8rem; color: var(--ink2); line-height: 1.8; margin-top: 6px; }

.tw-sentence-list { display: flex; flex-direction: column; gap: 10px; }
.tw-sentence-card {
  display: flex;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}
.tw-sentence-num {
  flex-shrink: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold-bg);
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex; align-items: center; justify-content: center;
}
.tw-sentence-body { flex: 1; min-width: 0; }
.tw-sentence-jp { font-family: var(--font-jp); font-size: 1rem; line-height: 1.7; color: var(--ink); }
.tw-sentence-ko { font-size: 0.82rem; color: var(--ink3); margin-top: 4px; }
.tw-sentence-tag {
  display: inline-block;
  margin-top: 8px;
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--ink3);
  background: var(--bg2);
  padding: 3px 10px;
  border-radius: 20px;
}

.tw-bonus-row { display: flex; flex-wrap: wrap; gap: 10px; }
.tw-bonus-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--gold-bg);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 20px;
  padding: 8px 16px;
}
.tw-bonus-word { font-family: var(--font-jp); font-weight: 700; color: var(--ink); }
.tw-bonus-reading { font-family: var(--font-jp); font-size: 0.72rem; color: var(--ink3); }
.tw-bonus-meaning { font-size: 0.8rem; color: var(--ink2); }

@media (min-width: 1025px) {
  .tw-sentence-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-flow: row;
    gap: 12px;
  }
}

/* ===================================================
   QUIZ SECTION
   =================================================== */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
}

.quiz-num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.quiz-question {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 16px;
  line-height: 2.2;
}
.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.quiz-option,
.lq-option {
  background: var(--bg2);
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: var(--font-jp);
  font-size: 0.9rem;
  text-align: left;
  transition: border-color var(--trans), background var(--trans), transform 100ms ease-out;
}
.quiz-option:hover, .lq-option:hover { border-color: var(--border2); background: var(--bg3); }
/* pointer-down에서 즉시 눌림감 — click 완료를 기다리지 않음 (Apple HIG: 응답은 press에서) */
.quiz-option:active, .lq-option:active { transform: scale(0.98); }
.quiz-option.selected, .lq-option.selected { border-color: var(--accent); background: var(--accent-bg); }
.quiz-option.correct, .lq-option.correct { border-color: #27ae60; background: #edfaf3; color: #1a7a45; }
.quiz-option.wrong, .lq-option.wrong { border-color: var(--accent); background: var(--accent-bg); color: var(--accent); }

.quiz-explanation {
  margin-top: 12px;
  padding: 10px 14px;
  background: var(--bg2);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--ink2);
  display: none;
}
.quiz-explanation.show { display: block; }

/* 일반 퀴즈 / 청해 퀴즈 전환 탭 */
.quiz-mode-tab-bar { display: flex; gap: 8px; margin-bottom: 20px; }
.quiz-mode-tab {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border2);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink3);
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.quiz-mode-tab:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
.quiz-mode-tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(192,57,43,0.3);
}

/* 청해 퀴즈 재생 프롬프트 */
.lq-prompt { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.lq-prompt .tts-btn {
  width: 40px; height: 40px;
  font-size: 1.15rem;
  background: var(--accent-bg);
  color: var(--accent);
}
.lq-prompt .tts-btn:hover { background: var(--accent); color: #fff; }
.lq-prompt .tts-btn.speaking { color: var(--accent); }
.lq-prompt-label { font-size: 0.85rem; color: var(--ink3); }
/* 청해 퀴즈의 보기는 한국어 뜻이므로 일본어 전용 폰트 대신 기본 폰트 사용 (단어·문형 퀴즈의 .lq-option은 일본어 보기이므로 그대로 font-jp 유지) */
.lq-option-ko { font-family: var(--font-body); }

/* 단어·문형 퀴즈 — 텍스트 입력형(write) 문제 */
.wq-instruction { font-size: 0.85rem; color: var(--ink3); margin-bottom: 10px; }
.wq-prompt {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  line-height: 1.9;
  color: var(--ink);
  margin-bottom: 16px;
}
.wq-prompt u { text-decoration-color: var(--accent); text-underline-offset: 3px; }
.wq-answer-row { display: flex; gap: 8px; }
.wq-input {
  flex: 1;
  padding: 10px 14px;
  border: 2px solid var(--border2);
  border-radius: var(--radius-sm);
  font-family: var(--font-jp);
  font-size: 0.95rem;
  background: var(--surface);
  color: var(--ink);
}
.wq-input:focus { outline: none; border-color: var(--accent); }
.wq-input:disabled { background: var(--bg2); opacity: 0.8; }
.wq-result {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  display: none;
}
.wq-result.show { display: block; }
.wq-result.correct { color: #1a7a45; }
.wq-result.wrong { color: var(--accent); }
.wq-result.partial { color: var(--gold); }

/* ===================================================
   ETC / BLOG SECTION
   =================================================== */
.etc-content {
  max-width: 680px;
}
.etc-heading {
  font-family: var(--font-serif);
  font-size: 1.6rem;
  color: var(--ink);
  margin-bottom: 20px;
  line-height: 1.3;
}
.etc-text {
  font-size: 0.9rem;
  color: var(--ink2);
  line-height: 2.4;        /* ruby rt 공간 확보 */
  margin-bottom: 16px;
}
.etc-image-placeholder {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--bg2);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink4);
  font-size: 0.82rem;
  margin-bottom: 16px;
  border: 2px dashed var(--border2);
  position: relative;
  overflow: hidden;
}
.etc-image-placeholder .upload-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* ETC Table */
.etc-table-wrap {
  overflow-x: auto;
  margin: 16px 0;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}
.etc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.etc-table th {
  background: var(--bg2);
  padding: 10px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--ink2);
  border-bottom: 2px solid var(--border);
}
.etc-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--bg3);
  font-family: var(--font-jp);
}
.etc-table tr:last-child td { border-bottom: none; }
.etc-table tr:hover td { background: var(--bg2); }

/* ===================================================
   BOOKMARKS / WORD COLLECTION MODAL
   =================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.5);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 80px 20px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans-slow);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 440px;
  max-width: 100%;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateX(20px);
  transition: transform var(--trans-slow);
}
.modal-overlay.open .modal-panel {
  transform: translateX(0);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 1.15rem;
}
.modal-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-body {
  padding: 20px 24px;
}

.modal-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.modal-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.bookmark-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  transition: background var(--trans);
}
.bookmark-item:hover { background: var(--bg2); }
.bookmark-item .bm-word {
  font-family: var(--font-jp);
  font-size: 1rem;
  font-weight: 600;
}
.bookmark-item .bm-meaning {
  font-size: 0.8rem;
  color: var(--ink3);
}
.bookmark-item .bm-chapter {
  font-size: 0.65rem;
  color: var(--ink4);
  margin-top: 2px;
}
.btn-remove-bm {
  color: var(--ink4);
  font-size: 0.8rem;
  padding: 2px 4px;
  flex-shrink: 0;
  transition: color var(--trans);
}
.btn-remove-bm:hover { color: var(--accent); }

/* Print options modal */
.print-modal {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.5);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.print-modal.open { display: flex; }
.print-modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 36px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.print-modal-title {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  margin-bottom: 10px;
}
.print-modal-desc {
  font-size: 0.85rem;
  color: var(--ink3);
  margin-bottom: 24px;
  line-height: 1.6;
}
.print-modal-btns {
  display: flex;
  gap: 12px;
}

/* ===================================================
   BUTTONS
   =================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  font-weight: 600;
  transition: all var(--trans);
  cursor: pointer;
}
.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent2); }
.btn-secondary {
  background: var(--bg2);
  color: var(--ink2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg3); border-color: var(--border2); }
.btn-ghost {
  color: var(--ink3);
}
.btn-ghost:hover { background: var(--bg2); color: var(--ink); }
.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: 50%;
}
.btn-sm { padding: 6px 12px; font-size: 0.76rem; }

/* Lock / admin button */
.btn-admin-lock {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--ink3);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans);
  box-shadow: var(--shadow-sm);
}
.btn-admin-lock:hover {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

.btn-bookmark {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--gold);
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--trans);
  box-shadow: var(--shadow-sm);
}
.btn-bookmark:hover { background: var(--gold-bg); }

.btn-download {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 0.58rem;
}

/* Fixed bottom-right buttons */
.fixed-actions {
  position: fixed;
  bottom: 28px;
  right: calc(var(--sidebar-w) + 16px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 95;
}

/* ===================================================
   PASSWORD / ADMIN AUTH MODAL
   =================================================== */
.auth-modal {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,0.6);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
}
.auth-modal.open { display: flex; }
.auth-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-box h2 {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  margin-bottom: 8px;
}
.auth-box p {
  font-size: 0.82rem;
  color: var(--ink3);
  margin-bottom: 20px;
}
.auth-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  transition: border-color var(--trans);
}
.auth-input:focus { outline: none; border-color: var(--accent); }
.auth-error {
  color: var(--accent);
  font-size: 0.78rem;
  margin-bottom: 10px;
  display: none;
}
.auth-error.show { display: block; }

/* ===================================================
   ADMIN PAGE
   =================================================== */
.admin-page {
  display: none;
  padding-top: var(--nav-h);
  min-height: 100vh;
}
.admin-page.active { display: block; }

.admin-nav {
  background: var(--ink);
  color: white;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: var(--nav-h);
  z-index: 80;
}
.admin-nav-title {
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.9;
}
.admin-nav-actions {
  margin-left: auto;
  display: flex;
  gap: 10px;
}

.admin-body {
  padding: 32px 40px;
  max-width: 900px;
}

.admin-section {
  margin-bottom: 48px;
}
.admin-section-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Chapter manager */
.chapter-list-admin {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.chapter-item-admin {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
}
.chapter-item-admin .ch-info { flex: 1; }
.chapter-item-admin .ch-level {
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  background: var(--accent);
  padding: 2px 8px;
  border-radius: 20px;
}
.chapter-item-admin .ch-title {
  font-family: var(--font-jp);
  font-size: 0.9rem;
  margin-top: 3px;
}
.chapter-item-admin .ch-actions {
  display: flex;
  gap: 6px;
}

/* Content editor */
.editor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.editor-card-header {
  background: var(--bg2);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.editor-card-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ink3);
}
.editor-card-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--ink3);
  letter-spacing: 0.03em;
}
.form-input,
.form-textarea,
.form-select {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
  width: 100%;
  transition: border-color var(--trans);
}
.form-input:focus,
.form-textarea:focus,
.form-select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}
.form-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}
.form-textarea.jp { font-family: var(--font-jp); }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-add-item {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px;
  border: 2px dashed var(--border2);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  color: var(--ink3);
  transition: all var(--trans);
  background: transparent;
}
.btn-add-item:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}

/* ===================================================
   TOAST NOTIFICATIONS
   =================================================== */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.toast {
  background: var(--ink);
  color: white;
  padding: 10px 20px;
  border-radius: var(--radius-xl);
  font-size: 0.82rem;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease forwards;
  max-width: 320px;
  text-align: center;
}
.toast.success { background: #27ae60; }
.toast.error { background: var(--accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-10px); }
}

/* ===================================================
   PRINT STYLES
   =================================================== */
/* ===================================================
   PRINT — Bookmark wordbook
   =================================================== */
@media print {
  /* ── Default: hide everything, show only active print target ── */
  body > *:not(#chapter-print-area):not(#bookmark-print-area) { display: none !important; }
  #chapter-print-area   { display: block !important; }
  #bookmark-print-area  { display: none; }

  /* When printing bookmarks (no chapter mode) */
  body.print-bookmark #chapter-print-area  { display: none !important; }
  body.print-bookmark #bookmark-print-area { display: block !important; }

  /* When printing chapter content */
  body.print-chapter #chapter-print-area  { display: block !important; }
  body.print-chapter #bookmark-print-area { display: none !important; }

  /* Print test mode: hide furigana and translations */
  body.print-test ruby rt       { visibility: hidden; }
  body.print-test .conv-ko      { visibility: hidden; }
  body.print-test .vocab-ex-ko  { visibility: hidden; }
  body.print-test .grammar-ex-ko{ visibility: hidden; }
  body.print-test .vocab-meaning { visibility: hidden; }
  body.print-test .bm-print-meaning { color: transparent !important; }
}

/* ===================================================
   PRINT — Chapter Print Area (CPA) styles
   ─ A4 portrait  210×297mm, margins 15mm
   =================================================== */
#chapter-print-area {
  display: none; /* hidden on screen */
  font-family: 'Noto Sans JP', 'DM Sans', sans-serif;
  font-size: 10pt;
  line-height: 1.65;
  color: #1a1714;
}

/* Cover strip */
.cpa-cover {
  margin-bottom: 8mm;
  padding-bottom: 5mm;
  border-bottom: 2.5pt solid #1a1714;
}
.cpa-meta {
  font-size: 8pt;
  color: #8a837a;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 2mm;
}
.cpa-title {
  font-size: 16pt;
  font-weight: 700;
  line-height: 1.2;
  margin: 0;
  color: #1a1714;
}

/* Section page break */
.cpa-section-break { break-before: page; }

/* Section header */
.cpa-section { margin-bottom: 6mm; }
.cpa-section-title {
  font-size: 12pt;
  font-weight: 700;
  color: #1a1714;
  border-bottom: 1.5pt solid #c0392b;
  padding-bottom: 2mm;
  margin-bottom: 5mm;
  display: flex;
  align-items: center;
  gap: 4pt;
}
.cpa-section-icon { font-size: 11pt; }
.cpa-section-jp   { font-size: 9pt; color: #8a837a; font-weight: 400; margin-left: 4pt; }

/* ── Conversation ── */
.cpa-conv { display: flex; flex-direction: column; gap: 4mm; }
.cpa-conv-block {
  display: flex;
  gap: 3mm;
  align-items: flex-start;
  break-inside: avoid;
}
.cpa-right { flex-direction: row-reverse; }
.cpa-avatar {
  width: 9mm; height: 9mm;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8pt;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.cpa-color-0 { background: #2d6a8f; }
.cpa-color-1 { background: #5c7a3e; }
.cpa-color-2 { background: #8b4a6b; }
.cpa-color-3 { background: #7a5c2e; }

/* 아바타 + 이름 묶음 */
.cpa-person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5mm;
  flex-shrink: 0;
}
.cpa-speaker {
  font-size: 6.5pt;
  color: #8a837a;
  font-weight: 600;
  text-align: center;
  white-space: nowrap;
  max-width: 14mm;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cpa-bubble {
  background: #f7f5f0;
  border: 0.5pt solid #d8d2c4;
  border-radius: 6pt;
  padding: 3mm 4mm;
  max-width: calc(100% - 18mm);
  flex: 1;
}
.cpa-right .cpa-bubble { margin-left: auto; }
.cpa-jp  { font-size: 10pt; line-height: 1.9; margin-bottom: 1.5mm; }
.cpa-ko  { font-size: 8pt; color: #b0a99f; border-top: 0.5pt solid #e5e0d5; padding-top: 1.5mm; }
.cpa-hl  { background: rgba(192,57,43,0.15); border-radius: 2pt; padding: 0 1pt; }

/* ── Vocabulary ── */
.cpa-vocab-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3mm;
}
.cpa-vocab-card {
  border: 0.5pt solid #d8d2c4;
  border-left: 2.5pt solid #c0392b;
  border-radius: 3pt;
  padding: 3mm;
  break-inside: avoid;
}
.cpa-vocab-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 2mm; }
.cpa-vocab-word { font-size: 13pt; font-weight: 700; line-height: 1.1; }
.cpa-vocab-reading { font-size: 7.5pt; color: #8a837a; margin-top: 0.5mm; }
.cpa-vocab-right { text-align: right; }
.cpa-vocab-meaning { font-size: 10pt; font-weight: 600; color: #c0392b; }
.cpa-vocab-type { font-size: 7pt; color: #8a837a; background: #eeebe3; border-radius: 10pt; padding: 0.5mm 2mm; display: inline-block; margin-top: 1mm; }
.cpa-example { border-top: 0.5pt dashed #d8d2c4; padding-top: 2mm; margin-top: 2mm; }
.cpa-ex-jp { font-size: 9pt; line-height: 1.85; }
.cpa-ex-ko { font-size: 7.5pt; color: #b0a99f; }

/* ── Grammar ── */
.cpa-grammar-card {
  border: 0.5pt solid #d8d2c4;
  border-left: 3pt solid #c9a84c;
  border-radius: 3pt;
  padding: 4mm;
  margin-bottom: 3mm;
  break-inside: avoid;
}
.cpa-grammar-pattern     { font-size: 11pt; font-weight: 700; margin-bottom: 2mm; }
.cpa-grammar-explanation { font-size: 9pt;  color: #4a4540; line-height: 1.7; margin-bottom: 3mm; }
.cpa-grammar-examples    { background: #fdf8ee; border: 0.5pt solid rgba(201,168,76,0.3); border-radius: 3pt; padding: 3mm; }
.cpa-hr { border: none; border-top: 0.5pt solid rgba(201,168,76,0.25); margin: 2mm 0; }

/* ── Quiz ── */
.cpa-quiz-card {
  border: 0.5pt solid #d8d2c4;
  border-radius: 4pt;
  padding: 4mm;
  margin-bottom: 3mm;
  break-inside: avoid;
}
.cpa-quiz-num      { font-size: 7.5pt; font-weight: 700; color: #c0392b; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 1.5mm; }
.cpa-quiz-question { font-size: 10pt; font-weight: 600; margin-bottom: 3mm; }
.cpa-quiz-options  { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5mm; }
.cpa-quiz-option   { background: #eeebe3; border-radius: 3pt; padding: 2mm 3mm; font-size: 9pt; }
.cpa-opt-num       { font-weight: 700; color: #4a4540; margin-right: 2pt; }

/* Answer key */
.cpa-answer-key {
  margin-top: 5mm;
  padding: 3mm 4mm;
  background: #f7f5f0;
  border: 0.5pt solid #d8d2c4;
  border-radius: 4pt;
  break-inside: avoid;
}
.cpa-ak-title { font-size: 8pt; font-weight: 700; color: #4a4540; margin-bottom: 2mm; }
.cpa-ak-list  { display: flex; flex-wrap: wrap; gap: 2mm 5mm; }
.cpa-ak-item  { font-size: 9pt; color: #1a1714; }

/* ── 대화 연습 (말하기 레벨 전용) ── */
.cpa-speaking-topic { border: 0.5pt solid #d8d2c4; border-radius: 4pt; padding: 4mm; margin-bottom: 3mm; break-inside: avoid; }
.cpa-speaking-topic-title { display: flex; align-items: baseline; gap: 2mm; flex-wrap: wrap; margin-bottom: 3mm; padding-bottom: 2mm; border-bottom: 0.5pt solid #e5e0d5; }
.cpa-speaking-topic-num { font-size: 7pt; font-weight: 700; color: #fff; background: #c0392b; border-radius: 8pt; padding: 0.5mm 2.5mm; }
.cpa-speaking-topic-ko { font-size: 8pt; color: #8a837a; }
.cpa-speaking-intro { background: #f7f5f0; border-radius: 3pt; padding: 2.5mm 3mm; margin-bottom: 3mm; }
.cpa-speaking-q { border-top: 0.5pt dashed #d8d2c4; padding-top: 2.5mm; margin-top: 2.5mm; }
.cpa-speaking-q:first-of-type { border-top: none; padding-top: 0; margin-top: 0; }
.cpa-speaking-q-dir { font-size: 7pt; font-weight: 700; color: #c0392b; margin-bottom: 1mm; }
.cpa-speaking-hint { margin-top: 1.5mm; font-size: 8pt; color: #8a837a; background: #fdf8ee; border-radius: 3pt; padding: 1.5mm 2.5mm; }

/* ── 활동노트 (말하기 레벨 전용) ── */
.cpa-note-prompt { font-size: 9pt; color: #4a4540; background: #fdf1f0; border-radius: 3pt; padding: 3mm 4mm; margin-bottom: 4mm; }
.cpa-note-content { font-size: 10pt; line-height: 1.9; white-space: pre-wrap; }
.cpa-note-line { border-bottom: 0.5pt solid #d8d2c4; height: 9mm; }

/* ── Check label for print modal ── */
.cpm-check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--trans);
}
.cpm-check-label:hover { background: var(--bg2); }
.cpm-check { accent-color: var(--accent); width: 16px; height: 16px; cursor: pointer; }

/* ===================================================
   RESPONSIVE
   =================================================== */

/* ─── Tablet ─── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 60px; }
  .header-search input { width: 140px; }
  .header-search input:focus { width: 200px; }
}

/* ─── Mobile (≤ 640px) ─── */
@media (max-width: 640px) {
  :root {
    --sidebar-w: 0px;
    --nav-h: 80px;   /* two compact rows */
  }

  /* Header rows */
  .header-row { padding: 0 12px; }
  .header-row-top { height: 40px; gap: 6px; }
  .header-row-bottom { height: 40px; gap: 6px; }

  /* Logo — compact */
  .logo-jp { font-size: 1rem; }
  .logo-en { display: none; }

  /* Search — shrinks to icon only, expands on focus */
  .header-search input {
    width: 32px;
    padding: 5px 5px 5px 28px;
    font-size: 0;           /* hide placeholder text */
    border-radius: var(--radius-xl);
  }
  .header-search input:focus {
    width: 160px;
    font-size: 0.8rem;
  }
  .header-search input::placeholder { font-size: 0.8rem; }

  /* Selects — equal width, fill row */
  .meta-select-wrap { flex: 1; }
  .meta-select-wrap select { max-width: 100%; width: 100%; font-size: 0.76rem; }

  /* Chapter title — show but small */
  .chapter-title-wrap { flex: 1.2; }
  .chapter-title { font-size: 0.75rem; }

  /* Admin indicator badge — hide text, show icon only */
  .admin-indicator span:not(.fa-shield-alt) { display: none; }

  /* Side tabs → bottom bar */
  .side-tabs {
    position: fixed;
    bottom: 0; top: auto; left: 0; right: 0;
    height: 58px;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 0 4px;
    overflow-x: auto;
  }
  .side-tab {
    width: 42px; height: 42px;
    font-size: 0.5rem;
    flex-shrink: 0;
  }
  .side-tab-divider { display: none; }
  .side-tab-bottom { flex-direction: row; margin-top: 0; }

  .main-content {
    margin-right: 0;
    margin-bottom: 58px;
    padding: 16px 14px;
    max-width: 100%;
  }

  .vocab-grid { grid-template-columns: 1fr; }
  .quiz-options { grid-template-columns: 1fr; }
  .fixed-actions { right: 14px; }

  /* Search dropdown — full width on mobile */
  .search-results-dropdown { width: calc(100vw - 24px); right: auto; left: 0; }

  /* Conv bubbles — narrower max */
  .conv-bubble-wrap { max-width: 85%; }
}

/* ─── Very small (≤ 380px) ─── */
@media (max-width: 380px) {
  .header-search input { width: 28px; }
  .meta-select-wrap select { font-size: 0.7rem; padding: 4px 18px 4px 6px; }
  .chapter-title-wrap { display: none; }
}

/* ===================================================
   MISC UTILITIES
   =================================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--ink4);
}
.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}
.empty-state p { font-size: 0.88rem; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
}
.badge-red { background: var(--accent-bg); color: var(--accent); }
.badge-gold { background: var(--gold-bg); color: var(--gold); }

/* === ADDITIONAL MISSING STYLES === */

/* Logo */
/* 굵고 큰 워드마크는 음수 tracking이 더 단단해 보임 (Apple 타이포그래피 원칙: 대형 텍스트일수록 자간을 좁힘) */
.logo-jp { font-family: var(--font-jp); font-weight: 700; font-size: 1.2rem; color: var(--accent); letter-spacing: -0.01em; }
/* 한자(日本語)가 작은 크기에서 흐릿하게 보이지 않도록 --ink3(저대비 회색) 대신 --ink2를 쓰고, 획이 또렷하게 굵기를 700으로 올림 */
.logo-en { font-family: var(--font-serif); font-weight: 700; font-size: 0.75rem; color: var(--ink2); letter-spacing: 0.1em; text-transform: uppercase; }
.site-logo { display: flex; align-items: baseline; gap: 8px; flex-shrink: 0; cursor: pointer; }

/* Section title sub */
.jp-sub { font-family: var(--font-jp); font-size: 0.9rem; color: var(--ink3); font-weight: 400; margin-left: 6px; }
.section-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; color: var(--accent); background: var(--accent-bg); padding: 4px 10px; border-radius: 20px; }
.furigana-toggle { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--ink3); cursor: pointer; user-select: none; }
.furigana-toggle input { cursor: pointer; accent-color: var(--accent); }
body.hide-furigana ruby rt { display: none; }

/* Admin indicator */
.admin-indicator { display: none; align-items: center; gap: 5px; font-size: 0.7rem; font-weight: 700; color: white; background: var(--accent); padding: 3px 10px; border-radius: 20px; }
.admin-indicator.show { display: flex; }

/* Search dropdown */
.sr-empty { padding: 16px; text-align: center; color: var(--ink4); font-size: 0.82rem; }

/* ETC viewer styles */
.etc-figure { margin: 16px 0; }
.etc-caption { font-size: 0.78rem; color: var(--ink4); text-align: center; margin-top: 6px; }
.etc-text { font-size: 0.9rem; color: var(--ink2); line-height: 2.4; margin-bottom: 14px; }
.etc-heading { font-family: var(--font-serif); font-size: 1.5rem; color: var(--ink); margin-bottom: 20px; }
.etc-content { max-width: 700px; }

/* Print modal */
.print-modal { position: fixed; inset: 0; background: rgba(26,23,20,0.5); z-index: 400; display: none; align-items: center; justify-content: center; }
.print-modal.open { display: flex; }
.print-modal-box { background: var(--surface); border-radius: var(--radius-lg); padding: 32px 36px; max-width: 360px; width: 100%; box-shadow: var(--shadow-lg); text-align: center; }
.print-modal-title { font-family: var(--font-serif); font-size: 1.3rem; margin-bottom: 10px; }
.print-modal-desc { font-size: 0.85rem; color: var(--ink3); margin-bottom: 20px; line-height: 1.6; }
.print-modal-btns { display: flex; gap: 12px; }

/* Toast wrap */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }


/* ===================================================
   IMAGE UPLOAD ROW (Admin)
   =================================================== */
.img-upload-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.img-upload-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink2);
  cursor: pointer;
  transition: all var(--trans);
  white-space: nowrap;
}
.img-upload-label:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-bg); }
/* Hide the native file input visually */
#img-upload-input { display: none; }
.img-upload-fname {
  font-size: 0.78rem;
  color: var(--ink4);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ===================================================
   IMAGE LIBRARY / PICKER MODAL
   =================================================== */
.img-modal-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: min(680px, 96vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  /* slide-in animation */
  animation: imgModalIn 0.28s cubic-bezier(0.4,0,0.2,1);
}
@keyframes imgModalIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.img-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--surface);
  position: sticky;
  top: 0;
}
.img-modal-title {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin: 0;
}
.img-modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--ink3);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg2);
  transition: all var(--trans);
  flex-shrink: 0;
}
.img-modal-close:hover {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  transform: rotate(90deg);
}

/* Grid inside modal — scrollable */
.img-modal-box .image-library-grid {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  /* ensure grid doesn't collapse */
  min-height: 120px;
}

@media (max-width: 640px) {
  .img-modal-box { width: 98vw; max-height: 92vh; border-radius: var(--radius-md); }
  .image-library-grid { grid-template-columns: repeat(auto-fill, minmax(90px,1fr)); gap: 8px; }
}

/* 줄바꿈 반영 */
/* pre-wrap 제거: nl2br()로 줄바꿈 처리 + ruby 위치 보호 */
.grammar-explanation,
.conv-ko,
.quiz-explanation {
  word-break: break-word;
}

/* ================================================
   CONVERSATION TABS (학습 페이지)
   ================================================ */
.conv-tab-bar {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.conv-tab-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border2);
  background: var(--surface);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ink3);
  cursor: pointer;
  transition: all var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
}
.conv-tab-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-bg);
}
.conv-tab-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 2px 8px rgba(192,57,43,0.3);
}
.conv-tab-btn:disabled,
.conv-tab-btn.disabled {
  opacity: 0.28;
  cursor: not-allowed;
  border-style: dashed;
}

/* 중급1/중급2 전용: 회화/독해 1/독해 2 — 숫자 원형 대신 텍스트 라벨이 있는 필 모양 */
.conv-tab-btn-wide {
  width: auto;
  height: 34px;
  padding: 0 18px;
  border-radius: 17px;
  font-size: 0.8rem;
}

/* 내레이션 블록 (학습 화면) */
.conv-narration {
  margin: 8px 4px;
  padding: 9px 16px;
  background: var(--bg2);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.82rem;
  color: var(--ink3);
  font-style: italic;
  line-height: 1.65;
}

/* ── 챕터 인쇄 모달: 회화 섹션 ── */
.cpm-section-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink3);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.cpm-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}
.cpm-conv-label {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}
/* 회화 체크박스 컨테이너: 가로 wrap */
#cpm-conv-checks {
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: wrap;
  gap: 4px 8px;
}

/* 인쇄: 내레이션 */
.cpa-narration {
  margin: 3mm 4mm;
  padding: 2.5mm 4mm;
  background: #fdf8ee;
  border-left: 2.5pt solid #c9a84c;
  border-radius: 0 3pt 3pt 0;
  font-size: 8.5pt;
  color: #7a6a50;
  font-style: italic;
  line-height: 1.6;
  break-inside: avoid;
}

/* ================================================
   VOCAB NARRATION (학습 화면)
   ================================================ */
.vocab-narration {
  /* 단어 그리드 전체 폭으로 span */
  grid-column: 1 / -1;
  padding: 9px 16px;
  background: var(--bg2);
  border-left: 3px solid var(--gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 0.85rem;
  color: var(--ink3);
  font-style: italic;
  line-height: 1.65;
  margin: 4px 0;
}

/* 인쇄: 단어 나레이션 — 그리드 전체 폭 */
.cpa-vocab-narration {
  grid-column: 1 / -1;
  margin: 2mm 0 3mm;
  padding: 2.5mm 4mm;
  background: #fdf8ee;
  border-left: 2.5pt solid #c9a84c;
  border-radius: 0 3pt 3pt 0;
  font-size: 8.5pt;
  color: #7a6a50;
  font-style: italic;
  line-height: 1.6;
  break-inside: avoid;
}

/* ================================================
   GRAMMAR INLINE TABLE (학습 화면 + 인쇄)
   ================================================ */
.grammar-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border-radius: var(--radius-sm);
}
.grammar-inline-table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}
.grammar-inline-table th,
.grammar-inline-table td {
  border: 1px solid var(--border2);
  padding: 6px 10px;
  text-align: left;
  line-height: 1.55;
}
.grammar-inline-table th {
  background: var(--bg2);
  font-weight: 700;
  color: var(--ink2);
}
.grammar-inline-table td { color: var(--ink); }

/* 인쇄용 */
@media print {
  .grammar-table-wrap { overflow: visible; }
  .grammar-inline-table th,
  .grammar-inline-table td {
    border: 0.5pt solid #ccc;
    padding: 2mm 3mm;
    font-size: 8pt;
  }
  .grammar-inline-table th { background: #f0ede6; }
}

/* ─── 말하기 레벨: 대화 연습(おしゃべりのたね) ─── */
.speaking-topic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.speaking-topic-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.speaking-topic-num {
  flex: 0 0 auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.speaking-topic-title-jp { font-family: var(--font-jp); font-size: 1.1rem; font-weight: 700; color: var(--ink2); }
.speaking-topic-title-ko { font-size: 0.85rem; color: var(--ink3); }
.speaking-topic-intro {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 14px;
  font-size: 0.875rem;
}
.speaking-intro-jp { font-family: var(--font-jp); color: var(--ink2); line-height: 1.9; }
.speaking-intro-ko { color: var(--ink3); margin-top: 4px; }

.speaking-question-list { display: flex; flex-direction: column; gap: 14px; }
.speaking-question { display: flex; gap: 12px; align-items: flex-start; }
.speaking-q-dir {
  flex: 0 0 auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.95rem;
  cursor: help;
}
.speaking-q-body { flex: 1; min-width: 0; }
.speaking-q-jp { font-family: var(--font-jp); color: var(--ink2); line-height: 1.9; }
.speaking-q-ko { font-size: 0.8rem; color: var(--ink3); margin-top: 2px; }
.speaking-q-hint {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--ink3);
  background: var(--gold-bg);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}
.speaking-q-hint-jp { font-family: var(--font-jp); color: var(--ink2); }
.speaking-q-hint-ko { color: var(--ink3); }

/* ─── 말하기 레벨: 활동노트 ─── */
.activity-note-prompt {
  font-size: 0.9rem;
  color: var(--ink2);
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 12px;
  line-height: 1.6;
}
.activity-note-textarea {
  width: 100%;
  min-height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-jp), inherit;
  font-size: 0.95rem;
  color: var(--ink2);
  resize: vertical;
  box-sizing: border-box;
  transition: border-color var(--trans);
}
.activity-note-textarea:focus { border-color: var(--accent); outline: none; }
.activity-note-status { margin-top: 8px; font-size: 0.78rem; color: var(--ink4); text-align: right; }

/* ─── 말하기 레벨: '이번주' 탭을 대체하는 챕터 소개 ─── */
.chapter-intro-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.ci-purpose {
  font-size: 0.9rem;
  color: var(--ink2);
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 18px;
  line-height: 1.7;
}
.ci-section-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent);
  margin: 18px 0 10px;
}
.ci-section-label:first-of-type { margin-top: 0; }
.ci-topics-list {
  margin: 0;
  padding-left: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ci-topics-list li { font-family: var(--font-jp); color: var(--ink2); line-height: 1.8; }
.ci-grammar-list { display: flex; flex-direction: column; gap: 12px; }
.ci-grammar-item {
  background: var(--bg2);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
}
.ci-grammar-pattern { font-family: var(--font-jp); font-weight: 700; color: var(--ink2); }
.ci-grammar-meaning { font-family: inherit; font-weight: 400; color: var(--ink3); }
.ci-grammar-example-jp { font-family: var(--font-jp); color: var(--ink2); margin-top: 6px; line-height: 1.8; }
.ci-grammar-example-ko { font-size: 0.8rem; color: var(--ink3); margin-top: 2px; }

/* Ruby 강제 인라인 (white-space 간섭 차단) */
.etc-text ruby,
.grammar-explanation ruby,
.grammar-ex-jp ruby,
.conv-jp ruby,
.vocab-ex-jp ruby,
.quiz-question ruby,
.speaking-topic-title-jp ruby,
.speaking-intro-jp ruby,
.speaking-q-jp ruby,
.speaking-q-hint-jp ruby,
.ci-topics-list ruby,
.ci-grammar-pattern ruby,
.ci-grammar-example-jp ruby {
  white-space: nowrap;
  display: inline ruby;
}
