:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --line: #ececef;
  --accent: #2563eb;
  --accent-soft: #eff4ff;
  --chip-bg: #f4f4f6;
  --hl: #fff3bf;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  color: var(--fg);
  background: #fafafb;
  line-height: 1.55;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px 80px; }

/* sticky header */
header {
  position: sticky; top: 0; z-index: 10;
  background: #fafafb;
  padding: 24px 0 12px;
  border-bottom: 1px solid var(--line);
}
h1 { font-size: 22px; font-weight: 700; margin: 0 0 14px; letter-spacing: -.3px; }
h1 .sub { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 8px; }

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1.5px solid var(--line);
  border-radius: var(--radius); padding: 11px 14px;
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { flex: none; color: var(--muted); }
.search input { flex: 1; border: 0; outline: 0; font-family: inherit; font-size: 16px; background: transparent; color: var(--fg); }
.clear {
  border: 0; background: var(--chip-bg); color: var(--muted); cursor: pointer;
  width: 22px; height: 22px; border-radius: 50%; font-size: 12px; line-height: 1; flex: none;
}
.clear:hover { background: #e3e3e7; color: var(--fg); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }

/* 필터 행 (난이도 / 분야 라벨 + 칩) */
.filter-row { display: flex; align-items: flex-start; gap: 10px; margin-top: 12px; }
.filter-row .filter-label {
  flex: 0 0 auto; font-size: 12px; font-weight: 700; color: var(--muted);
  padding-top: 6px; min-width: 34px; white-space: nowrap;
}
.filter-row .chips { margin-top: 0; flex: 1 1 auto; }

/* 난이도 배지 (각 용어 행) */
.lv { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; margin-left: 6px; vertical-align: middle; }
.lv-base { background: #e7f7ec; color: #1a8a4f; }
.lv-mid { background: #fff3e0; color: #c2710c; }
.lv-adv { background: #fdeaea; color: #d23f3f; }
.chip {
  font-size: 13px; padding: 5px 12px; border-radius: 999px;
  background: var(--chip-bg); color: #374151; border: 0; cursor: pointer;
  transition: background .12s, color .12s;
}
.chip:hover { background: #e7e7ea; }
.chip.active { background: var(--accent); color: #fff; }
.chip .n { opacity: .6; font-size: 11px; margin-left: 3px; }
.chip.active .n { opacity: .85; }

.alpha { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 10px; }
.alpha button {
  font-size: 12px; min-width: 24px; height: 24px; padding: 0 2px; border: 0; cursor: pointer;
  background: transparent; color: var(--muted); border-radius: 6px; font-weight: 600;
}
.alpha button:hover:not(:disabled) { background: var(--chip-bg); color: var(--fg); }
.alpha button.active { background: var(--accent-soft); color: var(--accent); }
.alpha button:disabled { opacity: .28; cursor: default; }

.count { font-size: 13px; color: var(--muted); margin: 16px 2px 4px; }

ul { list-style: none; margin: 0; padding: 0; }
li { padding: 14px 2px; border-bottom: 1px solid var(--line); content-visibility: auto; contain-intrinsic-size: auto 64px; }
.term { font-size: 16px; font-weight: 700; }
.term .ko { color: var(--muted); font-weight: 600; }
.badge {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
  margin-left: 8px; vertical-align: middle; white-space: nowrap;
}
.desc { font-size: 14px; color: #374151; margin-top: 3px; }

/* 상세 설명(클릭 토글) */
li.has-detail { cursor: pointer; }
li.has-detail:hover .term { color: var(--accent); }
.more-toggle { color: var(--accent); font-weight: 700; font-size: 13px; margin-left: 6px; vertical-align: middle; }
.detail {
  margin-top: 8px; padding: 11px 13px; border-radius: 8px;
  background: var(--accent-soft); color: #374151;
  font-size: 13.5px; line-height: 1.65;
}
.detail-foot { margin-top: 10px; display: flex; justify-content: flex-end; cursor: pointer; }
.detail-fold {
  border: 1px solid var(--line); background: #fff; color: var(--accent);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
  padding: 7px 16px; border-radius: 999px; transition: background .1s, transform .05s;
  pointer-events: none;            /* 클릭은 넓은 .detail-foot가 받도록 */
}
.detail-foot:hover .detail-fold { background: var(--accent-soft); }
.detail-foot:active .detail-fold { transform: scale(.96); background: #dfeaff; }
.group-sep {
  padding: 20px 2px 7px; font-size: 12px; font-weight: 700;
  color: var(--muted); border-bottom: 1px solid var(--line); letter-spacing: .2px;
}
mark { background: var(--hl); color: inherit; border-radius: 3px; padding: 0 1px; }

.empty { text-align: center; color: var(--muted); padding: 60px 0; font-size: 14px; }
.empty-msg { margin-bottom: 14px; }
.empty-add {
  border: 1.5px solid var(--line); background: var(--bg); color: var(--accent);
  cursor: pointer; font-size: 13px; font-weight: 600;
  padding: 8px 16px; border-radius: 999px; transition: border-color .12s, background .12s;
}
.empty-add:hover { border-color: var(--accent); background: var(--accent-soft); }
.empty-added { color: var(--accent); font-size: 13px; font-weight: 600; }

/* 탭 */
.tabs { display: flex; gap: 18px; border-bottom: 1.5px solid var(--line); margin-top: 14px; }
.tab {
  appearance: none; border: 0; background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 600; color: var(--muted);
  padding: 9px 2px; border-bottom: 2px solid transparent; margin-bottom: -1.5px;
}
.tab:hover { color: var(--fg); }
.tab.is-active { color: var(--fg); border-bottom-color: var(--accent); }

.toolbar { margin-top: 14px; }
.toolbar[hidden] { display: none; }

/* 탭 패널 */
.pane { display: none; }
.pane.is-active { display: block; }

/* 문장 해석 패널 */
.pane-interpret { padding-top: 18px; }
.pane-interpret textarea {
  width: 100%; box-sizing: border-box; resize: vertical;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 11px 14px; font: inherit; font-size: 16px; color: var(--fg);
  background: var(--bg); outline: 0; transition: border-color .15s, box-shadow .15s;
}
.pane-interpret textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ai-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.ai-go {
  border: 0; background: var(--accent); color: #fff; cursor: pointer;
  padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 600;
}
.ai-go:hover { background: #1d4ed8; }
.ai-go:disabled { opacity: .55; cursor: default; }
.ai-status { font-size: 13px; color: var(--muted); }
.ai-result { margin-top: 6px; }
.ai-block { padding: 14px 2px; border-bottom: 1px solid var(--line); }
.ai-label {
  font-size: 11px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); padding: 2px 8px; border-radius: 999px;
  display: inline-block; margin-bottom: 6px;
}
.ai-text { font-size: 14px; color: #374151; white-space: pre-wrap; }
.ai-terms { display: flex; flex-direction: column; gap: 8px; }
.ai-term { font-size: 14px; }
.ai-term-name { font-weight: 700; color: var(--fg); margin-right: 6px; }
.ai-term-mean { color: #374151; }
.ai-meta { font-size: 12px; color: var(--muted); margin-top: 8px; padding: 0 2px; line-height: 1.7; }
.ai-cum { color: var(--accent); font-weight: 600; }

/* 요청 단어 보드 (오른쪽 여백, 광고 자리처럼) */
.missing-board {
  position: fixed;
  top: 96px;
  left: calc(50% + 372px);   /* 본문(720) 절반 + 여백 */
  width: 200px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.missing-board h2 { font-size: 13px; font-weight: 700; margin: 0 0 4px; }
.missing-board .mb-sub { font-size: 11px; color: var(--muted); margin: 0 0 12px; line-height: 1.5; }
.missing-board ul { display: flex; flex-direction: column; gap: 7px; }
.missing-board li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 0; padding: 0; font-size: 13px;
}
.mb-term { color: var(--fg); word-break: break-all; }
.mb-count {
  font-size: 11px; color: var(--muted); background: var(--chip-bg);
  border-radius: 999px; padding: 1px 7px; flex: none;
}
.mb-empty { color: var(--muted); font-size: 12px; }

/* 본문 옆에 패널 둘 공간이 없으면 숨김 */
@media (max-width: 1180px) { .missing-board { display: none; } }

@media (max-width: 480px) {
  h1 { font-size: 20px; }
  .search input { font-size: 16px; }
}
