:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --muted: #667085;
  --line: #dfe3e8;
  --accent: #1f5f8b;
  --accent-soft: #e8f1f8;
  --divergent: #b4470f;
  --aligned: #2f7a4d;
  --warn: #8a6d1f;
  --radius: 6px;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; }
h1 { font-size: 1.15rem; }
h2 { font-size: 1rem; }
h3 { font-size: .9rem; }

/* ---------------------------------------------------------------- chrome */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: .6rem 1rem;
  background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 650; letter-spacing: -.01em; white-space: nowrap; }
.topbar .brand span { color: var(--muted); font-weight: 400; }
.topbar form.inline { display: inline; }
.spacer { flex: 1; }
.userchip { color: var(--muted); font-size: .85rem; }
.layout { display: grid; grid-template-columns: 288px minmax(0, 1fr); gap: 1rem; padding: 1rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > .panel-head {
  padding: .5rem .75rem; border-bottom: 1px solid var(--line); font-weight: 600; font-size: .85rem;
  display: flex; align-items: center; gap: .4rem;
}
.panel > .panel-body { padding: .6rem .75rem; }

/* ---------------------------------------------------------------- forms */
/* A form label belongs above its field.  Labels are inline by default, so next to a
   full-width input they push the field onto the following line — which put the login
   password box under the "Password" label of the field after it. */
label { display: block; margin-bottom: .2rem; }
/* Except where a label sits beside its control: facet rows, the sort control. */
.opt label, .resulthead label { display: inline; margin-bottom: 0; }

input[type=text], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: .4rem .55rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: inherit; font: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
button, .btn {
  padding: .35rem .7rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); font: inherit; cursor: pointer;
}
button:hover, .btn:hover { background: var(--accent-soft); border-color: var(--accent); text-decoration: none; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.08); }
button.link { border: none; background: none; color: var(--accent); padding: 0 .25rem; }
button.tiny, .btn.tiny { font-size: .78rem; padding: .15rem .4rem; }

.searchbar { display: flex; gap: .5rem; align-items: center; flex: 1; }
.searchbar input { max-width: 520px; }
.searchbar select { width: auto; }

/* ---------------------------------------------------------------- facets */
.facet { border-bottom: 1px solid var(--line); }
.facet:last-child { border-bottom: none; }
.facet > summary {
  cursor: pointer; padding: .5rem .75rem; font-weight: 600; font-size: .8rem;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); list-style: none;
  display: flex; align-items: center; gap: .35rem;
}
.facet > summary::-webkit-details-marker { display: none; }
.facet > summary::before { content: "▸"; font-size: .7rem; }
.facet[open] > summary::before { content: "▾"; }
.facet .options { padding: 0 .75rem .6rem; max-height: 15rem; overflow-y: auto; }
.opt { display: flex; align-items: baseline; gap: .4rem; padding: .12rem 0; font-size: .85rem; }
.opt input { margin: 0; }
.opt label { flex: 1; cursor: pointer; overflow-wrap: anywhere; }
.opt .n { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .78rem; }
.hint { color: var(--muted); font-size: .78rem; padding: 0 .75rem .5rem; }
.idchips { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .45rem; align-items: center; }
.idchips .chip { font-variant-numeric: tabular-nums; }
.chipx { margin-left: .3rem; font-weight: 600; text-decoration: none; opacity: .65; }
.chipx:hover { opacity: 1; text-decoration: none; }
/* The language-condition panel is the point of the sidebar: never hide a
   condition behind an inner scrollbar.  Only its language list scrolls. */
.facet .options.lc { max-height: none; }
.facet .options.lc .langlist { max-height: 11rem; overflow-y: auto; }

/* ---------------------------------------------------------------- results */
.resulthead { display: flex; align-items: center; gap: .75rem; margin-bottom: .6rem; flex-wrap: wrap; }
.count { font-weight: 600; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .85rem; margin-bottom: .55rem;
}
.card h3 { margin: 0 0 .2rem; font-size: .95rem; }
/* The label identifies the concept; the id is a reference you fall back to. */
.card h3 .concept-id { color: var(--muted); font-weight: 400; font-size: .85rem; }
.card .meta { color: var(--muted); font-size: .8rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.card .snippet { margin-top: .35rem; color: #33383f; font-size: .87rem; }
/* EN/FR designations from the Terms file: the fastest way to recognise a record. */
.cardterms { margin-top: .35rem; display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: .87rem; }
.cardterms .termpair { overflow-wrap: anywhere; }
.cardterms .lang-code { color: var(--muted); font-size: .78rem; margin-right: .15rem; }
.card mark { background: #fff3bf; padding: 0 .1em; }
.matchsrc {
  display: inline-block; font-size: .68rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border: 1px solid var(--line); border-radius: 3px; padding: 0 .25rem;
  vertical-align: .05em;
}
.chip {
  display: inline-block; padding: .05rem .4rem; border-radius: 999px; font-size: .75rem;
  background: var(--accent-soft); color: var(--accent); border: 1px solid #cfe1ee; white-space: nowrap;
}
.chip.grey { background: #eef0f3; color: var(--muted); border-color: var(--line); }
.chip.warn { background: #fdf3e2; color: var(--warn); border-color: #ecd9b0; }
.chip.div  { background: #fdeee6; color: var(--divergent); border-color: #f0cdb9; }
.chip.ok   { background: #eaf5ee; color: var(--aligned); border-color: #c6e3d1; }
.pager { display: flex; gap: .4rem; align-items: center; margin: .8rem 0; flex-wrap: wrap; }
.pager .cur { font-weight: 600; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- detail */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 1000px) { .detail-grid { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: .3rem .8rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .82rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; }
table.grid { width: 100%; border-collapse: collapse; font-size: .86rem; }
table.grid th, table.grid td { border-bottom: 1px solid var(--line); padding: .4rem .5rem; text-align: left; vertical-align: top; }
table.grid th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
/* Record headers are identifiers, not labels: leave their case alone. */
table.grid th.plain { text-transform: none; letter-spacing: 0; font-size: .82rem; color: var(--ink); }
table.grid tr.divergent td:first-child { border-left: 3px solid var(--divergent); }
.langrow .defn { overflow-wrap: anywhere; }
.langrow .rationale { color: var(--muted); font-size: .82rem; margin-top: .25rem; }
.scroll-x { overflow-x: auto; }
details.raw pre {
  background: #12161b; color: #d7dde5; padding: .75rem; border-radius: var(--radius);
  overflow: auto; max-height: 30rem; font-size: .8rem;
}
.lang-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; }

/* ---------------------------------------------------------------- annotations */
.comment { border: 1px solid var(--line); border-radius: var(--radius); padding: .45rem .55rem; margin-bottom: .4rem; background: #fff; }
.comment.resolved { opacity: .6; }
.comment .who { font-size: .78rem; color: var(--muted); display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.comment .who span { white-space: nowrap; }
.comment .body { white-space: pre-wrap; overflow-wrap: anywhere; margin-top: .2rem; }
.taglist { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .4rem; }
.taglist form { display: inline; }
.notice { padding: .5rem .75rem; border-radius: var(--radius); margin-bottom: .75rem; }
.notice.ok { background: #eaf5ee; border: 1px solid #c6e3d1; color: #24603b; }
.notice.bad { background: #fdeee6; border: 1px solid #f0cdb9; color: #8a3a10; }
.htmx-request .spin { visibility: visible; }
.spin { visibility: hidden; color: var(--muted); font-size: .8rem; }
.login-wrap { max-width: 22rem; margin: 12vh auto; }
.login-wrap .panel-body > * + * { margin-top: .6rem; }
.login-wrap label { color: var(--muted); font-size: .85rem; }
.login-wrap input { margin-bottom: .7rem; }
.login-wrap button { width: 100%; }
.compare-col { min-width: 22rem; }

/* ---------------------------------------------------------------- term data */
.termcard { border-left: 3px solid var(--accent-soft); padding: .1rem 0 .3rem .6rem; margin-bottom: .5rem; }
.termcard:last-child { margin-bottom: 0; }
.termhead { display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.termdef { margin-top: .15rem; overflow-wrap: anywhere; }
.termnote { margin-top: .2rem; font-size: .84rem; color: #4a5058; overflow-wrap: anywhere; }
.termlabel {
  display: inline-block; font-size: .7rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin-right: .3rem;
}

/* ---------------------------------------------------------------- settings */
.langgrid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: .1rem .9rem;
}
.langgrid .opt { padding: .18rem 0; }
