:root {
  --bg: #f6f7f9; --panel: #ffffff; --panel-2: #f0f2f5; --line: #e1e4e8; --text: #1d2330; --muted: #5d6675; --faint: #8a93a3;
  --accent: #3157d5; --accent-2: #e8eefc; --ok: #1f8a4c; --warn: #b26b00; --bad: #c0362c; --chip: #eef1f5;
  --lvA: #1f8a4c; --lvB: #2f6fd0; --lvC: #7b5cd6; --lvD: #b26b00; --lvE: #8a93a3; --lvM: #5d6675;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --panel: #161b23; --panel-2: #1c222c; --line: #2a313d; --text: #e6e9ef; --muted: #a3acba; --faint: #7a8494;
    --accent: #7c9cff; --accent-2: #1d2742; --chip: #222a36; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --panel: #161b23; --panel-2: #1c222c; --line: #2a313d; --text: #e6e9ef; --muted: #a3acba; --faint: #7a8494;
  --accent: #7c9cff; --accent-2: #1d2742; --chip: #222a36; --shadow: none; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans KR", sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 17px; margin: 0 0 10px; } h3 { font-size: 14px; margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 12px; } .nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 16px; padding: 8px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .04em; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: linear-gradient(135deg, #3157d5, #2a9d8f); }
.brand small { font-weight: 500; color: var(--faint); letter-spacing: 0; }
.nav { display: flex; gap: 2px; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--muted); }
.nav a:hover { background: var(--panel-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--accent-2); color: var(--accent); font-weight: 600; }
.topsearch { flex: 1; max-width: 520px; position: relative; }
.topsearch input { width: 100%; }
.topright { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.menu-btn { display: none; }
@media (max-width: 1100px) {
  .menu-btn { display: inline-flex; }
  .nav { display: none; position: absolute; top: 52px; left: 0; right: 0; flex-direction: column; background: var(--panel); border-bottom: 1px solid var(--line); padding: 8px; }
  .nav.open { display: flex; }
}

/* layout */
main { padding: 20px; max-width: 1500px; margin: 0 auto; }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side { grid-template-columns: 320px minmax(0, 1fr); }
@media (max-width: 900px) { .cols-2, .cols-3, .cols-4, .side { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card.tight { padding: 10px 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.spacer { flex: 1; }
.kpi { font-size: 24px; font-weight: 700; } .kpi-label { color: var(--muted); font-size: 12px; }

/* controls */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=search], input[type=password], input[type=number], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
textarea { width: 100%; font-family: var(--mono); font-size: 12.5px; }
label.field { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--panel); padding: 5px 10px; cursor: pointer; color: var(--muted); }
.seg button.on { background: var(--accent-2); color: var(--accent); font-weight: 600; }

/* chips */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; color: var(--muted); white-space: nowrap; }
.chip.lv { color: #fff; font-weight: 700; }
.lv-A { background: var(--lvA); } .lv-B { background: var(--lvB); } .lv-C { background: var(--lvC); } .lv-D { background: var(--lvD); } .lv-E { background: var(--lvE); } .lv-M { background: var(--lvM); }
.chip.lic-open, .chip.lic-attribution, .chip.lic-share_alike { background: rgba(31, 138, 76, .12); color: var(--ok); }
.chip.lic-unknown, .chip.lic-non_commercial, .chip.lic-academic_only, .chip.lic-commercial_license_required { background: rgba(178, 107, 0, .14); color: var(--warn); }
.chip.neg { background: rgba(192, 54, 44, .12); color: var(--bad); }
.swatch { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.stage { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); }

/* tables */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; }
table.data th, table.data td { padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.data tr:hover td { background: var(--panel-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 6px 12px; }
.kv > div:nth-child(odd) { color: var(--muted); }
.kv > div { overflow-wrap: anywhere; }

/* search / autocomplete */
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60; background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(16, 24, 40, .16); max-height: 420px; overflow: auto; }
.ac-item { display: flex; gap: 10px; align-items: baseline; padding: 7px 10px; cursor: pointer; }
.ac-item.on, .ac-item:hover { background: var(--accent-2); }
.ac-item .lbl { font-weight: 600; } .ac-item .meta { margin-left: auto; color: var(--faint); font-size: 12px; white-space: nowrap; }
.hero-search { max-width: 760px; margin: 24px auto 8px; }
.hero-search input { width: 100%; font-size: 17px; padding: 12px 14px; border-radius: 12px; }
.result { display: flex; gap: 12px; align-items: baseline; padding: 10px 6px; border-bottom: 1px solid var(--line); }
.result:last-child { border-bottom: 0; }

/* claims list */
.claim { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.claim:last-child { border-bottom: 0; }
.claim .sum { grid-column: 2 / 4; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.pred { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.group-list .grp { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; cursor: pointer; }
.group-list .grp:hover, .group-list .grp.on { background: var(--accent-2); }
.group-list .grp .n { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.bar { height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* graph */
.graph { width: 100%; height: 640px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); position: relative; overflow: hidden; }
.graph.small { height: 380px; }
.graph-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(127, 127, 127, .08); z-index: 5; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.path-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--panel); }
.path-card.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-2); }
.path-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.path-node { padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 600; }
.path-arrow { color: var(--faint); font-size: 12px; font-family: var(--mono); }
.step { margin: 6px 0 0 14px; padding-left: 10px; border-left: 2px solid var(--line); font-size: 12.5px; }

/* misc */
.spinner { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px; }
.empty { color: var(--muted); padding: 18px; text-align: center; }
.alert { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); }
.alert.err { border-color: rgba(192, 54, 44, .35); background: rgba(192, 54, 44, .07); color: var(--bad); }
.alert.warn { border-color: rgba(178, 107, 0, .35); background: rgba(178, 107, 0, .08); }
.alert.ok { border-color: rgba(31, 138, 76, .35); background: rgba(31, 138, 76, .08); }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; max-width: 420px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.tabs button { border: 0; background: none; padding: 8px 12px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding-top: 10px; }
.secret { font-family: var(--mono); padding: 10px; border-radius: 8px; background: var(--panel-2); border: 1px dashed var(--accent); overflow-wrap: anywhere; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); padding: 18px; max-width: 560px; width: 92vw; }
dialog::backdrop { background: rgba(0, 0, 0, .35); }
.kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; color: var(--faint); }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 360px; }
pre.json { background: var(--panel-2); border-radius: 8px; padding: 10px; overflow: auto; font-size: 12px; max-height: 360px; margin: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.fam-list { display: flex; flex-wrap: wrap; gap: 6px; }
.fam-list label { border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px 2px 6px; font-size: 12px; }
@media (max-width: 700px) {
  .topsearch { display: none; }
  .topbar { gap: 8px; padding: 8px 12px; flex-wrap: wrap; }
  .brand small { display: none; }
  main { padding: 12px; }
  .result { flex-wrap: wrap; }
  .kv { grid-template-columns: 1fr; }
}

/* graph views */
.graph.tall { height: 68vh; min-height: 520px; }
.graph-canvas { position: absolute; inset: 0; }
.graph-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.glabel { position: absolute; left: 0; top: 0; font-size: 11px; white-space: nowrap; color: var(--text); background: color-mix(in srgb, var(--panel) 72%, transparent);
  padding: 0 4px; border-radius: 4px; will-change: transform; }
.glabel.seed { font-weight: 700; font-size: 13px; }
.glabel.focus { outline: 2px solid #f4a261; font-weight: 700; }
.glabel.dim { opacity: .25; }
.graph-toolbar { position: absolute; top: 10px; right: 10px; z-index: 4; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.graph-toolbar .seg, .graph-toolbar .btn { box-shadow: var(--shadow); }
.graph-hint { position: absolute; left: 12px; bottom: 8px; z-index: 3; color: var(--faint); pointer-events: none; }
.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(16,24,40,.16);
  display: flex; flex-direction: column; min-width: 190px; z-index: 10; overflow: hidden; }
.menu button { text-align: left; background: none; border: 0; padding: 8px 12px; cursor: pointer; }
.menu button:hover { background: var(--accent-2); }
.swatch.line { width: 14px; height: 3px; border-radius: 2px; }
.graph-overlay { z-index: 6; }

/* text that must not break inside table cells: dates, ids, user names; tables scroll inside .table-wrap instead */
table.data th { white-space: nowrap; }
table.data td.nw, .nw { white-space: nowrap; }
table.data td.cell { white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
table.data td.wrap { white-space: normal; min-width: 220px; }
.spec-row { grid-template-columns: auto minmax(0, 1fr) !important; }
.spec-row .mono, .spec-row a { overflow-wrap: anywhere; }
pre.json { white-space: pre; max-width: 100%; }
@media (max-width: 700px) {
  .claim { grid-template-columns: auto minmax(0, 1fr); }
  .claim > .row.nowrap { grid-column: 2; white-space: normal; flex-wrap: wrap; }
  .claim .sum { grid-column: 1 / 3; }
}
.tabs { overflow-x: auto; scrollbar-width: thin; }
.tabs button { white-space: nowrap; flex: 0 0 auto; }
