/* 확률 정보 화면 */
:root {
  --g0: #75746d; --g1: #1b8a3a; --g2: #1d6fd6; --g3: #8a3db6; --g4: #a87c00; --g5: #d4541f; --g6: #cf2b2b;
  --pb-bar: color-mix(in srgb, var(--accent) 12%, transparent);
  --pb-tools-h: 58px;
}
[data-theme="dark"] {
  --g0: #b4b3ad; --g1: #57c776; --g2: #6aa8f5; --g3: #bd8ce3; --g4: #f0c246; --g5: #ff8d5f; --g6: #ff6a6a;
  --pb-bar: color-mix(in srgb, var(--accent) 17%, transparent);
}
.g0 { --g: var(--g0); } .g1 { --g: var(--g1); } .g2 { --g: var(--g2); } .g3 { --g: var(--g3); }
.g4 { --g: var(--g4); } .g5 { --g: var(--g5); } .g6 { --g: var(--g6); }
.pb-g { display: inline-block; padding: 0 7px; border-radius: 5px; font-size: 12.5px; font-weight: 700; line-height: 1.6;
  color: var(--g); background: color-mix(in srgb, var(--g) 12%, transparent); white-space: nowrap; }
.pb-gt { color: var(--g); font-weight: 650; }
.pb-count { min-width: 22px; padding: 0 6px; border-radius: 99px; background: var(--surface-2); text-align: center; font-size: 11.5px; color: var(--faint); font-weight: 650; font-variant-numeric: tabular-nums; }
.pb-sub { font-size: 12.5px; color: var(--faint); }
.pb mark, .pb-main mark { background: color-mix(in srgb, var(--accent) 28%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }

/* ---------- 전체 찾기 결과 (오른쪽 본문 자리) ---------- */
.pb-clear { width: 28px; height: 28px; border: 0; border-radius: 6px; background: transparent; color: var(--faint); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pb-clear:hover { background: var(--surface-2); color: var(--text); }
.pb-results { display: grid; gap: 14px; margin-bottom: 28px; }
.pb-results.loading { opacity: .55; transition: opacity .15s; }
.pb-res-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 14.5px; }
.pb-res-close { margin-left: auto; }
.pb-res-head .muted { font-size: 13px; }
.pb-res-posts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--faint); }
.pb-res-posts a { display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 12px; border-radius: 99px; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent-strong); font-weight: 600; }
.pb-res-posts a:hover { color: var(--accent-strong); border-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.pb-res { overflow: hidden; }
.pb-res-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.pb-res-title:hover { background: var(--surface-2); color: var(--text); }
.pb-res-title .t { font-weight: 700; font-size: 14.5px; }
.pb-res-title .ctx { color: var(--muted); font-size: 13px; }
.pb-res-title .d { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.pb-res .pb-tw { margin: 0; border: 0; border-radius: 0; box-shadow: none; }
.pb-res-more { display: flex; align-items: center; gap: 4px; justify-content: flex-end; min-height: 40px; padding: 0 16px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 650; color: var(--accent-strong); }
.pb-res-more:hover { background: var(--surface-2); color: var(--accent-strong); }
.pb-res-more svg.lucide { width: 14px; height: 14px; }
.pb-noresult { padding: 26px 20px; text-align: center; }
.pb-noresult p { margin: 2px 0; }

/* ---------- 합성 확률 비교 ---------- */
.pb-lead { margin: 6px 0 16px; color: var(--muted); font-size: 14px; line-height: 1.65; }
.pb-synth-table th .arrow { color: var(--faint); margin: 0 3px; font-weight: 400; }
.pb-synth-table tbody th { text-align: left; background: var(--surface); font-size: 14px; color: var(--text); white-space: nowrap; }
.pb-synth-table tbody th a { font-weight: 700; }
.pb-synth-table tbody th a:hover { color: var(--accent-strong); }
.pb-synth-table tbody th .d { display: block; font-size: 11.5px; font-weight: 400; color: var(--faint); }
.pb-synth-table td.p { cursor: default; font-size: 14px; }
.pb-foot-note { font-size: 13px; color: var(--faint); margin: 0; line-height: 1.6; }

/* ---------- 글 화면: 위쪽 분류 줄 + 본문 ---------- */
.pb-bar { position: relative; z-index: 20; margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.pb-bar-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 12px; }
.pb-search { flex: 1 1 320px; max-width: 520px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 13px; background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 99px; cursor: text; transition: border-color .12s, box-shadow .12s; }
.pb-search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.pb-search > svg.lucide { color: var(--accent); }
.pb-search input { flex: 1; min-width: 0; height: 100%; border: 0; padding: 0; background: transparent; box-shadow: none; font-size: 14.5px; }
.pb-search input:focus { box-shadow: none; }
.pb-search input::-webkit-search-cancel-button { display: none; }
.pb-bar-meta { margin: 0 0 0 auto; font-size: 12.5px; color: var(--faint); }
.pb-bar-meta a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.pb-cats { display: flex; flex-wrap: wrap; gap: 6px; }
.pb-cat { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface);
  font: inherit; font-size: 13.5px; font-weight: 650; color: var(--muted); cursor: pointer; white-space: nowrap; transition: background .12s, color .12s, border-color .12s; }
.pb-cat svg.lucide { width: 15px; height: 15px; color: var(--faint); }
.pb-cat .pb-cat-caret { width: 13px; height: 13px; margin-right: -3px; transition: transform .15s; }
.pb-cat:hover { color: var(--text); border-color: var(--border-strong); }
.pb-cat.on { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); color: var(--accent-strong); }
.pb-cat.on svg.lucide { color: var(--accent); }
.pb-cat[aria-expanded="true"] { background: var(--text); border-color: var(--text); color: var(--surface); }
.pb-cat[aria-expanded="true"] svg.lucide { color: var(--surface); }
.pb-cat[aria-expanded="true"] .pb-cat-caret { transform: rotate(180deg); }
.pb-cat-panel { position: absolute; left: 0; right: 0; top: calc(100% - 6px); padding: 14px 16px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); max-height: min(70vh, 560px); overflow-y: auto; scrollbar-width: thin; animation: pb-drop .14s ease-out; }
@keyframes pb-drop { from { opacity: 0; transform: translateY(-4px); } }
.pb-cat-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 14px; }
.pb-cat-head svg.lucide { width: 16px; height: 16px; color: var(--accent); }
.pb-cat-head span { font-size: 12.5px; color: var(--faint); }
.pb-cat-panel ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 2px 12px; }
.pb-cat-panel li a { display: block; padding: 8px 10px; border-radius: 8px; font-size: 13.5px; line-height: 1.45; color: var(--muted); }
.pb-cat-panel li a:hover { background: var(--surface-2); color: var(--text); }
.pb-cat-panel li a.on { background: var(--accent-soft); color: var(--accent-strong); font-weight: 650; }
.pb-new-dot { display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--accent); vertical-align: 2px; }

.pb-main { min-width: 0; }
.pb-crumbs { display: flex; align-items: center; gap: 4px; min-height: 32px; font-size: 13px; color: var(--faint); }
.pb-crumbs a { color: var(--muted); }
.pb-crumbs a:hover { color: var(--accent-strong); }
.pb-crumbs svg.lucide { width: 14px; height: 14px; }
.pb-title { margin: 6px 0 10px; font-size: 25px; font-weight: 750; line-height: 1.35; letter-spacing: -.02em; word-break: keep-all; overflow-wrap: anywhere; }
.pb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 13.5px; color: var(--muted); }
.pb-meta a { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.pb-meta a:hover { color: var(--accent-strong); }
.pb-meta a svg.lucide { width: 14px; height: 14px; }
.pb-basis { display: inline-flex; align-items: center; gap: 5px; font-weight: 700; color: var(--accent-strong); background: var(--accent-soft); border-radius: 99px; padding: 2px 10px; }
.pb-basis svg.lucide { width: 14px; height: 14px; }

.pb-change { margin-top: 16px; border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--border)); background: color-mix(in srgb, var(--blue) 4%, var(--surface)); border-radius: var(--radius); }
.pb-change summary { display: flex; align-items: center; gap: 8px; min-height: 46px; padding: 0 16px; cursor: pointer; list-style: none; font-size: 14px; }
.pb-change summary::-webkit-details-marker { display: none; }
.pb-change summary svg.lucide { color: var(--blue); }
.pb-change-more { margin-left: auto; font-size: 13px; color: var(--blue); font-weight: 650; white-space: nowrap; }
.pb-change[open] .pb-change-more { display: none; }
.pb-change .pb-tw { margin: 0 12px 12px; }
.pb-change-table td.ctx { color: var(--muted); font-size: 12.5px; }
.pb-change-table tr.added td:last-child { color: var(--green); font-weight: 650; }
.pb-change-table tr.removed td:last-child { color: var(--red); }
.pb-change-table tr.changed td:last-child { color: var(--blue); font-weight: 650; }

/* 찾기·클래스·목차 줄 (스크롤해도 위에 붙는다) */
.pb-tools { position: sticky; top: var(--header-h); z-index: 15; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin: 16px 0 0; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.pb-find { flex: 1 1 260px; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 12px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: text; transition: border-color .12s, box-shadow .12s; }
.pb-find:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.pb-find svg.lucide { color: var(--faint); }
.pb-find input { flex: 1; min-width: 0; border: 0; padding: 0; height: 100%; background: transparent; box-shadow: none; font-size: 14.5px; }
.pb-find input:focus { box-shadow: none; }
.pb-find-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pb-seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: calc(var(--radius-sm) + 3px); background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.pb-seg::-webkit-scrollbar { display: none; }
.pb-seg button { flex: 0 0 auto; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--muted); padding: 0 12px; height: 30px; font-size: 13.5px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.pb-seg button:hover { color: var(--text); }
.pb-seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(24, 22, 16, .08), 0 0 0 1px var(--border); }
[data-theme="dark"] .pb-seg button.on { background: var(--surface-3); box-shadow: none; }
.pb-toc { position: relative; }
.pb-toc .btn { height: 38px; }
.pb-toc .btn span { max-width: 180px; overflow: hidden; text-overflow: ellipsis; }
.pb-toc-menu { position: absolute; right: 0; top: calc(100% + 6px); width: min(360px, 86vw); max-height: min(62vh, 560px); overflow-y: auto; z-index: 30;
  display: grid; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.pb-toc-menu a { display: block; padding: 8px 10px; border-radius: 6px; font-size: 13.5px; line-height: 1.4; }
.pb-toc-menu a:hover { background: var(--surface-2); color: var(--text); }
.pb-toc-menu a.lv1 { font-weight: 650; }
.pb-toc-menu a.lv2 { padding-left: 24px; color: var(--muted); font-size: 13px; }
.pb-toc-menu a.on { color: var(--accent-strong); background: var(--accent-soft); }

/* 본문 */
.pb-body { padding-top: 6px; }
.pb-sec { margin-top: 28px; scroll-margin-top: calc(var(--header-h) + var(--pb-tools-h) + 8px); }
.pb-h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; font-size: 18.5px; font-weight: 750; line-height: 1.4; }
.pb-h2::before { content: ""; width: 4px; height: 18px; border-radius: 2px; background: var(--accent); flex-shrink: 0; }
.pb-h3 { margin: 22px 0 8px; font-size: 15.5px; font-weight: 700; scroll-margin-top: calc(var(--header-h) + var(--pb-tools-h) + 8px); }
.pb-note { margin: 8px 0 12px; padding: 10px 14px; border: 1px solid var(--border); border-left: 3px solid var(--border-strong); background: var(--surface); border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.7; color: var(--muted); }
.pb-note p { margin: 0; }
.pb-note p.warn { color: var(--text); }
.pb-note p.dot, .pb-note p.cont, .pb-note p.ex { padding-left: 12px; }
.pb-note p.ex { color: var(--faint); }
.pb-note a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.pb-img { margin: 10px 0 16px; }
.pb-img img { display: block; max-width: min(100%, 760px); height: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }

/* 클래스 탭 */
.pb-tabs { margin: 10px 0 18px; }
.pb-tabbar { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.pb-tabbar::-webkit-scrollbar { display: none; }
.pb-tabbar button { flex: 0 0 auto; border: 0; background: none; min-height: 38px; padding: 0 14px; font-size: 14px; font-weight: 650; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.pb-tabbar button:hover { color: var(--text); }
.pb-tabbar button.on { color: var(--text); border-bottom-color: var(--accent); }
.pb-pane { display: none; }
.pb-pane.on { display: block; }
.pb-pane-title { display: none; margin: 16px 0 6px; font-size: 14.5px; font-weight: 700; color: var(--muted); }
.pb-show-all .pb-pane, .pb-filtering .pb-pane { display: block; }
.pb-show-all .pb-pane-title, .pb-filtering .pb-pane-title { display: block; }
.pb-show-all .pb-tabbar, .pb-filtering .pb-tabbar { display: none; }

/* 표 */
.pb-tw { margin: 8px 0 18px; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); scroll-margin-top: calc(var(--header-h) + var(--pb-tools-h) + 8px); }
.pb-tw.tall { max-height: min(74vh, 780px); }
.pb-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; line-height: 1.45; }
.pb-table thead { position: sticky; top: 0; z-index: 2; }
.pb-table th { padding: 9px 12px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 650; text-align: center; vertical-align: middle;
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); min-width: 64px; }
.pb-table thead th { box-shadow: inset 0 -1px 0 var(--border); }
.pb-table th:first-child, .pb-table td:first-child { border-left: 0; }
.pb-table td { padding: 8px 12px; border-top: 1px solid var(--border); border-left: 1px solid var(--border); vertical-align: middle; }
.pb-table tbody tr:first-child td { border-top: 0; }
.pb-table tbody tr:hover td { background-color: color-mix(in srgb, var(--surface-2) 70%, var(--surface)); }
.pb-table td.p { text-align: right; white-space: nowrap; font-weight: 650; font-variant-numeric: tabular-nums; cursor: pointer;
  background-image: linear-gradient(90deg, var(--pb-bar) var(--w, 0%), transparent var(--w, 0%)); background-repeat: no-repeat; }
.pb-table td.p:hover { color: var(--accent-strong); }
.pb-table td.n { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pb-table td.dash { text-align: center; color: var(--faint); }
.pb-table td.rep { color: transparent; border-top-color: transparent; }
.pb-table td.rep .pb-g, .pb-table td.rep .pb-gt { visibility: hidden; }
.pb-table td a { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.pb-table tr.pb-hide { display: none; }
.pb-tw.pb-hide, .pb-sec.pb-hide, .pb-h3.pb-hide, .pb-tabs.pb-hide, .pb-pane.pb-hide,
.pb-filtering .pb-note, .pb-filtering .pb-img { display: none; }
.pb-find-empty { margin: 24px 0; padding: 30px 18px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); }
.pb-find-empty p { margin: 0 0 12px; }

.pb-locked-toc ul { list-style: none; margin: 0; padding: 6px 18px 16px; display: grid; gap: 10px; }
.pb-locked-toc li { display: grid; gap: 2px; font-size: 14px; }
.pb-locked-toc li span { font-size: 12.5px; color: var(--faint); }
.pb-foot { margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--faint); }
.pb-foot p { display: flex; gap: 6px; align-items: flex-start; margin: 0 0 6px; line-height: 1.6; }
.pb-foot p svg.lucide { margin-top: 3px; width: 14px; height: 14px; }
.pb-foot a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.pb-pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.pb-pager a { display: grid; gap: 2px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text); min-width: 0; transition: border-color .12s; }
.pb-pager a:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); color: var(--text); }
.pb-pager a span { font-size: 12px; color: var(--faint); }
.pb-pager a b { font-size: 14px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pb-pager a.next { text-align: right; grid-column: 2; }

/* 확률 계산 (확률 칸을 누르면) */
.pb-calc { position: absolute; z-index: 90; width: 300px; padding: 14px 16px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); font-size: 13.5px; animation: ui-pop .15s ease-out; }
.pb-calc h4 { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 0 0 2px; font-size: 18px; color: var(--accent-strong); font-variant-numeric: tabular-nums; }
.pb-calc h4 button { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; }
.pb-calc h4 button:hover { color: var(--text); background: var(--surface-2); }
.pb-calc .what { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; line-height: 1.5; }
.pb-calc .row { display: flex; justify-content: space-between; gap: 10px; padding: 6px 0; border-top: 1px solid var(--border); }
.pb-calc .row b { font-variant-numeric: tabular-nums; }
.pb-calc .try { display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border); color: var(--muted); flex-wrap: wrap; }
.pb-calc .try input { width: 80px; min-height: 32px; padding: 4px 8px; font-size: 14px; font-weight: 650; }
.pb-calc .try b { color: var(--accent-strong); font-size: 15px; }

@media (max-width: 767px) {
  .pb-search { flex-basis: 100%; max-width: none; }
  .pb-bar-meta { margin-left: 2px; }
  .pb-cats { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .pb-cats::-webkit-scrollbar { display: none; }
  .pb-cat { height: 36px; }
  .pb-cat-panel { padding: 12px; max-height: 64vh; }
  .pb-cat-panel ul { grid-template-columns: minmax(0, 1fr); }
  .pb-title { font-size: 21px; }
  .pb-tw.tall { max-height: none; }
  .pb-table thead { position: static; }
  .pb-tools { gap: 8px; }
  .pb-find { flex: 1 1 160px; height: 40px; }
  .pb-seg { order: 3; flex: 1 1 100%; }
  .pb-seg button { flex: 1 0 auto; height: 34px; padding: 0 10px; }
  .pb-toc .btn { height: 40px; }
  .pb-toc .btn span { max-width: 92px; }
  .pb-table { font-size: 13px; }
  .pb-table th, .pb-table td { padding: 7px 9px; }
  .pb-tabbar button { min-height: 40px; padding: 0 12px; }
  .pb-calc { left: 12px !important; right: 12px; width: auto; }
  .pb-pager { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
