:root {
  --fg: #1a1d23;
  --muted: #6b7280;
  --bg: #fafafa;
  --card: #ffffff;
  --border: #e3e6ea;
  --accent: #2451b7;
  --accent-fg: #fff;
  --danger: #b91c1c;
  --ok: #15803d;
  --code-bg: #f3f4f6;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 17px; margin: 0; }
.topbar h1 a { color: var(--fg); }
.topbar nav { display: flex; gap: 12px; align-items: center; }

main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 24px;
}

.foot {
  text-align: center;
  color: var(--muted);
  padding: 24px;
}

button, .btn {
  display: inline-block;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--fg);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}
button:hover, .btn:hover { border-color: #aaa; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
button.ghost { background: transparent; }

input[type=text], textarea, select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  width: 100%;
}

label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
  margin-bottom: 16px;
}

table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); font-weight: 600; }

.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--code-bg);
  color: var(--muted);
}
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.warn { background: #fef3c7; color: #92400e; }
.definedby-badge { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }

.muted { color: var(--muted); }
.flex { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.right { text-align: right; }
.gap { margin-top: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.toast {
  position: fixed;
  bottom: 16px;
  right: 16px;
  background: #1a1d23;
  color: #fff;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  max-width: 360px;
}
.toast.show { opacity: 1; }
.toast.error { background: var(--danger); }

h2 { margin: 0 0 12px; font-size: 18px; }
h3 { margin: 16px 0 8px; font-size: 14px; }

.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.crumbs a { color: var(--muted); }

.project-heading { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.project-heading .project-code {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--code-bg);
  color: var(--accent);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  margin-right: 4px;
}
.project-prefix { color: var(--muted); }

.admin-link {
  font-size: 12px;
  color: var(--muted);
}

/* ---- friendly viewer: copy-IRI icon button ---- */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: var(--muted);
  border-radius: 4px;
  cursor: pointer;
  vertical-align: middle;
  flex: none;
}
.icon-btn:hover { color: var(--accent); background: var(--code-bg); }
.icon-btn svg { display: block; }

.nowrap { white-space: nowrap; }

/* ---- language switcher ---- */
.lang-switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.lang-switch-wrap > span { font-size: 12px; }
select.lang-switch {
  width: auto;
  padding: 4px 8px;
  font-size: 13px;
}

/* ---- concept hierarchy tree ---- */
ul.tree { list-style: none; margin: 0; padding: 0; }
ul.tree.tree-root { margin-top: 4px; }
ul.tree ul.tree {
  margin-left: 10px;
  padding-left: 16px;
  border-left: 1px solid var(--border);
}
.tree-node { position: relative; padding: 2px 0; }

.concept { padding: 6px 0; }
.concept-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.concept-label { font-weight: 600; color: var(--fg); }
.concept-id { font-size: 11px; }
.concept-alt { font-size: 12.5px; font-style: italic; margin-top: 2px; }
.concept-def { font-size: 13px; margin-top: 3px; max-width: 70ch; }
.concept-rel { font-size: 12px; margin-top: 3px; }
.concept-rel .rel-term { color: var(--fg); }

.editorial-note {
  margin-top: 10px;
  padding: 10px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  color: #1e3a8a;
  font-size: 13px;
}

.chip {
  display: inline-block;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--code-bg);
  color: var(--accent);
}
.concept-parent { font-size: 11px; }

/* ---- viewer toolbar: hierarchy / A–Z toggle + expand controls ---- */
.concept-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.seg {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.seg-btn {
  border: none;
  border-radius: 0;
  padding: 5px 12px;
  background: var(--card);
  color: var(--fg);
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn.active { background: var(--accent); color: var(--accent-fg); }
.seg-btn:hover:not(.active) { background: var(--code-bg); }

/* ---- collapse twisty ---- */
.twisty {
  border: none;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  width: 18px;
  padding: 0;
  font-size: 11px;
  line-height: 1;
  flex: none;
}
.twisty:hover { color: var(--accent); }
.twisty-spacer { display: inline-block; width: 18px; flex: none; }
.tree-node.collapsed > ul.tree { display: none; }

/* ---- flat A–Z list ---- */
.flat-list { list-style: none; margin: 0; padding: 0; }
.flat-item { padding: 6px 0; border-bottom: 1px solid var(--border); }
.flat-item:last-child { border-bottom: none; }
