:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px; color-scheme: light;
  --bg: #f3f6f8; --surface: #fff; --ink: #142b3e; --muted: #536879;
  --line: #d3dee5; --accent: #1554c5; --selected: #eaf1ff; --hover: #edf3fc;
  --button: #155fe9; --button-text: #fff; --warn: #785817; --warn-bg: #eee8d4;
  --focus: #3876d9;
  color: var(--ink); background: var(--bg); -webkit-text-size-adjust: 100%;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101419; --surface: #171d24; --ink: #bbc5d0; --muted: #98a6b5;
  --line: #35414f; --accent: #93b2d8; --selected: #223043; --hover: #24303e;
  --button: #2d4666; --button-text: #c5d1df; --warn: #c5ae7b; --warn-bg: #302a20;
  --focus: #8ba8cb;
}
* { box-sizing: border-box; }
body { margin: 0; }
button,input,textarea { font: inherit; }
button,a,input,summary,textarea { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { min-height: 48px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 11px 16px; border-radius: 8px; font-weight: 600; }
@media(hover:hover) { button:hover { background: var(--hover); } }
button:disabled { opacity: .5; cursor: wait; }
button:focus-visible,a:focus-visible,summary:focus-visible,input:focus-visible,textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.masthead { min-height: 76px; padding: 12px max(24px,env(safe-area-inset-right)) 12px max(24px,env(safe-area-inset-left)); display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: var(--surface); }
.brand { min-height: 48px; color: var(--ink); text-decoration: none; font-size: 21px; font-weight: 750; letter-spacing: -.6px; display: flex; align-items: center; }
.brand-icon { display: inline-grid; place-items: center; margin-right: 10px; background: var(--selected); color: var(--accent); width: 34px; height: 34px; border-radius: 7px; }
.brand-dot { color: var(--accent); }
.display-controls { display: flex; align-items: center; gap: 14px; }
#theme { color: var(--accent); white-space: nowrap; }
#theme[aria-pressed="true"] { background: var(--selected); border-color: var(--accent); }
.aircraft { display: inline-block; color: var(--muted); font-size: 14px; font-weight: 650; letter-spacing: 1px; }
.workspace { display: grid; grid-template-columns: 235px minmax(0,1fr); min-height: calc(100dvh - 76px); }
aside { padding: 26px 18px; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.library-label { font-size: 14px; letter-spacing: 1px; font-weight: 700; color: var(--muted); display: flex; justify-content: space-between; }
.search { display: flex; align-items: center; background: var(--bg); margin: 20px 0 16px; border: 1px solid var(--line); border-radius: 8px; padding: 0 12px; gap: 9px; }
.search span { font-size: 25px; }
.search input { width: 100%; min-width: 0; min-height: 48px; border: 0; background: transparent; padding: 12px 0; font-size: 16px; color: var(--ink); }
input::placeholder { color: var(--muted); opacity: 1; }
#airports { display: grid; gap: 10px; }
.airport { display: block; width: 100%; text-align: left; padding: 16px; border-color: transparent; }
.airport strong { display: block; font-size: 22px; letter-spacing: .8px; }
.airport span { display: block; font-size: 16px; color: var(--muted); margin-top: 5px; }
.airport.active { background: var(--selected); border-color: var(--line); box-shadow: inset 3px 0 var(--accent); }
.airport.active strong { color: var(--accent); }
.sidebar-foot { margin-top: auto; padding-top: 60px; color: var(--muted); font-size: 14px; }
main { min-width: 0; width: 100%; max-width: 1050px; padding: 30px 36px max(40px,env(safe-area-inset-bottom)); }
.eyebrow { color: var(--muted); font-size: 13px; font-weight: 650; letter-spacing: 1.3px; }
.eyebrow span { margin-left: 8px; }
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 14px 0 20px; }
h1 { font-size: 44px; letter-spacing: -1px; line-height: 1.1; margin: 0; font-weight: 750; }
.title-row p { margin: 7px 0 0; font-size: 20px; color: var(--muted); }
.primary { background: var(--button); border-color: var(--button); color: var(--button-text); }
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; border-top: 1px solid var(--line); padding: 8px 0; font-size: 14px; color: var(--muted); }
.toolbar button { margin-left: auto; background: transparent; color: var(--accent); }
.draft { font-size: 12px; font-weight: 750; letter-spacing: 1px; color: var(--warn); background: var(--warn-bg); padding: 6px 9px; border-radius: 4px; }
#section-nav { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 0 16px; background: var(--bg); border-bottom: 1px solid var(--line); margin-bottom: 14px; }
#section-nav button { color: var(--accent); font-size: 16px; padding: 10px 14px; }
details { background: var(--surface); border: 1px solid var(--line); border-radius: 9px; margin-bottom: 14px; overflow: hidden; scroll-margin-top: 16px; }
summary { cursor: pointer; min-height: 60px; padding: 17px 20px; list-style: none; display: flex; align-items: center; gap: 12px; }
summary::-webkit-details-marker { display: none; }
summary::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 24px; font-weight: 400; }
details[open]>summary::after { content: '−'; }
summary h2 { margin: 0; font-size: 21px; letter-spacing: .7px; line-height: 1.5; }
.section-number { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.section-body { padding: 0 22px 20px; }
.section-body p { margin: 0; padding: 3px 0; line-height: 1.4; font-size: 18px; overflow-wrap: anywhere; }
.section-body h3 { font-size: 17px; letter-spacing: 1px; color: var(--muted); margin: 18px 0 5px; }
.watchlist { border-left: 3px solid var(--warn); }
.comms p { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.2fr); gap: 20px; border-bottom: 1px solid var(--line); }
.comms p:last-child { border: 0; }
.comms .frequency { font-variant-numeric: tabular-nums; font-weight: 650; text-align: right; }
.editor-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 15px; }
.editor-actions span { font-size: 14px; color: var(--muted); margin-right: auto; }
#editor label { font-weight: 650; }
#editor p { color: var(--muted); font-size: 16px; }
textarea { width: 100%; height: 60dvh; min-height: 300px; resize: vertical; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; font-family: ui-monospace,SFMono-Regular,monospace; line-height: 1.7; font-size: 17px; color: var(--ink); }
#status { font-size: 16px; color: var(--accent); line-height: 1.6; }
[hidden] { display: none!important; }
/* Tablet: a full-width guide in either orientation, with a compact airport strip. */
@media(max-width:1200px) {
  .workspace { display: block; }
  aside { padding: 14px max(24px,env(safe-area-inset-left)); border-right: 0; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(180px,1fr) minmax(0,2fr); gap: 16px; align-items: center; }
  .library-label,.sidebar-foot { display: none; }
  .search { margin: 0; }
  #airports { grid-template-columns: repeat(3,minmax(0,1fr)); }
  .airport { padding: 10px 16px; }
  .airport strong { font-size: 20px; }
  .airport span { font-size: 14px; }
  main { margin: 0 auto; padding: 24px 28px max(40px,env(safe-area-inset-bottom)); }
}
@media(max-width:700px) {
  .masthead { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .brand { font-size: 18px; }
  .display-controls { gap: 0; }
  .display-controls .aircraft { display: none; }
  #theme { font-size: 14px; padding: 10px; }
  aside { display: block; padding: 12px 16px; }
  .search { margin-bottom: 10px; }
  main { padding: 22px 16px 40px; }
  h1 { font-size: 38px; }
  .title-row p { font-size: 18px; }
  .toolbar { gap: 8px; }
  .section-body { padding: 0 17px 16px; }
  summary { padding: 16px; }
  .section-number { display: none; }
  .comms p { display: flex; flex-wrap: wrap; gap: 4px 16px; }
  .comms .frequency { text-align: left; }
  .editor-actions span { width: 100%; }
}
@media print {
  :root[data-theme] { --ink:#142b3e; --muted:#536879; --surface:#fff; --bg:#fff; --line:#d3dee5; }
  aside,.masthead,button,#section-nav,#status { display:none!important; }
  .workspace { display:block; }
  main { padding:0; max-width:none; }
  details { break-inside:avoid; }
}
.airport-search { position: relative; min-width: 0; }
#search-results { position: absolute; top: 100%; left: 0; width: max(100%, 280px); max-width: calc(100vw - 32px); max-height: 320px; overflow-y: auto; z-index: 20; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px #0003; }
#search-results button { display: block; width: 100%; text-align: left; margin-bottom: 4px; }
.airport .trip-role { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; margin: 0 0 8px; color: var(--accent); }
#assignments { display: flex; flex-direction: column; gap: 8px; margin: 0; flex-shrink: 0; }
#assignments button { font-size: 14px; }
#assignments button[aria-pressed="true"] { background: var(--selected); color: var(--accent); }
@media(max-width:700px) { .airport { padding: 10px 8px; } .airport .trip-role { font-size: 12px; letter-spacing: 0; } .airport span { overflow-wrap: anywhere; } }
@media print { #assignments { display: none; } }

.airport-heading { min-width: 0; }
.airport-heading #edit { margin-top: 14px; }
@media(max-width:480px) { .title-row { gap: 12px; align-items: flex-start; } #assignments { flex-shrink: 1; max-width: 52%; } #assignments button { padding: 10px; } }
dialog { width: min(560px, calc(100% - 32px)); max-height: 90dvh; overflow: auto; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
dialog::backdrop { background: #0009; }
dialog h2 { margin-top: 0; font-size: 22px; }
#report-description { height: 180px; min-height: 130px; margin-top: 12px; }
.report-actions { display: flex; justify-content: flex-end; gap: 12px; }
#report-status { color: var(--muted); }
#status a { color: var(--accent); }
#edit:disabled { cursor: not-allowed; }

summary .card-report { margin-left: auto; min-height: 44px; padding: 8px 10px; font-size: 13px; font-weight: 400; color: var(--muted); background: transparent; border-color: transparent; }
summary:has(.card-report)::after { margin-left: 0; }
summary h2 { min-width: 0; overflow-wrap: anywhere; }

.section-body p.note-bullet { position: relative; padding-left: 18px; }
.section-body p.note-bullet::before { content: '•'; position: absolute; left: 0; color: var(--muted); }
.section-body p.note-nested { margin-left: 22px; }
.section-body p.note-nested::before { content: '–'; }
/* Keep search focus visible without an inner rectangular outline. */
.search input:focus-visible { outline: none; }
.search:focus-within { border-color: var(--focus); }
.source-reference { font-size: .75rem; font-weight: 400; color: var(--muted); }

.offline-panel { margin: 0 auto; padding: 12px 24px; max-width: 1440px; font-size: 14px; }
.offline-panel p { margin: 6px 0; }
.offline-panel button { min-height: 48px; margin: 4px 8px; }
.offline-panel details { padding: 4px 0; }
.offline-panel summary { cursor: pointer; min-height: 48px; display: flex; align-items: center; }
.offline-panel li { margin: 12px 0; overflow-wrap: anywhere; white-space: pre-wrap; }
#update-notice { padding: 8px; border: 2px solid currentColor; border-radius: 8px; }

#request-airport { width:100%; box-sizing:border-box; margin:8px 0 16px; padding:12px; border:1px solid var(--line); border-radius:8px; background:var(--bg); color:var(--ink); font:inherit; }

.offline-panel #airport-picker-toggle { display:flex; align-items:center; justify-content:space-between; gap:16px; width:100%; margin:0; padding:0; border:0; border-radius:0; background:transparent; color:var(--ink); font-weight:400; text-align:left; }
.picker-chevron { font-size:22px; color:var(--accent); }
#airport-picker-toggle[aria-expanded="true"] .picker-chevron { transform:rotate(180deg); }
#airport-picker { display:flex; flex-wrap:wrap; gap:10px; padding:8px 0 12px; }
.offline-panel #airport-picker button { margin:0; border-radius:999px; color:var(--accent); }
#airport-picker button[aria-pressed="true"] { background:var(--selected); border-color:var(--accent); }

@media print { .toolbar { display:block; margin-bottom:12px; } #updated { display:block; } }

.reference-page { margin: 0 auto; max-width: 1050px; }
.reference-page a, .sidebar-foot a, .section-body a, .masthead > a:not(.brand) { color: var(--accent); }
.reference-card { margin: 22px 0; padding: 20px 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.reference-card li { line-height: 1.55; margin: 10px 0; }
.reference-card h2 { font-size: 22px; }
.comparison-scroll { overflow-x: auto; }
.reference-card table { width: 100%; border-collapse: collapse; font-size: 16px; }
.reference-card th, .reference-card td { text-align: left; padding: 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
@media (max-width: 600px) { .reference-page { padding: 20px 16px; } .reference-card { padding: 16px; } .reference-card ul { padding-left: 22px; } }
@media print { .reference-card { break-inside: avoid; } .reference-page { max-width: none; padding: 0; } .comparison-scroll { overflow: visible; } }

.reference-card .fms-label + ul { margin-inline-start: 24px; }
