/* ================================================
   JLPT MASTER — style.css
   Theme: Smart Blue (sky-blue & navy)
   ================================================ */

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

/* ── Variables ─────────────────────────────────── */
:root {
  --navy:       #1a2e5a;
  --navy2:      #243a6e;
  --sky:        #4a90d9;
  --sky2:       #6aaee8;
  --sky-light:  #e8f3fc;
  --sky-pale:   #f0f7ff;

  --bg:         #f5f7fa;
  --surface:    #ffffff;
  --border:     #d0dbe8;
  --border2:    #b8cde0;

  --ink:        #1a2535;
  --ink2:       #3a4a5c;
  --ink3:       #7a8fa8;
  --ink4:       #aabdce;

  --green:      #27ae60;
  --green-bg:   #edfaf3;
  --red:        #c0392b;
  --red-bg:     #fdf1f0;
  --gold:       #c9a84c;
  --gold-bg:    #fdf8ee;

  --shadow-sm:  0 1px 3px rgba(26,46,90,0.08);
  --shadow-md:  0 4px 12px rgba(26,46,90,0.12);
  --shadow-lg:  0 8px 32px rgba(26,46,90,0.15);

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

  --font-body:  'Inter', 'Noto Sans JP', sans-serif;
  --font-jp:    'Noto Sans JP', sans-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;   /* 2-row header */
  --sidebar-w:  72px;
}

/* ── Reset ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
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 rt { font-size: 0.55em; color: var(--ink3); }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }

/* ================================================
   HEADER — 2-row layout
   ================================================ */
.site-header {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--navy);
  z-index: 100;
  display: flex; flex-direction: column;
  box-shadow: 0 2px 12px rgba(26,46,90,0.25);
}
.header-row { display: flex; align-items: center; width: 100%; padding: 0 20px; }
.header-row-top    { height: 44px; gap: 12px; border-bottom: 1px solid rgba(255,255,255,0.1); }
.header-row-bottom { height: 40px; gap: 10px; background: var(--navy2); }

/* Logo */
.site-logo { display: flex; align-items: baseline; gap: 6px; flex-shrink: 0; cursor: pointer; transition: opacity var(--trans); }
.site-logo:hover { opacity: 0.8; }
.site-logo:active { transform: scale(0.97); }
.logo-main { font-weight: 700; font-size: 1.1rem; color: #fff; letter-spacing: 0.04em; }
.logo-sub  { font-size: 0.7rem; color: var(--sky2); letter-spacing: 0.12em; text-transform: uppercase; }

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

/* 연락처 버튼 */
.header-contact-btn {
  margin-left: auto;
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  font-size: 1rem;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: color var(--trans);
}
.header-contact-btn:hover { color: var(--sky2); }
/* 컨테이너가 아니라 아이콘에만 press 피드백을 줌 — 말풍선 안 텍스트 드래그 선택 시 팝업이 같이 흔들리는 것 방지 */
.header-contact-btn > i { display: inline-block; transition: transform 100ms ease-out; }
.header-contact-btn > i:active { transform: scale(0.92); }
.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;
  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); }

/* nihongo(J-UP) 사이트 전환 버튼 — 어디로 가는지 알 수 있게 아이콘 + 라벨 pill 형태 */
.header-nihongo-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.25);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  text-decoration: none;
  transition: color var(--trans), border-color var(--trans), background var(--trans);
}
.header-nihongo-btn i { font-size: 0.68rem; }
.header-nihongo-btn:hover { color: var(--sky2); border-color: var(--sky2); background: rgba(255,255,255,0.08); }
.header-nihongo-btn:active { transform: scale(0.94); }

/* Search */
.header-search { position: relative; flex-shrink: 0; }
.header-search input {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-xl);
  padding: 5px 12px 5px 30px;
  font-size: 0.82rem; color: #fff; width: 180px;
  transition: all var(--trans);
}
.header-search input::placeholder { color: rgba(255,255,255,0.5); }
.header-search input:focus { outline: none; background: rgba(255,255,255,0.2); border-color: var(--sky2); width: 240px; }
.header-search .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: rgba(255,255,255,0.5); font-size: 0.78rem; pointer-events: none; }

/* Level select */
.meta-select-wrap { position: relative; }
.meta-select-wrap select {
  appearance: none;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  padding: 4px 24px 4px 10px;
  font-size: 0.8rem; font-weight: 600; color: #fff;
  cursor: pointer; transition: all var(--trans);
}
.meta-select-wrap select:focus { outline: none; border-color: var(--sky2); background: rgba(255,255,255,0.2); }
.meta-select-wrap select option { background: var(--navy); }
.meta-select-wrap::after { content: '▾'; position: absolute; right: 9px; top: 50%; transform: translateY(-50%); font-size: 0.65rem; color: rgba(255,255,255,0.6); pointer-events: none; }

/* Mode buttons */
.mode-btn {
  padding: 5px 16px; border-radius: var(--radius-xl);
  font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em;
  transition: all var(--trans); color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.2);
}
.mode-btn:hover { background: rgba(255,255,255,0.15); color: #fff; }
.mode-btn.active { background: var(--sky); color: #fff; border-color: var(--sky); box-shadow: 0 2px 8px rgba(74,144,217,0.4); }



/* Chapter title / context label */
.context-label { font-size: 0.82rem; color: rgba(255,255,255,0.8); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }

/* Search dropdown */
.search-results-dropdown {
  position: fixed;
  /* top/left는 JS에서 동적으로 설정 */
  width: min(360px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: min(360px, calc(100vh - 120px));
  overflow-y: auto;
  display: none;
  z-index: 500;
}
.search-results-dropdown.active { display: block; }
.search-result-item { padding: 10px 14px; border-bottom: 1px solid var(--bg); cursor: pointer; transition: background var(--trans); font-size: 0.83rem; }
.search-result-item:hover { background: var(--sky-pale); }
.search-result-item .sr-jp { font-family: var(--font-jp); }
.search-result-item .sr-ko { font-size: 0.75rem; color: var(--ink3); }
.search-result-item .sr-meta { font-size: 0.68rem; color: var(--sky); margin-top: 2px; }
.search-footer-link {
  display: block; text-align: center; padding: 10px 14px;
  font-size: 0.8rem; font-weight: 700; color: var(--sky);
  cursor: pointer; transition: background var(--trans);
}
.search-footer-link:hover { background: var(--sky-pale); }

/* ================================================
   SEARCH RESULTS PAGE (포털형 통합 검색)
   ================================================ */
.srp-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 14px; border-bottom: 2px solid var(--border);
}
.srp-query { font-size: 1.15rem; font-weight: 700; color: var(--navy); }
.srp-query span#srp-query-text { color: var(--sky); }
.srp-count { font-size: 0.85rem; font-weight: 400; color: var(--ink3); margin-left: 4px; }
.srp-close-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--trans);
}
.srp-close-btn:hover { color: var(--sky); border-color: var(--sky); background: var(--sky-pale); }

.srp-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.srp-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 13px; border-radius: 999px;
  border: 1.5px solid var(--sky); background: var(--sky-pale);
  color: var(--sky); font-size: 0.8rem; font-weight: 700;
  cursor: pointer; transition: all var(--trans); user-select: none;
}
.srp-chip .srp-chip-count { color: inherit; opacity: 0.75; font-weight: 400; }
.srp-chip.off { border-color: var(--border2); background: var(--surface); color: var(--ink4); }
.srp-chip.off .srp-chip-count { opacity: 0.6; }

.srp-sections { display: flex; flex-direction: column; gap: 22px; }
.srp-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; }
.srp-section.hidden { display: none; }
.srp-section-header {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; background: var(--sky-pale);
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem; font-weight: 700; color: var(--navy);
}
.srp-section-header .srp-section-count { font-weight: 400; color: var(--ink3); font-size: 0.78rem; }
.srp-section-list { display: flex; flex-direction: column; }
.srp-row {
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 16px; border-bottom: 1px solid var(--bg);
  cursor: pointer; transition: background var(--trans);
}
.srp-row:last-child { border-bottom: none; }
.srp-row:hover { background: var(--sky-pale); }
.srp-row .sr-jp { font-family: var(--font-jp); font-size: 0.92rem; color: var(--ink); }
.srp-row .sr-ko { font-size: 0.8rem; color: var(--ink3); }
.srp-row .sr-meta { font-size: 0.7rem; color: var(--sky); }
.srp-empty { text-align: center; padding: 60px 20px; color: var(--ink4); }
.srp-row-grammar { padding: 14px 16px; }
.srp-mark { background: rgba(74,144,217,0.28); color: var(--navy); border-radius: 3px; padding: 0 2px; font-weight: 700; }

/* ================================================
   LAYOUT
   ================================================ */
.page-wrap { display: flex; padding-top: var(--nav-h); min-height: 100vh; }
.main-content { flex: 1; margin-right: var(--sidebar-w); padding: 28px 32px; max-width: calc(100% - var(--sidebar-w)); }

/* Side tabs */
.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: 14px 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.6rem; font-weight: 600; color: var(--ink3);
  transition: all var(--trans); gap: 3px; text-align: center;
}
.side-tab .tab-icon { font-size: 1.1rem; line-height: 1; }
.side-tab:hover { background: var(--sky-pale); color: var(--sky); }
.side-tab.active { background: var(--sky); color: #fff; }
.side-tab.disabled { opacity: 0.3; cursor: not-allowed; }
.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; }

/* ================================================
   CONTENT SECTIONS
   ================================================ */
.content-section { display: none; animation: fadeIn 0.28s 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: 24px; padding-bottom: 14px; border-bottom: 2px solid var(--border); }
.section-title { font-size: 1.3rem; font-weight: 700; color: var(--navy); display: flex; align-items: center; gap: 8px; }
.section-title .jp-sub { font-family: var(--font-jp); font-size: 0.85rem; color: var(--ink3); font-weight: 400; }

/* ================================================
   STUDY PAGE — 2-col grid
   ================================================ */
.study-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}
.study-col-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.study-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.study-card-header {
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.study-card-body { padding: 16px; }

/* Grammar item in study view */
.study-grammar-item {
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.study-grammar-item:last-child { border-bottom: none; }
.study-grammar-pattern { font-family: var(--font-jp); font-size: 1rem; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.study-grammar-explanation { font-size: 0.82rem; color: var(--ink2); line-height: 1.7; margin-bottom: 8px; }
.study-grammar-ex { background: var(--gold-bg); border: 1px solid rgba(201,168,76,0.2); border-radius: var(--radius-sm); padding: 8px 12px; font-size: 0.83rem; }
.study-grammar-ex-jp { font-family: var(--font-jp); line-height: 1.9; }
.study-grammar-ex-ko { font-size: 0.75rem; color: var(--ink3); }

/* Word list — 2-col on wide screens, 1-col on mobile */
.study-word-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
@media (max-width: 640px) {
  .study-word-list { grid-template-columns: 1fr; }
}
.study-word-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  font-size: 0.85rem; transition: background var(--trans);
}
.study-word-row:hover { background: var(--sky-pale); }
.study-word-row .num { font-size: 0.68rem; color: var(--ink4); width: 20px; flex-shrink: 0; }
.study-word-row .kanji { font-family: var(--font-jp); font-weight: 700; flex: 0 0 auto; font-size: 1rem; }
.study-word-row .reading { font-family: var(--font-jp); font-size: 0.75rem; color: var(--ink3); flex: 1; }
.study-word-row .meaning { font-size: 0.8rem; color: var(--sky); font-weight: 600; flex: 0 0 auto; }
.study-word-row .btn-star { margin-left: auto; flex-shrink: 0; }

/* Synonym list */
.study-synonym-list { display: flex; flex-direction: column; gap: 8px; }
.study-synonym-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg);
  font-family: var(--font-jp); font-size: 0.88rem;
  transition: background var(--trans);
}
.study-synonym-row:hover { background: var(--sky-pale); }
.syn-word { font-weight: 700; }
.syn-reading { font-size: 0.72rem; color: var(--ink3); }
.syn-ko { font-size: 0.75rem; color: var(--sky); font-family: var(--font-body); }
.syn-symbol { font-size: 1.1rem; color: var(--sky); flex-shrink: 0; font-weight: 700; }
.syn-group { display: flex; flex-direction: column; flex: 1; min-width: 0; }

/* Star button */
.btn-star {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem; 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); }

/* ================================================
   QUIZ PAGE
   ================================================ */
.quiz-type-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: var(--radius-xl);
  font-size: 0.68rem; font-weight: 700; letter-spacing: 0.06em;
  margin-bottom: 16px; flex-wrap: wrap; gap: 6px;
}
.type-tag {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.05em;
  color: #fff; background: var(--sky); margin-right: 4px;
}
.type-tag.active { background: var(--navy); }
.type-tag.dokkai { background: #7b6cf0; }
.type-tag.grammar-type { background: var(--gold); color: var(--ink); }

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

.quiz-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 18px 20px; margin-bottom: 14px;
  box-shadow: var(--shadow-sm); break-inside: avoid;
}
.quiz-num { font-size: 0.7rem; font-weight: 700; color: var(--sky); letter-spacing: 0.08em; margin-bottom: 6px; }
.quiz-passage {
  background: var(--sky-pale); border: 1px solid var(--border);
  border-left: 3px solid var(--sky);
  border-radius: var(--radius-sm); padding: 12px 16px;
  font-family: var(--font-jp); font-size: 0.9rem; line-height: 1.9;
  margin-bottom: 12px;
}
.quiz-question { font-size: 0.93rem; font-weight: 600; color: var(--ink); margin-bottom: 12px; font-family: var(--font-jp); line-height: 1.7; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-option {
  background: var(--bg); border: 2px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 14px;
  font-family: var(--font-jp); font-size: 0.88rem;
  text-align: left; transition: all var(--trans); cursor: pointer;
}
.quiz-option:hover:not(:disabled) { border-color: var(--border2); background: var(--sky-light); }
.quiz-option.selected-correct { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.quiz-option.selected-wrong   { border-color: var(--red);   background: var(--red-bg);   color: var(--red); }
.quiz-option.show-correct     { border-color: var(--green); background: var(--green-bg); }
.opt-label { font-size: 0.72rem; font-weight: 700; color: var(--ink3); margin-right: 6px; }

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

/* ================================================
   MODALS (auth, bookmark, print)
   ================================================ */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(26,46,90,0.45);
  backdrop-filter: blur(4px); z-index: 300;
  display: flex; align-items: flex-start; justify-content: flex-end;
  padding: 90px 16px 16px; 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: 420px; max-width: 100%;
  max-height: calc(100vh - 110px); 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: 18px 20px 14px; 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-size: 1.05rem; font-weight: 700; color: var(--navy); }
.modal-body { padding: 18px 20px; }
.modal-section-title { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink3); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.modal-section-title::after { content:''; flex:1; height:1px; background: var(--border); }

/* Bookmark item */
.bookmark-item { padding: 9px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 7px; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; transition: background var(--trans); }
.bookmark-item:hover { background: var(--sky-pale); }
.bm-word { font-family: var(--font-jp); font-size: 0.95rem; font-weight: 700; }
.bm-meaning { font-size: 0.78rem; color: var(--ink3); }
.bm-meta { font-size: 0.64rem; color: var(--ink4); margin-top: 2px; }
.btn-remove-bm { color: var(--ink4); font-size: 0.8rem; padding: 2px 4px; transition: color var(--trans); }
.btn-remove-bm:hover { color: var(--red); }
.bm-empty { color: var(--ink4); font-size: 0.82rem; text-align: center; padding: 12px; }

/* Auth modal */
.auth-modal { position: fixed; inset: 0; background: rgba(26,46,90,0.5); 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-size: 1.3rem; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.auth-box p  { font-size: 0.82rem; color: var(--ink3); margin-bottom: 18px; }
.auth-input { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.9rem; margin-bottom: 10px; transition: border-color var(--trans); }
.auth-input:focus { outline: none; border-color: var(--sky); }
.auth-error { color: var(--red); font-size: 0.78rem; margin-bottom: 8px; display: none; }
.auth-error.show { display: block; }

/* Print modal */
.print-modal { position: fixed; inset: 0; background: rgba(26,46,90,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: 30px 34px; max-width: 380px; width: 100%; box-shadow: var(--shadow-lg); text-align: center; }
.print-modal-title { font-size: 1.2rem; font-weight: 700; color: var(--navy); margin-bottom: 8px; }
.print-modal-desc  { font-size: 0.83rem; color: var(--ink3); margin-bottom: 20px; line-height: 1.6; }
.print-modal-btns  { display: flex; gap: 10px; }
.cpm-check-label { display: flex; align-items: center; gap: 8px; font-size: 0.88rem; cursor: pointer; padding: 6px 10px; border-radius: var(--radius-sm); transition: background var(--trans); text-align: left; }
.cpm-check-label:hover { background: var(--sky-pale); }
.cpm-check { accent-color: var(--sky); width: 16px; height: 16px; cursor: pointer; }

/* Image 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; animation: imgModalIn 0.28s ease; }
@keyframes imgModalIn { from { opacity:0; transform:translateY(20px) scale(0.97); } to { opacity:1; transform:none; } }
.img-modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); flex-shrink: 0; background: var(--surface); }
.img-modal-title { font-size: 1rem; font-weight: 700; color: var(--navy); }
.img-modal-close { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.8rem; color: var(--ink3); cursor: pointer; border: 1px solid var(--border); background: var(--bg); transition: all var(--trans); }
.img-modal-close:hover { background: var(--red); color: #fff; border-color: var(--red); transform: rotate(90deg); }
.img-modal-box .image-library-grid { padding: 14px; overflow-y: auto; flex: 1; }

/* ================================================
   BUTTONS
   ================================================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; transition: all var(--trans); cursor: pointer; }
.btn-primary { background: var(--sky); color: #fff; }
.btn-primary:hover { background: var(--sky2); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy2); }
.btn-secondary { background: var(--bg); color: var(--ink2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--sky-light); border-color: var(--border2); }
.btn-ghost { color: var(--ink3); }
.btn-ghost:hover { background: var(--sky-pale); color: var(--sky); }
.btn-sm { padding: 5px 12px; font-size: 0.76rem; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 50%; }

/* ================================================
   ADMIN PAGE
   ================================================ */
.admin-page { display: none; padding-top: var(--nav-h); min-height: 100vh; }
.admin-page.active { display: block; }
.admin-nav { background: var(--navy2); color: #fff; padding: 12px 28px; display: flex; align-items: center; gap: 14px; position: sticky; top: var(--nav-h); z-index: 80; flex-wrap: wrap; }
.admin-nav-title { font-size: 0.85rem; font-weight: 700; letter-spacing: 0.04em; }
.admin-nav-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.admin-body { padding: 28px 36px; max-width: 920px; }
.admin-section { margin-bottom: 44px; }
.admin-section-title { font-size: 1.1rem; font-weight: 700; color: var(--navy); margin-bottom: 16px; padding-bottom: 10px; border-bottom: 2px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* Admin tabs */
.admin-tab-bar { display: flex; gap: 4px; background: var(--bg); border-radius: var(--radius-md); padding: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.admin-tab { padding: 7px 16px; border-radius: var(--radius-sm); font-size: 0.8rem; font-weight: 600; color: var(--ink3); transition: all var(--trans); }
.admin-tab.active { background: var(--sky); color: #fff; }
.admin-tab:hover:not(.active) { background: var(--sky-light); color: var(--sky); }

/* Form fields */
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 0.73rem; font-weight: 600; color: var(--ink3); letter-spacing: 0.03em; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.form-input, .form-textarea, .form-select {
  background: var(--bg); 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(--sky); background: var(--surface); }
.form-textarea { resize: vertical; min-height: 80px; line-height: 1.6; }
.form-textarea.jp, .form-input.jp { font-family: var(--font-jp); }

/* Editor cards */
.editor-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.editor-card-header { background: var(--bg); padding: 9px 14px; display: flex; align-items: center; border-bottom: 1px solid var(--border); gap: 8px; }
.editor-card-num { font-size: 0.73rem; font-weight: 700; color: var(--ink3); }
.editor-card-body { padding: 14px; display: flex; flex-direction: column; gap: 10px; }

/* WYSIWYG */
.wysiwyg-toolbar { display: flex; gap: 4px; padding: 5px 8px; background: var(--bg); border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; flex-wrap: wrap; }
.wysiwyg-btn { padding: 3px 9px; border-radius: 4px; font-size: 0.82rem; cursor: pointer; background: var(--surface); border: 1px solid var(--border); color: var(--ink); transition: all var(--trans); }
.wysiwyg-btn:hover { background: var(--sky-light); border-color: var(--sky); }
.wysiwyg-area { min-height: 100px; border: 1px solid var(--border); border-radius: 0 0 var(--radius-sm) var(--radius-sm); padding: 10px 14px; font-size: 0.88rem; line-height: 1.75; outline: none; font-family: var(--font-jp); background: var(--bg); }
.wysiwyg-area:focus { background: var(--surface); }

/* Add item button */
.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.8rem; color: var(--ink3); transition: all var(--trans); background: transparent; cursor: pointer; margin-top: 4px; }
.btn-add-item:hover { border-color: var(--sky); color: var(--sky); background: var(--sky-pale); }

/* Upload row */
.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(--bg); 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(--sky); color: var(--sky); background: var(--sky-pale); }
#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 grid */
.image-library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px,1fr)); gap: 10px; }
.img-lib-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; text-align: center; transition: box-shadow var(--trans); }
.img-lib-item:hover { box-shadow: var(--shadow-md); }
.img-lib-item img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.img-lib-name { font-size: 0.67rem; color: var(--ink3); padding: 4px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.img-lib-size { font-size: 0.64rem; color: var(--ink4); padding: 0 6px 2px; }
.img-lib-actions { display: flex; gap: 4px; padding: 6px; justify-content: center; }

/* Chapter list admin */
.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: 12px 16px; display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow-sm); }
.ch-info { flex: 1; }
.ch-level { font-size: 0.68rem; font-weight: 700; color: #fff; background: var(--sky); padding: 2px 8px; border-radius: 20px; }
.ch-title { font-family: var(--font-jp); font-size: 0.88rem; margin-top: 3px; color: var(--ink2); }
.ch-actions { display: flex; gap: 6px; }

/* Table editor */
.tbl-editor { border-collapse: collapse; min-width: 360px; }
.tbl-editor th, .tbl-editor td { border: 1px solid var(--border2); padding: 3px; }
.tbl-editor th .form-input, .tbl-editor td .form-input { margin:0; border:none; background:transparent; padding:4px 6px; font-weight:600; }
.tbl-editor td .form-input { font-weight: 400; }

/* ETC block cards */
.etc-block-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 10px; }
.subsection-label { display: flex; align-items: center; gap: 8px; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink3); margin: 18px 0 12px; }
.subsection-label::before { content:''; width:4px; height:14px; background: var(--sky); border-radius:2px; }

/* Toast */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 7px; align-items: center; pointer-events: none; }
.toast { background: var(--navy); color: #fff; padding: 9px 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: var(--green); }
.toast.error   { background: var(--red); }
@keyframes toastIn  { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:none; } }
@keyframes toastOut { from { opacity:1; } to { opacity:0; transform:translateY(-8px); } }

/* Empty state */
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink4); }
.empty-icon { font-size: 2.5rem; margin-bottom: 10px; opacity: 0.5; }

/* Share toast */
.share-toast { background: var(--navy); color: #fff; padding: 14px 18px; border-radius: var(--radius-md); font-size: 0.82rem; max-width: 340px; }
.share-url-input { width: 100%; background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.25); border-radius: var(--radius-sm); padding: 6px 10px; color: #fff; font-size: 0.78rem; margin-top: 8px; }

/* ================================================
   PRINT STYLES
   ================================================ */
@media print {
  body > *:not(#study-print-area):not(#quiz-print-area):not(#bookmark-print-area) { display: none !important; }

  /* Study print */
  body.print-study #study-print-area  { display: block !important; }
  body.print-quiz  #quiz-print-area   { display: block !important; }
  body.print-bm    #bookmark-print-area { display: block !important; }

  /* test mode */
  body.print-test ruby rt  { visibility: hidden; }
  body.print-test .pr-ko   { color: transparent !important; border-bottom: 1px solid #ccc; }
  body.print-test .pr-bm-meaning { color: transparent !important; border-bottom: 1px solid #ccc; display: block; min-height: 18px; }
}

/* ── Study print area ── */
#study-print-area, #quiz-print-area, #bookmark-print-area { display: none; font-family: 'Noto Sans JP','Inter',sans-serif; font-size: 10pt; color: #1a2535; line-height: 1.6; }
.pr-cover { margin-bottom: 8mm; padding-bottom: 5mm; border-bottom: 2pt solid #1a2e5a; }
.pr-cover-meta { font-size: 8pt; color: #7a8fa8; letter-spacing: 0.1em; margin-bottom: 2mm; }
.pr-cover-title { font-size: 15pt; font-weight: 700; }
.pr-section { margin-bottom: 6mm; }
.pr-section-title { font-size: 11pt; font-weight: 700; border-bottom: 1.5pt solid #4a90d9; padding-bottom: 2mm; margin-bottom: 4mm; color: #1a2e5a; }
.pr-page-break { break-before: page; }

/* word grid for print */
.pr-word-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 3mm; }
.pr-word-card { border: 0.5pt solid #d0dbe8; border-radius: 3pt; padding: 3mm; break-inside: avoid; }
.pr-word-kanji { font-size: 12pt; font-weight: 700; }
.pr-word-reading { font-size: 8pt; color: #7a8fa8; }
.pr-ko { font-size: 9pt; color: #4a90d9; }

.pr-syn-row { display: flex; align-items: center; gap: 4mm; padding: 2.5mm 3mm; border: 0.5pt solid #d0dbe8; border-radius: 3pt; margin-bottom: 2mm; break-inside: avoid; }
.pr-syn-word { font-size: 11pt; font-weight: 700; }
.pr-syn-ko { font-size: 8.5pt; }
.pr-syn-sym { font-size: 12pt; color: #4a90d9; font-weight: 700; }

.pr-grammar-card { border: 0.5pt solid #d0dbe8; border-left: 2.5pt solid #c9a84c; border-radius: 3pt; padding: 3.5mm 4mm; margin-bottom: 3mm; break-inside: avoid; }
.pr-grammar-pattern { font-size: 11pt; font-weight: 700; margin-bottom: 2mm; }
.pr-grammar-exp { font-size: 8.5pt; color: #3a4a5c; margin-bottom: 2.5mm; line-height: 1.65; }
.pr-grammar-ex { background: #fdf8ee; border: 0.5pt solid rgba(201,168,76,0.3); border-radius: 3pt; padding: 2.5mm 3mm; font-size: 8.5pt; }

/* quiz print */
.pr-quiz-card { border: 0.5pt solid #d0dbe8; border-radius: 3pt; padding: 3mm 4mm; margin-bottom: 3mm; break-inside: avoid; }
.pr-quiz-num { font-size: 7.5pt; font-weight: 700; color: #4a90d9; margin-bottom: 1.5mm; }
.pr-quiz-q { font-size: 9.5pt; font-weight: 600; margin-bottom: 2.5mm; }
.pr-quiz-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5mm; }
.pr-quiz-opt { background: #f5f7fa; border-radius: 2pt; padding: 2mm 3mm; font-size: 8.5pt; }
.pr-answer-key { border: 0.5pt solid #d0dbe8; border-radius: 3pt; padding: 3mm 4mm; margin-top: 4mm; break-inside: avoid; }
.pr-ak-title { font-size: 8pt; font-weight: 700; margin-bottom: 1.5mm; }
.pr-ak-list { display: flex; flex-wrap: wrap; gap: 2mm 5mm; font-size: 8.5pt; }

/* bookmark print */
.pr-bm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 3mm; }
.pr-bm-card { border: 0.5pt solid #d0dbe8; border-radius: 3pt; padding: 3mm; break-inside: avoid; }
.pr-bm-word { font-size: 11pt; font-weight: 700; }
.pr-bm-meaning { font-size: 8.5pt; color: #7a8fa8; margin-top: 1.5mm; }

/* ================================================
   RESPONSIVE
   ================================================ */
@media (max-width: 900px) {
  .study-grid { grid-template-columns: 1fr; }
  .quiz-options { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 0px; --nav-h: 80px; }

  .header-row { padding: 0 12px; }
  .header-row-top { height: 40px; gap: 8px; }
  .header-row-bottom { height: 40px; gap: 6px; }
  .logo-main { font-size: 0.95rem; }
  .logo-sub  { display: none; }
  .header-search input { width: 30px; padding: 5px 5px 5px 28px; font-size: 0; }
  .header-search input:focus { width: 150px; font-size: 0.8rem; }
  .header-search input::placeholder { font-size: 0.8rem; }
  .meta-select-wrap { flex: 1; }
  .meta-select-wrap select { max-width: 100%; width: 100%; }

  .side-tabs { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: 56px; 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: 56px; padding: 16px 14px; max-width: 100%; }
  /* .search-results-dropdown: fixed positioning handled by JS */
  .admin-body { padding: 18px 14px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .image-library-grid { grid-template-columns: repeat(auto-fill, minmax(90px,1fr)); }
  .quiz-options { grid-template-columns: 1fr; }
  .modal-panel { width: 100%; max-width: 100%; }
}

@media (max-width: 380px) {
  .header-search input { width: 26px; }
  .mode-btn { padding: 4px 10px; font-size: 0.72rem; }
}

/* ================================================
   QUIZ FOLDER BOXES (Admin)
   ================================================ */
.quiz-folder-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.quiz-folder-box {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  cursor: pointer;
  transition: all var(--trans);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.quiz-folder-box::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--sky);
  border-radius: 2px 0 0 2px;
}
.quiz-folder-box:hover {
  border-color: var(--sky);
  box-shadow: var(--shadow-md);
  transform: translateX(3px);
}

.quiz-folder-icon {
  font-size: 1.8rem;
  flex-shrink: 0;
  line-height: 1;
}
.quiz-folder-content { flex: 1; min-width: 0; }
.quiz-folder-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 8px;
}
.quiz-folder-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quiz-folder-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--ink3);
  transition: all var(--trans);
}
.quiz-folder-tag.has-items {
  background: var(--sky-light);
  border-color: var(--sky);
  color: var(--navy);
}
.quiz-folder-tag b {
  color: var(--sky);
  font-weight: 700;
}

.quiz-folder-total {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--sky);
  line-height: 1;
}
.quiz-folder-total span {
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--ink3);
  margin-top: 2px;
  letter-spacing: 0.04em;
}

.quiz-folder-arrow {
  font-size: 1.4rem;
  color: var(--ink4);
  flex-shrink: 0;
  transition: transform var(--trans);
  font-weight: 300;
}
.quiz-folder-box:hover .quiz-folder-arrow {
  transform: translateX(4px);
  color: var(--sky);
}

/* ================================================
   QUIZ DRAWER (slide-in panel)
   ================================================ */
/* 배경 오버레이 — 클릭 가능하지만 드로어는 닫히지 않음
   (오버레이 클릭은 현재 closeQuizDrawer에 연결되어 있으나
    사용자 요구: x 버튼으로만 닫힘 → onclick 없이 둠) */
.quiz-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,46,90,0.25);
  backdrop-filter: blur(2px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans-slow);
}
.quiz-drawer-overlay.open {
  opacity: 1;
  pointer-events: all;   /* 배경 클릭 차단 — 드로어는 X버튼으로만 닫힘 */
  cursor: default;
}

.quiz-drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(520px, 96vw);
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--trans-slow);
}
.quiz-drawer.open {
  transform: translateX(0);
}

.quiz-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 2px solid var(--border);
  background: var(--navy);
  flex-shrink: 0;
}
.quiz-drawer-title {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}
.quiz-drawer-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  transition: all var(--trans);
  flex-shrink: 0;
}
.quiz-drawer-close:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
  transform: rotate(90deg);
}

.quiz-drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* 태그 그룹 */
.quiz-drawer-group {
  margin-bottom: 20px;
}
.quiz-drawer-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.quiz-drawer-tag-badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: var(--sky);
  color: #fff;
  letter-spacing: 0.04em;
}
.quiz-drawer-tag-count {
  font-size: 0.75rem;
  color: var(--ink3);
  font-weight: 600;
}

/* 문제 아이템 */
.quiz-drawer-item {
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  transition: background var(--trans);
}
.quiz-drawer-item:hover { background: var(--sky-pale); }

/* ================================================
   QUIZ CARD — star button top-right
   ================================================ */
.quiz-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.quiz-card-top .quiz-num { margin-bottom: 0; }

.quiz-star {
  width: 28px;
  height: 28px;
  font-size: 0.88rem;
  flex-shrink: 0;
}

/* ================================================
   BOOKMARK PRINT — quiz explanation / test mode
   ================================================ */
.pr-bm-quiz-exp {
  margin-top: 2.5mm;
  padding: 2mm 3mm;
  background: #f0f7ff;
  border-left: 2pt solid #4a90d9;
  border-radius: 2pt;
  font-size: 8pt;
  color: #3a4a5c;
  line-height: 1.6;
}
.pr-bm-exp-label {
  font-weight: 700;
  color: #4a90d9;
  margin-right: 4pt;
  font-size: 7.5pt;
}

/* pr-hidden-test: 테스트용 인쇄 시 내용을 공란 처리 */
@media print {
  .pr-hidden-test {
    color: transparent !important;
    background: linear-gradient(transparent, transparent);
    border-bottom: 0.8pt solid #aaa;
    display: inline-block;
    min-width: 40mm;
    min-height: 3mm;
  }
}

/* ================================================
   QUIZ PRINT — type/tag headers & passage
   ================================================ */

/* 문제 유형 헤더 (문자어휘 / 문법 / 독해) */
.pr-type-section-header {
  margin: 6mm 0 3mm;
  padding-bottom: 2mm;
  border-bottom: 2pt solid #1a2e5a;
}
.pr-type-section-header:first-child { margin-top: 0; }
.pr-type-label {
  font-size: 12pt;
  font-weight: 700;
  color: #1a2e5a;
  letter-spacing: 0.04em;
}

/* 태그 헤더 (한자 / 문맥 / 단문 …) */
.pr-tag-group {
  break-inside: avoid;   /* 태그+첫 문제가 페이지에서 잘리지 않음 */
}
.pr-tag-header {
  margin: 3mm 0 2mm 0;
  display: flex;
  align-items: center;
  gap: 2.5mm;
}
.pr-tag-badge {
  display: inline-block;
  padding: 0.6mm 3mm;
  border-radius: 10pt;
  font-size: 7pt;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
}

/* 독해 지문 블록 */
.pr-dokkai-block {
  break-inside: avoid;
  margin-bottom: 4mm;
}
.pr-print-passage {
  background: #f0f7ff;
  border: 0.5pt solid #b0cde8;
  border-left: 3pt solid #4a90d9;
  border-radius: 3pt;
  padding: 3.5mm 4mm;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 9pt;
  line-height: 2;
  margin-bottom: 3mm;
  break-inside: avoid;
}
.pr-dokkai-sub {
  margin-left: 4mm;  /* 독해 하위 문제 들여쓰기 */
}

/* 선택지 번호 */
.pr-opt-num {
  font-weight: 700;
  color: #4a90d9;
  margin-right: 3pt;
  font-size: 8.5pt;
}

/* ================================================
   SEARCH HIGHLIGHT (검색 결과 클릭 시 강조)
   ================================================ */
@keyframes searchPulse {
  0%   { background: var(--sky-light); }
  50%  { background: rgba(74,144,217,0.25); }
  100% { background: var(--sky-light); }
}
.search-highlight {
  animation: searchPulse 0.6s ease 2;
  border-color: var(--sky) !important;
  outline: 2px solid var(--sky);
  outline-offset: 1px;
  border-radius: var(--radius-sm);
}

/* ================================================
   SEARCH POPUP MODAL
   ================================================ */
.search-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,46,90,0.45);
  backdrop-filter: blur(4px);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--trans-slow);
}
.search-popup-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.search-popup-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: min(480px, 100%);
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  transform: translateY(16px) scale(0.97);
  transition: transform var(--trans-slow);
  overflow: hidden;
}
.search-popup-overlay.open .search-popup-box {
  transform: translateY(0) scale(1);
}

.search-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--navy);
  flex-shrink: 0;
}
.search-popup-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
}
.search-popup-close {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.1);
  transition: all var(--trans);
}
.search-popup-close:hover {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
  transform: rotate(90deg);
}

.search-popup-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* ── 팝업 내 단어 카드 ── */
.sp-word-card { display: flex; flex-direction: column; gap: 8px; }
.sp-word-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}
.sp-word {
  font-family: var(--font-jp);
  font-size: 2rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}
.sp-reading {
  font-family: var(--font-jp);
  font-size: 0.82rem;
  color: var(--ink3);
  margin-top: 2px;
}
.sp-meaning {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--sky);
}

/* ── 유사어 카드 ── */
.sp-syn-card { padding: 4px 0; }
.sp-syn-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.sp-syn-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 120px;
}
.sp-syn-sym {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--sky);
  flex-shrink: 0;
}

/* ── 문법 카드 ── */
.sp-grammar-card { display: flex; flex-direction: column; gap: 12px; }
.sp-grammar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.sp-grammar-pattern {
  font-family: var(--font-jp);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--navy);
}
.sp-grammar-exp {
  font-size: 0.875rem;
  color: var(--ink2);
  line-height: 1.75;
}
.sp-grammar-examples {
  background: var(--sky-pale);
  border: 1px solid var(--border);
  border-left: 3px solid var(--sky);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sp-ex-jp {
  font-family: var(--font-jp);
  font-size: 0.9rem;
  line-height: 1.9;
  color: var(--ink);
}
.sp-ex-ko {
  font-size: 0.78rem;
  color: var(--ink3);
}
.sp-hr {
  border: none;
  border-top: 1px dashed var(--border2);
  margin: 4px 0;
}

/* ── 문제(퀴즈) 카드 — 무작위 샘플링으로 화면에 없을 때 검색 팝업에 그대로 보여줌 ── */
.sp-quiz-card { display: flex; flex-direction: column; gap: 4px; }
.sp-quiz-card .quiz-option { cursor: default; }

@media (max-width: 640px) {
  .search-popup-overlay { padding: 12px; align-items: flex-end; }
  .search-popup-box {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 80vh;
  }
  .sp-word { font-size: 1.6rem; }
}
