/* --- 모던 미니멀 테마 --- */
:root {
    --miru-teal: #32C7C7;  
    --miru-red: #8D2222;   
    --bg-color: #F8F9FA;   
    --card-bg: #FFFFFF;    
    --text-main: #2C3E50;  
    --text-muted: #8391A2; 
    --border-light: #E9ECEF;
    --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.05);
}

html { scroll-behavior: smooth; }

/* 'Miru Sans', 'Miru IPA', 'Miru Title'은 fonts/fonts.css에 정의된 글꼴 묶음입니다. */
body { font-family: 'Miru Sans', sans-serif; margin: 0; padding: 20px 10px; background-color: var(--bg-color); color: var(--text-main); line-height: 1.6; }
/* 입력칸과 버튼은 기본으로 페이지 글꼴을 물려받지 않으므로 직접 맞춥니다. */
button, input, select, textarea { font-family: inherit; }
/* 경기천년제목('Miru Title')은 화면마다 하나 있는 큰 제목에만 씁니다. 탭 버튼, 작은 소제목, 안내 문구는 Noto입니다.
   그 글꼴에 없는 글자(한자, é ñ ç 등)는 Noto로 넘어갑니다. */
.page-title, .view-title, .appendix-title, .info-tab-title, .info-section-title { font-family: 'Miru Title', 'Miru Sans', sans-serif; }
.container { max-width: 1050px; margin: 0 auto; background: var(--card-bg); padding: 40px; border-radius: 16px; box-shadow: var(--shadow-soft); position: relative; }

.top-bar { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border-light); margin-bottom: 30px; padding-bottom: 20px; }
nav { display: flex; gap: 8px; }
nav button { padding: 10px 22px; border: none; background: transparent; cursor: pointer; border-radius: 8px; font-weight: 600; font-size: 0.95em; color: var(--text-muted); transition: all 0.2s ease; }
nav button:hover { background: #F1F3F5; color: var(--text-main); }
nav button.active { background: var(--miru-teal); color: white; box-shadow: 0 4px 10px rgba(50, 199, 199, 0.2); }

.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

/* --- 미루어 탭 3단 레이아웃 --- */
.info-tab-header { margin-bottom: 35px; }
.info-tab-title { font-size: 2.2em; margin: 0 0 5px; color: var(--text-main); }
.info-tab-description { color: var(--text-muted); margin: 0; font-size: 1.1em; }
.info-layout { display: flex; gap: 25px; align-items: flex-start; }
.info-toc { width: 180px; flex-shrink: 0; background: var(--card-bg); border: 1px solid var(--border-light); border-radius: 8px; padding: 20px; position: sticky; top: 20px; }
.toc-list { list-style: none; padding: 0; margin: 0; font-size: 0.95em; }
.toc-list > li { margin-bottom: 8px; }
.toc-list > li > a { text-decoration: none; color: var(--text-main); transition: color 0.2s; font-weight: 600; cursor: pointer; display: block; padding: 4px 0; }
.toc-list > li > a:hover { color: var(--miru-teal); }
.toc-list > li > a.active { color: var(--miru-teal); }
.toc-sublist { list-style: none; padding-left: 15px; margin-top: 5px; margin-bottom: 10px; font-size: 0.95em; border-left: 2px solid var(--border-light); display: none; }
.toc-sublist li { margin-bottom: 6px; }
.toc-sublist a { font-weight: 400; color: var(--text-muted); text-decoration: none; transition: color 0.2s; }
.toc-sublist a:hover { color: var(--miru-teal); font-weight: 600; }
.info-main { flex: 1; min-width: 0; background: #F8F9FA; padding: 30px; border-radius: 12px; }
.info-section { display: none; animation: fadeIn 0.3s ease; }
.info-section.active { display: block; }
.info-side { width: 300px; flex-shrink: 0; position: sticky; top: 20px; }
.info-side.is-hidden { display: none; }
.info-side-stack { display: flex; flex-direction: column; gap: 18px; }
.info-status-item { color: var(--text-muted); font-size: 0.95em; }
.info-status-box { color: var(--text-muted); background: white; border: 1px dashed var(--border-light); border-radius: 10px; padding: 18px 20px; }
.info-status-error { color: var(--miru-red); border-color: rgba(141, 34, 34, 0.25); background: rgba(141, 34, 34, 0.04); }
.info-section-title { color: var(--text-main); font-size: 1.5em; border-bottom: 1px solid var(--border-light); padding-bottom: 10px; margin-top: 0; margin-bottom: 15px; }
.info-subheading { color: var(--text-main); margin-top: 30px; margin-bottom: 15px; }
.info-body-text { color: var(--text-main); margin-bottom: 20px; }
.info-body-text:last-child { margin-bottom: 0; }
.info-main ul,
.info-main ol { color: var(--text-main); margin: 0 0 20px; padding-left: 22px; }
.info-main li + li { margin-top: 6px; }
.info-inline-code { font-family: monospace; background: rgba(44, 62, 80, 0.08); padding: 0.12em 0.35em; border-radius: 4px; font-size: 0.92em; }
.info-reference-block { margin: 24px 0; }
.info-side .info-reference-block { margin: 0; }
.info-reference-missing { color: var(--miru-red); background: rgba(141, 34, 34, 0.06); border: 1px dashed rgba(141, 34, 34, 0.25); border-radius: 10px; padding: 14px 16px; margin: 24px 0; }

.miru-table { width: 100%; border-collapse: collapse; font-size: 0.95em; margin-bottom: 15px; }
.miru-table th, .miru-table td { border-bottom: 1px solid var(--border-light); padding: 12px 10px; text-align: left; }
.miru-table tr:last-child th, .miru-table tr:last-child td { border-bottom: none; }

/* 학술용 표 스타일 */
.academic-table { width: 100%; border-collapse: collapse; margin-bottom: 25px; color: black; text-align: center; font-size: 1em; border-top: 3px double black; border-bottom: 3px double black; }
.academic-table caption { text-align: left; font-weight: bold; margin-bottom: 8px; color: black; }
.academic-table th, .academic-table td { padding: 8px 12px; }
.academic-table thead th { border-bottom: 1px solid black; font-weight: normal; }
.v-line { border-right: 1px solid black; }
.academic-example { width: 100%; border-collapse: collapse; margin-bottom: 20px; color: black; }
.academic-example td { padding: 4px 15px 4px 0; vertical-align: top; }

/* 사전/예문 스타일 */
.sentence-card { padding: 20px; border: 1px solid var(--border-light); border-radius: 12px; margin-bottom: 15px; position: relative; background: var(--card-bg); transition: border-color 0.2s; }
.sentence-card:hover { border-color: var(--miru-teal); }
.sentence-en { font-size: 1.2em; font-weight: 700; color: var(--text-main); margin-bottom: 6px; cursor: pointer; }
.sentence-ko { font-size: 0.95em; color: var(--text-muted); cursor: pointer; }

#sentence-detail-view, #tag-search-view, #tag-result-view { display: none; padding: 30px; background: #F8F9FA; border-radius: 12px; }
.back-btn { padding: 8px 16px; background: white; color: var(--text-main); border: 1px solid var(--border-light); border-radius: 6px; cursor: pointer; margin-bottom: 25px; font-weight: 600; box-shadow: 0 2px 4px rgba(0,0,0,0.02); transition: all 0.2s; }
.back-btn:hover { border-color: var(--text-muted); }

/* 태그 관련 CSS */
.tag-btn { background: #F1F3F5; color: var(--text-main); padding: 8px 16px; border-radius: 20px; border: 1px solid var(--border-light); cursor: pointer; font-size: 0.95em; transition: all 0.2s; font-weight: 500; }
.tag-btn:hover { background: var(--miru-teal); color: white; border-color: var(--miru-teal); }
.detail-tag-text { color: var(--miru-teal); cursor: pointer; font-weight: 600; transition: color 0.2s; }
.detail-tag-text:hover { color: var(--miru-red); text-decoration: underline; }

.detail-en { font-size: 1.6em; font-weight: 700; line-height: 1.6; margin-bottom: 8px; }
.interlinear { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 15px; }
/* 단어 앞 문장 부호(« 등)는 따로 한 칸에 두어, 주석이 단어 첫 글자부터 시작하게 합니다. */
.interlinear-column { display: grid; grid-template-columns: auto auto; justify-content: start; }
.interlinear-lead { grid-column: 1; grid-row: 1; line-height: 1.4; }
.interlinear-word { grid-column: 2; grid-row: 1; line-height: 1.4; }
.interlinear-gloss { grid-column: 2; grid-row: 2; font-size: 0.6em; font-weight: 400; color: var(--miru-teal); min-height: 1.2em; }
/* 주석 줄의 문법 약어(PFV, 1SG 등)는 라이프치히 규칙대로 작은 대문자로 씁니다. */
.gloss-abbr { font-variant-caps: all-small-caps; letter-spacing: 0.03em; }
.related-sense-title { font-size: 0.9em; font-weight: 600; color: var(--text-muted); margin: 14px 0 8px; }
.info-pdf-frame { width: 100%; height: 75vh; border: 1px solid var(--border-light); border-radius: 8px; background: white; }
.info-pdf-actions { margin-bottom: 12px; }
.detail-ko { font-size: 1.15em; color: var(--text-muted); border-top: 1px solid var(--border-light); padding-top: 15px; }
.clickable-word { cursor: pointer; transition: color 0.2s; border-bottom: 1px dashed transparent; }
.clickable-word.registered:hover { color: var(--miru-teal); border-bottom: 1px dashed var(--miru-teal); }
.clickable-word.unregistered:hover { color: var(--miru-red); border-bottom: 1px dashed var(--miru-red); }

.vocab-container { display: flex; gap: 30px; margin-top: 20px; }
.vocab-left { width: 38%; border-right: 1px solid var(--border-light); padding-right: 20px; display: flex; flex-direction: column; }
.search-mode-container { display: flex; gap: 15px; margin-bottom: 15px; font-size: 0.9em; color: var(--text-muted); }
.search-mode-container label { cursor: pointer; display: flex; align-items: center; gap: 6px; }
.search-mode-container input[type="radio"] { accent-color: var(--miru-teal); }
.search-box { width: 80%; max-width: 280px; padding: 12px 15px; margin-bottom: 15px; border: 1px solid var(--border-light); border-radius: 8px; font-size: 0.95em; background: #F8F9FA; transition: all 0.2s; }
.search-box:focus { border-color: var(--miru-teal); background: white; outline: none; box-shadow: 0 0 0 3px rgba(50, 199, 199, 0.1); }
.vocab-list { flex-grow: 1; max-height: 440px; overflow-y: auto; padding-right: 10px; scrollbar-width: thin; scrollbar-color: var(--miru-teal) transparent; overflow-anchor: none; }
.vocab-list::-webkit-scrollbar { width: 6px; }
.vocab-list::-webkit-scrollbar-thumb { background-color: var(--miru-teal); border-radius: 4px; }
.vocab-list::-webkit-scrollbar-thumb:hover { background-color: var(--miru-red); }
.vocab-item-wrapper { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.vocab-item { flex-grow: 1; padding: 12px 15px; cursor: pointer; border-radius: 8px; transition: background 0.2s; color: var(--text-main); font-weight: 500; }
.vocab-item:hover { background: #F1F3F5; }
.vocab-item.selected { background: rgba(50, 199, 199, 0.08); font-weight: 700; color: var(--miru-teal); }
.vocab-details { width: 62%; padding-left: 10px; }
.vocab-details h3 { font-size: 2.2em; color: var(--text-main); margin-bottom: 25px; display: flex; align-items: baseline; gap: 12px; }
.toggle-btn { padding: 6px 12px; font-size: 0.85em; background: white; border: 1px solid var(--border-light); border-radius: 6px; cursor: pointer; float: right; color: var(--text-muted); font-weight: 600; }
.toggle-btn:hover { background: #F8F9FA; border-color: var(--text-muted); }
.meaning-list { list-style: none; padding: 0; margin: 0; }
.pos-badge { font-size: 0.8em; background: #F1F3F5; color: var(--text-muted); padding: 4px 10px; border-radius: 6px; margin-right: 12px; vertical-align: middle; font-weight: 600; letter-spacing: 0.5px; }
.etym-container { font-size: 0.95em; color: var(--text-muted); margin-bottom: 25px; padding: 15px; background: #F8F9FA; border-radius: 8px; }
.etym-link { color: var(--text-main); font-weight: 600; cursor: pointer; border-bottom: 1px solid var(--border-light); transition: all 0.2s; padding-bottom: 1px; }
.etym-link:hover { color: var(--miru-teal); border-bottom-color: var(--miru-teal); }
.etym-none { color: inherit; }

#tooltip { display: none; position: absolute; background: white; color: var(--text-main); padding: 20px; border-radius: 12px; box-shadow: 0 10px 25px rgba(0,0,0,0.1); z-index: 100; width: 300px; border: 1px solid var(--border-light); }
.tooltip-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 15px; border-bottom: 1px solid var(--border-light); padding-bottom: 12px; }
#tooltip-word { font-size: 1.4em; font-weight: 700; color: var(--miru-teal); }
#tooltip .word-relations { display: none !important; }
#tooltip-forms { font-size: 0.9em; color: var(--text-muted); }
#tooltip-meaning { margin-bottom: 20px; font-size: 0.95em; }
#tooltip button { width: 100%; padding: 12px; background: #F1F3F5; color: var(--text-main); border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: background 0.2s; }
#tooltip button:hover { background: var(--miru-teal); color: white; }
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #DDE2E5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #C1C9D0; }

@media (max-width: 980px) {
    .info-layout { flex-direction: column; }
    .info-toc,
    .info-side { width: 100%; position: static; }
}

#tooltip button { width: 100%; padding: 12px; background: #F1F3F5; color: var(--text-main); border: none; border-radius: 8px; cursor: pointer; font-weight: 600; transition: background 0.2s; }
#tooltip button:hover { background: var(--miru-teal); color: white; }

/* 서버에서 내용을 받지 못했을 때 그 자리에 넣는 문구 */
.load-error { color: var(--miru-red); padding: 10px 0; margin: 0; font-size: 0.95em; }
#tooltip .load-error { padding: 0; font-size: 0.9em; }

/* 서버의 응답이 늦을 때(2초 넘게) 그 자리에 넣는 문구 */
.load-notice { color: var(--text-muted); padding: 10px 0; margin: 0; font-size: 0.95em; }
#tooltip .load-notice { padding: 0; font-size: 0.9em; }

/* 링크한 단어·예문·뜻이 (더는) 없을 때 그 자리에 넣는 문구 */
.not-found { color: var(--text-muted); padding: 10px 0; margin: 0; font-size: 0.95em; }

/* IPA가 나오는 모든 칸(.ipa)은 Noto Serif입니다.
   Noto Serif에 없는 기호(↗ ↘)만 'Miru Sans'로 넘어갑니다. */
.ipa { font-family: 'Miru IPA', 'Miru Sans', serif; }

/* --- 부록 탭 --- */
.appendix-title { margin: 0 0 20px; }
/* 가로를 꽉 채우고 가로:세로 3:1을 유지합니다. 크기 조절은 비율이 깨지지 않게 막습니다. */
.xsampa-frame { position: relative; width: 100%; aspect-ratio: 3 / 1; }
/* 입력칸(.xsampa-in)은 글자를 투명하게 받기만 하고, 그 아래 표시층(.xsampa-view)이 허용 문자만 그립니다.
   그래서 한글 입력기로 조합 중인 글자도 화면에 나타나지 않습니다.
   커서가 글자와 맞도록 두 층의 글꼴·여백·줄 간격은 반드시 같아야 합니다. */
.xsampa-view, .xsampa-in { position: absolute; top: 0; left: 0; width: 100%; height: 100%; margin: 0; box-sizing: border-box; padding: 16px 18px; border: 1px solid transparent; border-radius: 8px; font-family: 'Miru IPA', 'Miru Sans', serif; font-size: 1.4em; line-height: 1.6; letter-spacing: normal; white-space: pre-wrap; overflow-wrap: break-word; overflow-y: auto; scrollbar-width: none; }
.xsampa-view::-webkit-scrollbar, .xsampa-in::-webkit-scrollbar { display: none; }
.xsampa-view { overflow: hidden; background: #F8F9FA; border-color: var(--border-light); color: var(--text-main); pointer-events: none; transition: all 0.2s; }
.xsampa-in { display: block; background: transparent; color: transparent; caret-color: var(--text-main); resize: none; outline: none; }
/* 조합 중에는 입력칸 층 전체를 투명하게 해서, 브라우저가 그리는 조합 표시(밑줄·바탕)까지 보이지 않게 합니다. */
.xsampa-in.is-composing { caret-color: transparent; opacity: 0; }
.xsampa-in::selection { color: transparent; background: rgba(50, 199, 199, 0.25); }
.xsampa-frame:focus-within .xsampa-view { background: white; border-color: var(--miru-teal); box-shadow: 0 0 0 3px rgba(50, 199, 199, 0.1); }

.hoverable-card { background: white; border: 1px solid var(--border-light); border-radius: 8px; cursor: pointer; transition: all 0.2s; }
.hoverable-card:hover { border-color: var(--miru-teal); box-shadow: 0 2px 8px rgba(50,199,199,0.1); }

.list-item-hover { transition: background 0.2s; border-radius: 8px; }
.list-item-hover:hover { background-color: #F1F3F5; }

.pagination-btn { padding: 5px 10px; border: 1px solid var(--border-light); background: white; border-radius: 6px; color: var(--text-main); transition: background 0.2s; cursor: pointer; }
.pagination-btn:hover { background-color: #F1F3F5; }
.pagination-btn:disabled { background: #f9f9f9; border-color: #eee; color: #ccc; cursor: not-allowed; }
.pagination-btn.active { border-color: var(--miru-teal); background: var(--miru-teal); color: white; font-weight: bold; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #DDE2E5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #C1C9D0; }
