/* ============================================================
   ATCmanualCreator — css/viewer.css
   Structural styles for the document viewer.
   Colour tokens are defined by the active theme file in
   css/themes/. Switch themes via the palette button in the
   navbar — preference saved to localStorage.
   ============================================================ */
body.dark-mode .content-wrapper {
  background: var(--doc-bg) !important;
}
body.dark-mode .main-sidebar {
  background: var(--sidebar-bg) !important;
}
body.dark-mode .brand-link {
  background: rgba(0, 0, 0, 0.3) !important;
}
body.dark-mode .doc-table thead th {
  background:   #0d1526 !important;
  color:        #d8e0ed !important;
  border-color: var(--doc-border) !important;
}
/* ALL td cells — always readable */
body.dark-mode .doc-table tbody td {
  color:        var(--doc-text) !important;
  border-color: var(--doc-border);
}
/* Striped — odd rows: subtle highlight */
body.dark-mode .doc-table.table-striped tbody tr:nth-of-type(odd) td {
  background: rgba(255, 255, 255, 0.04) !important;
}
/* Striped — even rows: explicit dark surface (NOT transparent / white) */
body.dark-mode .doc-table.table-striped tbody tr:nth-of-type(even) td {
  background: var(--doc-surface) !important;
}
/* Non-striped tables */
body.dark-mode .doc-table:not(.table-striped) tbody td {
  background: var(--doc-surface) !important;
}
body.dark-mode .doc-table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.07) !important;
}
body.dark-mode .doc-chart-refs,
body.dark-mode .doc-reference-block,
body.dark-mode .approval-row {
  background: var(--doc-surface);
  border-color: var(--doc-border);
}
body.dark-mode .chapter-title,
body.dark-mode .doc-heading-1,
body.dark-mode .front-page-title,
body.dark-mode .title-main {
  color: #c8d7f0;
}
body.dark-mode .doc-heading-2 {
  color: #9baec8;
}
body.dark-mode .doc-paragraph,
body.dark-mode .doc-paragraph p {
  color: var(--doc-text);
}
body.dark-mode .doc-paragraph strong {
  color: #c8d7f0;
}
body.dark-mode .doc-paragraph code {
  background: var(--doc-code-bg);
  color: #7fb3d3;
}
body.dark-mode .toc-row td {
  border-color: var(--doc-border);
}
body.dark-mode .toc-row:hover td {
  background: rgba(255, 255, 255, 0.04);
}
body.dark-mode .doc-remark-note    .doc-remark-body { background: var(--remark-note-bg);    }
body.dark-mode .doc-remark-caution .doc-remark-body { background: var(--remark-caution-bg); }
body.dark-mode .doc-remark-warning .doc-remark-body { background: var(--remark-warning-bg); }
body.dark-mode .title-warning-box {
  background: rgba(192, 57, 43, 0.15);
  border-color: rgba(192, 57, 43, 0.35);
  color: #e8a09a;
}
body.dark-mode .doc-mermaid-wrapper {
  background: #0f1621;
  border-color: var(--doc-border);
}
body.dark-mode .doc-chart-wrapper {
  background: var(--doc-surface);
  border-color: var(--doc-border);
}
body.dark-mode .doc-chart-ref-item {
  color: var(--doc-text);
  border-color: var(--doc-border);
}
body.dark-mode .doc-chart-ref-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
body.dark-mode .doc-update-block {
  background: rgba(212, 168, 67, 0.12);
}
body.dark-mode link#hljs-dark-theme { }
   § 3 — BASE
   ════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family:  var(--font-body);
  font-size:    1.05rem;
  color:        var(--doc-text);
  background:   var(--doc-bg);
  overflow-x:   hidden;
  transition:   background-color 0.25s ease, color 0.25s ease;
}

.wrapper { min-height: 100vh; }

/* ════════════════════════════════════════════════════════
   § 4 — NAVBAR
   ════════════════════════════════════════════════════════ */
.main-header.navbar {
  background:    var(--navy-dark) !important;
  border-bottom: 3px solid var(--accent) !important;
  padding:       0 1rem;
  min-height:    var(--navbar-h);
  z-index:       1050;
}

.navbar-brand { padding: 0; }

.nav-brand-block  { line-height: 1.15; }
.nav-brand-title  {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      1.15rem;
  color:          #ffffff;
  letter-spacing: 0.5px;
}
.nav-brand-sub {
  font-family:    var(--font-head);
  font-size:      0.72rem;
  color:          rgba(255, 255, 255, 0.55);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.nav-icao-tag {
  font-family:    var(--font-mono);
  font-size:      0.75rem;
  background:     var(--accent);
  color:          #ffffff;
  padding:        1px 7px;
  border-radius:  3px;
  letter-spacing: 1px;
}

.navbar-version {
  font-family: var(--font-mono);
  font-size:   0.7rem;
  color:       rgba(255, 255, 255, 0.5);
}

/* Search box */
.navbar-search-wrapper {
  position:  relative;
  max-width: 280px;
  flex:      1;
}
.navbar-search-wrapper .fa-search {
  position:  absolute;
  left:      10px;
  top:       50%;
  transform: translateY(-50%);
  color:     rgba(255, 255, 255, 0.4);
  font-size: 0.8rem;
  pointer-events: none;
}
#doc-search {
  background:   rgba(255, 255, 255, 0.1);
  border:       1px solid rgba(255, 255, 255, 0.2);
  color:        #ffffff;
  padding:      0.35rem 0.75rem 0.35rem 2rem;
  border-radius: 4px;
  font-family:  var(--font-body);
  font-size:    0.9rem;
  width:        100%;
  transition:   all 0.2s;
}
#doc-search::placeholder { color: rgba(255, 255, 255, 0.35); }
#doc-search:focus {
  background:  rgba(255, 255, 255, 0.15);
  border-color: var(--gold);
  outline:     none;
  box-shadow:  0 0 0 2px rgba(212, 168, 67, 0.25);
}

/* Toolbar buttons */
.toolbar-btn {
  background:    transparent;
  border:        1px solid rgba(255, 255, 255, 0.25);
  color:         rgba(255, 255, 255, 0.75);
  padding:       0.3rem 0.65rem;
  border-radius: 4px;
  font-size:     0.8rem;
  cursor:        pointer;
  transition:    all 0.2s;
  white-space:   nowrap;
  line-height:   1.4;
}
.toolbar-btn:hover {
  background:   var(--accent);
  border-color: var(--accent);
  color:        #ffffff;
}
.toolbar-btn.btn-export {
  border-color: var(--gold);
  color:        var(--gold);
}
.toolbar-btn.btn-export:hover {
  background: var(--gold);
  color:      var(--navy-dark);
}
/* Dark mode toggle button (Phase 4) */
.toolbar-btn.btn-dark-mode {
  border-color: rgba(255, 255, 255, 0.2);
  color:        rgba(255, 255, 255, 0.65);
  font-size:    0.9rem;
  padding:      0.3rem 0.55rem;
}
.toolbar-btn.btn-dark-mode:hover {
  background:   rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
  color:        #ffffff;
}
/* Bookmark button (Phase 4) */
.toolbar-btn.btn-bookmarks {
  position: relative;
}
.bookmark-count-badge {
  position:      absolute;
  top:           -5px;
  right:         -5px;
  background:    var(--accent);
  color:         #ffffff;
  font-size:     0.6rem;
  min-width:     16px;
  height:        16px;
  border-radius: 8px;
  display:       flex;
  align-items:   center;
  justify-content: center;
  padding:       0 3px;
  display:       none;
}

/* ════════════════════════════════════════════════════════
   § 5 — SIDEBAR
   ════════════════════════════════════════════════════════ */
.main-sidebar {
  background: var(--sidebar-bg) !important;
  width:      var(--sidebar-w) !important;
  min-height: 100vh;
  box-shadow: 3px 0 12px rgba(0, 0, 0, 0.25);
  transition: background-color 0.25s ease;
}

.sidebar { padding-bottom: 2rem; }

.brand-link {
  background:    var(--navy-dark) !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08) !important;
  padding:       0.75rem 1rem;
  display:       flex;
  align-items:   center;
  gap:           0.6rem;
  text-decoration: none;
}

.brand-text {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      0.95rem;
  color:          #ffffff;
  letter-spacing: 0.5px;
  line-height:    1.2;
}
.brand-text small {
  display:        block;
  font-size:      0.65rem;
  opacity:        0.55;
  font-weight:    400;
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.brand-logo {
  width:      32px;
  height:     32px;
  object-fit: contain;
}
.brand-logo-icon {
  font-size: 1.4rem;
  color:     var(--gold);
}

/* Sidebar navigation */
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link {
  color:        var(--sidebar-text) !important;
  font-family:  var(--font-body);
  font-size:    0.875rem;
  padding:      0.45rem 1rem;
  border-radius: 4px;
  margin:       1px 6px;
  transition:   all 0.15s;
}
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link:hover {
  color:      #ffffff !important;
  background: rgba(255, 255, 255, 0.08) !important;
}
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active {
  background: var(--accent) !important;
  color:      #ffffff !important;
  box-shadow: 0 2px 8px rgba(192, 57, 43, 0.4);
}
.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active .nav-icon {
  color: #ffffff !important;
}

.nav-header {
  font-family:    var(--font-head);
  font-size:      0.65rem;
  font-weight:    700;
  letter-spacing: 2px;
  color:          rgba(255, 255, 255, 0.3) !important;
  padding:        0.8rem 1rem 0.3rem;
  margin-top:     0.3rem;
}
.nav-icon { color: rgba(255, 255, 255, 0.4) !important; }

/* ════════════════════════════════════════════════════════
   § 6 — CONTENT AREA
   ════════════════════════════════════════════════════════ */
.content-wrapper {
  background:  var(--doc-bg) !important;
  margin-left: var(--sidebar-w) !important;
  min-height:  calc(100vh - var(--navbar-h));
  padding:     0 !important;
  transition:  background-color 0.25s ease;
}

#doc-content {
  max-width:  960px;
  margin:     0 auto;
  padding:    2rem 2.5rem 4rem;
  min-height: calc(100vh - 100px);
  animation:  fadeInContent 0.25s ease;
}

@keyframes fadeInContent {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ════════════════════════════════════════════════════════
   § 7 — SPINNER OVERLAY
   ════════════════════════════════════════════════════════ */
#doc-spinner {
  display:         none;
  position:        fixed;
  inset:           0;
  background:      rgba(17, 28, 51, 0.7);
  z-index:         9999;
  justify-content: center;
  align-items:     center;
  flex-direction:  column;
  gap:             1rem;
  backdrop-filter: blur(4px);
}
#doc-spinner.active { display: flex; }

.spinner-ring {
  width:         50px;
  height:        50px;
  border:        4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation:     spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.spinner-text {
  color:          #ffffff;
  font-family:    var(--font-head);
  font-size:      0.95rem;
  letter-spacing: 1px;
}

/* ════════════════════════════════════════════════════════
   § 8 — DOCUMENT BLOCK TYPES
   ════════════════════════════════════════════════════════ */

/* ── Chapter header ────────────────────────────────── */
.chapter-header {
  border-bottom:  3px solid var(--accent);
  padding-bottom: 1.25rem;
  margin-bottom:  2rem;
}
.chapter-eyebrow {
  font-family:    var(--font-head);
  font-size:      0.75rem;
  font-weight:    700;
  letter-spacing: 3px;
  text-transform: uppercase;
  color:          var(--accent);
  margin-bottom:  0.3rem;
}
.chapter-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size:   2rem;
  color:       var(--navy);
  line-height: 1.15;
  margin:      0 0 0.5rem;
  transition:  color 0.25s;
}
.chapter-meta { margin-top: 0.5rem; }

/* ── Headings ──────────────────────────────────────── */
.doc-heading-1 {
  font-family:  var(--font-head);
  font-weight:  700;
  font-size:    1.35rem;
  color:        var(--navy);
  margin:       2rem 0 0.6rem;
  padding:      0.5rem 0 0.5rem 0.75rem;
  border-left:  4px solid var(--accent);
  line-height:  1.2;
  transition:   color 0.25s;
}
.doc-heading-2 {
  font-family:  var(--font-head);
  font-weight:  600;
  font-size:    1.1rem;
  color:        var(--navy-light);
  margin:       1.5rem 0 0.4rem;
  padding-left: 0.5rem;
  border-left:  2px solid var(--gold);
  transition:   color 0.25s;
}
h4.doc-heading-2 {
  font-size:   1rem;
  color:       var(--doc-text-muted);
  border-left: 2px solid var(--doc-border);
}

/* ── Paragraph ─────────────────────────────────────── */
.doc-paragraph {
  font-size:   1.05rem;
  line-height: 1.75;
  margin:      0 0 1rem;
  color:       var(--doc-text);
  transition:  color 0.25s;
}
.doc-paragraph p { margin-bottom: 0.6rem; }
.doc-paragraph strong { color: var(--navy); font-weight: 600; }
.doc-paragraph code {
  font-family:   var(--font-mono);
  font-size:     0.88em;
  background:    var(--doc-code-bg);
  padding:       1px 5px;
  border-radius: 3px;
}

/* ── Lists ─────────────────────────────────────────── */
.doc-list-unordered,
.doc-list-ordered {
  padding-left: 1.5rem;
  margin:       0 0 1rem;
  line-height:  1.7;
}
.doc-list-unordered li,
.doc-list-ordered  li {
  margin-bottom: 0.35rem;
  font-size:     1.02rem;
  color:         var(--doc-text);
}
.doc-list-unordered li::marker { color: var(--accent); }

.doc-definition-list { margin: 0 0 1rem; }
.doc-definition-list dt {
  font-family:    var(--font-head);
  font-weight:    600;
  font-size:      0.95rem;
  color:          var(--navy);
  margin-top:     0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.doc-definition-list dd {
  margin-left: 1.5rem;
  line-height: 1.65;
  color:       var(--doc-text);
}

/* ── Tables ────────────────────────────────────────── */
.doc-table-wrapper {
  overflow-x:    auto;
  margin:        0.5rem 0 1.5rem;
  border-radius: 6px;
  box-shadow:    0 1px 4px rgba(0, 0, 0, 0.08);
}
.doc-table {
  font-family: var(--font-body);
  font-size:   0.93rem;
  border:      none;
  width:       100%;
}
.doc-table thead th {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      0.82rem;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  background:     var(--navy) !important;
  color:          #ffffff !important;
  border:         none;
  padding:        0.6rem 0.75rem;
  transition:     background-color 0.25s;
}
.doc-table tbody td {
  padding:        0.5rem 0.75rem;
  vertical-align: middle;
  border-color:   var(--doc-border);
  line-height:    1.45;
  color:          var(--doc-text);
  transition:     color 0.25s, border-color 0.25s;
}
.doc-table.table-striped tbody tr:nth-of-type(odd) td {
  background: var(--table-odd);
}
.doc-table-caption {
  font-family:    var(--font-head);
  font-weight:    600;
  font-size:      0.85rem;
  text-align:     center;
  caption-side:   top;
  padding:        0.4rem;
  color:          var(--navy);
  letter-spacing: 0.3px;
}

/* ── Remarks ───────────────────────────────────────── */
.doc-remark {
  border-radius: 6px;
  margin:        1rem 0;
  overflow:      hidden;
  box-shadow:    0 1px 4px rgba(0, 0, 0, 0.07);
}
.doc-remark-header {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      0.8rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding:        0.45rem 0.9rem;
  display:        flex;
  align-items:    center;
}
.doc-remark-body {
  padding:     0.65rem 0.9rem;
  font-size:   0.97rem;
  line-height: 1.6;
}
.doc-remark-note    { border-left: 4px solid #0d6efd; }
.doc-remark-caution { border-left: 4px solid #ffc107; }
.doc-remark-warning { border-left: 4px solid #dc3545; }
.doc-remark-note    .doc-remark-header { background: rgba(13,  110, 253, 0.10); color: #0a58ca; }
.doc-remark-caution .doc-remark-header { background: rgba(255, 193,   7, 0.15); color: #a07a00; }
.doc-remark-warning .doc-remark-header { background: rgba(220,  53,  69, 0.10); color: #b02a37; }
.doc-remark-note    .doc-remark-body   { background: var(--remark-note-bg);    }
.doc-remark-caution .doc-remark-body   { background: var(--remark-caution-bg); }
.doc-remark-warning .doc-remark-body   { background: var(--remark-warning-bg); }

/* ── Images / Figures ──────────────────────────────── */
.doc-figure { margin: 1rem 0 1.5rem; }
.doc-figure-center { text-align: center; }
.doc-figure-left   { text-align: left;   }
.doc-figure-right  { text-align: right;  }
.doc-image, .doc-svg {
  border-radius: 4px;
  box-shadow:    0 2px 8px rgba(0, 0, 0, 0.12);
}
.doc-figure-caption {
  font-family:    var(--font-head);
  font-size:      0.82rem;
  color:          var(--doc-text-muted);
  font-weight:    500;
  letter-spacing: 0.3px;
  margin-top:     0.4rem;
  font-style:     italic;
}

/* ── Mermaid diagrams ──────────────────────────────── */
.doc-mermaid-wrapper {
  background:    var(--doc-surface);
  border:        1px solid var(--doc-border);
  border-radius: 6px;
  padding:       1rem;
  overflow-x:    auto;
  transition:    background-color 0.25s, border-color 0.25s;
}
.doc-mermaid-wrapper svg { max-width: 100%; height: auto; }

/* ── Charts ────────────────────────────────────────── */
.doc-chart-wrapper {
  position:      relative;
  background:    var(--doc-surface);
  border:        1px solid var(--doc-border);
  border-radius: 6px;
  padding:       1rem;
  transition:    background-color 0.25s, border-color 0.25s;
}

/* ── Chart refs / PDF links ────────────────────────── */
.doc-chart-refs {
  background:    var(--doc-surface);
  border:        1px solid var(--doc-border);
  border-radius: 6px;
  margin:        0.75rem 0 1.5rem;
  overflow:      hidden;
  transition:    background-color 0.25s, border-color 0.25s;
}
.doc-chart-refs-caption {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  background:     var(--navy);
  color:          #ffffff;
  padding:        0.5rem 0.9rem;
}
.doc-chart-refs-list { padding: 0.4rem 0; }
.doc-chart-ref-item {
  display:         flex;
  align-items:     center;
  gap:             0.5rem;
  padding:         0.5rem 0.9rem;
  color:           var(--doc-text);
  text-decoration: none;
  font-size:       0.95rem;
  border-bottom:   1px solid var(--doc-border);
  transition:      background 0.15s, color 0.25s;
}
.doc-chart-ref-item:last-child { border-bottom: none; }
.doc-chart-ref-item:hover { background: rgba(26, 39, 68, 0.04); color: var(--navy); text-decoration: none; }

/* ── References ────────────────────────────────────── */
.doc-reference-block {
  border:        1px solid var(--doc-border);
  border-radius: 6px;
  margin:        1rem 0;
  overflow:      hidden;
  transition:    border-color 0.25s;
}
.doc-reference-header {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      0.8rem;
  letter-spacing: 2px;
  background:     var(--navy-dark);
  color:          rgba(255, 255, 255, 0.7);
  padding:        0.5rem 0.9rem;
}
.doc-reference-list {
  list-style: none;
  padding:    0.5rem 0;
  margin:     0;
}
.doc-ref-item {
  padding:      0.45rem 0.9rem;
  font-size:    0.9rem;
  border-bottom: 1px solid var(--doc-border);
  display:      flex;
  gap:          0.5rem;
  align-items:  baseline;
  flex-wrap:    wrap;
  color:        var(--doc-text);
  transition:   color 0.25s, border-color 0.25s;
}
.doc-ref-item:last-child { border-bottom: none; }
.doc-ref-citation { color: var(--navy); font-weight: 500; }
.doc-ref-topic    { color: var(--doc-text-muted); font-size: 0.85rem; margin-left: auto; }

/* ── Update / Amendment badge ──────────────────────── */
.doc-update-block {
  font-size:   0.83rem;
  color:       var(--doc-text-muted);
  background:  rgba(212, 168, 67, 0.08);
  border-left: 3px solid var(--gold);
  padding:     0.4rem 0.75rem;
  margin:      0.5rem 0;
  display:     flex;
  flex-wrap:   wrap;
  gap:         0.4rem;
  align-items: center;
  transition:  background 0.25s;
}
.doc-update-date {
  color:          var(--gold);
  font-weight:    600;
  font-family:    var(--font-mono);
  font-size:      0.8rem;
}
.doc-update-by { color: var(--doc-text-muted); font-style: italic; }

.doc-block-wrapper { position: relative; }
.doc-update-badge {
  position:    absolute;
  right:       0;
  top:         0.3rem;
  font-size:   0.65rem;
  color:       var(--gold);
  font-family: var(--font-mono);
  opacity:     0.7;
}

/* ── Raw HTML block ────────────────────────────────── */
.doc-html-block { margin: 0.75rem 0; }

/* ── Search highlight (Phase 4) ────────────────────── */
mark.doc-search-highlight,
mark.search-highlight {
  background:   rgba(212, 168, 67, 0.4);
  color:        inherit;
  padding:      0 2px;
  border-radius: 2px;
}

/* ── Bookmark buttons on headings (Phase 4) ────────── */
.section-action-btn {
  background:    none;
  border:        none;
  color:         var(--doc-text-muted);
  font-size:     0.85rem;
  cursor:        pointer;
  opacity:       0;
  padding:       0 4px;
  margin-left:   6px;
  transition:    opacity 0.15s, color 0.15s;
  vertical-align: middle;
}
.doc-heading-1:hover .section-action-btn,
.doc-heading-2:hover .section-action-btn,
.chapter-title:hover .section-action-btn {
  opacity: 1;
}
.section-action-btn.bookmarked { color: var(--gold); opacity: 1; }
.section-action-btn.speaking   { color: var(--accent); opacity: 1; animation: pulse 1s ease infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ATIS reader floating control bar (Phase 4) */
#atis-control-bar {
  position:      fixed;
  bottom:        1.5rem;
  left:          50%;
  transform:     translateX(-50%);
  background:    var(--navy-dark);
  border:        1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding:       0.5rem 1rem;
  display:       none;
  gap:           0.75rem;
  align-items:   center;
  z-index:       1040;
  box-shadow:    0 4px 20px rgba(0, 0, 0, 0.4);
  font-family:   var(--font-head);
  font-size:     0.85rem;
  color:         rgba(255, 255, 255, 0.8);
}
#atis-control-bar.active { display: flex; }
#atis-control-bar button {
  background: none;
  border:     none;
  color:      rgba(255, 255, 255, 0.75);
  cursor:     pointer;
  padding:    0.2rem 0.4rem;
  border-radius: 4px;
  transition: all 0.15s;
}
#atis-control-bar button:hover { background: rgba(255,255,255,0.1); color: #fff; }
#atis-control-bar select {
  background:    transparent;
  border:        1px solid rgba(255,255,255,0.2);
  color:         rgba(255,255,255,0.8);
  border-radius: 3px;
  padding:       2px 4px;
  font-size:     0.75rem;
}
#atis-control-bar select option { background: #1a2744; }

/* Bookmark panel (Phase 4) */
#bm-dropdown {
  display:       none;
  position:      absolute;
  top:           calc(var(--navbar-h) + 2px);
  right:         1rem;
  width:         320px;
  max-height:    420px;
  overflow-y:    auto;
  background:    var(--bm-panel-bg);
  border:        1px solid var(--doc-border);
  border-radius: 6px;
  box-shadow:    0 6px 24px rgba(0, 0, 0, 0.15);
  z-index:       1045;
  transition:    background-color 0.25s;
}
#bm-dropdown.open { display: block; }
.bm-panel-header {
  padding:     0.6rem 0.9rem;
  background:  var(--navy);
  color:       #ffffff;
  font-family: var(--font-head);
  font-size:   0.8rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display:     flex;
  justify-content: space-between;
  align-items: center;
}
.bm-clear-btn {
  background: none;
  border:     none;
  color:      rgba(255,255,255,0.6);
  cursor:     pointer;
  font-size:  0.75rem;
}
.bm-clear-btn:hover { color: var(--accent-light); }
.bm-item {
  display:        flex;
  align-items:    center;
  gap:            0.5rem;
  padding:        0.55rem 0.9rem;
  border-bottom:  1px solid var(--doc-border);
  cursor:         pointer;
  text-decoration: none;
  color:          var(--search-panel-text);
  font-size:      0.9rem;
  transition:     background 0.15s;
}
.bm-item:last-child { border-bottom: none; }
.bm-item:hover { background: rgba(26,39,68,0.05); }
.bm-item-icon { color: var(--gold); font-size: 0.75rem; }
.bm-item-text { flex: 1; }
.bm-item-title { font-weight: 500; line-height: 1.3; }
.bm-item-ch    { font-size: 0.78rem; color: var(--doc-text-muted); }
.bm-remove-btn {
  background: none;
  border:     none;
  color:      var(--doc-text-muted);
  cursor:     pointer;
  padding:    0 2px;
  font-size:  0.8rem;
}
.bm-remove-btn:hover { color: var(--accent); }
.bm-empty {
  padding:   1.5rem;
  text-align: center;
  color:     var(--doc-text-muted);
  font-style: italic;
  font-size: 0.9rem;
}

/* Search results panel (Phase 4) */
#search-results-panel {
  display:    none;
  position:   absolute;
  top:        calc(var(--navbar-h) + 2px);
  left:       50%;
  transform:  translateX(-50%);
  width:      min(640px, 95vw);
  max-height: 480px;
  overflow-y: auto;
  background: var(--search-panel-bg);
  border:     1px solid var(--doc-border);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  z-index:    1045;
  transition: background-color 0.25s;
}
#search-results-panel.open { display: block; }
.sr-header {
  padding:     0.6rem 1rem;
  background:  var(--navy);
  color:       rgba(255,255,255,0.6);
  font-family: var(--font-head);
  font-size:   0.75rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  display:     flex;
  justify-content: space-between;
  align-items: center;
  position:    sticky;
  top:         0;
}
.sr-close-btn {
  background: none;
  border:     none;
  color:      rgba(255,255,255,0.5);
  cursor:     pointer;
}
.sr-close-btn:hover { color: #ffffff; }
.sr-item {
  display:       flex;
  flex-direction: column;
  padding:       0.65rem 1rem;
  border-bottom: 1px solid var(--doc-border);
  cursor:        pointer;
  text-decoration: none;
  color:         var(--search-panel-text);
  transition:    background 0.15s;
}
.sr-item:last-child { border-bottom: none; }
.sr-item:hover { background: rgba(26,39,68,0.05); }
.sr-item-heading {
  font-family: var(--font-head);
  font-weight: 600;
  font-size:   0.95rem;
  color:       var(--navy);
}
body.dark-mode .sr-item-heading { color: #c8d7f0; }
.sr-item-snippet {
  font-size:   0.85rem;
  color:       var(--doc-text-muted);
  line-height: 1.5;
  margin-top:  0.15rem;
}
.sr-item-meta {
  font-family:  var(--font-mono);
  font-size:    0.72rem;
  color:        var(--doc-text-muted);
  margin-top:   0.25rem;
}
.sr-empty {
  padding:    2rem;
  text-align: center;
  color:      var(--doc-text-muted);
  font-style: italic;
}

/* ════════════════════════════════════════════════════════
   § 9 — FRONT MATTER PAGES
   ════════════════════════════════════════════════════════ */

/* Title page */
.doc-title-page {
  text-align: center;
  max-width:  700px;
  margin:     0 auto;
  padding:    3rem 0;
}
.title-page-header {
  display:        flex;
  flex-direction: column;
  align-items:    center;
  gap:            0.75rem;
  margin-bottom:  2.5rem;
}
.title-logo      { max-height: 80px; width: auto; }
.title-logo-icon { font-size: 4rem; color: var(--accent); }
.title-org {
  font-family:    var(--font-head);
  font-weight:    600;
  font-size:      0.9rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color:          var(--navy);
}
.title-page-body  { margin-bottom: 2.5rem; }
.title-doc-type {
  font-family:    var(--font-head);
  font-size:      0.75rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color:          var(--accent);
  font-weight:    700;
  margin-bottom:  0.4rem;
}
.title-main {
  font-family: var(--font-head);
  font-weight: 800;
  font-size:   2.8rem;
  color:       var(--navy);
  line-height: 1.1;
  margin:      0 0 0.5rem;
  transition:  color 0.25s;
}
.title-subtitle {
  font-family:  var(--font-head);
  font-size:    1.2rem;
  color:        var(--navy-light);
  margin-bottom: 0.75rem;
}
.title-airport {
  font-family: var(--font-body);
  font-size:   1rem;
  color:       var(--doc-text-muted);
}
.title-meta-table {
  margin:          0 auto 2rem;
  border-collapse: collapse;
  width:           auto;
  font-size:       0.9rem;
}
.title-meta-table td {
  padding:       0.35rem 0.8rem;
  border-bottom: 1px solid var(--doc-border);
  text-align:    left;
}
.title-meta-table td:first-child {
  color:        var(--doc-text-muted);
  font-weight:  500;
  white-space:  nowrap;
  padding-right: 1.5rem;
}
.title-warning-box {
  background:    rgba(192, 57, 43, 0.07);
  border:        1px solid rgba(192, 57, 43, 0.2);
  border-radius: 6px;
  padding:       0.75rem 1rem;
  font-size:     0.88rem;
  color:         #7a2a20;
  max-width:     560px;
  margin:        0 auto 2rem;
  text-align:    left;
  transition:    background 0.25s, border-color 0.25s, color 0.25s;
}
.title-page-footer {
  font-family:    var(--font-head);
  font-size:      0.8rem;
  color:          var(--doc-text-muted);
  letter-spacing: 1px;
}

/* Front matter shared */
.doc-front-page {
  max-width:   860px;
  margin:      0 auto;
  padding-top: 1rem;
}
.front-page-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size:   2rem;
  color:       var(--navy);
  transition:  color 0.25s;
}
.front-page-rule {
  height:     3px;
  background: linear-gradient(to right, var(--accent), transparent);
  margin:     0.5rem 0 1.5rem;
}
.front-page-body {
  font-size:   1.05rem;
  line-height: 1.8;
  color:       var(--doc-text);
}
.front-section-title {
  font-family: var(--font-head);
  font-weight: 700;
  font-size:   1.15rem;
  color:       var(--navy);
  transition:  color 0.25s;
}

/* TOC */
.toc-table { width: 100%; border-collapse: collapse; }
.toc-table thead th {
  font-family:    var(--font-head);
  font-size:      0.75rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color:          var(--doc-text-muted);
  border-bottom:  2px solid var(--doc-border);
  padding:        0.5rem 0.75rem;
}
.toc-row td {
  padding:       0.45rem 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  font-size:     0.97rem;
  color:         var(--doc-text);
  transition:    color 0.25s;
}
body.dark-mode .toc-row td { border-bottom-color: var(--doc-border); }
.toc-row:hover td { background: var(--table-odd); }
.toc-pages {
  color:       var(--doc-text-muted);
  font-family: var(--font-mono);
  font-size:   0.8rem;
  white-space: nowrap;
}
.toc-section-divider td { height: 0.5rem; }

/* Approval page */
.approval-row {
  display:               grid;
  grid-template-columns: 120px 1fr 120px 150px;
  gap:                   1rem;
  padding:               1rem;
  border:                1px solid var(--doc-border);
  border-radius:         6px;
  margin-bottom:         0.75rem;
  align-items:           start;
  background:            var(--doc-surface);
  transition:            background-color 0.25s, border-color 0.25s;
}
.approval-role {
  font-family:    var(--font-head);
  font-weight:    700;
  font-size:      0.8rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color:          var(--accent);
  padding-top:    0.2rem;
}
.approval-name { font-weight: 600; font-size: 1rem; }
.approval-desig, .approval-unit { font-size: 0.88rem; }
.approval-unit  { margin-top: 0.15rem; }
.approval-date  { font-family: var(--font-mono); font-size: 0.85rem; padding-top: 0.2rem; }
.sig-box {
  border-bottom: 1.5px solid var(--navy);
  min-height:    48px;
  width:         130px;
}
.dist-list { font-size: 0.97rem; line-height: 1.9; padding-left: 1.2rem; }

/* Pending placeholder */
.doc-pending-page { color: var(--doc-text-muted); }

/* ════════════════════════════════════════════════════════
   § 9b — UPDATED_ON STAMPS
   ════════════════════════════════════════════════════════ */

/*
 * .doc-updated-inline  — appears inside heading text (h2/h3)
 *   Rendered by htmlEngine when block.updated_on is set on a heading/subheading.
 *   Shows as a small pill: [✎ 2025-11-01]
 */
.doc-updated-inline {
  display:        inline-flex;
  align-items:    center;
  gap:            4px;
  font-family:    var(--font-mono);
  font-size:      0.62rem;
  font-weight:    400;
  letter-spacing: 0.3px;
  color:          var(--gold);
  background:     rgba(212, 168, 67, 0.12);
  border:         1px solid rgba(212, 168, 67, 0.35);
  padding:        1px 7px 1px 5px;
  border-radius:  10px;
  white-space:    nowrap;
  vertical-align: middle;
  margin-left:    10px;
  position:       relative;
  top:            -1px;
  transition:     background 0.25s;
}
.doc-updated-inline .fa-pencil-alt { font-size: 0.7em; opacity: 0.8; }
body.dark-mode .doc-updated-inline {
  background: rgba(212, 168, 67, 0.18);
  border-color: rgba(212, 168, 67, 0.4);
}

/*
 * .doc-block-updated  — wrapper div for non-heading blocks
 * .doc-updated-corner — floating stamp anchored top-right of wrapper
 */
.doc-block-updated {
  position: relative;
  padding-top: 1.6rem;   /* room for the corner stamp */
}
.doc-updated-corner {
  position:       absolute;
  top:            0;
  right:          0;
  display:        inline-flex;
  align-items:    center;
  gap:            4px;
  font-family:    var(--font-mono);
  font-size:      0.62rem;
  color:          var(--gold);
  background:     rgba(212, 168, 67, 0.1);
  border:         1px solid rgba(212, 168, 67, 0.3);
  border-radius:  0 4px 0 6px;       /* top-right corner shape */
  padding:        2px 8px 2px 6px;
  white-space:    nowrap;
  pointer-events: none;
  transition:     background 0.25s;
}
.doc-updated-corner .fa-pencil-alt { font-size: 0.7em; opacity: 0.8; }
body.dark-mode .doc-updated-corner {
  background:  rgba(212, 168, 67, 0.18);
  border-color: rgba(212, 168, 67, 0.4);
}

/* Subtle left-bar on the whole updated block wrapper */
.doc-block-updated::before {
  content:    '';
  position:   absolute;
  left:       -10px;
  top:        0;
  bottom:     0;
  width:      3px;
  background: rgba(212, 168, 67, 0.4);
  border-radius: 2px;
}

/* ════════════════════════════════════════════════════════
   § 10 — PRINT STYLES
   ════════════════════════════════════════════════════════ */
@media print {
  .main-sidebar,
  .main-header,
  #doc-spinner,
  #atis-control-bar,
  #bm-dropdown,
  #search-results-panel,
  .section-action-btn { display: none !important; }

  body { background: #ffffff !important; color: #000000 !important; }
  .content-wrapper { margin-left: 0 !important; background: #ffffff !important; }
  #doc-content { max-width: 100%; padding: 0; }
  .chapter-header { border-bottom: 2px solid #000; }
  .doc-heading-1  { break-before: avoid; }
  .doc-table-wrapper,
  .doc-remark { break-inside: avoid; }
  a[href]::after { content: none !important; }
}

/* ════════════════════════════════════════════════════════
   § 11 — RESPONSIVE
   ════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .content-wrapper { margin-left: 0 !important; }
  #doc-content { padding: 1.25rem 1rem 3rem; }
  .title-main  { font-size: 2rem; }
  .approval-row { grid-template-columns: 1fr; }
  #bm-dropdown { width: calc(100vw - 2rem); right: 1rem; left: auto; transform: none; }
  #search-results-panel { left: 0.5rem; right: 0.5rem; transform: none; width: auto; }