:root {
  color-scheme: light;
  --paper: #ffffff;
  --ink: #202124;
  --muted: #60656c;
  --line: #d9dde2;
  --accent: #245caa;
  --wash: #f3f4f6;
  --danger: #a23e35;
  --white: #ffffff;
  font-family:
    Inter,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
[hidden] {
  display: none !important;
}
button,
input,
textarea,
select {
  font: inherit;
}
button,
a,
input,
textarea,
select {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
a {
  color: var(--accent);
  text-underline-offset: 4px;
}
button:disabled {
  opacity: 0.5;
  cursor: wait;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
h1,
h2,
h3,
p {
  margin-top: 0;
}
h1 {
  font-size: 1.5rem;
  line-height: 1.3;
  font-weight: 600;
  margin-bottom: 8px;
}
h2 {
  font-weight: 550;
  font-size: 1.2rem;
  margin-bottom: 12px;
}
h3 {
  font-size: 1.1rem;
  font-weight: 600;
}
p:last-child {
  margin-bottom: 0;
}
.topbar {
  min-height: 48px;
  padding: 8px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.12rem;
  font-weight: 650;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 18px;
}
.meta,
.pill,
.stat-label {
  font-size: 0.85rem;
}
.muted,
.fine-print {
  color: var(--muted);
}
.fine-print {
  font-size: 0.82rem;
  line-height: 1.6;
}
main {
  margin: auto;
  padding: 20px 24px 40px;
}
.login-panel {
  max-width: 360px;
  margin: 24px auto;
}
.login-panel form {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.login-panel .primary {
  margin-top: 4px;
  justify-self: start;
}
button {
  border-radius: 5px;
  padding: 7px 12px;
  border: 1px solid transparent;
  font-weight: 550;
}
.primary {
  background: var(--accent);
  color: white;
}
.primary:hover {
  background: #194780;
}
.secondary {
  background: var(--white);
  border-color: var(--line);
  color: var(--ink);
}
.secondary:hover {
  background: var(--wash);
}
.quiet {
  color: var(--muted);
  background: transparent;
  padding: 5px 0;
  font-size: 0.85rem;
}
.quiet:hover {
  color: var(--ink);
  text-decoration: underline;
}
.danger {
  background: var(--danger);
  color: white;
}
.danger:hover {
  background: #803029;
}
.delete-link {
  color: var(--danger);
}
.icon-button {
  font-size: 1.8rem;
  line-height: 1;
  padding: 3px 10px;
  background: transparent;
  color: var(--muted);
}
#breadcrumb {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 16px;
}
#breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}
#breadcrumb a:hover {
  text-decoration: underline;
}
.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 16px;
}
.page-heading h1 {
  overflow-wrap: anywhere;
}
.page-heading p {
  max-width: 720px;
}
.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.meta {
  color: var(--muted);
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin: 24px 0 12px;
}
.section-heading h2 {
  margin: 0;
  font-size: 1.2rem;
}
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.toolbar input {
  min-width: 0;
  max-width: 430px;
}
.toolbar select {
  width: auto;
  min-width: 130px;
}
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--white);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  min-width: 650px;
}
th {
  padding: 8px 12px;
  background: var(--wash);
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
td {
  padding: 10px 12px;
  vertical-align: top;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}
tbody tr:hover {
  background: #fafafa;
}
.record-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--ink);
  text-decoration: none;
  display: block;
}
.record-title:hover {
  color: var(--accent);
  text-decoration: underline;
}
.excerpt {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: 5px;
  max-width: 520px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.row-actions {
  display: flex;
  gap: 16px;
  white-space: nowrap;
}
.row-actions button {
  font-size: 0.8rem;
}
.number {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.pill {
  display: inline-block;
  letter-spacing: 0;
  padding: 2px 6px;
  background: var(--wash);
  white-space: nowrap;
}
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  color: var(--muted);
  font-size: 0.8rem;
}
.pager .actions {
  gap: 8px;
}
.definition-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.definition {
  background: var(--white);
  padding: 12px 0;
  border-top: 1px solid var(--line);
  min-width: 0;
}
.definition p {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}
.definition h3 {
  font-size: 0.9rem;
  color: var(--muted);
  margin-bottom: 6px;
}
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.stat-label {
  color: var(--muted);
  display: block;
  margin-bottom: 5px;
}
.stat-value {
  font-size: 1.15rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.query-panel {
  margin: 20px 0;
}
.query-panel summary {
  cursor: pointer;
  font-weight: 550;
  color: var(--accent);
}
pre {
  background: var(--wash);
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 12px;
  font-size: 0.8rem;
  line-height: 1.7;
  overflow: auto;
  max-height: 360px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
code {
  font-family: Consolas, monospace;
}
.category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.category-note {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 5px;
  padding: 10px 13px;
  font-size: 0.82rem;
  max-width: 360px;
}
.category-note strong {
  display: block;
}
.category-note p {
  margin: 4px 0;
  color: var(--muted);
}
.tag {
  display: inline-block;
  background: var(--wash);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  max-width: 180px;
}
.tag.empty {
  color: var(--muted);
  background: transparent;
  padding: 0;
}
.empty-state {
  padding: 16px 0;
  color: var(--muted);
}
.empty-state h3 {
  color: var(--ink);
  font-size: 1.2rem;
}
.loading {
  padding: 16px 0;
  color: var(--muted);
}
.notice,
.page-error {
  padding: 13px 17px;
  border-radius: 5px;
  margin-bottom: 22px;
}
.notice {
  background: #e4eee3;
  color: #30583e;
  border: 1px solid #c5d8c4;
}
.error {
  color: var(--danger);
  font-size: 0.88rem;
  white-space: pre-wrap;
}
.page-error {
  background: #f9ece8;
  border: 1px solid #e7c8bd;
}
label {
  font-size: 0.83rem;
  font-weight: 550;
  display: block;
  margin-bottom: 6px;
}
input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 8px 10px;
  background: var(--white);
  color: var(--ink);
  line-height: 1.45;
}
textarea {
  resize: vertical;
  min-height: 100px;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
}
.sql-input {
  font-family: Consolas, monospace;
  font-size: 0.82rem;
  min-height: 170px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}
.full-width {
  grid-column: 1/-1;
}
.field-help {
  font-size: 0.75rem;
  color: var(--muted);
  margin: 5px 0 0;
}
.category-editor {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}
.category-row {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 5px;
  margin-bottom: 12px;
  display: grid;
  gap: 10px;
  background: var(--paper);
}
.category-row .quiet {
  justify-self: start;
}
.form-grid .error {
  grid-column: 1/-1;
}
dialog {
  width: min(720px, calc(100% - 32px));
  max-height: calc(100dvh - 48px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--white);
  color: var(--ink);
  overflow: auto;
}
dialog::backdrop {
  background: #0006;
}
#confirmation {
  max-width: 470px;
}
.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}
.dialog-heading .meta {
  margin-bottom: 8px;
}
.dialog-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 24px;
}
#editor-error,
#delete-error {
  margin-top: 18px;
}
@media (max-width: 700px) {
  .topbar {
    padding: 8px 16px;
  }
  .topbar-right {
    gap: 15px;
  }
  main {
    padding: 16px;
  }
  .page-heading {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
  }
  .page-heading .actions {
    width: 100%;
  }
  .definition-grid {
    grid-template-columns: 1fr;
  }
  .definition {
    padding: 12px 0;
  }
  .toolbar {
    flex-wrap: wrap;
  }
  .toolbar input {
    max-width: none;
    flex: 1 1 190px;
  }
  .toolbar select {
    flex: 1;
  }
  .stats {
    gap: 22px;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .full-width {
    grid-column: auto;
  }
  dialog {
    padding: 22px;
    max-height: calc(100dvh - 24px);
  }
  .login-panel {
    margin: 16px auto;
  }
  .section-heading {
    align-items: flex-start;
  }
  .row-actions {
    gap: 12px;
  }
  .pager {
    align-items: flex-start;
  }
  td,
  th {
    padding: 10px;
  }
  .category-note {
    max-width: 100%;
  }
}
.category-list + .toolbar {
  margin-top: 18px;
}
