/* RFRNT App - Typography-first brutalist stylesheet */

/* Valkyrie OT A - Serif (reference documents, body text) */
@font-face {
  font-family: 'Valkyrie';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/valkyrie/valkyrie_ot_a_regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Valkyrie';
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/valkyrie/valkyrie_ot_a_italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Valkyrie';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/static/fonts/valkyrie/valkyrie_ot_a_bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Valkyrie';
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url('/static/fonts/valkyrie/valkyrie_ot_a_bold_italic.woff2') format('woff2');
}

/* Iosevka Aile - Sans-serif (UI, headings, technical documents) */
@font-face {
  font-family: 'Iosevka Aile';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/iosevka-aile/IosevkaAile-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka Aile';
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/iosevka-aile/IosevkaAile-Italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka Aile';
  font-style: normal;
  font-weight: 600;
  font-display: block;
  src: url('/static/fonts/iosevka-aile/IosevkaAile-SemiBold.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka Aile';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/static/fonts/iosevka-aile/IosevkaAile-Bold.woff2') format('woff2');
}

/* Iosevka - Monospace (code, pre blocks) */
@font-face {
  font-family: 'Iosevka';
  font-style: normal;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/iosevka/Iosevka-Regular.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka';
  font-style: italic;
  font-weight: 400;
  font-display: block;
  src: url('/static/fonts/iosevka/Iosevka-Italic.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka';
  font-style: normal;
  font-weight: 700;
  font-display: block;
  src: url('/static/fonts/iosevka/Iosevka-Bold.woff2') format('woff2');
}

@font-face {
  font-family: 'Iosevka';
  font-style: italic;
  font-weight: 700;
  font-display: block;
  src: url('/static/fonts/iosevka/Iosevka-BoldItalic.woff2') format('woff2');
}

/* Font variables */
:root {
  --font-sans: 'Iosevka Aile', system-ui, sans-serif;
  --font-serif: 'Valkyrie', Georgia, serif;
  --font-mono: 'Iosevka', monospace;
}

/* Reset and base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 19px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  line-height: 1.55;
  letter-spacing: -0.01em;
  color: #222;
  background: #f4f4f4;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1rem; font-weight: 600; }

a {
  color: #000;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

a:hover {
  text-decoration-thickness: 2px;
}

/* Code */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: #000;
  color: #fff;
  padding: 0.06em 0.35em 0.14em;
  border-radius: 2px;
  white-space: nowrap;
}

pre {
  background: #000;
  color: #fff;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0;
  border-radius: 2px;
}

pre code {
  background: transparent;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

/* Syntax highlighted code blocks */
.code-block {
  background: #000;
  border-radius: 2px;
  margin: 1rem 0;
  overflow: hidden;
  display: flex;
  position: relative;
}

.code-block[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 0;
  right: 0;
  font-size: 0.65rem;
  color: #555;
  padding: 0.35rem 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-sans);
}

.code-block .line-numbers {
  flex-shrink: 0;
  padding: 1rem 0.75rem;
  margin: 0;
  text-align: right;
  color: #555;
  background: #000;
  border-right: 1px solid #333;
  user-select: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
}

.code-block .code-content {
  flex-grow: 1;
  padding: 1rem;
  margin: 0;
  overflow-x: auto;
  background: transparent;
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
}

.code-block .code-content code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  white-space: pre;
}

/* Pastel syntax highlighting colors
   Syntect produces space-separated class names like "storage type rust"
   CSS class selectors match if ANY of the element's classes match */
.keyword { color: #f5a9b8; }
.storage { color: #f5a9b8; }
.variable { color: #f5f5a9; }
.string { color: #a8d8a8; }
.comment { color: #8899aa; font-style: italic; }
.constant { color: #f5d0a9; }
.entity { color: #c9b8f5; }
.support { color: #a9c8f5; }
.punctuation { color: #888; }
.meta { color: inherit; }
.source { color: inherit; }

/* Layout */
.container {
  max-width: 44rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-wide {
  max-width: 56rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-narrow {
  max-width: 32rem;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.container-full {
  max-width: none;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* Header */
.header {
  padding: 1rem 0;
  border-bottom: 1px solid #000;
}

.header-inner {
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.header-brand {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  color: #000;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-end;
  flex-shrink: 0;
}

.header-brand:hover {
  text-decoration: none;
}

.header-brand-subtitle {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  opacity: 0.7;
  margin-top: -0.1rem;
}

.header-breadcrumbs {
  display: flex;
  align-items: center;
  min-width: 0;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
  grid-column: -1;
}

/* Breadcrumbs */
.breadcrumb-sep {
  color: #999;
  margin: 0 0.5rem;
  font-weight: 400;
}

.breadcrumb-link {
  color: #666;
  text-decoration: none;
  font-size: 0.9rem;
}

.breadcrumb-link:hover {
  color: #000;
  text-decoration: underline;
}

.breadcrumb-current {
  color: #000;
  font-size: 0.9rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.header-nav a {
  font-size: 0.9rem;
  text-decoration: none;
}

.header-nav a:hover {
  text-decoration: underline;
}

.header-user {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: 0.9rem;
}

.header-link {
  color: #666;
  text-decoration: none;
}

.header-link:hover {
  color: #000;
  text-decoration: underline;
}

.header-username {
  color: #666;
  cursor: pointer;
}

.header-username::after {
  content: ' ▾';
  font-size: 0.7em;
}

/* User dropdown menu */
.user-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 160px;
  background: #fff;
  border: 1px solid #000;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease, visibility 0s linear 0.1s;
}

.user-dropdown::before {
  content: '';
  position: absolute;
  top: -1rem;
  left: -1rem;
  right: -1rem;
  bottom: -1rem;
  z-index: -1;
}

.header-user:hover .user-dropdown {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.1s ease, visibility 0s linear 0s;
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  color: #000;
  text-decoration: none;
  text-align: left;
  font-size: 0.9rem;
  background: none;
  border: none;
  cursor: pointer;
}

.dropdown-item:hover {
  background: #f5f5f5;
}

.dropdown-item-btn {
  font-family: inherit;
}

.dropdown-divider {
  height: 1px;
  background: #e0e0e0;
  margin: 0.25rem 0;
}

/* Main content */
.main {
  padding: 2.5rem 0;
  min-height: calc(100vh - 80px);
}

/* Page header */
.page-header {
  margin-bottom: 2rem;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

.page-subtitle {
  color: #666;
  font-size: 1rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn:hover {
  background: #000;
  color: #fff;
  text-decoration: none;
}

.btn-primary {
  background: #000;
  color: #fff;
}

.btn-primary:hover {
  background: #333;
}

.btn-danger {
  border-color: #000;
  color: #000;
}

.btn-danger:hover {
  background: #000;
  color: #fff;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8rem;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

.btn-ghost:hover {
  background: #f5f5f5;
  color: #000;
}

/* Button dropdown */
.btn-dropdown {
  position: relative;
  display: inline-flex;
}

.btn-dropdown > .btn:first-child {
  border-right: none;
}

.btn-dropdown-toggle {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
  border-left: 1px solid rgba(255,255,255,0.3);
}

.btn-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 0.25rem;
  min-width: 100%;
  background: #fff;
  border: 1px solid #000;
  z-index: 100;
  display: none;
  white-space: nowrap;
}

.btn-dropdown-menu.is-open {
  display: block;
}

/* Actions dropdown for document page */
.actions-dropdown {
  position: relative;
  display: inline-block;
}

.actions-dropdown-toggle::after {
  content: ' ▾';
  font-size: 0.7em;
}

.actions-dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  min-width: 160px;
  background: #fff;
  border: 1px solid #000;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.1s ease, visibility 0s linear 0.1s;
}

.actions-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -1rem;
  left: -1rem;
  right: -1rem;
  bottom: -1rem;
  z-index: -1;
}

.actions-dropdown:hover .actions-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition: opacity 0.1s ease, visibility 0s linear 0s;
}

.dropdown-item-danger {
  color: #c00;
}

.dropdown-item-danger:hover {
  background: #fee;
}

.dropdown-item-disabled {
  color: #999;
  cursor: default;
}

.dropdown-item-disabled:hover {
  background: transparent;
}

/* Caution wrap for approval-required edit buttons */
.caution-wrap {
  display: inline-block;
  padding: 3px;
  background: repeating-linear-gradient(
    -45deg,
    #fff,
    #fff 4px,
    #000 4px,
    #000 8px
  );
  position: relative;
}

.caution-tooltip {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #000;
  color: #fff;
  font-size: 0.8rem;
  font-weight: normal;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 100;
}

.caution-tooltip strong {
  color: #fff;
  font-weight: 700;
}

.caution-wrap:hover .caution-tooltip {
  opacity: 1;
}

/* Generic tooltip */
.has-tooltip {
  position: relative;
  cursor: help;
}

.tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.25rem;
  padding: 0.5rem 0.75rem;
  background: #000;
  color: #fff;
  font-size: 0.8rem;
  font-weight: normal;
  white-space: nowrap;
  text-transform: none;
  letter-spacing: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.1s ease;
  z-index: 100;
}

.has-tooltip:hover .tooltip {
  opacity: 1;
}

/* Forms */
.form-group {
  margin-bottom: 1.5rem;
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.75rem;
  font-family: var(--font-sans);
  font-size: 1rem;
  border: 1px solid #000;
  background: #fff;
  color: #000;
  transition: box-shadow 0.1s ease;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px #000;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: #999;
}

.form-textarea {
  min-height: 20rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  resize: vertical;
}

.form-hint {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: #666;
}

.form-error {
  color: #cc0000;
  font-size: 0.85rem;
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: #cc0000;
}

.shortcode-field {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.shortcode-field .form-input {
  width: auto;
  max-width: 12rem;
}

.shortcode-hint {
  font-size: 0.85rem;
  color: #666;
}

.shortcode-hint code {
  font-family: var(--font-mono);
  background: #f5f5f5;
  color: #333;
  padding: 0.1em 0.3em;
  border-radius: 2px;
}

.form-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: normal;
}

.form-checkbox input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  cursor: pointer;
}

.checkbox-inline {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-weight: normal;
}

.checkbox-inline input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  cursor: pointer;
}

/* Radio card - selectable option cards */
.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid #ccc;
  cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}

.radio-card:hover {
  border-color: #000;
}

.radio-card:has(input:checked) {
  border-color: #000;
  background-color: #f9f9f9;
}

.radio-card input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin-top: 0.15rem;
  cursor: pointer;
}

.radio-card-content {
  flex: 1;
}

.radio-card-danger:has(input:checked) {
  border-color: #cc0000;
  background-color: #fff5f5;
}

.radio-card-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.radio-card-disabled input {
  cursor: not-allowed;
}

.form-hint {
  font-size: 0.85rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Cards */
.card {
  border: 1px solid #000;
  padding: 1.5rem;
}

.card-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: #666;
}

.card-danger {
  border-color: #cc0000;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  padding-top: 1.5rem;
  margin-bottom: 1rem;
}

/* Document references (footer) */
.doc-references {
  border-top: 1px solid #ccc;
  padding-top: 2rem;
}

.references-section {
  margin-bottom: 2rem;
}

.references-section:last-child {
  margin-bottom: 0;
}

.references-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 1rem;
}

.references-list li {
  display: block;
}

.reference-item {
  display: block;
  text-decoration: none;
}

.reference-item:hover {
  text-decoration: none;
}

.reference-title {
  display: block;
  color: #666;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.reference-item:hover .reference-title {
  color: #333;
}

/* Tables */
.table-wrapper {
  border: 1px solid #000;
  overflow: hidden;
}

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

.table th,
.table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #000;
}

.table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: #fafafa;
}

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

.table tbody tr:hover {
  background: #fafafa;
}

.table tbody tr.clickable-row {
  cursor: pointer;
}

.table td a {
  text-decoration: none;
}

.table td a:hover {
  text-decoration: underline;
}

/* Cells with full-cell clickable links */
.table td.td-link {
  padding: 0;
}

.table td.td-link a {
  display: block;
  padding: 0.75rem 1rem;
}

/* Reference numbers */
/* Reference badges - technical (default): black bg, white text */
.ref {
  font-family: var(--font-mono);
  font-size: 0.85em;
  font-weight: 600;
  text-decoration: none;
  background: #000;
  color: #fff;
  padding: 0.15em 0.4em;
  border-radius: 2px;
  text-decoration: none;
  border: 1px solid #000;
  white-space: nowrap;
}

.ref:hover {
  background: #333;
  border-color: #333;
  text-decoration: none;
}

/* Reference badges - reference docs: white bg, black border, black text */
.ref-reference {
  background: #fff;
  color: #000;
  border: 1px solid #000;
}

.ref-reference:hover {
  background: #f5f5f5;
  border-color: #000;
}

/* Document view */
.doc-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #000;
}

.doc-ref {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 0.5rem;
}

.doc-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 0.5ch;
  row-gap: 0.1rem;
}

.doc-byline {
  font-size: 0.8rem;
  font-weight: normal;
  color: #666;
  white-space: nowrap;
}

.doc-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #666;
  font-size: 0.8rem;
}

.doc-meta-left span + span::before {
  content: "·";
  margin: 0 0.5rem;
}

.doc-content {
  line-height: 1.7;
}

/* Document type: Reference (serif) */
.doc-content.doc-type-reference {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
}

.doc-content.doc-type-reference p + p {
  text-indent: 1.5em;
}

.doc-content.doc-type-reference h1,
.doc-content.doc-type-reference h2,
.doc-content.doc-type-reference h3,
.doc-content.doc-type-reference h4,
.doc-content.doc-type-reference h5,
.doc-content.doc-type-reference h6 {
  font-family: var(--font-serif);
}

.doc-content.doc-type-reference a {
  font-variant: small-caps;
  text-decoration: none;
  transition: color 0.1s ease;
}

.doc-content.doc-type-reference a:hover {
  color: #555;
}

/* Document type: Technical (sans) */
.doc-content.doc-type-technical {
  font-family: var(--font-sans);
}

.doc-content p {
  margin-bottom: 1rem;
}

.doc-content h2 {
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.doc-content h3 {
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
}

.doc-content ul,
.doc-content ol {
  margin: 1rem 0 1rem 1.5rem;
}

.doc-content li {
  margin-bottom: 0.175rem;
}

.doc-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.doc-content th,
.doc-content td {
  border: 1px solid #ccc;
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.doc-content th {
  background: #f5f5f5;
  font-weight: 600;
}

.doc-content hr {
  border: none;
  border-top: 1px solid #000;
  margin: 0.75rem 0 1rem;
  opacity: 0.4;
}

.doc-content img {
  max-width: 100%;
  height: auto;
  cursor: zoom-in;
}

/* Sidenote references (superscript numbers in text) */
.sidenote-ref {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
  color: #666;
  font-weight: 600;
}

/* Footnote mode: add brackets and link styling */
.sidenote-ref.footnote-ref {
  color: #0066cc;
  text-decoration: none;
}

.sidenote-ref.footnote-ref::before {
  content: '[';
}

.sidenote-ref.footnote-ref::after {
  content: ']';
}

.sidenote-ref.footnote-ref:hover {
  text-decoration: underline;
}

/* Sidenotes - hidden by default, JS controls visibility */
.sidenote {
  display: none;
  font-size: 0.8rem;
  line-height: 1.4;
  color: #444;
}

.sidenote-number {
  font-size: 0.75em;
  vertical-align: super;
  line-height: 0;
  font-weight: 600;
  margin-right: 0.25em;
}

/* Margin-positioned sidenotes (JS adds .sidenote-margin class) */
.sidenote-margin {
  display: block;
  text-align: left;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 3px;
}

/* Left-side sidenotes */
.sidenote-left {
  text-align: right;
}

/* Footnotes section (created by JS on narrow viewports) */
.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid #ccc;
}

.footnotes-heading {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: #666;
}

.footnotes-list {
  margin: 0;
  padding-left: 1.5rem;
}

.footnote-item {
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #444;
}

.footnote-content {
  display: inline;
}

.footnote-backlink {
  color: #666;
  text-decoration: none;
  margin-left: 0.25em;
}

.footnote-backlink:hover {
  color: #0066cc;
}

/* Highlight animation for footnote navigation */
.footnote-highlight {
  animation: footnote-flash 1.5s ease-out;
}

@keyframes footnote-flash {
  0% {
    background-color: transparent;
  }
  15% {
    background-color: #eee;
  }
  85% {
    background-color: #eee;
  }
  100% {
    background-color: transparent;
  }
}


/* Version badge */
.version-badge {
  font-family: var(--font-mono);
  font-size: 0.8em;
  font-weight: 600;
  background: #f5f5f5;
  color: #666;
  padding: 0.1em 0.4em;
  border: 1px solid #ccc;
  margin-left: 0.5rem;
}

.doc-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.doc-actions-sm {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.inline-form {
  display: inline;
}

.btn-watching {
  background: #f0f0f0;
}

/* Alerts */
.alert {
  padding: 1rem;
  margin-bottom: 1.5rem;
  border: 1px solid #000;
}

.alert-error {
  background: #fff0f0;
  border-color: #000;
}

.alert-success {
  background: #f0fff0;
  border-color: #000;
}

.alert-info {
  background: #e7f3ff;
  border-color: #0066cc;
}

.alert-warning {
  background: #fff8e5;
  border-color: #cc9900;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.badge-info {
  background: #e7f3ff;
  color: #0066cc;
}

.badge-warning {
  background: #fff3cd;
  color: #856404;
}

.badge-success {
  background: #d4edda;
  color: #155724;
}

.badge-danger {
  background: #f8d7da;
  color: #721c24;
}

.badge-revert {
  background: #f5f0ff;
  color: #6b21a8;
}

.badge-muted {
  background: #f5f5f5;
  color: #666;
}

.badge-draft {
  background: #e9ecef;
  color: #495057;
}

.badge-proposed {
  background: #cce5ff;
  color: #004085;
}

.badge-review {
  background: #fff3cd;
  color: #856404;
}

.badge-implemented {
  background: #d4edda;
  color: #155724;
}

.badge-stamp {
  position: absolute;
  transform: rotate(-12deg);
  background: transparent;
  color: #c41e3a;
  border: 2px solid #c41e3a;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0.1rem 0.4rem;
  letter-spacing: 0.08em;
  opacity: 0.75;
  pointer-events: none;
  margin-left: 0.5rem;
  margin-top: -0.2rem;
}

/* Search */
.search-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.search-form .form-input {
  flex: 1;
}

.search-results-count {
  font-size: 0.9rem;
  color: #666;
  margin-top: 1rem;
}

/* Live search dropdown in header */
.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 0.4rem 0.75rem;
  border: 1px solid #000;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  background: #fff;
}

.search-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
}

.search-input::placeholder {
  color: #999;
}

.search-shortcut {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: #999;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.15rem 0.35rem;
  pointer-events: none;
  letter-spacing: 0.1em;
}

.search-input:focus + .search-shortcut {
  display: none;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #000;
  border-top: none;
  display: none;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
}

.search-results.active {
  display: block;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  text-decoration: none;
  color: #000;
  border-bottom: 1px solid #eee;
}

.search-result:last-child {
  border-bottom: none;
}

.search-result:hover,
.search-result.selected {
  background: #000;
  color: #fff;
}

.search-result-ref {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  background: #f0f0f0;
  flex-shrink: 0;
}

.search-result:hover .search-result-ref,
.search-result.selected .search-result-ref {
  background: #333;
  color: #fff;
}

.search-result-title {
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-no-results {
  padding: 0.75rem;
  color: #666;
  font-size: 0.9rem;
  text-align: center;
}

/* Timestamps - uses data-timestamp attribute, processed by JS */
[data-timestamp] {
  cursor: help;
  border-bottom: 1px dotted #999;
}

/* Edit info */
.edit-info {
  color: #666;
  font-size: 0.85rem;
}

.edit-info .editor {
  font-weight: 600;
}

/* Category grid for document hierarchy */
.category-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 2px solid #000;
}

.category-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: #000;
  border-bottom: 1px solid #e0e0e0;
  transition: background 0.1s ease;
}

.category-card:last-child {
  border-bottom: none;
}

.category-card:hover {
  background: #f5f5f5;
  text-decoration: none;
}

.category-code {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 700;
  background: #000;
  color: #fff;
  padding: 0.25rem 0.5rem;
  min-width: 4rem;
  text-align: center;
  border-radius: 2px;
}

.category-name {
  font-size: 1rem;
  flex-grow: 1;
}

.category-count {
  font-size: 0.9rem;
  color: #666;
}

/* Pinned documents */
.pinned-section {
  margin-bottom: 2rem;
}

.pinned-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: 0.5rem;
}

.pinned-card {
  display: block;
  text-decoration: none;
}

.pinned-card:hover {
  text-decoration: none;
}

.pinned-title {
  display: block;
  color: #666;
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

/* Pin editing page */
.pin-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.pin-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid #e0e0e0;
  margin-bottom: 0.5rem;
  background: #fff;
  cursor: grab;
}

.pin-item .ref {
  flex-shrink: 0;
}

.pin-item.dragging {
  opacity: 0.5;
}

.pin-drag-handle {
  color: #999;
  cursor: grab;
  flex-shrink: 0;
}

.pin-title {
  flex-grow: 1;
  min-width: 0;
}

.pin-remove-form {
  flex-shrink: 0;
}

.available-docs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
}

.available-doc {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid #e0e0e0;
}

.available-doc .ref {
  flex-shrink: 0;
}

.available-doc-title {
  flex-grow: 1;
  font-size: 0.9rem;
  min-width: 0;
}

/* Settings navigation */
.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 2px solid #000;
}

.settings-nav-item {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  text-decoration: none;
  color: #000;
  border-bottom: 1px solid #e0e0e0;
  transition: background 0.1s ease;
}

.settings-nav-item:last-child {
  border-bottom: none;
}

.settings-nav-item:hover {
  background: #f5f5f5;
  text-decoration: none;
}

/* Error pages */
.error-page {
  text-align: center;
  padding: 4rem 1rem;
}

.error-code {
  font-family: var(--font-mono);
  font-size: 6rem;
  font-weight: 700;
  line-height: 1;
  color: #000;
}

.error-title {
  font-size: 1.5rem;
  margin: 1rem 0 0.5rem;
}

.error-message {
  color: #666;
  margin-bottom: 2rem;
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fafafa;
  padding: 1rem;
}

.login-container {
  width: 100%;
  max-width: 24rem;
}

.login-header {
  text-align: center;
  margin-bottom: 2rem;
}

.login-brand {
  font-family: var(--font-sans);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.login-instance-name {
  font-family: var(--font-sans);
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: #666;
  margin: 0 0 0.5rem 0;
}

.login-subtitle {
  color: #666;
}

.login-card {
  background: #fff;
  border: 1px solid #000;
  padding: 2rem;
}

.login-card .btn {
  width: 100%;
  padding: 0.875rem;
}

/* Utility classes */
.flex {
  display: flex;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.ml-2 { margin-left: 0.5rem; }
.ml-4 { margin-left: 1rem; }
.ml-6 { margin-left: 1.5rem; }

.text-muted {
  color: #666;
}

.text-danger {
  color: #cc0000;
}

.hidden {
  display: none;
}

.text-sm {
  font-size: 0.875rem;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.pr-0, .table td.pr-0, .table th.pr-0 { padding-right: 0; }

.table td.td-action {
  text-align: right;
  padding-right: 1rem;
  width: 1%;
  white-space: nowrap;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Image upload overlay */
.upload-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  border-radius: 0.25rem;
}

.upload-overlay-text {
  color: white;
  font-size: 1.125rem;
  font-weight: 500;
  padding: 1rem 2rem;
  border: 2px dashed white;
  border-radius: 0.5rem;
}

/* Search filters */
.search-input-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.search-input-row .form-input {
  flex: 1;
}

.search-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.form-select-sm {
  padding: 0.4rem 0.6rem;
  font-size: 0.85rem;
  min-width: 10rem;
}

@media (max-width: 48rem) {
  .search-filters {
    flex-direction: column;
  }
  
  .form-select-sm {
    width: 100%;
  }
}

/* Document content needs relative positioning for sidenotes */
.doc-content {
  position: relative;
}

/* Refresh banner for stale document detection */
.refresh-banner {
  text-align: center;
  margin-bottom: 1rem;
}

.refresh-banner[hidden] {
  display: none;
}

/* Modal overlay */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal.is-active {
  display: flex;
}

.modal-content {
  background: #fff;
  border: 2px solid #000;
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  box-shadow: 4px 4px 0 #000;
}

.modal-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.modal-description {
  color: #666;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.modal-url {
  margin-bottom: 1rem;
  word-break: break-all;
}

.modal-content .form-textarea {
  min-height: 6rem;
  margin-bottom: 1rem;
}

.modal-input {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.9rem;
  border: 1px solid #000;
  margin-bottom: 0.5rem;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px #000;
}

.modal-input::placeholder {
  color: #999;
}

textarea.modal-input {
  min-height: 5rem;
  resize: vertical;
}

.modal-error {
  color: #b31d28;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  display: none;
}

.modal-body {
  padding-bottom: 1rem;
}

.modal-choices {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.modal-choice {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #e0e0e0;
  cursor: pointer;
  transition: border-color 0.15s;
}

.modal-choice:hover {
  border-color: #999;
}

.modal-choice:has(input:checked) {
  border-color: #000;
  background: #f9f9f9;
}

.modal-choice input[type="radio"] {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.modal-choice-content {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.modal-choice-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.modal-choice-desc {
  font-size: 0.8rem;
  color: #666;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* Image lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 1001;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  padding: 2rem;
}

.lightbox.is-active {
  display: flex;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border: 4px solid #fff;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
  .lightbox {
    padding: 0;
  }
  .lightbox img {
    border: none;
    box-shadow: none;
  }
}

/* Comments on pending edits */
.comments {
  margin: 1.5rem 0;
}

.comment {
  border-bottom: 1px solid var(--color-border);
  padding: 1rem 0;
}

.comment:last-child {
  border-bottom: none;
}

.comment-meta {
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.comment-content {
  line-height: 1.5;
}

.btn-quote {
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  margin-left: 0.5rem;
}

.btn-quote:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.comment-form {
  margin-top: 1rem;
}

.comment-form textarea {
  width: 100%;
  margin-bottom: 0.5rem;
  font-family: inherit;
  font-size: inherit;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  resize: vertical;
}

.comment-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
}

/* Review decision block */
.review-decision {
  margin: 1.5rem 0;
  padding: 1rem;
  background: var(--color-bg-muted);
  border-radius: 4px;
}

.review-decision h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
}

.review-decision blockquote {
  margin: 0.5rem 0 0 0;
  padding-left: 1rem;
  border-left: 3px solid var(--color-border);
  font-style: italic;
}

/* Notification Tray */
.notification-tray {
  position: relative;
  margin-right: 1rem;
}

.notification-bell {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  position: relative;
  color: #666;
  transition: color 0.1s ease, border-color 0.1s ease;
}

.notification-bell:hover {
  color: #000;
  border-color: #000;
}

.bell-icon {
  display: block;
}

.notification-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  font-size: 0.6rem;
  font-weight: 700;
  background: #cc0000;
  color: #fff;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-badge[hidden] {
  display: none;
}

.notification-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  width: 300px;
  max-height: 400px;
  background: #fff;
  border: 1px solid #000;
  z-index: 100;
  display: none;
}

.notification-dropdown.is-open {
  display: block;
}

.notification-dropdown-header {
  padding: 0.75rem 1rem;
  font-weight: 600;
  border-bottom: 1px solid #e0e0e0;
}

.notification-list {
  max-height: 280px;
  overflow-y: auto;
}

.notification-item {
  display: block;
  padding: 0.75rem 1rem;
  text-decoration: none;
  color: #000;
  border-bottom: 1px solid #f0f0f0;
}

.notification-item:last-child {
  border-bottom: none;
}

.notification-item:hover {
  background: #f5f5f5;
}

.notification-item.is-unread {
  background: #f8f8ff;
}

.notification-item.is-unread:hover {
  background: #f0f0ff;
}

.notification-message {
  font-size: 0.9rem;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.notification-time {
  font-size: 0.75rem;
  color: #666;
}

.notification-empty {
  padding: 2rem 1rem;
  text-align: center;
  color: #666;
  font-size: 0.9rem;
}

.notification-more {
  padding: 0.5rem 1rem;
  text-align: center;
  color: #666;
  font-size: 0.85rem;
  border-top: 1px solid #f0f0f0;
}

.notification-dropdown-footer {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid #e0e0e0;
  font-size: 0.85rem;
}

.notification-mark-all {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  padding: 0;
}

.notification-mark-all:hover {
  color: #000;
  text-decoration: underline;
}

.mark-all-check {
  color: #2a7d2a;
  margin-left: 0.25rem;
}

.notification-see-all {
  color: #000;
}

/* Full notifications page */
.notification-list-full {
  border: 1px solid #e0e0e0;
}

.notification-item-full {
  display: block;
  padding: 1rem;
  text-decoration: none;
  color: #000;
  border-bottom: 1px solid #e0e0e0;
}

.notification-item-full:last-child {
  border-bottom: none;
}

.notification-item-full:hover {
  background: #f5f5f5;
}

.notification-item-full.is-unread {
  background: #f8f8ff;
}

.notification-item-full.is-unread:hover {
  background: #f0f0ff;
}

.notification-meta {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
}

.notification-status {
  color: #999;
}

/* Status select dropdown */
.doc-status {
  display: inline-flex;
  align-items: center;
}

.status-clickable {
  cursor: pointer;
  border: none;
  font-family: var(--font-sans);
}

.status-clickable:hover {
  opacity: 0.8;
}

/* Document comments */
.doc-comments {
  margin-top: 2rem;
}

.comments-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.comments-list .comment {
  border: 1px solid #e0e0e0;
  padding: 0.75rem 1rem;
}

.comments-list .comment-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8rem;
  margin-bottom: 0.5rem;
}

.comments-list .comment-author {
  font-weight: 600;
}

.comments-list .comment-date {
  color: #666;
}

.comments-list .comment-content {
  font-size: 0.9rem;
}

.comments-list .comment-content p:last-child {
  margin-bottom: 0;
}

.doc-comments .comment-form {
  margin-top: 1rem;
}

.doc-comments .comment-form textarea {
  min-height: 80px;
}

/* Dark mode */
html[data-theme="dark"] {
  filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"] img,
html[data-theme="dark"] video,
html[data-theme="dark"] iframe,
html[data-theme="dark"] .code-block {
  filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"] .lightbox {
  filter: invert(1) hue-rotate(180deg);
}

html[data-theme="dark"] .lightbox img {
  filter: none;
}

/* Theme toggle button */
.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  cursor: pointer;
  z-index: 1000;
  color: inherit;
  text-decoration: underline;
}

@media (max-width: 768px) {
  .theme-toggle {
    position: static;
  }
}
