:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-alt: #f9fafb;
  --line: #d7dce2;
  --line-strong: #aeb6c1;
  --text: #1f2328;
  --muted: #66717f;
  --accent: #d9002b;
  --accent-dark: #9f001f;
  --focus: #1663d8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  font-family: Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: 58px 1fr;
  width: 100%;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 230px;
  min-width: 210px;
}

.brand-mark {
  width: 6px;
  height: 34px;
  background: var(--accent);
}

.brand-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 18px;
}

.brand-subtitle {
  max-width: 190px;
  color: var(--muted);
  font-size: 11px;
  line-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbar {
  display: flex;
  align-items: end;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.server-load-indicator {
  display: inline-flex;
  min-height: 30px;
  align-self: end;
  align-items: center;
  gap: 7px;
  padding: 0 9px;
  color: var(--muted);
  background: #f1f4f6;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}

.server-load-dot {
  width: 8px;
  height: 8px;
  background: #87959d;
  border-radius: 50%;
}

.server-load-indicator[data-level="normal"] {
  color: #116b3d;
  background: #e5f5eb;
  border-color: #a9d8ba;
}

.server-load-indicator[data-level="normal"] .server-load-dot { background: #2aa567; }

.server-load-indicator[data-level="busy"] {
  color: #795500;
  background: #fff4cf;
  border-color: #dfc471;
}

.server-load-indicator[data-level="busy"] .server-load-dot { background: #d99a00; }

.server-load-indicator[data-level="high"] {
  color: #9d241c;
  background: #fde8e6;
  border-color: #e6aaa5;
}

.server-load-indicator[data-level="high"] .server-load-dot {
  background: #d43b31;
  animation: aw-server-load-pulse 1.2s ease-in-out infinite;
}

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

.tool-button,
.link-button,
.inline-button {
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.tool-button:hover,
.link-button:hover,
.inline-button:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.tool-button:focus-visible,
.link-button:focus-visible,
.inline-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.field,
.quick-search {
  display: grid;
  gap: 3px;
  min-width: 140px;
}

.field > span,
.quick-search > label {
  color: var(--muted);
  font-size: 11px;
  line-height: 12px;
}

.field select,
.quick-search input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  padding: 0 9px;
}

.quick-search {
  min-width: 260px;
  flex: 1;
}

.quick-search-control {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto 28px 28px auto;
  align-items: center;
  height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--panel);
  overflow: hidden;
}

.quick-search-control:focus-within {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.quick-search-control input {
  min-width: 0;
  border: 0;
  border-radius: 0;
  outline: 0;
}

.quick-search-count {
  min-width: 42px;
  padding: 0 5px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
  white-space: nowrap;
}

.inline-button {
  min-width: 28px;
  width: auto;
  height: 32px;
  padding: 0 7px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
}

.inline-button:disabled {
  color: #aeb6c1;
  cursor: default;
}

.inline-button.search-command {
  min-width: 46px;
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(360px, 1fr) minmax(210px, 280px);
  gap: 0;
}

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

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

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

.navigation-tab {
  min-width: 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.navigation-tab:hover {
  color: var(--text);
  background: #f0f2f4;
}

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

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

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

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

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

.full-search-form {
  display: grid;
  gap: 7px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.search-form-field {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: var(--text);
  font-size: 12px;
}

.search-form-field > span {
  color: var(--text);
}

.search-form-field input,
.search-form-field select {
  min-width: 0;
  width: 100%;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: var(--panel);
  color: var(--text);
}

.search-query-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
}

.search-query-control input {
  border-radius: 3px 0 0 3px;
}

.search-submit {
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line-strong);
  border-left: 0;
  border-radius: 0 3px 3px 0;
  background: var(--panel-alt);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.case-option {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  font-size: 12px;
  cursor: pointer;
}

.case-option input {
  width: 15px;
  height: 15px;
  margin: 0;
}

.search-results-summary {
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
  font-size: 12px;
  font-weight: 700;
}

.search-results {
  min-height: 0;
  display: grid;
  grid-template-rows: 31px minmax(0, 1fr);
  overflow: hidden;
}

.search-result-header,
.search-result-row {
  display: grid;
  grid-template-columns: 78px minmax(120px, 1fr) minmax(96px, 0.72fr);
  align-items: center;
}

.search-result-header {
  border-bottom: 1px solid var(--line-strong);
  background: var(--panel-alt);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
}

.search-result-header span,
.search-result-row span {
  min-width: 0;
  padding: 0 6px;
  border-right: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.search-result-row {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 0;
  border-bottom: 1px solid #edf0f2;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  font-size: 11px;
  cursor: pointer;
}

.search-result-row:hover {
  background: #fff3f5;
}

.search-result-row.active {
  background: #f6e8eb;
  box-shadow: inset 3px 0 var(--accent);
}

.pane-header,
.document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel-alt);
}

.pane-header {
  padding: 8px 10px;
}

.pane-header.compact {
  min-height: 34px;
  padding: 7px 10px;
}

.pane-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.pane-count {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.tree {
  overflow: auto;
  padding: 6px 0 14px;
}

.tree details {
  margin: 0;
}

.tree summary {
  list-style: none;
  cursor: pointer;
  min-height: 26px;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  color: var(--text);
  font-size: 12px;
  line-height: 15px;
}

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

.tree summary::before {
  content: "+";
  width: 14px;
  color: var(--muted);
  flex: 0 0 14px;
}

.tree details[open] > summary::before {
  content: "-";
}

.tree .level-1 > summary {
  font-weight: 700;
}

.tree .level-2 > summary {
  padding-left: 18px;
}

.tree .level-3 > summary {
  padding-left: 32px;
}

.doc-link {
  width: 100%;
  display: grid;
  gap: 2px;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 5px 8px 5px 48px;
  cursor: pointer;
}

.doc-link:hover {
  background: #fff3f5;
}

.doc-link.active {
  border-left-color: var(--accent);
  background: #f6e8eb;
}

.doc-link .doc-name {
  font-size: 12px;
  line-height: 15px;
}

.doc-link .doc-code {
  color: var(--muted);
  font-size: 11px;
  line-height: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-pane {
  display: grid;
  grid-template-rows: 50px 1fr;
  min-width: 0;
}

.document-header {
  padding: 7px 10px;
}

.document-title-wrap {
  min-width: 0;
}

.document-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-meta {
  color: var(--muted);
  font-size: 11px;
  line-height: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.document-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.figure-back-button {
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
}

.figure-back-button[hidden] {
  display: none;
}

#viewer {
  width: 100%;
  height: 100%;
  border: 0;
  background: #ffffff;
}

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

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

.status-list {
  margin: 0;
  padding: 8px 10px 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 10px;
  font-size: 12px;
}

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

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

.figure-list {
  overflow: auto;
  height: calc(100% - 35px);
  padding: 6px 0 12px;
}

.figure-item {
  display: grid;
  gap: 2px;
  width: 100%;
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  text-align: left;
  padding: 7px 10px;
}

.figure-title {
  color: var(--text);
  font-size: 12px;
  line-height: 15px;
}

.figure-file {
  color: var(--muted);
  font-size: 11px;
  line-height: 13px;
  overflow-wrap: anywhere;
}

.empty-note,
.loading-note {
  color: var(--muted);
  font-size: 12px;
  padding: 12px;
}

.raw-document {
  min-height: 100%;
  padding: 18px;
  background: #ffffff;
  color: var(--text);
}

.raw-document h1 {
  margin: 0 0 10px;
  font-size: 18px;
}

.raw-document p {
  color: var(--muted);
  font-size: 13px;
}

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

.safety-dialog {
  width: min(410px, calc(100vw - 28px));
  max-width: none;
  max-height: min(620px, calc(100vh - 40px));
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.28);
  overflow: hidden;
}

.safety-dialog::backdrop {
  background: rgba(31, 35, 40, 0.32);
}

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

.safety-dialog-frame {
  min-height: 150px;
  max-height: min(500px, calc(100vh - 108px));
  margin: 8px 8px 0;
  padding: 7px;
  border: 7px solid transparent;
  overflow: hidden;
}

.safety-dialog-frame.warning {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(135deg, #e0002b 0 8px, #ffffff 8px 16px) border-box;
}

.safety-dialog-frame.caution {
  background:
    linear-gradient(#ffffff, #ffffff) padding-box,
    repeating-linear-gradient(135deg, #f2d600 0 8px, #111111 8px 16px) border-box;
}

.safety-dialog-content {
  max-height: calc(min(500px, 100vh - 108px) - 28px);
  padding: 2px 8px 8px;
  background: #ffffff;
  color: #111111;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
  line-height: 1.25;
  overflow: auto;
}

.safety-dialog-content > div {
  max-width: 100%;
}

.safety-dialog-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  border-top: 1px solid var(--line);
  background: var(--panel-alt);
}

.safety-dialog-ok {
  min-width: 76px;
  height: 30px;
  border: 2px solid var(--accent);
  border-radius: 4px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.safety-dialog-ok:hover,
.safety-dialog-ok:focus-visible {
  background: #fff3f5;
  outline: 0;
}

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

  .info-pane {
    display: none;
  }
}

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

  .app-shell {
    min-height: 100%;
    height: auto;
    grid-template-rows: auto 1fr;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .brand {
    width: auto;
  }

  .toolbar {
    flex-wrap: wrap;
  }

  .field,
  .quick-search {
    min-width: 160px;
    flex: 1 1 180px;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(220px, 40vh) minmax(520px, 60vh);
  }

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

  .document-pane {
    min-height: 520px;
  }
}
.portal-switch {
  display: inline-flex;
  min-width: 108px;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 11px;
  border-radius: 5px;
  text-decoration: none;
  white-space: nowrap;
}

.portal-switch svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

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

.engine-manual-link {
  min-width: auto;
  padding: 0 10px;
  text-decoration: none;
  white-space: nowrap;
}

.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;
}

body.ai-standalone #contentsTab,
body.ai-standalone #searchTab {
  display: none;
}

body.aw-ai-active .topbar {
  justify-content: space-between;
}

body.aw-ai-active .toolbar {
  flex: 0 0 auto;
  align-items: center;
}

body.aw-ai-active .toolbar > :not(.portal-switch):not(.server-load-indicator) {
  display: none;
}

.aw-ai-panel.active {
  display: block;
  min-height: 0;
  overflow: hidden;
  background: #eef2f5;
}

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

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

.aw-conversation-heading,
.aw-ai-heading,
.aw-ai-compose-row,
.aw-ai-heading-actions {
  display: flex;
  align-items: center;
}

.aw-conversation-heading {
  min-height: 58px;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px 9px 15px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

.aw-icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  color: #485562;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
}

.aw-icon-button:hover:not(:disabled) {
  color: var(--accent-dark);
  border-color: var(--accent);
}

.aw-icon-button:disabled {
  color: #a6adb5;
  cursor: default;
}

.aw-conversation-search {
  margin: 10px;
}

.aw-conversation-search input {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
}

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

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

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

.aw-conversation-item.active {
  background: #fff1f4;
  border-color: #e4a5b2;
}

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

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

.aw-conversation-empty {
  padding: 22px 10px;
  text-align: center;
}

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

.aw-ai-heading {
  min-height: 58px;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

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

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

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

.aw-ai-heading-actions {
  gap: 4px;
}

.aw-ai-messages {
  min-height: 0;
  padding: 18px clamp(14px, 3vw, 42px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.aw-ai-empty {
  max-width: 680px;
  margin: 42px auto;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.aw-ai-message {
  max-width: 980px;
  margin: 0 auto 12px;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.aw-ai-message.user {
  margin-left: max(40px, calc((100% - 900px) / 2 + 80px));
  background: #f1f4f7;
}

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

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

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

.aw-ai-model-badge {
  display: inline-flex;
  margin-left: 8px;
  padding: 2px 7px;
  color: #6f2333;
  background: #fff1f4;
  border: 1px solid #e5b1bc;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  vertical-align: middle;
}

.aw-ai-answer {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.62;
}

.aw-ai-answer p,
.aw-ai-answer ul,
.aw-ai-answer ol,
.aw-ai-answer h3,
.aw-ai-answer h4 {
  margin: 0 0 8px;
}

.aw-ai-answer ul,
.aw-ai-answer ol {
  padding-left: 24px;
}

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

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

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

.aw-ai-callout {
  padding: 8px 10px;
  background: #fff8d9;
  border-left: 3px solid #c49a00;
  font-weight: 600;
}

.aw-ai-citation {
  color: var(--focus);
  font-weight: 700;
}

.aw-ai-sources {
  display: grid;
  gap: 5px;
  margin-top: 10px;
}

.aw-ai-source {
  display: grid;
  gap: 3px;
  width: 100%;
  padding: 7px 9px;
  color: var(--text);
  background: #f7f8fa;
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  text-align: left;
}

.aw-ai-source:hover {
  border-color: var(--accent);
}

.aw-ai-source:focus-visible {
  border-color: var(--focus);
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.aw-ai-source small {
  color: var(--muted);
  font-size: 10px;
}

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

.aw-ai-pending {
  display: flex;
  width: fit-content;
  align-items: center;
  gap: 8px;
  margin: 0 auto 12px;
  color: var(--muted);
  font-size: 11px;
}

.aw-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid #c7cdd3;
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: aw-spin 700ms linear infinite;
}

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

.aw-ai-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  padding: 10px 18px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.aw-ai-compose-row {
  grid-column: 1 / -1;
  justify-content: space-between;
  gap: 8px;
}

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

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

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

.aw-ai-grounded {
  color: #24643a;
  font-size: 10px;
  font-weight: 700;
}

.aw-ai-composer textarea {
  width: 100%;
  min-height: 72px;
  max-height: 180px;
  resize: vertical;
  padding: 9px 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  font: inherit;
  line-height: 1.45;
}

.aw-ai-send {
  display: grid;
  width: 108px;
  min-height: 42px;
  align-self: end;
  align-content: center;
  grid-template-rows: auto auto;
  gap: 1px;
  color: #ffffff;
  background: var(--accent-dark);
  border: 1px solid var(--accent-dark);
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
}

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

.aw-ai-send:disabled {
  opacity: 0.55;
  cursor: default;
}

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

@media (max-width: 760px) {
  .portal-switch {
    height: 44px;
    min-height: 44px;
  }

  body.aw-ai-active {
    overflow: hidden;
  }

  body.aw-ai-active .app-shell {
    height: 100dvh;
    min-height: 0;
  }

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

  .aw-ai-layout {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(150px, 28%) minmax(0, 1fr);
  }

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

  .aw-ai-messages {
    padding: 12px 10px;
  }

  .aw-ai-message.user {
    margin-left: 24px;
  }

  .aw-ai-heading,
  .aw-ai-composer {
    padding-right: 10px;
    padding-left: 10px;
  }

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

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

  .aw-ai-compose-field {
    flex: 1 1 150px;
  }

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