:root {
  --surface: #ffffff;
  --surface-soft: #f5f7f9;
  --surface-strong: #e8edf2;
  --ink: #17212b;
  --muted: #5d6975;
  --line: #d6dee5;
  --line-strong: #b8c4ce;
  --accent: #1769a8;
  --accent-hover: #11578e;
  --accent-soft: #e5f0f8;
  --secondary: #0a7773;
  --secondary-soft: #e3f2f0;
  --danger: #b42318;
  --warning: #e6a817;
  --topbar: #18252e;
  --shadow: 0 4px 18px rgb(25 42 56 / 12%);
  --shadow-raised: 0 8px 24px rgb(25 42 56 / 16%);
  font-family: "Segoe UI Variable Text", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: var(--surface-soft);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
  background: var(--surface-soft);
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
}

.topbar {
  z-index: 5;
  display: flex;
  align-items: center;
  min-height: 62px;
  gap: 12px;
  padding: 8px 14px;
  color: #ffffff;
  background: #263236;
  border-bottom: 3px solid var(--accent);
  box-shadow: 0 2px 8px rgb(16 27 29 / 20%);
}

.brand {
  display: flex;
  align-items: center;
  min-width: 190px;
  gap: 9px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid rgb(255 255 255 / 28%);
  border-radius: 4px;
}

.brand-mark svg {
  width: 22px;
  height: 22px;
}

.brand-copy {
  display: grid;
  min-width: 0;
}

.brand-copy strong {
  overflow: hidden;
  font-size: 17px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  overflow: hidden;
  margin-top: 2px;
  color: #c8d0d2;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-tools,
.manual-switch {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.history-tools {
  gap: 4px;
}

.icon-button {
  display: inline-grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  color: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.topbar .icon-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 12%);
  border-color: rgb(255 255 255 / 18%);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.35;
}

.manual-switch {
  overflow: hidden;
  border: 1px solid #758083;
  border-radius: 4px;
}

.manual-option {
  min-width: 58px;
  height: 34px;
  padding: 0 12px;
  color: #d9dfe0;
  background: transparent;
  border: 0;
  border-right: 1px solid #758083;
  cursor: pointer;
}

.manual-option:last-child {
  border-right: 0;
}

.manual-option:hover {
  background: rgb(255 255 255 / 10%);
}

.manual-option.active {
  color: #ffffff;
  background: var(--accent);
}

.quick-find {
  display: flex;
  align-items: center;
  width: min(430px, 38vw);
  min-width: 220px;
  height: 36px;
  margin-left: auto;
  padding-left: 10px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid #7c8789;
  border-radius: 4px;
}

.quick-find > svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--muted);
}

.quick-find input {
  width: 100%;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: 0;
}

.quick-find .inline {
  width: 30px;
  height: 32px;
  color: var(--ink);
}

.quick-find .inline:hover:not(:disabled) {
  background: var(--surface-strong);
}

.find-count {
  min-width: 38px;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
}

.server-load-indicator {
  display: inline-flex;
  min-height: 32px;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 0 10px;
  color: #dce4e7;
  background: rgb(255 255 255 / 7%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}

.server-load-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  background: #91a0a7;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgb(145 160 167 / 15%);
}

.server-load-indicator[data-level="normal"] {
  color: #dff8ea;
  background: rgb(28 128 75 / 20%);
  border-color: rgb(91 211 144 / 38%);
}

.server-load-indicator[data-level="normal"] .server-load-dot {
  background: #5bd390;
  box-shadow: 0 0 0 3px rgb(91 211 144 / 18%);
}

.server-load-indicator[data-level="busy"] {
  color: #fff1c2;
  background: rgb(164 105 0 / 28%);
  border-color: rgb(245 190 70 / 55%);
}

.server-load-indicator[data-level="busy"] .server-load-dot {
  background: #f5be46;
  box-shadow: 0 0 0 3px rgb(245 190 70 / 22%);
}

.server-load-indicator[data-level="high"] {
  color: #ffe1df;
  background: rgb(175 42 33 / 32%);
  border-color: rgb(255 112 101 / 58%);
}

.server-load-indicator[data-level="high"] .server-load-dot {
  background: #ff7065;
  box-shadow: 0 0 0 3px rgb(255 112 101 / 24%);
  animation: server-load-pulse 1.2s ease-in-out infinite;
}

@keyframes server-load-pulse {
  50% { opacity: 0.45; }
}

.workspace {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(460px, 1fr) minmax(220px, 270px);
  min-height: 0;
  overflow: hidden;
}

.workspace.ai-mode {
  grid-template-columns: minmax(0, 1fr);
}

.workspace.ai-mode .document-pane,
.workspace.ai-mode .info-pane {
  display: none;
}

.workspace.ai-mode .navigation-pane {
  border-right: 0;
}

.navigation-pane,
.info-pane,
.document-pane {
  min-width: 0;
  min-height: 0;
  background: var(--surface);
}

.navigation-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-right: 1px solid var(--line);
}

.navigation-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.navigation-tab {
  height: 40px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.navigation-tab:hover {
  color: var(--ink);
  background: #e9edec;
}

.navigation-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-bottom-color: var(--accent);
}

.navigation-panel {
  display: none;
  min-height: 0;
}

.navigation-panel.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.navigation-panel[hidden] {
  display: none;
}

.pane-heading {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 13px;
  border-bottom: 1px solid var(--line);
}

.pane-heading > div,
.pane-heading.compact {
  min-width: 0;
}

.pane-heading strong {
  display: block;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pane-heading small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.pane-heading .icon-button {
  color: var(--muted);
}

.pane-heading .icon-button:hover {
  color: var(--ink);
  background: var(--surface-strong);
}

.tree {
  min-height: 0;
  overflow: auto;
  padding: 6px 0 18px;
  scrollbar-gutter: stable;
}

.tree details {
  min-width: 0;
}

.tree summary {
  display: flex;
  min-height: 32px;
  align-items: center;
  gap: 5px;
  padding: 5px 8px;
  cursor: pointer;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  user-select: none;
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::before {
  width: 14px;
  flex: 0 0 14px;
  color: var(--muted);
  content: ">";
  font-size: 11px;
  text-align: center;
  transform: rotate(0deg);
  transition: transform 120ms ease;
}

.tree details[open] > summary::before {
  transform: rotate(90deg);
}

.tree summary:hover {
  background: var(--surface-soft);
}

.document-node {
  border-bottom: 1px solid #edf0ef;
}

.document-summary {
  display: grid !important;
  grid-template-columns: 15px 58px minmax(0, 1fr) auto;
  min-height: 42px !important;
  padding: 5px 8px !important;
  align-items: center;
}

.document-summary::before {
  grid-column: 1;
}

.document-summary .doc-code {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.document-summary .doc-title {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-summary .module-count {
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.document-node.active-document > .document-summary {
  background: #edf6f5;
}

.module-node {
  min-width: 0;
}

.module-summary {
  display: grid !important;
  grid-template-columns: 14px minmax(64px, auto) minmax(0, 1fr) auto;
  min-height: 36px !important;
  padding: 4px 8px 4px calc(18px + var(--module-depth, 0) * 12px) !important;
  color: #3f494d;
  font-weight: 500 !important;
}

.module-summary::before {
  grid-column: 1;
}

.module-link {
  display: grid;
  grid-template-columns: minmax(64px, auto) minmax(0, 1fr) auto;
  width: 100%;
  min-height: 35px;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 4px calc(35px + var(--module-depth, 0) * 12px);
  color: #3f494d;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  cursor: pointer;
  text-align: left;
}

.module-link:hover,
.module-summary:hover {
  background: var(--surface-soft);
}

.module-link.active,
.module-node.active > .module-summary {
  color: #004e4c;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.module-code {
  overflow: hidden;
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-title {
  overflow: hidden;
  font-size: 11px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.module-page {
  color: var(--muted);
  font-size: 9px;
  white-space: nowrap;
}

.tree .outline-group {
  margin-left: 16px;
  border-left: 1px solid var(--surface-strong);
}

.document-link,
.outline-link {
  display: grid;
  width: 100%;
  min-height: 38px;
  padding: 5px 9px 5px 26px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  cursor: pointer;
  text-align: left;
}

.document-link:hover,
.outline-link:hover {
  background: var(--surface-soft);
}

.document-link.active {
  color: #004e4c;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.document-link .doc-code {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.document-link .doc-title {
  overflow: hidden;
  margin-top: 2px;
  font-size: 12px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outline-link {
  min-height: 30px;
  padding-left: calc(27px + var(--outline-depth, 0) * 12px);
  color: #475155;
  font-size: 11px;
  line-height: 1.25;
}

.search-panel.active {
  grid-template-rows: auto auto minmax(0, 1fr);
}

.search-form {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.search-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.search-field {
  display: flex;
  gap: 5px;
}

.search-field input,
.search-options select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #aeb7b6;
  border-radius: 4px;
}

.search-field input {
  flex: 1 1 auto;
}

.command-button {
  display: inline-flex;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--accent);
  border: 1px solid #005653;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

.command-button svg {
  width: 16px;
  height: 16px;
}

.command-button:hover {
  background: #005956;
}

.command-button:disabled {
  cursor: default;
  opacity: 0.48;
}

.search-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.search-form .check-option {
  display: flex;
  align-items: center;
  gap: 7px;
}

.check-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.search-summary {
  min-height: 38px;
  padding: 10px 12px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  line-height: 1.35;
}

.search-results {
  min-height: 0;
  overflow: auto;
  padding-bottom: 20px;
  scrollbar-gutter: stable;
}

.search-result {
  display: block;
  width: 100%;
  padding: 9px 12px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--surface-strong);
  cursor: pointer;
  text-align: left;
}

.search-result:hover {
  background: var(--surface-soft);
}

.search-result-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.search-result-head strong {
  overflow: hidden;
  color: var(--accent);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-result-head span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 10px;
}

.search-result p {
  display: -webkit-box;
  overflow: hidden;
  margin: 5px 0 0;
  font-size: 11px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.search-result mark {
  color: inherit;
  background: #ffe299;
}

.document-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: #c8cecd;
}

.document-header {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.document-heading {
  display: grid;
  min-width: 0;
}

.document-heading strong {
  overflow: hidden;
  font-size: 14px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-heading small {
  overflow: hidden;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-header .icon-button,
.pdf-toolbar .icon-button {
  color: #465054;
}

.document-header .icon-button:hover,
.pdf-toolbar .icon-button:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-strong);
}

.pdf-toolbar {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 3px;
  padding: 4px 9px;
  background: #eef1f0;
  border-bottom: 1px solid #aeb7b6;
}

.page-control {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 3px;
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.page-control input {
  width: 58px;
  height: 30px;
  padding: 0 5px;
  text-align: center;
  border: 1px solid #aeb7b6;
  border-radius: 3px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  margin: 0 5px;
  background: #c2c9c8;
}

.toolbar-spacer {
  flex: 1 1 auto;
}

.zoom-select {
  width: 92px;
  height: 30px;
  padding: 0 5px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #aeb7b6;
  border-radius: 3px;
  font-size: 11px;
}

.viewer-host {
  position: relative;
  min-height: 0;
}

.viewer-container {
  position: absolute;
  inset: 0;
  overflow: auto;
  background: #c9cfce;
}

.viewer-container .pdfViewer {
  padding: 18px 0 36px;
}

.viewer-container .pdfViewer .page {
  border: 1px solid #aeb4b3;
  box-shadow: var(--shadow);
}

.viewer-message {
  position: absolute;
  z-index: 12;
  top: 16px;
  left: 50%;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  color: #ffffff;
  background: rgb(38 50 54 / 94%);
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 4px;
  box-shadow: var(--shadow);
  font-size: 12px;
  transform: translateX(-50%);
}

.viewer-message[hidden] {
  display: none;
}

.viewer-message.error {
  background: var(--danger);
}

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgb(255 255 255 / 35%);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.viewer-message.error .spinner {
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.info-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border-left: 1px solid var(--line);
}

.info-section {
  min-height: 0;
  border-bottom: 1px solid var(--line);
}

.info-section .pane-heading.compact {
  min-height: 42px;
}

.document-status {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 8px 7px;
  margin: 0;
  padding: 11px 13px 15px;
  font-size: 11px;
}

.document-status dt {
  color: var(--muted);
}

.document-status dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.outline-section {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.outline-list {
  min-height: 0;
  overflow: auto;
  padding: 5px 0 18px;
  scrollbar-gutter: stable;
}

.outline-item {
  display: block;
  width: 100%;
  min-height: 31px;
  padding: 5px 9px 5px calc(11px + var(--outline-depth, 0) * 13px);
  color: #3f494d;
  background: transparent;
  border: 0;
  border-left: 3px solid transparent;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.25;
  text-align: left;
}

.outline-item:hover {
  background: var(--surface-soft);
}

.outline-item.active {
  color: #004e4c;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.outline-item strong,
.outline-item span,
.outline-item small {
  display: block;
}

.outline-item strong {
  color: var(--accent);
  font-size: 10px;
}

.outline-item span {
  margin-top: 2px;
}

.outline-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.empty-note {
  padding: 16px 12px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.ai-panel.active {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: #f4f6f5;
}

.ai-heading {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 13px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.ai-heading strong,
.ai-heading small {
  display: block;
}

.ai-heading strong {
  font-size: 13px;
}

.ai-heading small {
  max-width: 220px;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-messages {
  min-height: 0;
  overflow: auto;
  padding: 10px;
  scrollbar-gutter: stable;
}

.ai-empty {
  padding: 18px 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  text-align: center;
}

.ai-message {
  margin-bottom: 9px;
  padding: 9px 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.ai-message.user {
  margin-left: 20px;
  background: #e8f3f2;
  border-color: #bdd7d4;
}

.ai-message.assistant {
  margin-right: 8px;
  border-left: 3px solid var(--accent);
}

.ai-message.error {
  color: #7a260d;
  background: #fff4ef;
  border-color: #e7b9a9;
}

.ai-message > strong {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 10px;
  text-transform: uppercase;
}

.ai-message.user > strong,
.ai-message.error > strong {
  color: inherit;
}

.ai-answer {
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.ai-answer.streaming {
  white-space: pre-wrap;
}

.ai-answer.streaming::after {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 3px;
  background: var(--secondary);
  content: "";
  vertical-align: -0.12em;
  animation: ai-caret-blink 900ms steps(1, end) infinite;
}

@keyframes ai-caret-blink {
  0%, 48% { opacity: 1; }
  49%, 100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ai-answer.streaming::after {
    animation: none;
  }
}

/* Authenticated portal and persistent conversation workspace */
[hidden] {
  display: none !important;
}

.aircraft-gate {
  width: 100%;
  min-height: 100dvh;
  overflow: auto;
  background: #edf1f4;
}

.portal-topbar {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 24px;
  color: #ffffff;
  background: var(--topbar);
  border-bottom: 2px solid var(--accent);
  box-shadow: 0 3px 12px rgb(8 20 29 / 20%);
}

.portal-brand,
.portal-account,
.portal-account-button,
.portal-controlled-note {
  display: flex;
  align-items: center;
}

.portal-brand {
  gap: 11px;
}

.portal-brand > span:last-child,
.portal-user {
  display: grid;
  gap: 2px;
}

.portal-brand strong {
  font-size: 16px;
}

.portal-brand small,
.portal-user small {
  color: #b8c6d0;
  font-size: 11px;
}

.portal-account {
  gap: 8px;
}

.portal-user {
  min-width: 110px;
  margin-right: 4px;
  text-align: right;
}

.portal-user strong {
  overflow: hidden;
  max-width: 190px;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-account-button {
  min-height: 38px;
  gap: 7px;
  padding: 0 12px;
  color: #e9eff3;
  background: transparent;
  border: 1px solid #52636f;
  border-radius: 5px;
  cursor: pointer;
}

.portal-account-button:hover {
  color: #ffffff;
  background: rgb(255 255 255 / 9%);
  border-color: #84939d;
}

.portal-account-button svg,
.portal-controlled-note svg {
  width: 16px;
  height: 16px;
}

.aircraft-selector {
  width: min(1060px, calc(100% - 40px));
  margin: 0 auto;
  padding: 72px 0 40px;
}

.selector-heading {
  margin-bottom: 28px;
}

.selector-heading p {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
}

.selector-heading h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
  letter-spacing: 0;
}

.selector-heading > span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
}

.aircraft-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.aircraft-option {
  display: grid;
  min-height: 176px;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  grid-template-rows: 1fr auto;
  align-items: center;
  gap: 10px 16px;
  padding: 24px;
  color: var(--ink);
  text-align: left;
  text-decoration: none;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--accent);
  border-radius: 7px;
  box-shadow: 0 3px 12px rgb(24 42 54 / 8%);
  cursor: pointer;
}

.s76d-option {
  border-top-color: var(--secondary);
}

.aircraft-option:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 22px rgb(24 42 54 / 14%);
  transform: translateY(-1px);
}

.s76d-option:hover {
  border-color: var(--secondary);
}

.aircraft-option-icon {
  display: grid;
  width: 54px;
  height: 54px;
  grid-row: 1 / 3;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid #c2dced;
  border-radius: 6px;
}

.s76d-option .aircraft-option-icon {
  color: var(--secondary);
  background: var(--secondary-soft);
  border-color: #b9dcd9;
}

.aircraft-option-icon svg {
  width: 27px;
  height: 27px;
}

.aircraft-option-copy {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.aircraft-option-copy small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.aircraft-option-copy strong {
  font-size: 27px;
  line-height: 1.1;
}

.aircraft-option-copy > span {
  color: #45545f;
  font-size: 13px;
  line-height: 1.45;
}

.aircraft-option-meta {
  grid-column: 2;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.aircraft-option-arrow {
  width: 21px;
  height: 21px;
  grid-column: 3;
  grid-row: 1 / 3;
  color: #6f7e88;
}

.portal-controlled-note {
  gap: 8px;
  margin: 24px 0 0;
  color: #5e6b75;
  font-size: 12px;
}

@media (max-width: 760px) {
  .portal-topbar {
    align-items: flex-start;
    padding: 10px 12px;
  }

  .portal-account-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
  }

  .portal-account-button span,
  .portal-user,
  .portal-brand small {
    display: none;
  }

  .aircraft-selector {
    width: min(100% - 24px, 620px);
    padding-top: 38px;
  }

  .selector-heading h1 {
    font-size: 25px;
  }

  .aircraft-options {
    grid-template-columns: 1fr;
  }

  .aircraft-option {
    min-height: 156px;
    padding: 18px;
  }
}

.auth-gate {
  display: grid;
  width: 100%;
  min-height: 100dvh;
  padding: 28px;
  place-items: center;
  overflow: auto;
  background: #e9eef2;
}

.auth-shell {
  width: min(440px, 100%);
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow-raised);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 22px;
  color: #ffffff;
  background: var(--topbar);
}

.auth-brand > div {
  display: grid;
  gap: 2px;
}

.auth-brand strong {
  font-size: 18px;
}

.auth-brand small {
  color: #c8d2da;
  font-size: 12px;
}

.auth-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 22px 12px;
}

.auth-heading h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0;
}

.access-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.access-badge svg,
.controlled-note svg {
  width: 15px;
  height: 15px;
}

.auth-form {
  display: grid;
  gap: 8px;
  padding: 8px 22px 20px;
}

.auth-form label,
.dialog-fields label,
.admin-create-form label {
  color: #31404c;
  font-size: 12px;
  font-weight: 600;
}

.auth-form input,
.dialog-fields input,
.admin-create-form input,
.admin-create-form select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.auth-form input:focus,
.dialog-fields input:focus,
.admin-create-form input:focus,
.admin-create-form select:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(23 105 168 / 14%);
}

.auth-submit {
  min-height: 44px;
  margin-top: 8px;
  justify-content: center;
}

.auth-feedback,
.form-feedback {
  min-height: 18px;
  margin: 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.auth-feedback {
  padding: 0 22px 8px;
}

.form-feedback.success {
  color: #177245;
}

.controlled-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 12px 22px;
  color: #594000;
  background: #fff7dc;
  border-top: 1px solid #ead99f;
  font-size: 11px;
}

.account-menu {
  position: relative;
  flex: 0 0 auto;
}

.account-menu > summary {
  display: flex;
  min-width: 150px;
  height: 42px;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 5px;
  color: #ffffff;
  border: 1px solid rgb(255 255 255 / 22%);
  border-radius: 5px;
  cursor: pointer;
  list-style: none;
}

.account-menu > summary::-webkit-details-marker {
  display: none;
}

.account-menu > summary:hover,
.account-menu[open] > summary {
  background: rgb(255 255 255 / 10%);
}

.account-menu > summary > svg {
  width: 15px;
  height: 15px;
  margin-left: auto;
}

.account-avatar {
  display: grid;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  place-items: center;
  color: #ffffff;
  background: var(--secondary);
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
}

.account-summary {
  display: grid;
  min-width: 0;
}

.account-summary strong,
.account-summary small {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-summary strong {
  font-size: 12px;
}

.account-summary small {
  color: #bdc8d0;
  font-size: 10px;
}

.account-dropdown {
  position: absolute;
  z-index: 40;
  top: calc(100% + 7px);
  right: 0;
  display: grid;
  width: 230px;
  padding: 5px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-raised);
}

.account-dropdown button {
  display: flex;
  min-height: 40px;
  align-items: center;
  gap: 9px;
  padding: 0 10px;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}

.account-dropdown button:hover {
  background: var(--surface-strong);
}

.account-dropdown svg {
  width: 17px;
  height: 17px;
  color: var(--muted);
}

.ai-panel.active {
  display: block;
  overflow: hidden;
}

.ai-layout {
  display: grid;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.conversation-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  background: #edf2f5;
  border-right: 1px solid var(--line-strong);
}

.conversation-heading {
  display: flex;
  min-height: 62px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px 9px 15px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.conversation-heading strong {
  color: #20323f;
  font-size: 14px;
}

.conversation-heading .icon-button,
.ai-heading-actions .icon-button {
  color: var(--muted);
}

.conversation-heading .icon-button:hover:not(:disabled),
.ai-heading-actions .icon-button:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
}

.conversation-search {
  display: flex;
  align-items: center;
  height: 38px;
  margin: 10px;
  padding: 0 9px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 5px;
}

.conversation-search svg {
  width: 15px;
  height: 15px;
  flex: 0 0 auto;
  color: var(--muted);
}

.conversation-search input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 7px;
  background: transparent;
  border: 0;
  outline: 0;
}

.conversation-list {
  min-height: 0;
  padding: 0 7px 10px;
  overflow: auto;
  scrollbar-gutter: stable;
}

.conversation-item {
  display: grid;
  width: 100%;
  min-height: 58px;
  align-content: center;
  gap: 5px;
  margin-bottom: 3px;
  padding: 8px 10px;
  color: var(--ink);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  text-align: left;
}

.conversation-item:hover {
  background: #ffffff;
  border-color: var(--line);
}

.conversation-item.active {
  background: var(--accent-soft);
  border-color: #a9c9df;
}

.conversation-item strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item span {
  color: var(--muted);
  font-size: 10px;
}

.conversation-empty {
  padding: 22px 10px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.ai-chat-pane {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  background: #f3f6f8;
}

.ai-chat-pane .ai-heading {
  padding: 9px 18px;
}

.ai-heading-actions {
  display: flex;
  align-items: center;
  gap: 3px;
}

.ai-message.status-interrupted {
  border-color: #d5b04c;
}

.ai-message-status {
  display: block;
  margin-top: 8px;
  color: #795b00;
  font-size: 10px;
  font-weight: 600;
}

.form-dialog {
  width: min(520px, calc(100vw - 28px));
  max-height: calc(100dvh - 28px);
  padding: 0;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgb(9 22 31 / 30%);
}

.form-dialog::backdrop {
  background: rgb(18 30 39 / 58%);
}

.dialog-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin: 0;
  min-height: 0;
}

.dialog-shell > header {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 10px 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-shell h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.dialog-shell header small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.dialog-close {
  color: var(--muted);
}

.dialog-fields {
  display: grid;
  gap: 8px;
  padding: 18px;
  overflow: auto;
}

.dialog-shell > footer {
  display: flex;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--line);
}

.dialog-shell > footer .command-button {
  min-height: 40px;
}

.compact-dialog {
  min-height: 230px;
}

.admin-dialog {
  width: min(1080px, calc(100vw - 28px));
}

.admin-shell {
  grid-template-rows: auto auto auto auto minmax(180px, 1fr);
  max-height: calc(100dvh - 28px);
}

.admin-overview {
  display: grid;
  grid-template-columns: minmax(260px, 0.8fr) minmax(420px, 1.2fr);
  gap: 10px;
  padding: 12px 18px;
  background: #eef2f5;
  border-bottom: 1px solid var(--line);
}

.admin-status-card {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  min-width: 0;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.admin-status-card > span:nth-child(2) {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.admin-status-card small,
.admin-status-card em {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  font-style: normal;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-status-card strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-status-icon {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--muted);
  background: var(--surface-strong);
  border-radius: 50%;
}

.admin-status-icon.online {
  color: #147a48;
  background: #e2f5e9;
}

.admin-status-icon svg {
  width: 18px;
  height: 18px;
}

.server-card[data-level="normal"] .admin-status-icon {
  color: #147a48;
  background: #e2f5e9;
}

.server-card[data-level="busy"] {
  border-color: #dec277;
  background: #fffaf0;
}

.server-card[data-level="busy"] .admin-status-icon {
  color: #8d6200;
  background: #fff0c4;
}

.server-card[data-level="high"] {
  border-color: #e3a49f;
  background: #fff5f4;
}

.server-card[data-level="high"] .admin-status-icon {
  color: var(--danger);
  background: #fde5e3;
}

.admin-server-metrics {
  max-width: 260px;
  color: var(--muted);
  font: 600 10px/1.45 "Cascadia Mono", Consolas, monospace;
  text-align: right;
}

.admin-create-form {
  display: grid;
  grid-template-columns: 1fr 1.15fr 1.1fr 1.1fr 150px auto;
  align-items: end;
  gap: 9px;
  padding: 14px 18px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line);
}

.admin-create-form label {
  display: grid;
  gap: 5px;
}

.admin-create-form .command-button {
  min-height: 42px;
  white-space: nowrap;
}

.admin-feedback {
  min-height: 0;
  padding: 0 18px;
}

.admin-feedback:not(:empty) {
  padding-top: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.user-list {
  min-height: 0;
  overflow: auto;
}

.user-list-header,
.user-row {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) minmax(190px, 1fr) 145px 105px 46px;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
}

.user-list-header {
  position: sticky;
  z-index: 1;
  top: 0;
  min-height: 36px;
  color: var(--muted);
  background: #eef2f5;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.user-row {
  min-height: 66px;
  border-bottom: 1px solid var(--line);
}

.user-row:hover {
  background: #f8fafb;
}

.user-identity,
.user-activity {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.user-identity strong,
.user-activity span {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-name-line {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
}

.user-name-line > strong {
  min-width: 0;
}

.presence-badge {
  display: inline-flex;
  min-height: 18px;
  flex: 0 0 auto;
  align-items: center;
  padding: 0 6px;
  color: var(--muted);
  background: #edf1f4;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 700;
}

.presence-badge.online {
  color: #116b3d;
  background: #daf2e3;
}

.user-activity .online-text {
  color: #147a48;
  font-weight: 700;
}

.user-identity small,
.user-activity small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-row select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
}

.user-active-toggle {
  display: flex;
  min-height: 36px;
  align-items: center;
  gap: 7px;
  color: var(--ink);
  font-size: 11px;
  cursor: pointer;
}

.user-active-toggle input {
  width: 17px;
  height: 17px;
}

.row-action {
  color: var(--muted);
}

.row-action:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
}

.command-button.busy,
button.busy {
  cursor: wait;
  opacity: 0.65;
}

@media (max-width: 1120px) {
  .account-summary {
    display: none;
  }

  .account-menu > summary {
    min-width: 44px;
    justify-content: center;
  }

  .account-menu > summary > svg {
    display: none;
  }

  .admin-create-form {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .auth-gate {
    padding: 12px;
  }

  .auth-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .auth-form input,
  .dialog-fields input,
  .admin-create-form input,
  .admin-create-form select,
  .conversation-search input {
    min-height: 44px;
    font-size: 16px;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .account-menu {
    grid-column: 3;
  }

  .account-menu > summary {
    width: 46px;
    height: 46px;
    padding: 0;
  }

  .quick-find {
    grid-column: 1 / -1;
  }

  .topbar > .server-load-indicator {
    grid-column: 1 / -1;
    grid-row: 4;
    width: 100%;
    justify-content: center;
  }

  .portal-account .server-load-indicator[data-level="normal"] .server-load-label,
  .portal-account .server-load-indicator[data-level="unknown"] .server-load-label {
    display: none;
  }

  .admin-overview {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .admin-status-card {
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .admin-server-metrics {
    grid-column: 1 / -1;
    max-width: none;
    text-align: left;
  }

  .ai-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(190px, 28vh) minmax(560px, 1fr);
  }

  .conversation-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line-strong);
  }

  .conversation-heading {
    min-height: 52px;
  }

  .conversation-search {
    height: 46px;
    margin: 7px 10px;
  }

  .ai-chat-pane .ai-heading {
    padding: 8px 10px;
  }

  .form-dialog,
  .admin-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
  }

  .admin-create-form {
    grid-template-columns: 1fr;
    max-height: 52vh;
    overflow: auto;
  }

  .user-list-header {
    display: none;
  }

  .user-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    padding: 13px;
  }

  .user-activity {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .user-row select {
    grid-column: 1;
  }

  .user-active-toggle {
    grid-column: 2;
  }

  .row-action {
    grid-column: 2;
    grid-row: 1;
  }
}

.ai-sources {
  display: grid;
  gap: 5px;
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.ai-source {
  display: block;
  width: 100%;
  padding: 6px 7px;
  color: var(--ink);
  background: #f7f9f8;
  border: 1px solid #d7dddb;
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}

.ai-source:hover {
  background: var(--accent-soft);
  border-color: #9fc6c2;
}

.ai-source span,
.ai-source small {
  display: block;
  overflow-wrap: anywhere;
}

.ai-source span {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.ai-source small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
}

.ai-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  color: var(--muted);
  font-size: 11px;
}

.ai-pending .spinner {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

.ai-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  padding: 9px;
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.ai-compose-row {
  display: flex;
  grid-column: 1 / -1;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.ai-compose-row select {
  width: auto;
  min-width: 104px;
  height: 28px;
  padding: 0 24px 0 7px;
  font-size: 10px;
}

.ai-grounded {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 9px;
}

.ai-grounded svg {
  width: 13px;
  height: 13px;
  color: var(--accent);
}

.ai-composer textarea {
  width: 100%;
  min-height: 68px;
  max-height: 150px;
  padding: 8px;
  resize: vertical;
  color: var(--ink);
  background: #fff;
  border: 1px solid #b9c1bf;
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  line-height: 1.4;
}

.ai-composer textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgb(0 117 113 / 14%);
}

.ai-send {
  min-width: 62px;
  align-self: stretch;
  justify-content: center;
}

.ai-mode .ai-heading {
  padding-right: max(20px, calc((100% - 1080px) / 2));
  padding-left: max(20px, calc((100% - 1080px) / 2));
}

.ai-mode .ai-heading strong {
  font-size: 15px;
}

.ai-mode .ai-heading small {
  max-width: 480px;
  font-size: 11px;
}

.ai-mode .ai-messages {
  padding: 24px max(20px, calc((100% - 1080px) / 2));
}

.ai-mode .ai-message {
  margin-bottom: 16px;
  padding: 16px 18px;
}

.ai-mode .ai-message.user {
  max-width: 760px;
  margin-left: auto;
}

.ai-mode .ai-message.assistant {
  margin-right: 0;
}

.ai-mode .ai-message > strong {
  margin-bottom: 10px;
  font-size: 11px;
}

.ai-mode .ai-answer {
  font-size: 14px;
  line-height: 1.72;
  white-space: normal;
}

.ai-mode .ai-answer.streaming {
  white-space: pre-wrap;
}

.ai-answer h3,
.ai-answer h4 {
  margin: 18px 0 7px;
  color: #263235;
  letter-spacing: 0;
  line-height: 1.35;
}

.ai-answer h3 {
  font-size: 17px;
}

.ai-answer h4 {
  font-size: 15px;
}

.ai-answer p {
  margin: 0 0 10px;
}

.ai-answer ul,
.ai-answer ol {
  margin: 4px 0 13px;
  padding-left: 24px;
}

.ai-answer li {
  margin: 5px 0;
  padding-left: 2px;
}

.ai-answer .ai-callout {
  padding: 9px 11px;
  color: #4c3500;
  background: #fff6d8;
  border-left: 3px solid #d89b00;
}

.ai-citation {
  color: var(--accent);
  font-size: 0.9em;
  font-weight: 700;
  white-space: nowrap;
}

.ai-mode .ai-sources {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 15px;
  padding-top: 13px;
}

.ai-mode .ai-source {
  padding: 9px 10px;
}

.ai-mode .ai-source span {
  font-size: 11px;
}

.ai-mode .ai-source small {
  font-size: 11px;
}

.ai-mode .ai-composer {
  padding: 12px max(20px, calc((100% - 1080px) / 2));
}

.ai-mode .ai-composer textarea {
  min-height: 76px;
  font-size: 14px;
}

.ai-mode .ai-send {
  min-width: 86px;
}

.notice-dialog {
  width: min(520px, calc(100vw - 28px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid #8f999a;
  border-radius: 6px;
  box-shadow: 0 16px 50px rgb(0 0 0 / 28%);
}

.notice-dialog::backdrop {
  background: rgb(25 31 33 / 58%);
}

.notice-shell {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  padding: 20px;
}

.notice-symbol {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #3e2a00;
  background: var(--warning);
  border-radius: 4px;
}

.notice-symbol svg {
  width: 24px;
  height: 24px;
}

.notice-copy h2 {
  margin: 0;
  font-size: 18px;
}

.notice-copy p {
  margin: 8px 0 0;
  color: #465054;
  font-size: 13px;
  line-height: 1.55;
}

.notice-shell .acknowledge {
  grid-column: 2;
  justify-self: end;
}

/* UI/UX Pro Max: dense technical workspace refinement */
.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;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 12px;
  padding: 9px 12px;
  color: #ffffff;
  background: var(--accent);
  border-radius: 4px;
  transform: translateY(-150%);
  transition: transform 160ms ease-out;
}

.skip-link:focus {
  transform: translateY(0);
}

button,
a,
select,
input,
textarea {
  transition: color 160ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out, box-shadow 160ms ease-out, transform 100ms ease-out;
}

button:active:not(:disabled),
.icon-button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgb(23 105 168 / 24%);
  outline-offset: 1px;
  border-color: var(--accent);
}

.topbar {
  min-height: 60px;
  gap: 10px;
  padding: 8px 16px;
  background: var(--topbar);
  border-bottom: 1px solid #2d82bd;
  box-shadow: 0 3px 12px rgb(8 20 29 / 24%);
}

.brand {
  min-width: 205px;
  gap: 10px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  background: var(--accent);
  border-color: rgb(255 255 255 / 32%);
  border-radius: 6px;
  box-shadow: inset 0 0 0 1px rgb(0 0 0 / 8%);
}

.brand-copy strong {
  font-size: 16px;
  font-weight: 700;
}

.brand-copy small {
  color: #b8c6d0;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 5px;
}

.icon-button svg {
  width: 17px;
  height: 17px;
  stroke-width: 1.9;
}

.topbar .icon-button:hover:not(:disabled) {
  background: rgb(255 255 255 / 10%);
  border-color: rgb(255 255 255 / 22%);
}

.manual-switch {
  display: flex;
  max-width: min(520px, 46vw);
  height: 38px;
  overflow-x: auto;
  overflow-y: hidden;
  background: rgb(0 0 0 / 10%);
  border-color: #61717d;
  border-radius: 6px;
}

.manual-option {
  min-width: 62px;
  height: 36px;
  color: #d1d9df;
  border-right-color: #61717d;
  font-size: 12px;
  font-weight: 700;
}

.manual-option.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: inset 0 -2px 0 #79b7df;
}

.manual-option.external-reader::after {
  content: "↗";
  margin-left: 5px;
  color: #9fc0d6;
  font-size: 10px;
}

.quick-find {
  width: min(480px, 40vw);
  height: 40px;
  padding-left: 12px;
  background: #f9fbfc;
  border-color: #82919c;
  border-radius: 6px;
  box-shadow: 0 1px 2px rgb(0 0 0 / 12%);
}

.quick-find:focus-within {
  border-color: #6ab1df;
  box-shadow: 0 0 0 3px rgb(71 158 214 / 20%);
}

.quick-find input {
  height: 38px;
  font-size: 13px;
}

.quick-find input::placeholder,
.ai-composer textarea::placeholder,
.search-form input::placeholder {
  color: #87939d;
}

.quick-find .inline {
  width: 34px;
  height: 36px;
}

.workspace {
  grid-template-columns: minmax(280px, 320px) minmax(520px, 1fr) minmax(250px, 292px);
}

.navigation-pane {
  background: #f7f9fa;
  border-right-color: var(--line-strong);
}

.navigation-tabs {
  min-height: 46px;
  background: #edf1f4;
  border-bottom-color: var(--line-strong);
}

.navigation-tab {
  display: inline-flex;
  height: 46px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: #596875;
  border-bottom-width: 2px;
  font-size: 12px;
  font-weight: 650;
}

.navigation-tab svg {
  width: 16px;
  height: 16px;
  stroke-width: 1.9;
}

.navigation-tab:hover {
  color: var(--ink);
  background: #e2e8ec;
}

.navigation-tab.active {
  color: var(--accent);
  background: var(--surface);
  border-bottom-color: var(--accent);
}

.pane-heading {
  min-height: 58px;
  padding: 9px 12px;
  background: var(--surface);
  border-bottom-color: var(--line);
}

.pane-heading strong {
  color: #263540;
  font-size: 13px;
  font-weight: 700;
}

.pane-heading small {
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.tree {
  padding: 7px 0 20px;
  background: #f9fafb;
}

.tree > details > summary {
  min-height: 36px;
  padding: 7px 10px;
  color: #52616d;
  background: #f0f3f5;
  border-top: 1px solid #e2e7eb;
  border-bottom: 1px solid #e2e7eb;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.tree summary::before {
  color: #76848e;
}

.document-node {
  background: #ffffff;
  border-bottom-color: #e4e9ed;
}

.document-summary {
  grid-template-columns: 15px 62px minmax(0, 1fr) auto;
  min-height: 45px !important;
  padding: 6px 10px !important;
}

.document-summary .doc-code,
.module-code,
.outline-item strong,
.search-result-head span,
.page-control input {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.document-summary .doc-code {
  color: var(--accent);
  font-size: 10px;
}

.document-summary .doc-title {
  color: #283640;
  font-size: 12px;
  font-weight: 600;
}

.document-summary .module-count {
  min-width: 28px;
  padding: 2px 5px;
  color: #596976;
  background: #edf1f4;
  border-radius: 3px;
  font-size: 9px;
  text-align: center;
}

.document-node.active-document > .document-summary {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.module-link {
  min-height: 38px;
  color: #42515d;
  background: #ffffff;
  border-left-width: 3px;
  font-size: 11px;
}

.module-link:hover,
.module-summary:hover {
  color: var(--ink);
  background: #f0f5f8;
}

.module-link.active,
.module-node.active > .module-summary {
  color: #113f63;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.search-panel {
  background: #f7f9fa;
}

.search-form {
  padding: 14px 12px 12px;
  background: #ffffff;
  border-bottom-color: var(--line);
}

.search-form label > span {
  color: #53616d;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.search-field input,
.search-form select {
  min-height: 38px;
  border-color: var(--line-strong);
  border-radius: 5px;
  font-size: 12px;
}

.command-button {
  min-height: 38px;
  background: var(--accent);
  border-color: var(--accent-hover);
  border-radius: 5px;
  font-size: 12px;
}

.command-button:hover:not(:disabled) {
  background: var(--accent-hover);
}

.search-summary {
  min-height: 38px;
  padding: 10px 12px;
  color: #5d6a75;
  background: #f0f3f5;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.search-results {
  background: #ffffff;
}

.search-result {
  min-height: 74px;
  padding: 11px 12px;
  border-left: 3px solid transparent;
  border-bottom-color: #e4e9ed;
}

.search-result:hover {
  background: #f2f7fa;
  border-left-color: var(--accent);
}

.search-result-head strong {
  color: #203441;
  font-size: 11px;
  line-height: 1.4;
}

.search-result-head span {
  color: var(--accent);
  font-size: 9px;
}

.search-result p {
  color: #5a6670;
  font-size: 10px;
  line-height: 1.5;
}

.search-result mark {
  color: #3e2c00;
  background: #ffe7a2;
  border-radius: 2px;
}

.document-pane {
  background: #e7ecf0;
}

.document-header {
  min-height: 58px;
  padding: 8px 14px;
  background: #ffffff;
  border-bottom-color: var(--line);
}

.document-heading strong {
  color: #1d2c37;
  font-size: 14px;
  font-weight: 700;
}

.document-heading small {
  margin-top: 3px;
  color: #65727d;
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 9px;
  font-variant-numeric: tabular-nums;
}

.document-header .icon-button,
.pdf-toolbar .icon-button {
  color: #435460;
}

.document-header .icon-button:hover,
.pdf-toolbar .icon-button:hover:not(:disabled) {
  color: var(--accent);
  background: var(--accent-soft);
  border-color: #bfd7e8;
}

.pdf-toolbar {
  min-height: 48px;
  gap: 5px;
  padding: 6px 10px;
  background: #f8fafb;
  border-bottom-color: var(--line-strong);
  box-shadow: 0 1px 3px rgb(33 48 60 / 8%);
}

.page-control {
  height: 36px;
  background: #ffffff;
  border-color: var(--line-strong);
  border-radius: 5px;
}

.page-control input {
  height: 34px;
  font-size: 11px;
}

.page-control span {
  color: #687580;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
}

.zoom-select {
  height: 36px;
  color: #33434e;
  background: #ffffff;
  border-color: var(--line-strong);
  border-radius: 5px;
  font-size: 11px;
}

.viewer-host,
.viewer-container {
  background: #dfe5ea;
}

.viewer-container .pdfViewer {
  padding-top: 18px;
  padding-bottom: 32px;
}

.viewer-container .pdfViewer .page {
  border: 1px solid #b9c4cc;
  box-shadow: 0 6px 22px rgb(30 46 59 / 20%);
}

.viewer-message {
  color: #344651;
  background: rgb(255 255 255 / 96%);
  border-color: var(--line-strong);
  border-radius: 6px;
  box-shadow: var(--shadow-raised);
}

.info-pane {
  background: #f8fafb;
  border-left-color: var(--line-strong);
}

.info-section {
  background: #ffffff;
  border-bottom-color: var(--line);
}

.document-status {
  grid-template-columns: minmax(78px, auto) minmax(0, 1fr);
  gap: 8px 12px;
  padding: 14px 13px 17px;
}

.document-status dt {
  color: #73808b;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.document-status dd {
  color: #2f3e49;
  font-size: 11px;
  line-height: 1.4;
}

.outline-list {
  padding-top: 7px;
  background: #ffffff;
}

.outline-item {
  min-height: 38px;
  padding-top: 7px;
  padding-bottom: 7px;
  color: #46545f;
  border-left-width: 3px;
  font-size: 11px;
  line-height: 1.35;
}

.outline-item:hover {
  color: #263640;
  background: #f0f5f8;
}

.outline-item.active {
  color: #123f60;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.outline-item small {
  color: #78858f;
  font-size: 9px;
}

.ai-panel.active {
  background: #f3f6f8;
}

.ai-heading {
  min-height: 62px;
  background: #ffffff;
  border-bottom-color: var(--line-strong);
}

.ai-heading strong {
  color: #20323f;
  font-weight: 700;
}

.ai-heading small {
  color: #61707c;
  font-family: "Cascadia Mono", Consolas, monospace;
}

.ai-message {
  border-color: var(--line);
  box-shadow: 0 2px 8px rgb(31 48 61 / 6%);
}

.ai-message.user {
  background: var(--accent-soft);
  border-color: #bfd7e8;
}

.ai-message.assistant {
  border-left-color: var(--secondary);
}

.ai-message > strong,
.ai-citation,
.ai-source span {
  color: var(--secondary);
}

.ai-answer .ai-callout {
  color: #493400;
  background: #fff7dc;
  border-left-color: var(--warning);
}

.ai-source {
  background: #f8fafb;
  border-color: var(--line);
}

.ai-source:hover {
  background: var(--secondary-soft);
  border-color: #9bc9c6;
}

.ai-composer {
  background: #ffffff;
  border-top-color: var(--line-strong);
  box-shadow: 0 -4px 16px rgb(30 47 60 / 7%);
}

.ai-composer textarea {
  border-color: var(--line-strong);
  border-radius: 6px;
}

.ai-composer textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgb(23 105 168 / 15%);
}

.ai-grounded svg {
  color: var(--secondary);
}

.notice-dialog {
  border-color: var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 22px 60px rgb(9 22 31 / 30%);
}

.notice-symbol {
  color: #4a3300;
  background: #f4c85a;
}

/* Shared aircraft switch and AI composer controls. The AW189 reader uses the
   same dimensions, icon geometry and visible label. */
.aircraft-switch-button {
  display: inline-flex;
  width: auto;
  min-width: 108px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border-radius: 5px;
  white-space: nowrap;
}

.aircraft-switch-button span {
  font-size: 12px;
  font-weight: 600;
}

.ai-compose-controls {
  display: flex;
  min-width: 0;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-compose-field {
  display: inline-flex;
  min-width: 0;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
}

.ai-compose-field select {
  min-width: 132px;
  height: 30px;
  padding: 0 26px 0 8px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
}

.ai-send,
.ai-mode .ai-send {
  display: grid;
  min-width: 108px;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  align-content: center;
  column-gap: 7px;
  row-gap: 1px;
}

.ai-send > svg {
  grid-row: 1 / 3;
  align-self: center;
}

.ai-send > span,
.ai-send > kbd {
  grid-column: 2;
}

.ai-send > kbd {
  color: rgb(255 255 255 / 78%);
  background: transparent;
  border: 0;
  font: 500 8px/1.2 "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(235px, 275px) minmax(430px, 1fr);
  }

  .info-pane {
    display: none;
  }

  .brand {
    min-width: 160px;
  }
}

@media (max-width: 760px) {
  html,
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    min-height: 0;
    gap: 7px;
    padding: 8px;
    overflow: hidden;
  }

  .brand-mark,
  .icon-button,
  .manual-option {
    min-width: 44px;
    min-height: 44px;
  }

  .brand-mark {
    width: 44px;
    height: 44px;
  }

  .manual-switch {
    height: 46px;
  }

  .manual-option {
    height: 44px;
  }

  .brand {
    min-width: 0;
  }

  .history-tools {
    display: flex;
    grid-column: 2;
    grid-row: 1;
  }

  .history-tools .icon-button:not(#aircraftPortalButton) {
    display: none;
  }

  .manual-switch {
    width: 100%;
    max-width: none;
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
  }

  .manual-option {
    flex: 1 0 auto;
  }

  .account-menu {
    grid-column: 3;
    grid-row: 1;
  }

  .quick-find {
    grid-column: 1 / -1;
    grid-row: 3;
    width: 100%;
    min-width: 0;
    margin: 0;
    height: 46px;
  }

  .navigation-tabs,
  .navigation-tab {
    min-width: 0;
  }

  .navigation-tab span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .quick-find input,
  .search-field input,
  .search-form select,
  .ai-composer textarea {
    font-size: 16px;
  }

  .quick-find input {
    height: 44px;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(235px, 36vh) minmax(560px, 64vh);
    min-height: 795px;
  }

  .navigation-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .document-pane {
    min-height: 560px;
  }

  .document-header {
    min-height: 56px;
  }

  .pdf-toolbar {
    overflow-x: auto;
  }

  .pdf-toolbar .icon-button,
  .document-header .icon-button {
    width: 44px;
    height: 44px;
  }

  .page-control,
  .page-control input,
  .zoom-select,
  .command-button {
    min-height: 44px;
  }

  .navigation-tab {
    height: 48px;
    font-size: 11px;
  }

  .navigation-tab svg {
    width: 17px;
    height: 17px;
  }

  .viewer-container .pdfViewer {
    padding-top: 10px;
  }

  .search-options {
    grid-template-columns: 1fr;
  }

  .workspace.ai-mode {
    grid-template-rows: minmax(760px, 100vh);
    min-height: 760px;
  }

  .ai-mode .ai-messages {
    padding: 14px 10px;
  }

  .ai-mode .ai-message {
    padding: 12px;
  }

  .ai-mode .ai-sources {
    grid-template-columns: 1fr;
  }

  .ai-mode .ai-composer {
    padding: 9px;
  }

  .ai-compose-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .ai-compose-controls {
    width: 100%;
  }

  .ai-compose-field {
    flex: 1 1 100%;
  }

  .ai-compose-field select {
    min-width: 0;
    flex: 1;
  }

  .ai-composer,
  .ai-mode .ai-composer {
    grid-template-columns: minmax(0, 1fr);
  }

  .ai-send,
  .ai-mode .ai-send {
    width: 100%;
    min-height: 48px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
