/*
 * Typography. Every size on every page comes from the scale below, so text
 * of the same role looks the same everywhere: --text-xs for fine print
 * (footnotes, legends, small labels), --text-sm for secondary text (muted
 * notes, table labels, buttons, form labels), --text-md for body text, and
 * --text-lg to --text-2xl for headings. One font stack serves every page;
 * form controls and buttons inherit it rather than the browser's own.
 */
:root {
  --ink: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ea;
  --bg: #fafafa;
  --accent: #2f5d8a;
  --accent-hover: #264d73;
  --accent-soft: #eaf1f8;
  --oais-accent: #8a4b2f;
  --oais-soft: #f8f1ea;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  /* Panels, cards and fields; text on the accent colour; quieter fills; error text; shadows. */
  --surface: #ffffff;
  --surface-alt: #f1f2f4;
  --on-accent: #ffffff;
  --danger-ink: #8e2a1f;
  --oais-border: #e6cdb8;
  --faint: #8b909a;
  --shadow: rgba(31, 36, 48, 0.12);

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.75rem;
  --leading: 1.5;
  --leading-tight: 1.25;

  /*
   * Latin first, then each script the interface or the data may hold. Font
   * fallback is per character, so each script finds its own font; Chinese and
   * Japanese share characters, so the page's language decides which of their
   * fonts comes first (see :lang below).
   */
  /* No system-ui: in Chrome on Windows it hands characters it lacks to the system's own fallback
     (MV Boli, a handwriting face, for Thaana) before the fonts listed after it get a chance. */
  --font-latin: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans";
  --font-scripts: "Noto Sans Thaana", "MV Boli", "Noto Sans Arabic", "Segoe UI Arabic", Tahoma,
    "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP";
  --font-sans: var(--font-latin), var(--font-scripts), sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

:lang(ja) {
  --font-sans: var(--font-latin), "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", var(--font-scripts), sans-serif;
}
:lang(zh) {
  --font-sans: var(--font-latin), "PingFang SC", "Microsoft YaHei", "Noto Sans SC", var(--font-scripts), sans-serif;
}
:lang(dv) {
  /* Thaana first, as for Arabic: Windows' own Thaana font (MV Boli) is a handwriting face. */
  --font-sans: "Noto Sans Thaana", var(--font-latin), var(--font-scripts), sans-serif;
  --leading: 1.8;
}
:lang(ar) {
  /* Arabic first: Latin system fonts carry Arabic glyphs that don't suit running text. */
  --font-sans: "Noto Sans Arabic", "Segoe UI", Tahoma, var(--font-latin), var(--font-scripts), sans-serif;
  --leading: 1.7;
}

* { box-sizing: border-box; }

html { font-size: 100%; -webkit-text-size-adjust: 100%; }
/* Thaana letters are small for their size: scale the whole type scale up on Dhivehi pages. */
html:lang(dv) { font-size: 112.5%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-md);
  line-height: var(--leading);
  color: var(--ink);
  background: var(--bg);
}

h1, h2, h3, h4 { line-height: var(--leading-tight); font-weight: 700; color: var(--ink); }
h1 { font-size: var(--text-2xl); margin: 0 0 1rem; }
h2 { font-size: var(--text-xl); margin: 1.75rem 0 0.75rem; }
h3 { font-size: var(--text-lg); margin: 1.25rem 0 0.5rem; }
h4 { font-size: var(--text-md); margin: 1rem 0 0.5rem; }

/* Controls take the page's font, not the browser's. */
button, input, select, textarea, optgroup {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  color: inherit;
}
input, select, textarea { font-size: var(--text-sm); }

code, pre, kbd, samp { font-family: var(--font-mono); }

/* Links in running text look like every other link, not the browser's default blue. */
a { color: var(--accent); }

/* Scripts with no capitals or joined letters: no forced capitals, no letter-spacing (it breaks Arabic's joins). */
:lang(ar) *, :lang(dv) *, :lang(zh) *, :lang(ja) * { letter-spacing: normal !important; }
:lang(zh) em, :lang(ja) em, :lang(ar) em, :lang(dv) em { font-style: normal; font-weight: 600; }

/*
 * Right to left, and mixed content.
 *
 * unicode-bidi: plaintext makes each of these elements determine its own
 * text direction from its own content (the Unicode Bidi Algorithm's
 * standard auto-detection, the same mechanism as the HTML dir="auto"
 * attribute, just applied via CSS so it doesn't need to be added to every
 * template individually). The catalogue mixes English, Dhivehi and other
 * content record by record, so per-element auto-detection is right for the
 * content. The page's own direction follows the interface's language: right
 * to left for Dhivehi and Arabic (the dir attribute on each page's html
 * element), so the layout mirrors; the rules below use start/end, not
 * left/right, so they mirror with it. Code, identifiers and descriptions
 * stay left to right whatever the page.
 */
h1, h2, h3, p, td, th, .pill, .card .label, .oais-comment, .bridge-note p,
input[type="text"], textarea, .page-info, .breadcrumb, .muted {
  unicode-bidi: plaintext;
}
[dir="rtl"] code, [dir="rtl"] pre, [dir="rtl"] textarea.code-input, [dir="rtl"] textarea.sparql,
[dir="rtl"] textarea.import-textarea, [dir="rtl"] input[type="url"] {
  direction: ltr;
  unicode-bidi: isolate;
}

/* -- buttons: one look, in a few variants -- */

button, .button, input[type="submit"], input[type="button"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: var(--leading-tight);
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover, input[type="submit"]:hover, input[type="button"]:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  text-decoration: none;
}
button:focus-visible, .button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
button:disabled { opacity: 0.45; cursor: not-allowed; }

.button-secondary, button.button-secondary {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--accent);
}
.button-secondary:hover, button.button-secondary:hover { background: var(--accent-soft); border-color: var(--accent); }
.button + .button, .button + button, button + .button-secondary { margin-inline-start: 0.5rem; }

.button-danger, button.button-danger {
  background: var(--surface);
  color: var(--danger);
  border-color: var(--danger);
}
.button-danger:hover, button.button-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

/* Buttons that look like links or icons. */
.nav-link-btn, .danger-link, .page-link, #highlight-clear,
.node-context-menu .menu-item, .delete-btn, .row-actions button {
  background: none;
  border: none;
  font-weight: 400;
}
.nav-link-btn {
  color: var(--accent);
  font-size: var(--text-sm);
  padding: 0;
}
.nav-link-btn:hover { background: none; text-decoration: underline; }
.danger-link {
  margin-top: 0.5rem;
  padding: 0;
  color: var(--muted);
  font-size: var(--text-xs);
  text-decoration: underline;
}
.danger-link:hover { background: none; color: var(--danger); }
.delete-btn, .row-actions button {
  color: var(--muted);
  font-size: var(--text-md);
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 50%;
}
.delete-btn:hover { background: var(--danger-soft); color: var(--danger); }
.row-actions button:not(.delete-btn):hover { background: var(--accent-soft); color: var(--accent); }
#highlight-clear { align-self: flex-start; margin-top: 1.1rem; padding: 0; color: var(--accent); font-size: var(--text-xs); }
#highlight-clear:hover { background: none; text-decoration: underline; }

/* -- page frame -- */

.topnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  align-items: center;
  padding: 0.9rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}
.topnav .brand {
  font-size: var(--text-md);
  font-weight: 700;
  margin-inline-end: 1rem;
  color: var(--ink);
  text-decoration: none;
}
.topnav .brand { display: inline-flex; align-items: center; gap: 0.5rem; }
.brand-logo { height: 1.75rem; width: auto; max-width: 8rem; }
.theme-sample { display: inline-block; width: 1rem; height: 1rem; border-radius: 3px; border: 1px solid var(--border);
  vertical-align: middle; }
.topnav a { color: var(--accent); text-decoration: none; }
.topnav a:hover { text-decoration: underline; }

.nav-spacer { flex: 1; }

/* The menu's groups: a disclosure each, opening a drop-down on wide screens and a list on phones. */
.nav-groups { display: flex; flex-wrap: wrap; gap: 0.5rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.nav-group { position: relative; }
.nav-group summary { color: var(--accent); cursor: pointer; list-style: none; }
.nav-group summary::-webkit-details-marker { display: none; }
.nav-group summary::after { content: " \25BE"; color: var(--muted); }
.nav-group summary:focus-visible, .nav-items a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.nav-items { list-style: none; margin: 0; padding: 0.4rem 0; }
.nav-items a { display: block; padding: 0.3rem 0.9rem; white-space: nowrap; }
@media (min-width: 48rem) {
  .nav-group details[open] > .nav-items {
    position: absolute;
    inset-inline-start: 0;
    top: calc(100% + 0.5rem);
    z-index: 20;
    min-width: 14rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 18px var(--shadow);
  }
}
@media (max-width: 47.99rem) {
  .nav-groups { flex-direction: column; width: 100%; }
  .nav-items a { padding-inline-start: 1rem; }
}

.lang-switcher { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-inline-end: 0.5rem; }
.topnav .lang-link {
  color: var(--muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}
.topnav .lang-link:hover { background: var(--accent-soft); text-decoration: none; }
.topnav .lang-link.active { color: var(--accent); font-weight: 700; background: var(--accent-soft); }

main.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
main.container-wide {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}
main.container-narrow {
  max-width: 420px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: var(--text-xs);
  padding: 2rem 0;
}

/* -- text -- */

.breadcrumb a { color: var(--muted); text-decoration: none; font-size: var(--text-sm); }
.breadcrumb a:hover { text-decoration: underline; }

.types { color: var(--muted); font-size: var(--text-sm); }
.muted { color: var(--muted); font-size: var(--text-sm); }
.small, .muted.small { font-size: var(--text-xs); }

code {
  background: var(--surface-alt);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.specimen {
  font-size: var(--text-xl);
  padding: 1rem;
  background: var(--accent-soft);
  border-radius: 8px;
}

.pill {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: var(--text-xs);
  font-weight: 600;
  margin-inline-end: 0.3rem;
}
.pill-oais {
  background: var(--oais-soft);
  color: var(--oais-accent);
}

.button-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.button-link:hover { text-decoration: underline; }

.notice { padding: 0.6rem 0.85rem; border-radius: 4px; background: var(--accent-soft); color: var(--ink); font-size: var(--text-sm); }
.notice.error { background: var(--danger-soft); color: var(--danger-ink); }

/* -- tables -- */

table.listing, table.attrs {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
table.listing th, table.listing td,
table.attrs td {
  text-align: start;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.listing th { font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
table.attrs td.prop { color: var(--muted); width: 220px; font-size: var(--text-sm); }
table.attrs td.rationale { color: var(--muted); font-size: var(--text-sm); }

/* -- panels and cards -- */

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.grid section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
}
.grid h3 { margin-top: 0; font-size: var(--text-sm); color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--ink);
}
.card:hover { border-color: var(--accent); }
.card .count { font-size: var(--text-2xl); font-weight: 700; color: var(--accent); line-height: var(--leading-tight); }
.card .label { color: var(--muted); font-size: var(--text-sm); }
.card-accent .count { color: var(--oais-accent); }

.repinfo-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.repinfo-template-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.repinfo-template-card h3 { margin: 0; }
.repinfo-template-card p { margin: 0; }

.report-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem;
}
.report-panel h3 { margin-top: 0; font-size: var(--text-md); }

.persistence-note {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: var(--text-sm);
}

/* An email record's message (EmailView): its header, and its HTML in a sandboxed frame. */
.email { margin: 1.25rem 0; }
.email-frame {
  display: block;
  width: 100%;
  height: 32rem;
  resize: vertical;
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.email-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  max-height: 40rem;
  overflow: auto;
}

.callout {
  background: var(--oais-soft);
  border: 1px solid var(--oais-border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.editor-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.25rem 0;
}
.editor-section h2 { margin-top: 0; font-size: var(--text-md); text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }

/* -- forms -- */

.form { display: flex; flex-direction: column; gap: 1rem; max-width: 520px; }
.form label { display: flex; flex-direction: column; gap: 0.35rem; font-size: var(--text-sm); color: var(--muted); }
input[type="text"], input[type="search"], input[type="password"], input[type="url"], input[type="email"],
input[type="number"], input[type="date"], input:not([type]), select, textarea {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
/* Single-line fields and drop-downs the same height, whatever the browser's own sizing. */
input[type="text"], input[type="search"], input[type="password"], input[type="url"], input[type="email"],
input[type="number"], input[type="date"], input:not([type]), select:not([multiple]):not([size]) {
  height: 2.5rem;
  line-height: var(--leading-tight);
}
.form button { align-self: flex-start; }
.form fieldset { border: 1px solid var(--border); border-radius: 6px; padding: 0.9rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.9rem; }
.form legend { font-weight: 600; color: var(--ink); padding: 0 0.3rem; }
.form .form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form .form-row label { flex: 1; min-width: 10rem; }
.form label.checkbox { flex-direction: row; align-items: center; gap: 0.5rem; color: var(--ink); }
.form label.checkbox input { width: auto; }
.form fieldset.checks { gap: 0.4rem; }
#edit-element .form { max-width: 46rem; }

textarea.sparql, textarea.code-input, textarea.import-textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
textarea.sparql { min-height: 180px; }
textarea.code-input { min-height: 420px; white-space: pre; tab-size: 2; }
textarea.import-textarea { min-height: 420px; }

.inline-form { display: inline; }
/* A row of buttons, some of them forms of their own (e.g. POST actions), wrapping on a narrow screen. */
.button-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.button-row form { margin: 0; }

.inline-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}
.inline-add-form select,
.inline-add-form input[type="text"] {
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
}
.inline-add-form input[type="text"] { flex: 1; min-width: 160px; }
.inline-add-form input.select-filter { flex: 0 1 150px; min-width: 110px; font-style: italic; }
:lang(zh) .inline-add-form input.select-filter, :lang(ja) .inline-add-form input.select-filter,
:lang(ar) .inline-add-form input.select-filter, :lang(dv) .inline-add-form input.select-filter { font-style: normal; }
/* Callout revealed when the relationship target picker's "+ Create new ..."
   option is chosen -- flex-basis 100% drops it onto its own line so it reads
   as a distinct step rather than one more indistinguishable box in the row
   of plain text inputs above it. */
.create-new-box {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  font-size: var(--text-sm);
}
.create-new-box input[type="text"] { flex: 1; min-width: 200px; }

/* -- pagination -- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin: 1.5rem 0;
  padding: 0.75rem;
}
.page-link {
  color: var(--accent);
  text-decoration: none;
  font-size: var(--text-sm);
  padding: 0;
}
.page-link:hover { background: none; text-decoration: underline; }
.page-link.disabled { color: var(--faint); pointer-events: none; }
.page-info { color: var(--muted); font-size: var(--text-sm); }

/* -- OAIS mapping -- */

.oais-node {
  border-inline-start: 3px solid var(--oais-accent);
  padding-block: 0.6rem;
  padding-inline: 1rem 0;
  margin: 0.6rem 0;
}
.oais-node-head { display: flex; align-items: center; gap: 0.5rem; }
.oais-node-head .prop { color: var(--muted); font-size: var(--text-xs); font-family: var(--font-mono); }
.oais-node-head .prop.oais-incoming { font-style: italic; }
.oais-comment { color: var(--muted); font-size: var(--text-sm); margin: 0.35rem 0; }
.oais-ric-links { font-size: var(--text-sm); }
.oais-ric-links ul { margin: 0.2rem 0; padding-inline-start: 1.2rem; }
.oais-children { margin-inline-start: 0.5rem; }

/* -- graph page -- */

.graph-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.9rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--text-sm);
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); }

.highlight-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-start;
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: var(--text-xs);
}
.highlight-group { display: flex; flex-direction: column; gap: 0.3rem; min-width: 160px; }
.highlight-heading { color: var(--muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; letter-spacing: 0.02em; }
.highlight-checkboxes { display: flex; flex-direction: column; gap: 0.15rem; max-height: 140px; overflow-y: auto; }
.highlight-checkbox { display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }
.highlight-checkbox input { margin: 0; }

.swatch { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.swatch-rico { background: var(--accent); }
.swatch-oais { background: var(--oais-accent); }
.swatch-other { background: #6b7280; }
.swatch-line { width: 22px; height: 0; border-top: 2px dashed var(--danger); display: inline-block; }

.spacer { flex: 1; }

.depth-link {
  display: inline-block;
  width: 1.6rem;
  height: 1.6rem;
  line-height: 1.6rem;
  text-align: center;
  border-radius: 50%;
  color: var(--accent);
  text-decoration: none;
  border: 1px solid var(--border);
  margin: 0 0.15rem;
}
.depth-link.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

#network {
  height: 640px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

.node-context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 200px;
  max-width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 6px 20px var(--shadow);
  padding: 0.3rem 0;
  font-size: var(--text-sm);
}
.node-context-menu .menu-heading {
  padding: 0.35rem 0.9rem;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.node-context-menu .menu-item {
  display: block;
  width: 100%;
  padding: 0.45rem 0.9rem;
  border-radius: 0;
  text-align: start;
  color: var(--ink);
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-context-menu .menu-item:hover { background: var(--accent-soft); }
.node-context-menu .menu-item .menu-item-prop { font-weight: 600; }
.node-context-menu .menu-item .menu-item-url {
  display: block;
  color: var(--muted);
  font-size: var(--text-xs);
  overflow: hidden;
  text-overflow: ellipsis;
}
.node-context-menu .menu-divider { border-top: 1px solid var(--border); margin: 0.3rem 0; }

/* -- entity editor -- */

.edit-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1rem;
}
.edit-header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}
.edit-header-actions .button + .button, .edit-header-actions button + .button-secondary { margin-inline-start: 0; }

.bridge-note {
  margin-top: 0.4rem;
  padding: 0.4rem 0.6rem;
  background: var(--oais-soft);
  border-inline-start: 2px solid var(--oais-accent);
  border-radius: 4px;
  font-size: var(--text-xs);
}
.bridge-note .pill { margin-inline-end: 0.3rem; }
.bridge-note p { margin: 0.3rem 0 0; }

.pill-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.pill-with-delete {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: var(--accent-soft);
  border-radius: 999px;
  padding-block: 0.1rem;
  padding-inline: 0.65rem 0.2rem;
}
.pill-with-delete .pill { margin: 0; background: transparent; padding: 0; }

.danger-zone {
  margin-top: 2rem;
  padding-top: 0.5rem;
}
.danger-zone summary {
  cursor: pointer;
  color: var(--muted);
  font-size: var(--text-xs);
  user-select: none;
}
.danger-zone summary:hover { color: var(--ink); }

/* -- help pages and the structure adapters' README files (/help/engines/{engine}) -- */

.readme { max-width: 52rem; line-height: 1.6; }
.readme h1 { margin-bottom: 1rem; }
.readme h2 { margin-top: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.readme li { margin-bottom: 0.4rem; }
.readme pre {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  font-size: var(--text-sm);
}
.readme pre code { background: none; padding: 0; }

/* -- RepInfo Tools structure editor -- */

.structure-tree td { vertical-align: top; }
.structure-tree tr.selected td { background: var(--accent-soft); }
.structure-tree .element-kind {
  display: inline-block; min-width: 4.2rem; font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted);
}
.structure-tree .problems { margin: 0.3rem 0 0; padding-inline-start: 1.1rem; color: var(--danger-ink); font-size: var(--text-sm); }
.structure-tree .row-actions, .row-actions { white-space: nowrap; }

/* -- the archive's own image viewer (resource page) -- */

.image-viewer canvas { display: block; background: #222; border-radius: 4px; cursor: crosshair; max-width: 100%; }
.image-controls { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin-bottom: 0.5rem; font-size: var(--text-sm); }
.image-controls label { display: flex; align-items: center; gap: 0.3rem; }

/* ---- Retention charts (RetentionController): the reference data-viz palette's
   series blue and its fixed status steps; status is always shown with a label. ---- */
:root {
  --viz-series: #2a78d6;
  --viz-series-light: #86b6ef;
  --viz-series-dark: #184f95;
  --viz-critical: #d03b3b;
  --viz-serious: #ec835a;
  --viz-warning: #fab219;
  --viz-neutral: #a3a29c;
  --viz-track: #f0efec;
  --viz-surface: #fcfcfb;
}
.viz-series { background: var(--viz-series); }
.viz-series-light { background: var(--viz-series-light); }
.viz-series-dark { background: var(--viz-series-dark); }
.viz-critical { background: var(--viz-critical); }
.viz-serious { background: var(--viz-serious); }
.viz-warning { background: var(--viz-warning); }
.viz-neutral { background: var(--viz-neutral); }
.viz-text-critical { color: var(--viz-critical); font-weight: 600; }

.viz-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; margin: 1rem 0 1.5rem; }
.viz-tile { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.75rem 1rem; border: 1px solid var(--border);
  border-radius: 6px; background: var(--viz-surface); color: var(--ink); text-decoration: none; }
.viz-tile:hover { border-color: var(--accent); }
.viz-tile.viz-critical, .viz-tile.viz-neutral { background: var(--viz-surface); border-inline-start: 4px solid; }
.viz-tile.viz-critical { border-inline-start-color: var(--viz-critical); }
.viz-tile.viz-neutral { border-inline-start-color: var(--viz-neutral); }
.viz-tile-value { font-size: var(--text-xl); font-weight: 600; font-variant-numeric: tabular-nums; }
.viz-tile-label { font-size: var(--text-sm); color: var(--muted); }

.viz-chart { margin: 1.5rem 0; }
.viz-hbars { display: flex; flex-direction: column; gap: 2px; max-width: 46rem; }
.viz-hbar { display: grid; grid-template-columns: minmax(9rem, 12rem) 1fr 3.5rem; align-items: center; gap: 0.5rem;
  padding: 3px 0; }
.viz-hbar:hover { background: var(--accent-soft); }
.viz-hbar-label { font-size: var(--text-sm); }
.viz-hbar-track { display: block; height: 18px; }
.viz-hbar-fill { display: block; height: 100%; min-width: 0; border-start-end-radius: 4px; border-end-end-radius: 4px; }
.viz-hbar-value { font-size: var(--text-sm); font-variant-numeric: tabular-nums; color: var(--ink); }

.viz-columns { display: flex; align-items: stretch; gap: 2px; height: 14rem; max-width: 60rem; overflow-x: auto;
  border-bottom: 1px solid var(--border); padding-bottom: 0; }
.viz-column { flex: 1 0 1.6rem; display: grid; grid-template-rows: 1.2rem 1fr 2.2rem; text-align: center; }
.viz-column:hover { background: var(--accent-soft); }
.viz-column-value { font-size: var(--text-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.viz-column-track { display: flex; align-items: flex-end; justify-content: center; }
.viz-column-fill { display: block; width: 70%; border-start-start-radius: 4px; border-start-end-radius: 4px; }
.viz-column-label { font-size: var(--text-xs); color: var(--muted); white-space: nowrap; padding-top: 0.25rem; }

.viz-stack { display: flex; gap: 2px; width: 8rem; height: 10px; }
.viz-stack span { display: block; height: 100%; min-width: 0; }
.viz-stack span:last-child { border-start-end-radius: 4px; border-end-end-radius: 4px; }

.viz-progress { display: inline-flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.viz-progress-track { display: inline-block; width: 8rem; height: 8px; background: var(--viz-track); border-radius: 4px;
  overflow: hidden; }
.viz-progress-fill { display: block; height: 100%; border-radius: 4px; }
.viz-progress-text { color: var(--muted); font-variant-numeric: tabular-nums; }

.record-panel { margin: 1rem 0 1.5rem; padding: 0.75rem 1rem; border: 1px solid var(--border); border-radius: 6px; }
.record-panel h2 { margin-top: 0.5rem; }
fieldset.decide { border: 1px solid var(--border); border-radius: 6px; padding: 0.75rem 1rem; margin-top: 1rem; }
.repinfo-group { border-top: 1px solid var(--border); padding: 0.5rem 0 0.75rem; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; color: var(--muted); }
.viz-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: middle; }

/* A wide table scrolls inside its box on a narrow screen, never the page. */
.table-scroll { overflow-x: auto; }

/* -- The Representation Information Network (repinfo/network.html, js/rin.js) -- */
.rin-graph { overflow: auto; border: 1px solid var(--border); border-radius: 8px; background: #ffffff; }
.rin-graph svg { display: block; }
.rin-legend { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; font-size: var(--text-sm); }
.rin-understood { background: #cdebd3; }
.rin-held { background: #cfe0f5; }
.rin-listed { background: #fbe3b4; }
.rin-gap { background: #f6c9c3; }
.rin-limit { background: #e1e3e7; }
.rin-through { background: #ffffff; }
.rin-cycle-sample { display: inline-block; width: 1.6rem; border-top: 2px dashed var(--danger); vertical-align: middle; }
