:root {
  --bg: #f5f6f8; --panel: #ffffff; --line: #e2e5ea; --line2: #eef0f3;
  --text: #1c2129; --muted: #667085; --accent: #1f5fbf; --accent-bg: #e8f0fc;
  --hit: #b54708; --hit-bg: #fef3e2; --sel: #dbe8fb; --mark: #fff0a8;
  --ok: #067647; --ok-bg: #e7f6ec; --warn: #b42318; --warn-bg: #fdecea;
  --text2: #3b4453; --hover: #f2f5fa; --set-bg: #f7f9fd; --tree: #b7c1cf;
  --src-bg: #eceff4; --src-fg: #475467;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "D2Coding", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418; --panel: #191d23; --line: #2b313a; --line2: #22272e;
    --text: #e6e9ee; --muted: #98a2b3; --accent: #7cacf8; --accent-bg: #1c2b44;
    --hit: #fdb022; --hit-bg: #3a2a10; --sel: #22385a; --mark: #5c4d12;
    --ok: #47cd89; --ok-bg: #0f2e1f; --warn: #f97066; --warn-bg: #3a1614;
    --text2: #c5ccd6; --hover: #20262e; --set-bg: #1c2129; --tree: #4a5566;
    --src-bg: #2a313b; --src-fg: #b5bfcc;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { height: 100dvh; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", system-ui, sans-serif; display: flex; flex-direction: column; }
button, input, select { font: inherit; color: inherit; }

.top { display: flex; align-items: center; gap: 16px; padding: 7px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brandbox { display: flex; align-items: center; gap: 12px; flex: none; }
.brand { font-weight: 700; font-size: 16px; white-space: nowrap; }
.search { display: flex; flex: 1; max-width: 760px; gap: 6px; }
.search select, .search input { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 10px; }
.search input { flex: 1; min-width: 0; font-family: var(--mono); }
.search input:focus, .search select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.search button { border: 0; border-radius: 8px; padding: 7px 16px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
.gear { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; width: 36px; height: 36px; cursor: pointer; font-size: 16px; flex: none; }
#logoutForm { margin: 0; }
.dbinfo { font-size: 11.5px; line-height: 1.35; color: var(--muted); white-space: nowrap; padding-left: 12px; border-left: 1px solid var(--line); }
.dbinfo .warn { color: var(--warn); }

.layout { flex: 1; display: grid; grid-template-columns: clamp(360px, 34vw, 500px) 1fr; min-height: 0; }
.left { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.lbar { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--line); background: var(--panel); padding-right: 12px; }
.summary { flex: 1; min-width: 0; padding: 8px 16px; font-size: 13px; color: var(--text2); font-weight: 500; }
.lopt { display: inline-flex; align-items: center; gap: 5px; flex: none; font-size: 12.5px; font-weight: 600; color: var(--text2);
        border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 7px; cursor: pointer; background: var(--bg); user-select: none; }
.lopt:has(input:checked) { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.lopt input { margin: 0; accent-color: var(--accent); }
.results { overflow: auto; flex: 1; }
.right { overflow: auto; min-height: 0; }
.back { display: none; }

/* ----- 결과 트리 ----- */
.results { padding: 8px 8px 28px; background: var(--bg); }
.group { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; overflow: hidden; }
.group.set { box-shadow: inset 3px 0 0 var(--accent); }

.node { position: relative; display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: 6px;
        align-items: start; padding: 9px 12px 9px 8px; cursor: pointer; transition: background .12s; }
.node + .node, .kids { border-top: 1px solid var(--line2); }
.kids .node { border-top: 0; }
.node:hover { background: var(--hover); }
.node.selected { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.node.rep, .node.norep { background: var(--set-bg); }
.node.rep:hover { background: var(--hover); }
.node.rep.selected { background: var(--sel); }
.node.norep { cursor: default; }

.l1 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 6px; line-height: 20px; font-size: 14px; }
.pn { font-family: var(--mono); font-weight: 700; font-size: 14.5px; color: var(--text); letter-spacing: -.1px; }
.noun { color: var(--text2); }
.wuc { font-family: var(--mono); font-size: 11.5px; line-height: 18px; color: var(--muted); background: var(--line2); border-radius: 4px; padding: 0 5px; }
.src { font: 700 10.5px/18px var(--mono); padding: 0 6px; border-radius: 4px; background: var(--src-bg); color: var(--src-fg); letter-spacing: .3px; }
.tag.set { background: var(--accent); color: #fff; font-weight: 700; font-size: 10.5px; line-height: 18px; padding: 0 7px; border-radius: 4px; margin: 0; }
.star { color: var(--hit); font-size: 12px; }

.sub { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 14px; margin-top: 4px; font-size: 12.5px; line-height: 18px; color: var(--muted); }
.sub > span { white-space: nowrap; }
.sub b { font-family: var(--mono); font-weight: 600; color: var(--text); margin-left: 3px; }
.sub .dot { width: 1px; height: 11px; background: var(--tree); margin: 0 8px; font-size: 0; }
.sub .link.note { font-weight: 600; }

/* 일치 표시 */
.node > div:last-child { padding-top: 1px; }
.tag { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 8px; border-radius: 999px; white-space: nowrap; font-weight: 600; }
.tag.m-exact, .tag.m-normalized { background: var(--ok-bg); color: var(--ok); }
.tag.m-prefix, .tag.m-contains { background: var(--accent-bg); color: var(--accent); }
.tag.m-fuzzy { background: var(--hit-bg); color: var(--hit); }
.tag.m-multi { background: var(--ok-bg); color: var(--ok); }
mark { background: var(--mark); color: inherit; border-radius: 3px; padding: 0 1px; box-shadow: 0 0 0 1px var(--mark); }

/* 펼침 버튼 */
.twisty { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-top: -1px;
          border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text2); cursor: pointer; padding: 0; }
.twisty:hover { border-color: var(--accent); color: var(--accent); }
.twisty svg { width: 12px; height: 12px; transition: transform .15s; }
.twisty[aria-expanded="true"] svg { transform: rotate(90deg); }

/* 트리 연결선: 펼침 버튼 중심(x=19px)에서 구성품으로 */
.group.open > .node.rep::after, .group.open > .node.norep::after {
  content: ""; position: absolute; left: 18px; top: 32px; bottom: 0; border-left: 2px solid var(--tree); }
.kids { position: relative; }
.node.child { padding-left: 40px; }
.node.child::before { content: ""; position: absolute; left: 18px; top: 0; bottom: 0; border-left: 2px solid var(--tree); }
.node.child:last-child::before { bottom: auto; height: 20px; }
.node.child::after { content: ""; position: absolute; left: 18px; top: 18px; width: 14px; height: 2px; background: var(--tree); border-radius: 0 2px 2px 0; }
.node.child > span:first-child { display: none; }
.node.child { grid-template-columns: minmax(0, 1fr) auto; }
.node.child.dim .pn, .node.child.dim .noun { color: var(--muted); font-weight: 500; }
.node.child.dim .sub b { color: var(--muted); font-weight: 500; }

.more { display: inline-flex; align-items: center; gap: 4px; margin: 2px 0 10px 40px; border: 1px dashed var(--accent); border-radius: 999px;
        background: none; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; padding: 3px 12px; }
.more:hover { background: var(--accent-bg); border-style: solid; }
.norep-msg { font-size: 12.5px; color: var(--muted); margin-top: 4px; font-style: italic; }

/* ----- 상세 ----- */
.detail { padding: 18px 24px 36px; max-width: 1100px; }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }
.dhead h1 { margin: 0; font-family: var(--mono); font-size: 22px; }
.dhead .dnoun { font-size: 16px; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 2px; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; background: var(--panel); }
.chip b { color: var(--muted); font-weight: 500; margin-right: 4px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 16px 0 14px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { font-size: 11px; background: var(--line2); border-radius: 999px; padding: 0 6px; margin-left: 4px; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 12px; }
.card h3 { margin: 0 0 10px; font-size: 14px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 20px; }
.kv > div { display: grid; grid-template-columns: 130px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line2); }
.kv dt { color: var(--muted); font-size: 12px; margin: 0; }
.kv dd { margin: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 13px; }

.link { color: var(--accent); cursor: pointer; text-decoration: underline; text-decoration-color: transparent; background: none; border: 0; padding: 0; font: inherit; text-align: left; }
.link:hover { text-decoration-color: currentColor; }
.link.note .nicon { font-size: 11px; margin-left: 3px; }
.picon { font: 600 9px/1 system-ui, sans-serif; background: var(--warn); color: #fff; border-radius: 3px; padding: 2px 3px; margin-right: 5px; vertical-align: 2px; }
.ic { border: 0; background: none; color: var(--muted); cursor: pointer; padding: 0 4px; font-size: 14px; line-height: 1; }
.ic:hover { color: var(--accent); }
.nullv { color: var(--muted); }
.chip .link { font-size: 12px; }
.chip.spec { cursor: default; font: inherit; font-size: 12px; }
button.chip.spec { cursor: pointer; }
.chip.spec.yes { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.chip.spec.yes b, .chip.spec.no b, .chip.spec.from b { color: inherit; font-weight: 600; margin: 0 0 0 4px; }
.chip.spec.no { background: var(--line2); color: var(--muted); border-color: transparent; }
.chip.spec.from { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
.tabs .n.yes { background: var(--ok-bg); color: var(--ok); }
.nospec { color: var(--muted); }
.tscroll { overflow-x: auto; }
.remarks { white-space: pre-wrap; line-height: 1.6; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { border-bottom: 1px solid var(--line2); padding: 6px 8px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--bg); }
td.mono { font-family: var(--mono); }
.func { margin: 14px 0 6px; font-weight: 600; }
sup.nref { color: var(--accent); font-size: 10px; margin-left: 2px; }
.notes { font-size: 12px; color: var(--muted); margin-top: 10px; }
.notes div { margin: 2px 0; white-space: pre-wrap; }
.eq { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.info { background: var(--accent-bg); color: var(--accent); padding: 8px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; }
.none { color: var(--muted); padding: 10px 0; }
.clickrow { cursor: pointer; }
.clickrow:hover td { background: var(--bg); }

/* ----- 모바일: 목록 → 상세 전환 ----- */
@media (max-width: 860px) {
  .top { flex-wrap: wrap; gap: 8px; }
  .search { order: 3; flex-basis: 100%; max-width: none; flex-wrap: wrap; }
  .search select { flex: 1 1 40%; min-width: 0; }
  .search input { flex: 1 1 60%; }
  .layout { grid-template-columns: 1fr; }
  .right { display: none; }
  body.show-detail .left { display: none; }
  body.show-detail .right { display: block; }
  .back { display: block; margin: 10px 16px 0; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
  .detail { padding: 12px 16px 40px; }
  .kv > div { grid-template-columns: 110px 1fr; }
}

/* ----- 팝업 ----- */
.modal { position: fixed; inset: 0; background: rgba(15, 20, 30, .45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal[hidden] { display: none; }
.mbox { background: var(--panel); border-radius: 12px; width: min(560px, 100%); max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.mhead { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.mhead h2 { margin: 0; font-size: 15px; flex: 1; }
.mclose { border: 0; background: none; font-size: 16px; cursor: pointer; color: var(--muted); }
.mbody { padding: 14px 16px 18px; overflow: auto; }
.mbody p { margin: 0 0 10px; }
.btn { display: inline-block; border: 0; border-radius: 8px; padding: 7px 14px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; text-decoration: none; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 8px; margin: 8px 0; cursor: pointer; }
.opt input { margin-top: 3px; }
.flist { margin: 0; padding-left: 18px; }
.flist li { margin: 6px 0; }
.flist a { color: var(--accent); font-family: var(--mono); }
.warn { color: var(--warn); }

/* ----- 출처 표시 ----- */
.sub .link.note { font: inherit; font-family: var(--mono); font-weight: 600; }

/* ----- 교정 규격 ----- */
.shead { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.shead h3 { margin: 0; }
.sicallout { background: var(--hit-bg); color: var(--text); border-radius: 8px; padding: 8px 12px; font-size: 13px; margin-bottom: 6px; }
.sicallout .snote { white-space: pre-wrap; }
.func { display: flex; align-items: baseline; gap: 6px; margin: 16px 0 6px; }
.fnum { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); font-size: 11px; font-weight: 700; }
.spectbl td { font-size: 12.5px; }
.spectbl .li + .li { margin-top: 4px; padding-top: 4px; border-top: 1px dotted var(--line2); }
.stype { display: inline-block; font: 600 10px/15px system-ui, sans-serif; padding: 0 5px; margin-left: 6px; border-radius: 4px; background: var(--accent-bg); color: var(--accent); vertical-align: 1px; }
.equation { font-size: 12px; color: var(--accent); margin-top: 2px; }
sup.nref { cursor: help; }
.notes .nh { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.notes { border-top: 1px solid var(--line2); padding-top: 8px; }

/* ----- 비교 선택 ----- */
.pick { width: 16px; height: 16px; margin: 0 2px 0 0; accent-color: var(--accent); cursor: pointer; flex: none; align-self: center; }
.node.picked { box-shadow: inset 3px 0 0 var(--hit); }
.node.picked.selected { box-shadow: inset 3px 0 0 var(--accent); }
.pickbar { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--panel);
           box-shadow: 0 -4px 12px rgba(15, 20, 30, .06); }
.pickbar[hidden] { display: none; }
.pinfo { flex: 1; min-width: 0; font-size: 12.5px; display: flex; flex-direction: column; }
.pinfo span { color: var(--muted); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbtn { border: 0; border-radius: 8px; padding: 7px 12px; background: var(--accent); color: #fff; font-weight: 700; cursor: pointer; white-space: nowrap; }
.pbtn.sec { background: var(--line2); color: var(--text2); font-weight: 600; }
.pbtn:disabled { opacity: .45; cursor: not-allowed; }

/* 장비형·장비명 구글 검색 링크 */
.glink { color: inherit; text-decoration: none; border-bottom: 1px dashed transparent; }
.glink:hover { color: var(--accent); border-bottom-color: currentColor; }
.gicon { font-size: .6em; margin-left: 4px; color: var(--muted); vertical-align: .35em; font-family: system-ui, sans-serif; }
.glink:hover .gicon { color: var(--accent); }

.dbinfo .ver { font-family: var(--mono); font-size: 11px; }
.dbinfo .d2 .warn { font-family: inherit; }

/* 왼쪽 하단: 환경설정 · 로그아웃 */
.lfoot { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-top: 1px solid var(--line); background: var(--panel); }
.fbtn { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--bg); color: var(--text2);
        border-radius: 7px; padding: 4px 10px; font-size: 12.5px; cursor: pointer; }
.fbtn:hover { background: var(--hover); color: var(--accent); }
.fbtn span { font-size: 14px; line-height: 1; }

/* ----- 단독 / 세트 구분 머리글 ----- */
.gsec { display: flex; align-items: center; gap: 6px; margin: 10px 4px 6px; font-size: 12px; font-weight: 700; color: var(--text2); letter-spacing: .02em; }
.gsec:first-child { margin-top: 2px; }
.gsec b { font-weight: 600; font-size: 11px; color: var(--muted); background: var(--line2); border-radius: 999px; padding: 0 7px; }
.gsec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gsec.set span { color: var(--accent); }
.summary .vsel { font-family: var(--mono); color: var(--accent); }
.vclear { margin-left: 6px; border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 1px 8px; font-size: 11.5px; cursor: pointer; color: var(--text2); }
.vclear:hover { color: var(--accent); border-color: var(--accent); }

/* ----- 간략 목록 ----- */
.vlist { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.vrow { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; cursor: pointer; border-top: 1px solid var(--line2); font-size: 14px; }
.vrow:first-child { border-top: 0; }
.vrow:hover { background: var(--hover); }
.vrow.selected { background: var(--sel); box-shadow: inset 3px 0 0 var(--accent); }
.vcaret { width: 14px; flex: none; color: var(--muted); text-align: center; transition: transform .15s; }
.vrow.open .vcaret { transform: rotate(90deg); color: var(--accent); }
.vval { font-family: var(--mono); font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vcnt { font-size: 11.5px; color: var(--muted); flex: none; }
.vrow .tag { flex: none; }
.mini { padding: 4px 10px 10px 30px; background: var(--set-bg); border-top: 1px solid var(--line2); }
.mini .gsec { margin: 8px 0 4px; font-size: 11.5px; }
.mrow { display: flex; align-items: baseline; gap: 6px; padding: 4px 8px; border-radius: 6px; cursor: pointer; font-size: 13px; line-height: 1.45; }
.mrow:hover { background: var(--hover); }
.mrow.selected { background: var(--sel); }
.mrow .mtxt { font-family: var(--mono); font-size: 12.5px; min-width: 0; }
.mrow .src { flex: none; }
.mset { border-left: 2px solid var(--accent); margin: 2px 0 4px; padding-left: 4px; }
.mrow.rep .mtxt { font-weight: 700; }
.mrow.kid { margin-left: 14px; }
.mrow.norep { cursor: default; color: var(--muted); }
.mrow .star { color: var(--hit); font-size: 11px; }
.mload { color: var(--muted); font-size: 12.5px; padding: 6px 8px; }

/* ----- 번역 버튼 ----- */
.trbox { position: relative; }
.trbtn { float: right; margin: -2px 0 6px 10px; border: 1px solid var(--accent); background: var(--panel); color: var(--accent);
         border-radius: 999px; padding: 1px 11px; font-size: 12px; font-weight: 700; cursor: pointer; line-height: 20px; }
.trbtn:hover { background: var(--accent-bg); }
.trbtn:disabled { opacity: .6; cursor: progress; }
.trbox.translated .trbtn { background: var(--accent); color: #fff; }
.trbox.translated .tr-text { border-left: 3px solid var(--accent); padding-left: 10px; }
.trerr { clear: both; margin-top: 6px; font-size: 12px; color: var(--warn); }
.trvia { clear: both; margin-top: 4px; font-size: 11px; color: var(--muted); text-align: right; }
.trerr a { color: var(--accent); margin-left: 6px; white-space: nowrap; }
