/* Sphinx — a registrar's ledger, on screen.
   Palette: cool paper, pine ink, verification green, record amber, seal red.
   Type: serif display (certificate register), system sans body, mono for hashes. */

:root {
  --paper: #f6f7f4;
  --card: #ffffff;
  --ink: #1c2b27;
  --muted: #5d6b66;
  --line: #d9dfda;
  --line-strong: #b9c3bc;
  --verify: #176b4e;
  --verify-soft: #e2efe8;
  --amber: #8f6408;
  --amber-soft: #f6ecd4;
  --danger: #8c2f26;
  --danger-soft: #f5e2df;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--verify); }

button { font-family: var(--font-body); }

:focus-visible {
  outline: 2px solid var(--verify);
  outline-offset: 2px;
}

/* ----- top bar ----- */

.topbar {
  background: var(--ink);
  color: #edf2ef;
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 22px;
  height: 22px;
  align-self: center;
  color: #7fc7a8;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.5px;
}

.brand-tag {
  font-size: 11.5px;
  color: #9db3aa;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-right { display: flex; align-items: center; gap: 12px; }

.user-badge { font-size: 13.5px; color: #cfdcd5; }

/* ----- layout ----- */

.app {
  max-width: 1120px;
  margin: 0 auto;
  padding: 26px 20px 60px;
  min-height: 60vh;
}

.footer {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 20px 34px;
  color: var(--muted);
  font-size: 12.5px;
  border-top: 1px solid var(--line);
}

.footer-sep { margin: 0 8px; }

.centered { text-align: center; padding: 70px 0; }
.muted { color: var(--muted); }

/* ----- headings ----- */

h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; }
h1 { font-size: 27px; }
h2 { font-size: 20px; }
h3 { font-size: 16px; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.page-head .sub { color: var(--muted); font-size: 13.5px; margin-top: 4px; }

/* ----- buttons ----- */

.btn {
  border: 1px solid var(--line-strong);
  background: var(--card);
  color: var(--ink);
  border-radius: 4px;
  padding: 7px 13px;
  font-size: 13.5px;
  cursor: pointer;
}

.btn:hover { border-color: var(--ink); }

.btn-primary {
  background: var(--verify);
  border-color: var(--verify);
  color: #fff;
}

.btn-primary:hover { background: #125a41; border-color: #125a41; }

.btn-danger {
  background: var(--card);
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover { background: var(--danger-soft); }

.btn-quiet {
  background: transparent;
  border-color: transparent;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn-small { padding: 3px 9px; font-size: 12.5px; }

.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ----- pills / badges ----- */

.pill {
  display: inline-block;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 2px 9px;
  border: 1px solid var(--line-strong);
  color: var(--muted);
  background: var(--card);
  vertical-align: middle;
}

.pill-quiet { background: transparent; border-color: #4b5f58; color: #a9bdb4; }
.pill-ok { border-color: var(--verify); color: var(--verify); background: var(--verify-soft); }
.pill-warn { border-color: var(--amber); color: var(--amber); background: var(--amber-soft); }
.pill-bad { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }

/* ----- cards & tables ----- */

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

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 11.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-strong);
}

.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }

.row-link { cursor: pointer; }
.row-link:hover td { background: #f2f5f1; }

.name-cell { display: flex; align-items: center; gap: 9px; }

.icon { width: 17px; height: 17px; flex: none; color: var(--muted); }

.mono { font-family: var(--font-mono); font-size: 12px; }

.hash {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-all;
}

.hash b { color: var(--verify); font-weight: 600; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ----- tabs ----- */

.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 2px solid var(--line-strong);
  margin: 18px 0 16px;
  flex-wrap: wrap;
}

.tab {
  border: none;
  background: transparent;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
}

.tab:hover { color: var(--ink); }

.tab.active {
  color: var(--ink);
  border-bottom-color: var(--verify);
  font-weight: 600;
}

/* ----- breadcrumb / toolbar ----- */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.crumbs { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; }

.crumb {
  background: none;
  border: none;
  color: var(--verify);
  cursor: pointer;
  padding: 2px 3px;
  font-size: 14px;
}

.crumb:hover { text-decoration: underline; }

.crumb-sep { color: var(--line-strong); }

.crumb-current { font-weight: 600; }

/* ----- the chain: audit ledger (signature element) ----- */

.chain { position: relative; margin-left: 14px; }

.chain::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: repeating-linear-gradient(to bottom, var(--verify) 0 6px, transparent 6px 11px);
}

.chain-entry {
  position: relative;
  padding: 10px 14px 10px 26px;
  margin-bottom: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.chain-entry::before {
  content: "";
  position: absolute;
  left: -19px;
  top: 16px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--verify);
  background: var(--paper);
}

.chain-entry.entry-signature { border-left: 3px solid var(--verify); }
.chain-entry.entry-read { border-left: 3px solid var(--line-strong); }

.chain-head-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  align-items: baseline;
}

.chain-type { font-weight: 600; font-size: 14px; }

.chain-sentence { font-size: 14px; flex: 1; min-width: 240px; line-height: 1.5; }

.chain-seq {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  margin-right: 6px;
}

.chain-actor-email { color: var(--muted); font-size: 12.5px; }

.chain-meta-col { text-align: right; flex: none; max-width: 340px; }

.chain-meta { font-size: 12.5px; color: var(--muted); }

.chain-payload {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  margin-top: 5px;
  word-break: break-all;
}

/* ----- signature badge (hover/focus shows all signatures) ----- */

.sigwrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 7px;
  vertical-align: middle;
}

.sigmark { width: 16px; height: 16px; color: var(--verify); cursor: default; display: block; }

.sigtip {
  display: none;
  position: absolute;
  top: 21px;
  left: -12px;
  z-index: 45;
  background: var(--card);
  border: 1px solid var(--verify);
  border-radius: 6px;
  padding: 9px 12px;
  min-width: 300px;
  box-shadow: 0 8px 26px rgba(20, 32, 28, 0.25);
  font-size: 12.5px;
  font-weight: 400;
  font-family: var(--font-body);
  text-align: left;
  cursor: default;
}

.sigwrap:hover .sigtip,
.sigwrap:focus .sigtip,
.sigwrap:focus-within .sigtip { display: block; }

.sigtip-title { font-weight: 600; color: var(--verify); margin-bottom: 4px; }

.sigtip-row { color: var(--muted); padding: 1px 0; }

/* ----- clickable file names ----- */

.file-click { cursor: pointer; }

.file-name-link {
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}

.file-click:hover .file-name-link { color: var(--verify); text-decoration-color: var(--verify); }

/* ----- forms ----- */

.field { margin-bottom: 12px; }

.field label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

.field input[type="text"], .field input[type="email"], .field input[type="datetime-local"],
.field select, .field textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 14px;
  font-family: var(--font-body);
  background: #fff;
  color: var(--ink);
}

.inline-form { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ----- modal ----- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 43, 39, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 60px 16px;
  z-index: 50;
  overflow-y: auto;
}

.modal {
  background: var(--card);
  border-radius: 8px;
  border-top: 4px solid var(--verify);
  width: 100%;
  max-width: 520px;
  padding: 20px 22px;
  box-shadow: 0 12px 40px rgba(20, 32, 28, 0.3);
}

.modal h2 { margin-bottom: 12px; }

.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ----- toasts ----- */

.toasts {
  position: fixed;
  bottom: 18px;
  right: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  max-width: 380px;
}

.toast {
  background: var(--ink);
  color: #edf2ef;
  border-radius: 6px;
  padding: 11px 14px;
  font-size: 13.5px;
  box-shadow: 0 6px 22px rgba(20, 32, 28, 0.35);
  border-left: 4px solid var(--verify);
}

.toast-error { border-left-color: #d97b6f; }

/* ----- misc ----- */

.notice {
  border: 1px solid var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13.5px;
  margin-bottom: 14px;
}

.notice-danger { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }

.progress {
  height: 6px;
  background: var(--line);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar { height: 100%; background: var(--verify); width: 0%; transition: width 0.15s; }

.empty { color: var(--muted); font-size: 14px; padding: 26px 8px; text-align: center; }

.seal {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--verify);
  border: 1.5px solid var(--verify);
  border-radius: 999px;
  padding: 3px 12px;
  display: inline-block;
}

@media (max-width: 720px) {
  .brand-tag { display: none; }
  .actions { justify-content: flex-start; }
  .table .hide-narrow { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ----- selection, bulk bar, pagination ----- */

.checkcell { width: 34px; }
.checkcell input { width: 15px; height: 15px; cursor: pointer; }

.bulkbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--verify-soft);
  border: 1px solid var(--verify);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
}

.bulkbar-count { font-size: 13.5px; font-weight: 600; color: var(--verify); }

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 13px;
}

.sortlink { color: inherit; text-decoration: none; }
.sortlink:hover { color: var(--ink); text-decoration: underline; }
.sortlink.active { color: var(--verify); }
.sortarrow { font-size: 9px; }

/* ----- clickable names ----- */

.entry-link { color: inherit; text-decoration: none; }
.entry-link:hover span { color: var(--verify); text-decoration: underline; text-underline-offset: 3px; }

.linkbutton {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
  text-align: left;
}

.linkbutton:hover { color: var(--verify); text-decoration-color: var(--verify); }

/* ----- drag and drop ----- */

.dropzone {
  border: 1.5px dashed var(--line-strong);
  border-radius: 6px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-top: 12px;
}

.dragging .dropzone {
  border-color: var(--verify);
  background: var(--verify-soft);
  color: var(--verify);
}

.dragging { outline: 2px dashed var(--verify); outline-offset: 6px; }

/* ----- modal extras ----- */

.modal-wide { max-width: 720px; }

.pickerlist {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px;
  margin-bottom: 10px;
}

.checkrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
  font-size: 13.5px;
  cursor: pointer;
}

.logrow {
  font-size: 12.5px;
  padding: 2px 4px;
  font-family: var(--font-mono);
  color: var(--muted);
}

.logrow-bad { color: var(--danger); }

/* ----- history + blacklist chrome ----- */

.notice-history {
  border-color: var(--verify);
  background: var(--verify-soft);
  color: var(--verify);
}

.chain-entry.entry-blacklist { border-left: 3px solid var(--danger); }

.chain-details { margin-top: 6px; font-size: 12.5px; }
.chain-details summary { cursor: pointer; color: var(--verify); }
.chain-subrow { padding: 3px 0 3px 10px; color: var(--muted); }

/* ----- search ----- */

.searchwrap { display: inline-flex; gap: 6px; align-items: center; }

.searchbox {
  padding: 6px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 13.5px;
  font-family: var(--font-body);
  min-width: 220px;
  background: #fff;
  color: var(--ink);
}

/* ----- preview panel ----- */

.preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 27, 0.72);
  z-index: 70;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 22px;
}

.preview-panel {
  background: var(--paper);
  border-radius: 8px;
  width: 100%;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(15, 25, 22, 0.45);
}

.preview-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.preview-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 13.5px;
  cursor: pointer;
  color: var(--ink);
}

.preview-back:hover { border-color: var(--ink); }
.preview-back-arrow { font-size: 16px; line-height: 1; }

.preview-title { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 140px; }
.preview-name { font-family: var(--font-display); font-size: 17px; word-break: break-all; }
.preview-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.preview-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  overflow: hidden;
}

.preview-center {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  overflow: auto;
}

.preview-media { max-width: 100%; max-height: 100%; background: #fff; border-radius: 4px; }

.preview-frame {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  background: #fff;
  display: block;
}

.preview-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Text and diffs scroll inside the panel; the panel itself never overflows. */
.preview-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fff;
}
.preview-select {
  padding: 5px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  color: var(--ink);
}

.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; }
.segbutton { border: none; background: var(--card); padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--muted); }
.segbutton + .segbutton { border-left: 1px solid var(--line-strong); }
.segbutton.active { background: var(--verify); color: #fff; }

.mdframe {
  flex: 1;
  min-height: 0;
  width: 100%;
  border: none;
  background: #fff;
  display: block;
}

/* ----- code view and diffs ----- */

.codeview {
  margin: 0;
  padding: 12px 0;
  background: #fff;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  overflow-x: auto;
  tab-size: 4;
}

.codeline { display: flex; white-space: pre; padding: 0 14px; }
.codeline:hover { background: #f6f8f5; }
.gutter { color: #9aa8a2; user-select: none; padding-right: 14px; flex: none; }
.codetext { white-space: pre; }
.diffmark { width: 14px; flex: none; color: var(--muted); }

.diff-add { background: #e6f4ec; }
.diff-add .diffmark { color: var(--verify); font-weight: 700; }
.diff-remove { background: #fbeceb; }
.diff-remove .diffmark { color: var(--danger); font-weight: 700; }
.diffwrap { display: block; }

.diffgap {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--verify);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 5px 14px;
  background: #f2f5f1;
  cursor: pointer;
}

.diffgap:hover { background: #e8eee6; }

.diffsegment { display: block; }

/* ----- side-by-side comparison ----- */

.sideheader, .sideline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
}

.sideheader {
  position: sticky;
  top: 0;
  z-index: 2;
  font-family: var(--font-body);
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.sideheader .sidecell { padding: 6px 12px; background: #f2f5f1; }

.sidebody {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  background: #fff;
  overflow-x: auto;
}

.sidecell {
  display: flex;
  white-space: pre;
  padding: 0 10px;
  background: #fff;
  min-width: 0;
  overflow-x: auto;
}

.side-empty { background: #f7f8f6; }

.sideline .gutter { padding-right: 10px; }

.diffsummary {
  padding: 8px 14px;
  background: #f2f5f1;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 13px;
}

.diffheader {
  padding: 8px 14px;
  background: var(--verify-soft);
  color: var(--verify);
  font-family: var(--font-body);
  font-size: 13px;
}

.tok-keyword { color: #8a1f74; }
.tok-string { color: #1d6b3a; }
.tok-comment { color: #7b8a84; font-style: italic; }
.tok-number { color: #9a5a06; }
.tok-tag { color: #1c5aa8; }
.tok-key { color: #1c5aa8; }
.tok-punct { color: #55635e; }

/* ----- search match highlighting ----- */

mark.hl {
  background: #fdf3c8;
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.byline { font-size: 11.5px; opacity: 0.8; }

/* ----- guide page ----- */

.guide { max-width: 900px; }
.guide h2 { margin-top: 30px; margin-bottom: 10px; }
.guide p, .guide li { font-size: 14.5px; }
.guide ul, .guide ol { padding-left: 22px; }
.guide li { margin-bottom: 7px; }
.guide code { font-family: var(--font-mono); font-size: 12.5px; background: #eef2ed; padding: 1px 5px; border-radius: 3px; }
.guide-table td { vertical-align: top; font-size: 13.5px; }
.guide-table td:first-child { white-space: nowrap; }

/* ----- signing banners ----- */

.banners { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

.banner {
  border-radius: 6px;
  padding: 12px 16px;
  margin-top: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid;
}

.banner-bad {
  border-color: var(--danger);
  background: var(--danger-soft);
  color: var(--danger);
}

.banner-warn {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber);
}

.banner-detail {
  margin-top: 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  opacity: 0.85;
  word-break: break-word;
}

/* ----- collaborative editor ----- */

.editor-host {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #fff;
}

.editor-host iframe { width: 100%; height: 100%; border: none; display: block; }

/* A file with a collaborative session open right now. */
.pill-live {
  border-color: var(--verify);
  color: #fff;
  background: var(--verify);
}

/* ----- full-bleed editor panel ----- */

.preview-overlay-max { padding: 0; }

.preview-panel-max {
  max-width: none;
  border-radius: 0;
  height: 100vh;
}

/* ----- built-in editor ----- */

.editor-surface { flex: 1; min-height: 0; display: flex; background: #fff; }
.editor-surface.split .editor-wrap { width: 50%; }
.editor-surface.split .editor-preview { width: 50%; display: block; }

.editor-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  background: #fff;
  overflow: hidden;
}

.editor-preview { display: none; border-left: 1px solid var(--line); min-width: 0; }
.editor-preview iframe { width: 100%; height: 100%; border: none; }

.editor-gutter {
  flex: none;
  overflow: hidden;
  padding: 12px 10px 12px 14px;
  background: #f6f8f5;
  border-right: 1px solid var(--line);
  color: #9aa8a2;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
  user-select: none;
  white-space: pre;
}

.editor-lineno { height: calc(13px * 1.55); }

/* The textarea sits transparently over an identically laid out highlighted copy,
   so editing behaves natively while the text still gets coloured. */
.editor-stack { position: relative; flex: 1; min-width: 0; }

.editor-highlight,
.editor-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  border: none;
}

.editor-highlight { pointer-events: none; color: var(--ink); background: #fff; }
.editor-line { min-height: calc(13px * 1.55); }

.editor-input {
  color: transparent;
  caret-color: var(--ink);
  background: transparent;
  resize: none;
  outline: none;
}

.editor-input::selection { background: #cfe3d8; color: transparent; }

/* ----- new document chooser ----- */

.kindgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.kindbutton {
  border: 1px solid var(--line-strong);
  background: var(--card);
  border-radius: 5px;
  padding: 10px 8px;
  cursor: pointer;
  text-align: left;
  font-family: var(--font-body);
}

.kindbutton:hover { border-color: var(--ink); }
.kindbutton.active { border-color: var(--verify); background: var(--verify-soft); }
.kindlabel { font-size: 13.5px; }
.kindhint { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

@media (max-width: 720px) {
  .kindgrid { grid-template-columns: repeat(2, 1fr); }
  .editor-surface.split { flex-direction: column; }
  .editor-surface.split .editor-wrap,
  .editor-surface.split .editor-preview { width: 100%; height: 50%; }
}

/* ----- merge interface ----- */

.mergeblock { border-bottom: 1px solid var(--line); }
.mergeauto { background: #fbfdfb; }
.mergeconflict { background: #fffaf7; border-left: 3px solid var(--danger); }

.mergehead {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  flex-wrap: wrap;
  background: #f2f5f1;
  border-bottom: 1px solid var(--line);
}

.mergesides { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); }
.mergeside { background: #fff; min-width: 0; overflow-x: auto; }

.mergesidelabel {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 5px 12px 0;
}

.mergecode { padding: 4px 0 10px; font-size: 12.5px; }
.mergecode.chosen { background: #f0f8f3; }
.mergecode.notchosen { opacity: 0.45; text-decoration: line-through; text-decoration-color: rgba(140,47,38,0.35); }
.mergecode .codeline { padding: 0 12px; }

@media (max-width: 720px) {
  .mergesides { grid-template-columns: 1fr; }
}

/* ----- overflow menus ----- */

.menuhost { position: relative; display: inline-flex; }
.caret { margin-left: 5px; font-size: 9px; opacity: 0.7; }

.menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 40;
  min-width: 200px;
  max-height: 60vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 10px 28px rgba(20, 32, 28, 0.18);
  padding: 4px;
}

.menu-left { right: auto; left: 0; }

.menuitem {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  padding: 7px 10px;
  font-size: 13.5px;
  font-family: var(--font-body);
  color: var(--ink);
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
}

.menuitem:hover { background: #f2f5f1; }
.menuitem[disabled] { opacity: 0.45; cursor: not-allowed; }
.menuitem-danger { color: var(--danger); }
.menuitem-danger:hover { background: var(--danger-soft); }
.menusep { height: 1px; background: var(--line); margin: 4px 2px; }

/* Row actions stay quiet until the row is under the pointer, so a long list of
   files reads as a list rather than a wall of buttons. Touch always shows them. */
.table tbody tr .actions { opacity: 0.35; transition: opacity 0.12s; }
.table tbody tr:hover .actions,
.table tbody tr:focus-within .actions { opacity: 1; }

@media (hover: none) {
  .table tbody tr .actions { opacity: 1; }
}

/* ----- row action icons -----
   Fixed order (edit, view, download) so the leftmost is always the primary action
   for that row and the sequence never rearranges under the pointer. */

.iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.iconbtn:hover { background: #eef2ec; border-color: var(--line-strong); color: var(--ink); }
.iconbtn:active { background: #e2e8df; }
.iconbtn-primary { color: var(--verify); }
.iconbtn-primary:hover { color: var(--verify); border-color: var(--verify); background: var(--verify-soft); }

.actionicon { width: 17px; height: 17px; display: block; }

/* Right-aligned and evenly sized. Because availability nests, every icon keeps a
   fixed distance from the right edge, so nothing shifts between rows. */
.actions { justify-content: flex-end; flex-wrap: nowrap; }

/* Hovering the row lights the name and its primary action together, which is what
   says "clicking the name does this" without needing a stretched shape to say it. */
.table tbody tr:hover .iconbtn-primary {
  background: var(--verify-soft);
  border-color: var(--verify);
}

.table tbody tr:hover .linkbutton {
  color: var(--verify);
  text-decoration-color: var(--verify);
}

/* Icons are quiet enough to stay put; only the overflow trigger fades. */
.table tbody tr .actions { opacity: 1; }
.table tbody tr .actions .menuhost { opacity: 0.4; transition: opacity 0.12s; }
.table tbody tr:hover .actions .menuhost,
.table tbody tr:focus-within .actions .menuhost { opacity: 1; }

@media (hover: none) {
  .table tbody tr .actions .menuhost { opacity: 1; }
}

/* An element told to hide must hide, whatever display it was given elsewhere. */
[hidden] { display: none !important; }

/* ----- diff colouring -----
   Removed red, added green, edited blue, with the words that actually changed
   marked inside an edited line. */

.diff-change { background: #eaf0fb; }
.diff-change .diffmark { color: #2a4f9b; font-weight: 700; }
.sidecell.diff-change { background: #eaf0fb; }

.seg-del {
  background: #f6c9c4;
  border-radius: 2px;
  text-decoration: line-through;
  text-decoration-color: rgba(140, 47, 38, 0.6);
}

.seg-ins { background: #b9e4c9; border-radius: 2px; }

/* ----- wrapping -----
   Wrapped by default so no line needs its own scrollbar. With wrapping off the whole
   document scrolls sideways as one, and side by side moves both columns together. */

.preview-scroll .codeline,
.preview-scroll .sidecell { white-space: normal; }

.preview-scroll .codetext,
.preview-scroll .sidecell .codetext {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  flex: 1;
  min-width: 0;
}

.preview-scroll.nowrap .codetext,
.preview-scroll.nowrap .sidecell .codetext { white-space: pre; overflow-wrap: normal; }
.preview-scroll.nowrap .codeview,
.preview-scroll.nowrap .sidebody { overflow-x: auto; }
.preview-scroll.nowrap .codeline,
.preview-scroll.nowrap .sideheader,
.preview-scroll.nowrap .sideline { min-width: max-content; }

/* Never a scrollbar per line. */
.sidecell { overflow-x: visible; }
.sidebody { overflow-x: visible; }

.wrapglyph { font-size: 13px; }

/* ----- name cell extras ----- */

.versiontag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  background: #eef2ec;
  border-radius: 3px;
  padding: 1px 5px;
}

/* ----- library transfer ----- */

.transferrow {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}

.transferrow:first-of-type { border-top: none; }

.transferhead {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.checkline { display: flex; align-items: center; gap: 6px; margin-top: 8px; font-size: 13.5px; }

/* ----- access history grid ----- */

.accessgrid td { padding: 6px 10px; vertical-align: top; font-size: 13px; }
.accessgrid th { padding: 7px 10px; }
.accessgrid .pill { font-size: 11.5px; }
.accessgrid .hash { font-size: 11px; }

/* What a library records and keeps, shown wherever the library is. */
.librarypolicy { display: flex; gap: 6px; flex-wrap: wrap; }
.librarypolicy .pill { font-size: 11.5px; }
