:root {
  color-scheme: dark;
  --topbar: 68px;
  --bg: #080a0f;
  --bg-soft: #0d1017;
  --panel: rgba(14, 17, 25, 0.82);
  --panel-solid: #10131b;
  --panel-elevated: rgba(20, 24, 34, 0.94);
  --surface: rgba(255, 255, 255, 0.045);
  --surface-strong: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.09);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #f5f6fa;
  --text-soft: #b6bac5;
  --text-muted: #9096a3;
  --violet: #9a6cff;
  --violet-strong: #7c3aed;
  --cyan: #43d8f5;
  --green: #63e6a7;
  --contract: #f4bd57;
  --contract-strong: #d58a17;
  --red: #ff7b94;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
  --radius-xl: 26px;
  --radius-lg: 19px;
  --radius-md: 14px;
  --radius-surface: 12px;
  --radius-control: 10px;
  --radius-marker: 8px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --display: "Manrope", "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f7;
  --bg-soft: #f7f8fc;
  --panel: rgba(250, 251, 255, 0.86);
  --panel-solid: #fbfcff;
  --panel-elevated: rgba(255, 255, 255, 0.96);
  --surface: rgba(33, 38, 52, 0.045);
  --surface-strong: rgba(33, 38, 52, 0.075);
  --line: rgba(25, 30, 43, 0.1);
  --line-strong: rgba(25, 30, 43, 0.17);
  --text: #141722;
  --text-soft: #505665;
  --text-muted: #626c7a;
  --violet: #7651df;
  --violet-strong: #6134d5;
  --cyan: #078aa4;
  --green: #13815a;
  --contract: #a96307;
  --contract-strong: #8c4c00;
  --red: #d74161;
  --shadow: 0 24px 70px rgba(30, 38, 58, 0.18);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  overflow: hidden;
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

::selection {
  background: rgba(139, 92, 246, 0.35);
}

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.aurora {
  position: fixed;
  z-index: 0;
  width: 44vw;
  height: 44vw;
  border-radius: 999px;
  filter: blur(110px);
  opacity: 0.13;
  pointer-events: none;
  animation: drift 16s ease-in-out infinite alternate;
}

.aurora-one {
  top: -28vw;
  right: -12vw;
  background: #7c3aed;
}

.aurora-two {
  bottom: -34vw;
  left: 18vw;
  background: #06b6d4;
  animation-delay: -7s;
}

html[data-theme="light"] .aurora {
  opacity: 0.1;
}

@keyframes drift {
  to { transform: translate3d(6vw, 3vw, 0) scale(1.09); }
}

.app {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(100dvh - var(--topbar));
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar);
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 74%, transparent);
  backdrop-filter: blur(28px) saturate(145%);
}

.brand-cluster,
.top-actions,
.brand,
.brand-wordmark,
.source-chip,
.toolbar-button,
.source-status,
.source-controls,
.filter-row,
.select-all,
.source-footer,
.chat-header,
.connection-badge,
.eyebrow,
.fact-row,
.composer-footer,
.selection-hint,
.inspector-meta,
.inspector-actions,
.dialog-header,
.setting-section,
.switch-row,
.dialog-footer,
.primary-button,
.secondary-button,
.danger-ghost,
.answer-meta,
.answer-actions,
.citation-link,
.user-label,
.answer-label {
  display: flex;
  align-items: center;
}

.brand-cluster {
  min-width: 0;
  gap: 14px;
}

.brand {
  min-width: 0;
  gap: 11px;
}

.brand-logo {
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 12px;
  overflow: hidden;
  background: transparent;
  box-shadow: none;
}

.brand-logo img {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-wordmark {
  align-items: flex-start;
  flex-direction: column;
  line-height: 1.15;
}

.brand-wordmark strong {
  font-family: var(--display);
  font-size: 0.92rem;
  letter-spacing: 0.035em;
  white-space: nowrap;
}

.brand-wordmark small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.2;
  white-space: nowrap;
}

.source-chip,
.connection-badge {
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.79rem;
}

.source-chip {
  padding: 7px 10px;
}

.live-dot {
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 12px color-mix(in srgb, var(--green) 75%, transparent);
}

.live-dot.is-offline {
  background: var(--red);
  box-shadow: 0 0 12px color-mix(in srgb, var(--red) 60%, transparent);
}

.live-dot.is-pending {
  background: var(--amber, #f5b942);
  box-shadow: 0 0 12px color-mix(in srgb, var(--amber, #f5b942) 65%, transparent);
}

.top-actions {
  gap: 8px;
}

.program-top-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 3px;
  margin: 0 12px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.program-top-nav button {
  min-height: 34px;
  padding: 0 11px;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 650;
  white-space: nowrap;
}

.program-top-nav button:hover {
  color: var(--text);
}

.program-top-nav button.is-active {
  background: color-mix(in srgb, var(--violet) 19%, var(--panel-solid));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--violet) 31%, transparent);
  color: var(--text);
}

.program-top-nav button.has-pending-answer {
  position: relative;
  padding-right: 25px;
}

.program-top-nav button.has-pending-answer::after {
  position: absolute;
  top: 50%;
  right: 10px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 16%, transparent);
  content: "";
  transform: translateY(-50%);
  animation: pending-answer-pulse 1.7s ease-in-out infinite;
}

@keyframes pending-answer-pulse {
  50% { opacity: .45; box-shadow: 0 0 0 5px color-mix(in srgb, var(--violet) 8%, transparent); }
}

@media (prefers-reduced-motion: reduce) {
  .program-top-nav button.has-pending-answer::after { animation: none; }
}

.icon-button,
.toolbar-button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--surface);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.icon-button:hover,
.toolbar-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.icon-button:active,
.toolbar-button:active,
.filter-pill:active,
.send-button:active,
.suggestions button:active {
  transform: scale(0.97);
}

.icon-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 13px;
}

.toolbar-button {
  gap: 9px;
  min-height: 44px;
  padding: 0 13px;
  border-radius: 13px;
  color: var(--text-soft);
  font-size: 0.88rem;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--violet) 38%, transparent);
  outline-offset: 2px;
}

.toolbar-count {
  display: grid;
  min-width: 21px;
  height: 21px;
  padding: 0 5px;
  place-items: center;
  border-radius: 999px;
  background: color-mix(in srgb, var(--violet) 17%, transparent);
  color: var(--violet);
  font-size: .67rem;
  font-weight: 700;
}

.chat-trigger {
  position: relative;
}

.contract-trigger {
  position: relative;
  border-color: color-mix(in srgb, var(--contract) 28%, var(--line));
  background: color-mix(in srgb, var(--contract) 7%, var(--surface));
}

.contract-trigger > svg {
  color: var(--contract);
}

.contract-trigger.has-contract {
  border-color: color-mix(in srgb, var(--contract) 48%, var(--line));
}

.contract-toolbar-status {
  padding: 3px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--contract) 14%, transparent);
  color: var(--contract);
  font-size: .63rem;
  font-weight: 700;
}

kbd {
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 0.72rem;
}

.avatar {
  display: grid;
  width: auto;
  min-width: 76px;
  height: 44px;
  place-items: center;
  margin-left: 3px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  color: var(--text-soft);
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 650;
  box-shadow: none;
}

.account-button {
  width: auto;
  min-width: 76px;
  padding: 0 12px;
  cursor: pointer;
}

.account-button:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
}

.account-button span {
  max-width: 132px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-button .account-glyph {
  display: none;
}

.account-button.is-authenticated {
  border-color: color-mix(in srgb, var(--cyan) 55%, var(--line));
  color: var(--text);
}

.theme-icon-sun {
  display: none;
}

html[data-theme="light"] .theme-icon-moon {
  display: none;
}

html[data-theme="light"] .theme-icon-sun {
  display: block;
}

.source-toggle {
  display: grid;
}

.chat-scrim {
  position: fixed;
  inset: var(--topbar) 0 0;
  z-index: 38;
  background: rgba(1, 3, 7, .58);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(4px);
  transition: opacity 180ms ease;
}

.chat-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

.chat-panel {
  position: fixed;
  z-index: 42;
  top: var(--topbar);
  bottom: 0;
  left: 0;
  display: flex;
  width: min(390px, 92vw);
  min-height: 0;
  flex-direction: column;
  padding: 22px 16px 16px;
  border-right: 1px solid var(--line-strong);
  background: var(--panel-elevated);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(-104%);
  transition: transform 220ms cubic-bezier(.22,.8,.22,1), opacity 180ms ease;
  backdrop-filter: blur(28px) saturate(140%);
}

.chat-panel.is-open {
  opacity: 1;
  transform: translateX(0);
}

.chat-panel-heading {
  align-items: flex-start;
  padding-bottom: 12px;
}

.new-chat-button,
.source-add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border: 1px solid color-mix(in srgb, var(--violet) 32%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--violet) 11%, var(--surface));
  color: var(--text);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
}

.new-chat-button {
  width: 100%;
  margin-bottom: 10px;
}

.new-chat-button svg,
.source-add-button svg {
  width: 17px;
  height: 17px;
  color: var(--violet);
}

.source-add-button {
  min-height: 44px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  font-size: .74rem;
}

.upload-drop-target {
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.upload-drop-target.is-dragover,
.contract-empty.is-dragover {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--cyan) 15%, var(--surface));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cyan) 16%, transparent), 0 12px 30px color-mix(in srgb, var(--cyan) 12%, transparent);
}

.source-add-button.is-dragover {
  transform: translateY(-1px);
}

.chat-list {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
}

.chat-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  margin: 2px 0;
  border-radius: 14px;
}

.chat-row.is-active {
  background: color-mix(in srgb, var(--violet) 12%, var(--surface));
}

.chat-select {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 58px;
  padding: 8px 9px;
  border-radius: 14px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.chat-select:hover {
  background: var(--surface);
}

.chat-avatar {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--violet) 28%, var(--line));
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(154,108,255,.17), rgba(67,216,245,.08));
  color: var(--violet);
  font-size: .66rem;
  font-weight: 700;
}

.chat-copy {
  min-width: 0;
}

.chat-copy strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-copy strong {
  font-size: .8rem;
  font-weight: 650;
}

.chat-copy small {
  display: block;
  margin-top: 2px;
  color: var(--text-muted);
  font-size: .68rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
  white-space: normal;
}

.chat-role-details {
  margin: 0 8px 7px 57px;
}

.chat-role-details summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 0 5px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .67rem;
  list-style: none;
}

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

.chat-role-details summary::before {
  content: "+";
  color: var(--violet);
  font-size: .8rem;
  font-weight: 700;
}

.chat-role-details[open] summary::before {
  content: "−";
}

.chat-role-details p {
  margin: 0 0 8px;
  color: var(--text-soft);
  font-size: .72rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.chat-message-count {
  min-width: 20px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-muted);
  font-size: .62rem;
  text-align: center;
}

.chat-delete,
.source-delete {
  display: grid;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  place-items: center;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.chat-delete:hover,
.source-delete:hover {
  background: color-mix(in srgb, var(--red) 10%, transparent);
  color: var(--red);
}

.chat-delete svg,
.source-delete svg {
  width: 16px;
  height: 16px;
}

.chat-panel-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 11px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: .69rem;
}

.team-memory-wrap {
  position: relative;
  flex: 0 0 auto;
  margin-top: 8px;
}

.team-memory-card {
  flex: 0 0 auto;
  margin-top: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 76%, transparent);
}

.team-memory-card > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-right: 34px;
  cursor: pointer;
  list-style: none;
}

.team-memory-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  border-color: transparent;
  background: var(--surface-strong);
  color: var(--text-soft);
}

.team-memory-close svg {
  width: 14px;
  height: 14px;
}

.team-memory-card > summary::-webkit-details-marker {
  display: none;
}

.team-memory-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: .76rem;
  font-weight: 650;
}

.team-memory-title svg {
  width: 16px;
  height: 16px;
  color: var(--violet);
}

.team-memory-count {
  min-width: 22px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-muted);
  font-size: .62rem;
  text-align: center;
}

.team-memory-card > p {
  margin: 8px 0;
  color: var(--text-muted);
  font-size: .66rem;
  line-height: 1.45;
}

.team-memory-preview {
  max-height: 88px;
  margin-bottom: 9px;
  overflow-y: auto;
  color: var(--text-soft);
  font-size: .7rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.team-memory-card label {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: .64rem;
}

.team-memory-card textarea {
  display: block;
  width: 100%;
  min-height: 54px;
  resize: vertical;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: 0;
  background: var(--surface);
  font-size: .72rem;
  line-height: 1.4;
}

.team-memory-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 7px;
}

.team-memory-actions button {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 9px;
  background: var(--surface-strong);
  color: var(--text-soft);
  cursor: pointer;
  font-size: .66rem;
}

.team-memory-actions button:first-child {
  background: color-mix(in srgb, var(--violet) 22%, var(--surface));
  color: var(--text);
}

.team-memory-actions button:hover {
  filter: brightness(1.12);
}

.team-memory-card > small {
  display: block;
  margin-top: 5px;
  color: var(--text-muted);
  font-size: .61rem;
}

.chat-panel-note svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--violet);
}

.layout {
  display: grid;
  grid-template-columns: 318px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
}

@media (min-width: 1101px) {
  .layout {
    transition: grid-template-columns 220ms cubic-bezier(.22,.8,.22,1);
  }

  .layout.is-sources-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .layout.is-sources-collapsed .sources-panel {
    visibility: hidden;
    overflow: hidden;
    padding: 0;
    border-right-width: 0;
    opacity: 0;
    pointer-events: none;
  }

  .layout.is-sources-collapsed .conversation-inner,
  .layout.is-sources-collapsed .welcome-card,
  .layout.is-sources-collapsed .message-row {
    width: min(1040px, calc(100% - 64px));
  }

  .layout.is-sources-collapsed .composer,
  .layout.is-sources-collapsed .fine-print {
    width: min(1040px, 100%);
  }
}

.sources-panel {
  --source-radius-surface: var(--radius-surface);
  --source-radius-control: var(--radius-control);
  --source-radius-marker: var(--radius-marker);
  position: relative;
  z-index: 18;
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  padding: 24px 18px 16px;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(28px) saturate(135%);
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 5px 15px;
}

.panel-heading-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.panel-heading h2,
.chat-header h1,
.inspector-header h2,
.dialog-header h2 {
  margin: 3px 0 0;
  font-family: var(--display);
  letter-spacing: -0.035em;
}

.panel-heading h2 {
  font-size: 1.36rem;
}

.eyebrow {
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.105em;
  text-transform: uppercase;
}

.eyebrow svg {
  width: 14px;
  height: 14px;
  color: var(--violet);
}

.close-panel {
  display: none;
}

.contract-source-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin: 0 0 13px;
  padding: 11px;
  border: 1px solid color-mix(in srgb, var(--contract) 34%, var(--line));
  border-radius: var(--source-radius-surface);
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--contract) 10%, transparent), transparent 72%),
    var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.contract-source-card:hover {
  border-color: color-mix(in srgb, var(--contract) 62%, var(--line));
  background:
    linear-gradient(105deg, color-mix(in srgb, var(--contract) 16%, transparent), transparent 76%),
    var(--surface-strong);
}

.contract-source-card:active {
  transform: scale(.985);
}

.contract-source-card.has-contract .contract-source-icon {
  background: color-mix(in srgb, var(--contract) 18%, var(--panel-solid));
  box-shadow: 0 0 20px color-mix(in srgb, var(--contract) 16%, transparent);
}

.contract-source-icon,
.contract-file-icon,
.contract-empty-seal {
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--contract) 42%, var(--line));
  background: color-mix(in srgb, var(--contract) 11%, var(--panel-solid));
  color: var(--contract);
}

.contract-source-icon {
  width: 40px;
  height: 43px;
  border-radius: var(--source-radius-control);
}

.contract-source-icon svg {
  width: 19px;
  height: 19px;
}

.contract-source-copy,
.contract-file-copy {
  min-width: 0;
}

.contract-source-copy strong,
.contract-source-copy small,
.contract-file-copy strong,
.contract-file-copy small {
  display: block;
}

.contract-source-copy strong {
  font-size: .82rem;
}

.contract-source-copy small {
  margin-top: 3px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: .68rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-status {
  justify-content: space-between;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--source-radius-control);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.78rem;
}

.source-status > span:first-child {
  display: flex;
  align-items: center;
  gap: 6px;
}

.ready-label {
  color: var(--green);
  font-size: 0.69rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-controls {
  gap: 8px;
}

.source-controls .search-control {
  width: 100%;
  min-height: 44px;
  border-radius: var(--source-radius-control);
}

.search-control {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.search-control:focus-within {
  border-color: color-mix(in srgb, var(--violet) 65%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 12%, transparent);
}

.search-control svg {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  color: var(--text-muted);
}

.search-control input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  caret-color: var(--violet);
  font-size: 0.86rem;
}

.search-control input::placeholder,
.composer textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
  -webkit-text-fill-color: var(--text-muted);
}

.filter-row {
  gap: 6px;
  padding: 14px 0 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filter-row::-webkit-scrollbar {
  display: none;
}

.filter-pill {
  flex: 0 0 auto;
  cursor: pointer;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: 150ms ease;
}

.filter-pill:hover {
  color: var(--text-soft);
}

.filter-pill.is-active {
  border-color: color-mix(in srgb, var(--violet) 32%, transparent);
  background: color-mix(in srgb, var(--violet) 14%, transparent);
  color: color-mix(in srgb, var(--violet) 80%, var(--text));
}

.select-all {
  gap: 10px;
  padding: 10px 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--text-soft);
  cursor: pointer;
  font-size: 0.83rem;
}

.select-all input,
.source-check input,
.switch-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.check-box {
  display: grid;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
}

.check-box svg {
  width: 13px;
  height: 13px;
  opacity: 0;
}

input:checked + .check-box {
  border-color: transparent;
  background: linear-gradient(145deg, var(--violet), var(--violet-strong));
  color: #fff;
  box-shadow: 0 0 14px rgba(139, 92, 246, .24);
}

input:checked + .check-box svg {
  opacity: 1;
}

.source-list {
  min-height: 0;
  flex: 1;
  padding: 8px 1px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--line-strong) transparent;
}

.source-list.is-dragover {
  border-radius: var(--source-radius-surface);
  background: color-mix(in srgb, var(--cyan) 7%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--cyan) 55%, transparent);
}

.source-list.is-dragover .source-empty {
  color: var(--cyan);
}

.source-library-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 8px 0 1px;
}

.source-sort-control {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: .69rem;
}

.source-sort-control select {
  min-width: 0;
  min-height: 44px;
  padding: 0 27px 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--source-radius-control);
  outline: 0;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font: inherit;
  font-size: .71rem;
}

.source-sort-control select:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--violet) 38%, transparent);
  outline-offset: 2px;
}

.source-sort-control select option {
  background: var(--panel-solid);
  color: var(--text);
}

.source-group-toggle {
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: var(--source-radius-control);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: .69rem;
  font-weight: 600;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.source-group-toggle:hover,
.source-group-toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--violet) 32%, var(--line));
  background: color-mix(in srgb, var(--violet) 10%, var(--surface));
  color: var(--text);
}

.source-topic-group {
  margin: 2px 0 5px;
}

.source-topic-group > summary {
  position: relative;
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 9px 0 25px;
  border-radius: var(--source-radius-control);
  color: var(--text-soft);
  cursor: pointer;
  font-size: .78rem;
  font-weight: 600;
  list-style: none;
  transition: background 140ms ease, color 140ms ease;
}

.source-topic-group > summary::-webkit-details-marker {
  display: none;
}

.source-topic-group > summary::before {
  position: absolute;
  left: 8px;
  width: 7px;
  height: 7px;
  border-top: 1.7px solid currentColor;
  border-right: 1.7px solid currentColor;
  content: "";
  transform: rotate(45deg);
  transition: transform 150ms ease;
}

.source-topic-group[open] > summary::before {
  transform: translateY(-2px) rotate(135deg);
}

.source-topic-group > summary:hover {
  background: var(--surface);
  color: var(--text);
}

.source-topic-group > summary small {
  display: grid;
  min-width: 23px;
  height: 23px;
  place-items: center;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: var(--source-radius-marker);
  background: var(--surface);
  color: var(--text-muted);
  font-size: .65rem;
  font-weight: 600;
}

.source-group-items {
  padding: 3px 0 4px 6px;
  border-left: 1px solid color-mix(in srgb, var(--violet) 22%, var(--line));
  margin-left: 11px;
}

.source-group-items .source-row {
  grid-template-columns: 20px 30px minmax(0, 1fr) 32px;
  gap: 7px;
  padding: 8px 5px;
}

.source-group-items .source-icon {
  width: 30px;
  height: 34px;
}

.source-group-items .source-copy strong {
  font-size: .75rem;
}

.source-group-items .source-copy small {
  font-size: .65rem;
}

.source-row {
  display: grid;
  grid-template-columns: 20px 34px minmax(0, 1fr) 36px;
  gap: 10px;
  align-items: center;
  width: 100%;
  margin: 2px 0;
  padding: 10px 8px;
  border-radius: var(--source-radius-control);
  cursor: pointer;
  transition: background 150ms ease;
}

.source-open {
  min-width: 0;
  padding: 4px 0;
  border-radius: var(--source-radius-marker);
  background: transparent;
  color: inherit;
  cursor: pointer;
  text-align: left;
}

.source-row:not(.is-custom) .source-open {
  grid-column: 3 / 5;
}

.source-row:hover,
.source-row.is-active {
  background: var(--surface);
}

.source-check {
  display: grid;
  place-items: center;
  cursor: pointer;
}

.source-icon {
  display: grid;
  width: 34px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--source-radius-marker);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: .03em;
}

.source-icon.pdf {
  border-color: rgba(255, 96, 124, .25);
  color: #ff7b94;
}

.source-icon.docx {
  border-color: rgba(67, 216, 245, .24);
  color: var(--cyan);
}

.source-icon.xlsx {
  border-color: rgba(99, 230, 167, .3);
  color: var(--green);
}

.source-icon.png {
  border-color: rgba(244, 189, 87, .3);
  color: var(--contract);
}

.source-icon.audio {
  border-color: rgba(154, 108, 255, .28);
  color: var(--violet);
}

.source-icon.txt,
.source-icon.md,
.source-icon.rtf,
.source-icon.doc {
  border-color: rgba(99, 230, 167, .24);
  color: var(--green);
}

.source-copy {
  min-width: 0;
}

.source-copy strong {
  display: block;
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-copy small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-empty {
  padding: 30px 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-align: center;
}

.source-footer {
  flex-direction: column;
  align-items: stretch;
  gap: 9px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: 0.72rem;
}

.source-footer > div,
.source-footer a {
  display: flex;
  align-items: center;
  gap: 7px;
}

.source-footer a {
  width: max-content;
  color: var(--text-soft);
  transition: color 150ms ease;
}

.source-footer a:hover {
  color: var(--violet);
}

.source-footer a svg {
  width: 15px;
  height: 15px;
}

.chat-surface {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-soft) 44%, transparent), transparent 34%);
}

.chat-header {
  z-index: 5;
  justify-content: space-between;
  gap: 16px;
  padding: 19px clamp(20px, 4vw, 54px) 15px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(24px);
}

.chat-header h1 {
  font-size: clamp(1.16rem, 2vw, 1.42rem);
}

.chat-heading-copy {
  min-width: 0;
}

.chat-heading-copy p {
  margin: 3px 0 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: .72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connection-badge {
  flex: 0 0 auto;
  padding: 7px 10px;
}

.conversation {
  position: relative;
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  scrollbar-color: var(--line-strong) transparent;
}

.conversation-inner,
.welcome-card,
.message-row {
  width: min(860px, calc(100% - 40px));
  margin-right: auto;
  margin-left: auto;
}

.welcome-card {
  position: relative;
  margin-top: clamp(28px, 5vh, 66px);
  margin-bottom: 38px;
  padding: clamp(24px, 4vw, 42px);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(circle at 88% 10%, rgba(67, 216, 245, .11), transparent 28%),
    radial-gradient(circle at 14% 2%, rgba(154, 108, 255, .14), transparent 31%),
    var(--panel);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), var(--shadow);
  backdrop-filter: blur(24px) saturate(130%);
}

.welcome-card::after {
  position: absolute;
  right: -80px;
  bottom: -120px;
  width: 260px;
  height: 260px;
  border: 1px solid color-mix(in srgb, var(--violet) 15%, transparent);
  border-radius: 50%;
  content: "";
  box-shadow: 0 0 80px rgba(139, 92, 246, .11);
}

.welcome-icon {
  display: grid;
  width: 50px;
  height: 50px;
  margin-bottom: 19px;
  place-items: center;
  border: 1px solid rgba(154, 108, 255, .32);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(154, 108, 255, .2), rgba(67, 216, 245, .08));
  color: var(--violet);
  box-shadow: 0 0 32px rgba(139, 92, 246, .12);
}

.welcome-card h2 {
  max-width: 640px;
  margin: 10px 0 12px;
  font-family: var(--display);
  font-size: clamp(1.8rem, 4.5vw, 2.8rem);
  line-height: 1.08;
  letter-spacing: -0.05em;
}

.welcome-card > p {
  max-width: 610px;
  margin: 0;
  color: var(--text-soft);
  font-size: 1rem;
}

.fact-row {
  position: relative;
  z-index: 1;
  gap: 10px;
  margin-top: 28px;
}

.fact-row > span {
  min-width: 0;
  flex: 1;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.fact-row small,
.fact-row strong {
  display: block;
}

.fact-row small {
  color: var(--text-muted);
  font-size: 0.69rem;
}

.fact-row strong {
  margin-top: 3px;
  overflow: hidden;
  font-size: 0.81rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestions {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.suggestions button {
  display: flex;
  min-height: 70px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  cursor: pointer;
  color: var(--text-soft);
  text-align: left;
  transition: 160ms ease;
}

.suggestions button:hover {
  border-color: color-mix(in srgb, var(--violet) 36%, var(--line));
  background: color-mix(in srgb, var(--violet) 10%, var(--surface));
  color: var(--text);
}

.suggestions button span {
  font-size: 0.82rem;
  font-weight: 600;
}

.suggestions button svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--violet);
}

.resource-library-link {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.resource-library-link:hover {
  border-color: rgba(154, 108, 255, .42);
  background: var(--surface-strong);
}

.resource-library-copy {
  display: grid;
  gap: 3px;
}

.resource-library-copy strong {
  font-size: .82rem;
  font-weight: 700;
}

.resource-library-copy small {
  color: var(--text-soft);
  font-size: .71rem;
  line-height: 1.4;
}

.resource-library-action {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  color: #c8b5ff;
  font-size: .76rem;
  font-weight: 700;
}

.resource-library-action svg {
  width: 15px;
  height: 15px;
}

.resource-catalog-link {
  display: inline-flex;
  margin: 9px 2px 0;
  color: var(--text-soft);
  font-size: .72rem;
  text-decoration-color: color-mix(in srgb, var(--text-soft) 45%, transparent);
}

.resource-catalog-link:hover {
  color: var(--text);
}

.message-row {
  padding: 17px 0;
}

.message-row:first-of-type {
  padding-top: 32px;
}

.user-message {
  width: min(620px, 88%);
  margin-left: auto;
}

.user-label,
.answer-label {
  gap: 7px;
  margin-bottom: 7px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: .02em;
}

.user-label {
  justify-content: flex-end;
}

.user-bubble {
  padding: 14px 17px;
  border: 1px solid color-mix(in srgb, var(--violet) 30%, var(--line));
  border-radius: 19px 19px 5px 19px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--violet) 18%, var(--surface)), color-mix(in srgb, var(--cyan) 7%, var(--surface)));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  white-space: pre-wrap;
}

.user-image {
  display: block;
  width: min(300px, 100%);
  max-height: 260px;
  margin: 0 0 10px auto;
  border: 1px solid var(--line);
  border-radius: var(--source-radius-control);
  object-fit: cover;
}

.user-file-attachments {
  display: grid;
  gap: 6px;
  margin: 0 0 10px;
}

.user-file-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: min(340px, 100%);
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  color: var(--text-soft);
  font-size: .72rem;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease;
}

.user-file-attachment:hover {
  border-color: var(--cyan);
  background: color-mix(in srgb, var(--surface-strong) 82%, transparent);
}

.user-file-attachment-type {
  flex: 0 0 auto;
  color: var(--cyan);
  font-size: .62rem;
  font-weight: 700;
}

.user-file-attachment-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04), 0 20px 60px rgba(0,0,0,.12);
  backdrop-filter: blur(20px);
}

.answer-card::before {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(154,108,255,.65), rgba(67,216,245,.45), transparent);
  content: "";
}

.answer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 17px;
  border-bottom: 1px solid var(--line);
}

.answer-label {
  margin: 0;
  color: var(--text-soft);
}

.mini-logo {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 8px;
  background: linear-gradient(145deg, var(--violet), #6331cc);
  color: #fff;
  font-family: var(--display);
  font-size: 0.65rem;
  font-weight: 700;
}

.answer-meta {
  gap: 7px;
  color: var(--text-muted);
  font-size: 0.7rem;
}

.answer-body {
  padding: 20px 20px 15px;
  color: var(--text-soft);
  font-size: 0.94rem;
  line-height: 1.72;
}

.answer-body > :first-child {
  margin-top: 0;
}

.answer-body > :last-child {
  margin-bottom: 0;
}

.answer-body h2,
.answer-body h3,
.answer-body h4 {
  margin: 1.35em 0 .45em;
  color: var(--text);
  font-family: var(--display);
  line-height: 1.28;
  letter-spacing: -.025em;
}

.answer-body h2 { font-size: 1.22rem; }
.answer-body h3 { font-size: 1.08rem; }
.answer-body h4 { font-size: 1rem; }
.answer-body p { margin: .65em 0; }
.answer-body ul,
.answer-body ol { margin: .65em 0; padding-left: 1.35em; }
.answer-body li { margin: .38em 0; padding-left: .18em; }
.answer-body strong { color: var(--text); font-weight: 650; }
.answer-body code {
  padding: .12em .35em;
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-strong) 84%, transparent);
  color: var(--cyan);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: .88em;
}
.answer-body pre {
  max-width: 100%;
  margin: .8em 0;
  padding: 12px 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  line-height: 1.55;
}
.answer-body pre code {
  display: block;
  padding: 0;
  background: transparent;
  color: var(--text-soft);
  white-space: pre;
}
.answer-body hr {
  margin: .9em 0;
  border: 0;
  border-top: 1px solid var(--line);
}
.answer-body del { color: var(--text-muted); }
.answer-body .markdown-table-scroll {
  max-width: 100%;
  margin: 1em 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  -webkit-overflow-scrolling: touch;
}
.answer-body .markdown-table-scroll:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: -3px;
}
.answer-body table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: .88em;
  line-height: 1.5;
}
.answer-body th,
.answer-body td {
  min-width: 7rem;
  max-width: 22rem;
  padding: .72rem .85rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  text-align: left;
  vertical-align: top;
}
.answer-body th {
  background: color-mix(in srgb, var(--surface-strong) 78%, transparent);
  color: var(--text);
  font-weight: 650;
}
.answer-body [data-align="center"] { text-align: center; }
.answer-body [data-align="right"] { text-align: right; }
.answer-body tr:last-child td { border-bottom: 0; }
.answer-body th:last-child,
.answer-body td:last-child { border-right: 0; }
.answer-body .markdown-table-scroll th code,
.answer-body .markdown-table-scroll td code { white-space: nowrap; }
@media (min-width: 1101px) {
  .answer-body .markdown-table-scroll table {
    width: 100%;
    min-width: 100%;
    table-layout: auto;
  }
}

.inline-citation {
  display: inline-grid;
  width: 23px;
  height: 21px;
  margin: 0 2px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--violet) 32%, transparent);
  border-radius: 7px;
  background: color-mix(in srgb, var(--violet) 12%, transparent);
  color: var(--violet);
  cursor: pointer;
  font-size: .69rem;
  font-weight: 700;
  vertical-align: .12em;
}

.inline-citation:hover {
  background: color-mix(in srgb, var(--violet) 20%, transparent);
}

.inline-citation.is-contract {
  border-color: color-mix(in srgb, var(--contract) 45%, transparent);
  background: color-mix(in srgb, var(--contract) 13%, transparent);
  color: var(--contract);
}

.inline-citation.is-contract:hover {
  background: color-mix(in srgb, var(--contract) 22%, transparent);
}

.citation-list {
  display: grid;
  min-width: 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.citation-section {
  padding: 0 20px 17px;
}

.citation-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--text-muted);
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.citation-heading span:last-child {
  display: grid;
  min-width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: .64rem;
}

.citation-link {
  min-width: 0;
  width: 100%;
  justify-content: flex-start;
  align-items: flex-start;
  gap: 9px;
  min-height: 72px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  color: var(--text-soft);
  text-align: left;
  transition: 150ms ease;
}

.citation-link:hover {
  border-color: color-mix(in srgb, var(--violet) 30%, var(--line));
  color: var(--text);
}

.contract-citation-section {
  padding: 0 20px 15px;
}

.contract-citation-card {
  display: grid;
  min-width: 0;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 78px;
  padding: 12px;
  border: 1px solid color-mix(in srgb, var(--contract) 46%, var(--line));
  border-radius: 13px;
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--contract) 12%, transparent), transparent 72%),
    var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  text-align: left;
}

.contract-citation-card:hover {
  border-color: color-mix(in srgb, var(--contract) 72%, var(--line));
  color: var(--text);
}

.contract-citation-card .citation-number {
  width: 32px;
  height: 32px;
  background: color-mix(in srgb, var(--contract) 16%, transparent);
  color: var(--contract);
}

.contract-citation-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--contract);
  font-size: .68rem;
  font-weight: 750;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.contract-answer-nudge {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 0 20px 16px;
  padding: 11px 12px;
  border: 1px dashed color-mix(in srgb, var(--contract) 46%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--contract) 7%, var(--surface));
}

.contract-answer-nudge > svg {
  color: var(--contract);
}

.contract-answer-nudge strong,
.contract-answer-nudge small {
  display: block;
}

.contract-answer-nudge strong {
  font-size: .76rem;
}

.contract-answer-nudge small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: .66rem;
}

.contract-answer-nudge button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: var(--source-radius-marker);
  background: color-mix(in srgb, var(--contract) 16%, var(--surface));
  color: var(--contract);
  cursor: pointer;
  font-size: .68rem;
  font-weight: 700;
}

.mini-logo svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

.citation-number {
  display: grid;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--violet) 13%, transparent);
  color: var(--violet);
  font-size: .72rem;
  font-weight: 700;
}

.citation-copy {
  min-width: 0;
}

.citation-copy strong,
.citation-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.citation-copy > span {
  display: -webkit-box;
  margin-top: 4px;
  overflow: hidden;
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: .72rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.citation-chevron {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  margin-top: 6px;
  color: var(--text-muted);
}

.citation-copy strong {
  font-size: .8rem;
  font-weight: 600;
}

.citation-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: .68rem;
}

.answer-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 14px;
  border-top: 1px solid var(--line);
}

.answer-actions {
  gap: 5px;
}

.answer-actions .icon-button {
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--text-muted);
}

.answer-actions .icon-button:hover {
  background: var(--surface);
  color: var(--text);
}

.answer-actions .icon-button.is-active {
  background: color-mix(in srgb, var(--violet) 14%, var(--surface));
  color: var(--violet);
}

.answer-actions svg {
  width: 17px;
  height: 17px;
}

.answer-foot > span {
  color: var(--text-muted);
  font-size: .68rem;
}

.thinking-card {
  display: flex;
  min-height: 66px;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-surface);
  background: var(--panel);
  color: var(--text-soft);
}

.thinking-orb {
  position: relative;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(from 180deg, var(--violet), var(--cyan), var(--violet));
  animation: spin 1.5s linear infinite;
}

.thinking-orb::after {
  position: absolute;
  inset: 3px;
  border-radius: inherit;
  background: var(--panel-solid);
  content: "";
}

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

.thinking-copy {
  min-width: 0;
  color: var(--text);
  font-size: .84rem;
  font-weight: 600;
  line-height: 1.4;
}

.thinking-copy.is-swapping {
  animation: thinkingSwap 220ms cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes thinkingSwap {
  from { opacity: .3; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

body.reduced-motion .thinking-row .thinking-orb,
body.reduced-motion .thinking-copy.is-swapping {
  animation: none !important;
}

@media (max-width: 560px) {
  .thinking-card {
    min-height: 58px;
    padding: 11px 13px;
  }

  .thinking-copy {
    font-size: .78rem;
  }
}
.error-card {
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--red) 30%, var(--line));
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--red) 7%, var(--panel));
}

.error-card strong,
.error-card span {
  display: block;
}

.error-card strong {
  color: var(--text);
}

.error-card span {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: .86rem;
}

.composer-zone {
  position: relative;
  z-index: 8;
  flex: 0 0 auto;
  padding: 13px clamp(20px, 4vw, 54px) max(13px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 68%, transparent), var(--bg) 34%);
  backdrop-filter: blur(22px);
}

.composer,
.fine-print {
  width: min(860px, 100%);
  margin: 0 auto;
}

.composer {
  position: relative;
  padding: 13px 13px 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--panel-elevated);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 18px 60px rgba(0,0,0,.22), 0 0 0 1px rgba(154,108,255,.025);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.composer:focus-within {
  border-color: color-mix(in srgb, var(--violet) 48%, var(--line));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 14px 40px rgba(0,0,0,.24);
}

.composer textarea {
  display: block;
  width: 100%;
  min-height: 1.5em;
  max-height: 160px;
  resize: none;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  caret-color: var(--violet);
  opacity: 1;
  -webkit-text-fill-color: var(--text);
  font-size: 1rem;
  line-height: 1.5;
}

.composer-footer {
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-tool {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border-radius: 11px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.composer-tool:hover {
  background: var(--surface);
  color: var(--violet);
}

.composer-tool svg {
  width: 18px;
  height: 18px;
}

.selection-hint {
  gap: 7px;
  color: var(--text-muted);
  font-size: .72rem;
}

.send-button {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(145deg, #a27aff, #7842e8 60%, #5f2eca);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 8px 22px rgba(124, 58, 237, .34), inset 0 1px 0 rgba(255,255,255,.26);
  transition: opacity 150ms ease, transform 150ms ease, filter 150ms ease;
}

.send-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.send-button:disabled {
  cursor: not-allowed;
  opacity: .35;
  box-shadow: none;
}

.send-button svg {
  width: 19px;
  height: 19px;
}

.fine-print {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 5px 0;
  color: var(--text-muted);
  font-size: .66rem;
}

.scrim,
.inspector-scrim {
  position: fixed;
  inset: var(--topbar) 0 0;
  z-index: 16;
  display: none;
  background: rgba(1, 3, 7, .55);
  opacity: 0;
  backdrop-filter: blur(4px);
  transition: opacity 180ms ease;
}

.inspector-scrim {
  inset: 0;
  z-index: 50;
}

.inspector {
  position: fixed;
  z-index: 55;
  top: calc(var(--topbar) + 12px);
  right: 12px;
  bottom: 12px;
  display: flex;
  width: min(445px, calc(100vw - 24px));
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--panel-elevated);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(calc(100% + 28px));
  transition: transform 220ms cubic-bezier(.22,.8,.22,1), opacity 180ms ease;
  backdrop-filter: blur(28px) saturate(140%);
}

.inspector.is-open {
  opacity: 1;
  transform: translateX(0);
}

.inspector-scrim.is-open {
  display: block;
  opacity: 1;
}

.inspector-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 19px 19px 15px;
  border-bottom: 1px solid var(--line);
}

.inspector-header > div,
.dialog-header > div:not(.contract-header-actions) {
  min-width: 0;
  flex: 1;
}

.inspector-header > .icon-button,
.dialog-header > .icon-button {
  flex: 0 0 44px;
}

.inspector-header h2 {
  max-width: 100%;
  overflow: hidden;
  font-size: 1.25rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-meta {
  gap: 11px;
  padding: 14px 19px 10px;
}

.source-type {
  display: grid;
  min-width: 42px;
  height: 45px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--violet);
  font-size: .62rem;
  font-weight: 700;
}

.inspector-file-copy {
  min-width: 0;
  flex: 1;
}

.inspector-meta strong,
.inspector-meta small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inspector-meta strong { font-size: .84rem; }

.inspector-summary {
  flex: 0 0 auto;
  max-height: 190px;
  overflow-y: auto;
  margin: 0 19px 12px;
  padding: 13px 15px;
  border: 1px solid color-mix(in srgb, var(--violet) 19%, var(--line));
  border-radius: 15px;
  background: color-mix(in srgb, var(--violet) 9%, var(--surface));
}

.inspector-summary .eyebrow {
  color: var(--violet);
  font-size: .7rem;
}

.inspector-summary p {
  margin: 7px 0 0;
  color: var(--text-soft);
  font-size: .8rem;
  line-height: 1.55;
  white-space: pre-wrap;
}

.inspector-summary[hidden] { display: none; }

.inspector-original-link {
  display: inline-flex;
  margin: 0 19px 12px;
  color: var(--violet);
  font-size: .82rem;
  font-weight: 700;
  text-decoration: none;
}

.inspector-original-link:hover { text-decoration: underline; }
.inspector-original-link[hidden] { display: none; }

.inspector-text-tools {
  padding: 0 19px 12px;
}

.inspector-notice {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: .76rem;
  line-height: 1.45;
}

.inspector-notice[hidden],
.inspector-full-toggle[hidden] { display: none; }

.inspector-full-toggle {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--violet);
  font: inherit;
  font-size: .8rem;
  font-weight: 700;
  cursor: pointer;
}

.inspector-full-toggle:hover { text-decoration: underline; }
.inspector-meta small { margin-top: 2px; color: var(--text-muted); font-size: .72rem; }

.page-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}

.page-nav .icon-button {
  width: 33px;
  height: 33px;
  border-radius: 10px;
}

.page-nav .icon-button:first-child svg {
  transform: rotate(180deg);
}

.page-nav .icon-button:disabled {
  cursor: not-allowed;
  opacity: .32;
}

.inspector-search {
  flex: 0 0 auto;
  margin: 0 19px 12px;
}

.inspector-body {
  min-height: 0;
  flex: 1;
  padding: 4px 19px 20px;
  overflow-y: auto;
}

.source-page {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: color-mix(in srgb, var(--panel-solid) 85%, var(--surface));
  color: var(--text-soft);
  font-size: .84rem;
  line-height: 1.7;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.source-page mark {
  padding: 1px 2px;
  border-radius: 4px;
  background: rgba(154,108,255,.27);
  color: var(--text);
}

.inspector-evidence-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 19px 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--violet) 32%, var(--line));
  border-radius: 10px;
  background: color-mix(in srgb, var(--violet) 8%, var(--panel));
  color: var(--text-soft);
  font-size: .72rem;
}

.inspector-evidence-note svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--violet);
}

.source-loading {
  display: flex;
  justify-content: center;
  gap: 7px;
  padding: 50px;
}

.source-loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet);
  animation: bounce 1s ease-in-out infinite;
}

.source-loading span:nth-child(2) { animation-delay: .12s; }
.source-loading span:nth-child(3) { animation-delay: .24s; }
@keyframes bounce { 50% { transform: translateY(-7px); opacity: .5; } }

.inspector-actions {
  gap: 9px;
  padding: 13px 19px max(16px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}

.primary-button,
.secondary-button,
.danger-ghost {
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 12px;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  transition: 150ms ease;
}

.primary-button {
  padding: 0 15px;
  background: linear-gradient(145deg, #9c70ff, #7137db);
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 58, 237, .24), inset 0 1px 0 rgba(255,255,255,.24);
}

.secondary-button {
  padding: 0 14px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-soft);
}

.primary-button:hover,
.secondary-button:hover,
.danger-ghost:hover {
  filter: brightness(1.08);
}

.primary-button svg,
.secondary-button svg,
.danger-ghost svg {
  width: 17px;
  height: 17px;
}

.inspector-actions .secondary-button { flex: 0 0 auto; }
.inspector-actions .primary-button { flex: 1; }

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  padding: 20px;
  place-items: center;
  background: rgba(2, 4, 9, .65);
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(7px);
  transition: opacity 180ms ease;
}

.modal-layer.is-open {
  opacity: 1;
  pointer-events: auto;
}

.contract-layer {
  z-index: 74;
}

.contract-dialog {
  display: flex;
  width: min(980px, 100%);
  max-height: min(880px, calc(100dvh - 40px));
  min-height: 560px;
  overflow: hidden;
  flex-direction: column;
  border: 1px solid color-mix(in srgb, var(--contract) 28%, var(--line-strong));
  border-radius: 24px;
  background: var(--panel-elevated);
  box-shadow: var(--shadow), 0 0 70px color-mix(in srgb, var(--contract) 8%, transparent);
  transform: translateY(14px) scale(.985);
  transition: transform 200ms ease;
}

.contract-layer.is-open .contract-dialog {
  transform: translateY(0) scale(1);
}

.contract-dialog-header {
  flex: 0 0 auto;
}

.contract-dialog-header .eyebrow svg {
  color: var(--contract);
}

.contract-header-actions,
.contract-dialog-footer,
.contract-dialog-footer > div,
.contract-reader-tools,
.contract-filebar,
.contract-analysis-note {
  display: flex;
  align-items: center;
}

.contract-header-actions {
  gap: 8px;
  flex: 0 0 auto;
}

.contract-replace {
  min-height: 40px;
}

.contract-empty {
  display: flex;
  min-height: 500px;
  flex: 1;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 48px 24px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 12%, color-mix(in srgb, var(--contract) 10%, transparent), transparent 38%),
    linear-gradient(180deg, transparent, color-mix(in srgb, var(--surface) 40%, transparent));
}

.contract-empty-seal {
  width: 76px;
  height: 76px;
  margin-bottom: 20px;
  border-radius: 23px;
  box-shadow: 0 18px 45px color-mix(in srgb, var(--contract) 15%, transparent), inset 0 1px 0 rgba(255,255,255,.12);
}

.contract-empty-seal svg {
  width: 34px;
  height: 34px;
}

.contract-empty h3 {
  max-width: 520px;
  margin: 10px 0 8px;
  font-family: var(--display);
  font-size: clamp(1.65rem, 3vw, 2.25rem);
  letter-spacing: -.045em;
}

.contract-empty p {
  max-width: 590px;
  margin: 0;
  color: var(--text-soft);
}

.contract-upload-button {
  min-height: 48px;
  margin-top: 24px;
  padding: 0 20px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--contract) 92%, white), var(--contract-strong));
  color: #23180a;
  box-shadow: 0 12px 30px color-mix(in srgb, var(--contract) 22%, transparent), inset 0 1px 0 rgba(255,255,255,.36);
}

.contract-empty > small {
  margin-top: 12px;
  color: var(--text-muted);
  font-size: .7rem;
}

.contract-workspace {
  min-height: 0;
  flex: 1;
  overflow: hidden;
}

.contract-workspace:not([hidden]) {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.contract-filebar {
  gap: 11px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--contract) 4%, var(--surface));
}

.contract-file-icon {
  width: 40px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 11px;
}

.contract-file-copy {
  flex: 1;
}

.contract-file-copy strong {
  overflow: hidden;
  font-size: .84rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.contract-file-copy small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: .69rem;
}

.contract-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 20px 0;
  border-bottom: 1px solid var(--line);
}

.contract-tabs button {
  position: relative;
  padding: 10px 13px 12px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 650;
}

.contract-tabs button::after {
  position: absolute;
  right: 11px;
  bottom: -1px;
  left: 11px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--contract);
  content: "";
  opacity: 0;
}

.contract-tabs button.is-active {
  color: var(--text);
}

.contract-tabs button.is-active::after {
  opacity: 1;
}

.contract-analysis-view,
.contract-text-view {
  min-height: 0;
  overflow: hidden;
}

.contract-analysis-view:not([hidden]) {
  display: flex;
  flex-direction: column;
}

.contract-text-view:not([hidden]) {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.contract-analysis-note {
  gap: 8px;
  margin: 14px 20px 0;
  padding: 9px 11px;
  border: 1px solid color-mix(in srgb, var(--contract) 22%, var(--line));
  border-radius: 11px;
  background: color-mix(in srgb, var(--contract) 6%, var(--surface));
  color: var(--text-muted);
  font-size: .7rem;
}

.contract-analysis-note svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  color: var(--contract);
}

.contract-analysis-body {
  min-height: 0;
  flex: 1;
  padding: 8px 22px 28px;
  overflow-y: auto;
  color: var(--text-soft);
  font-size: .89rem;
  line-height: 1.68;
  scrollbar-color: var(--line-strong) transparent;
}

.contract-analysis-body h2,
.contract-analysis-body h3,
.contract-analysis-body h4 {
  margin: 1.2em 0 .42em;
  color: var(--text);
  font-family: var(--display);
  letter-spacing: -.025em;
}

.contract-analysis-body h2 {
  font-size: 1.22rem;
}

.contract-analysis-body h3 {
  font-size: 1.05rem;
}

.contract-analysis-body p {
  margin: .58em 0;
}

.contract-analysis-body ul,
.contract-analysis-body ol {
  margin: .6em 0;
  padding-left: 1.35em;
}

.contract-analysis-body li {
  margin: .42em 0;
}

.contract-analysis-body strong {
  color: var(--text);
}

.contract-analysis-loading {
  display: flex;
  min-height: 300px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  color: var(--text-soft);
  text-align: center;
}

.contract-analysis-loading .thinking-orb {
  width: 44px;
  height: 44px;
}

.contract-analysis-loading small {
  color: var(--text-muted);
}

.contract-retry {
  align-self: flex-start;
  margin: 0 22px 22px;
}

.contract-reader-tools {
  gap: 10px;
  padding: 13px 20px;
  border-bottom: 1px solid var(--line);
}

.contract-reader-tools .search-control {
  max-width: 430px;
}

.contract-page-label {
  margin-left: auto;
  color: var(--text-muted);
  font-size: .7rem;
  white-space: nowrap;
}

.contract-text-body {
  min-height: 0;
  padding: 18px 20px 26px;
  overflow-y: auto;
  scrollbar-color: var(--line-strong) transparent;
}

.contract-text-body .source-page {
  max-width: 780px;
  min-height: 100%;
  margin: 0 auto;
  border-color: color-mix(in srgb, var(--contract) 18%, var(--line));
  background: color-mix(in srgb, var(--panel-solid) 92%, var(--contract) 2%);
}

.contract-text-body .source-page mark {
  background: color-mix(in srgb, var(--contract) 31%, transparent);
}

.contract-dialog-footer {
  justify-content: space-between;
  gap: 12px;
  padding: 13px 20px max(14px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel-elevated) 94%, transparent);
}

.contract-dialog-footer > div {
  gap: 8px;
}

.settings-dialog {
  width: min(540px, 100%);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  background: var(--panel-elevated);
  box-shadow: var(--shadow);
  transform: translateY(14px) scale(.98);
  transition: transform 200ms ease;
}

.modal-layer.is-open .settings-dialog {
  transform: translateY(0) scale(1);
}

.dialog-header {
  justify-content: space-between;
  align-items: flex-start;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 { font-size: 1.35rem; }

.setting-section {
  justify-content: space-between;
  gap: 16px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
}

.setting-copy strong,
.setting-copy small,
.switch-row strong,
.switch-row small {
  display: block;
}

.setting-copy strong,
.switch-row strong { font-size: .86rem; }
.setting-copy small,
.switch-row small { margin-top: 3px; color: var(--text-muted); font-size: .72rem; }

.segmented {
  display: flex;
  flex: 0 0 auto;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
}

.segmented button {
  padding: 7px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .72rem;
}

.segmented button.is-active {
  background: var(--panel-elevated);
  color: var(--text);
  box-shadow: 0 3px 10px rgba(0,0,0,.14);
}

.switch-row {
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px;
  cursor: pointer;
}

.switch {
  position: relative;
  width: 43px;
  height: 25px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--surface-strong);
  transition: 160ms ease;
}

.switch::after {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--text-muted);
  content: "";
  transition: 160ms ease;
}

.switch-row input:checked + .switch {
  background: var(--violet-strong);
}

.switch-row input:checked + .switch::after {
  background: #fff;
  transform: translateX(18px);
}

.dialog-footer {
  justify-content: space-between;
  gap: 12px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
}

.delete-confirmation-layer {
  z-index: 90;
}

.delete-confirmation-dialog {
  width: min(460px, 100%);
}

.delete-confirmation-message {
  margin: 0;
  padding: 20px;
  color: var(--text-soft);
  font-size: .86rem;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.delete-confirmation-footer {
  justify-content: flex-end;
}

.delete-confirm-button {
  display: inline-flex;
  min-width: 168px;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 0 17px;
  border: 1px solid color-mix(in srgb, var(--red) 46%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--red) 16%, var(--panel-elevated));
  color: var(--red);
  cursor: pointer;
  font-size: .84rem;
  font-weight: 700;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.delete-confirm-button:hover {
  border-color: color-mix(in srgb, var(--red) 72%, var(--line));
  background: color-mix(in srgb, var(--red) 24%, var(--panel-elevated));
}

.delete-confirm-button:active {
  transform: scale(.98);
}

.delete-confirm-button:focus-visible,
.chat-delete:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.delete-confirm-button svg {
  width: 17px;
  height: 17px;
}

.dialog-fields {
  display: grid;
  gap: 15px;
  padding: 19px 20px 20px;
}

.dialog-fields label,
.dialog-fields label > span {
  display: block;
}

.dialog-fields label > span {
  margin-bottom: 7px;
  color: var(--text-soft);
  font-size: .76rem;
  font-weight: 600;
}

.dialog-fields input,
.dialog-fields textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
}

.account-dialog {
  width: min(460px, 100%);
}

.auth-tabs {
  margin: 19px 20px 0;
}

.auth-tabs button {
  flex: 1;
}

.auth-hint {
  margin: 0;
  padding: 0 20px 19px;
  color: var(--text-muted);
  font-size: .76rem;
  line-height: 1.5;
}

.composer textarea.is-dragover {
  outline: 2px dashed color-mix(in srgb, var(--cyan) 80%, transparent);
  outline-offset: 4px;
  border-radius: 7px;
  background: color-mix(in srgb, var(--cyan) 7%, transparent);
}

.composer-attachments {
  display: grid;
  gap: 6px;
  margin: 10px 0 2px;
}

.composer-attachment {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid color-mix(in srgb, var(--cyan) 28%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--cyan) 7%, var(--surface));
}

.composer-attachment-type {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--cyan) 28%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--cyan) 9%, var(--surface));
  color: var(--cyan);
  font-size: .58rem;
  font-weight: 750;
  text-transform: uppercase;
}

.composer-attachment-type.is-image {
  overflow: hidden;
  padding: 0;
}

.composer-attachment-type img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.composer-attachment-copy {
  min-width: 0;
  flex: 1;
}

.composer-attachment-copy strong,
.composer-attachment-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-attachment-copy strong {
  font-size: .76rem;
  font-weight: 650;
}

.composer-attachment-copy small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: .68rem;
}

.composer-attachment .icon-button {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-color: transparent;
  background: transparent;
}

.account-summary {
  margin: 20px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--text);
  font-size: .88rem;
  font-weight: 600;
}

.dialog-fields input {
  height: 44px;
  padding: 0 12px;
}

.password-field {
  position: relative;
  display: block;
  margin: 0 !important;
  color: inherit !important;
  font: inherit !important;
}

.password-field input {
  padding-right: 46px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 6px;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 9px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transform: translateY(-50%);
}

.password-toggle:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.password-toggle svg {
  width: 17px;
  height: 17px;
}

.dialog-fields textarea {
  min-height: 112px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.5;
}

.dialog-fields input:focus,
.dialog-fields textarea:focus {
  border-color: color-mix(in srgb, var(--violet) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 10%, transparent);
}

.danger-ghost {
  padding: 0 10px;
  background: transparent;
  color: var(--red);
}

.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--panel-elevated);
  color: var(--text-soft);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: 180ms ease;
  font-size: .8rem;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}

@media (max-width: 1100px) {
  :root {
    --topbar: 108px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "program program";
    gap: 2px 8px;
    height: var(--topbar);
    padding: 7px 18px 8px;
  }

  .brand-cluster {
    grid-area: brand;
  }

  .top-actions {
    grid-area: actions;
  }

  .program-top-nav {
    grid-area: program;
    justify-self: center;
    margin: 0 0 2px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .source-toggle,
  .close-panel {
    display: grid;
  }

  .sources-panel {
    position: fixed;
    z-index: 20;
    top: var(--topbar);
    bottom: 0;
    left: 0;
    width: min(360px, 90vw);
    border-right: 1px solid var(--line-strong);
    box-shadow: var(--shadow);
    transform: translateX(-105%);
    transition: transform 220ms cubic-bezier(.22,.8,.22,1);
  }

  .sources-panel.is-open {
    transform: translateX(0);
  }

  .scrim.is-open {
    display: block;
    opacity: 1;
  }

  .search-trigger {
    display: none;
  }
}

@media (max-width: 720px) {
  :root {
    --topbar: 102px;
  }

  .search-control input {
    font-size: 1rem;
  }

  .topbar {
    padding: 0 12px;
  }

  .program-top-nav {
    gap: 3px;
    padding: 3px;
  }

  .program-top-nav button {
    min-height: 44px;
    padding: 0 8px;
    font-size: .67rem;
  }

  .mobile-source-trigger {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .brand-cluster {
    gap: 8px;
  }

  .brand-logo {
    width: 34px;
    height: 34px;
    border-radius: 11px;
  }

  .brand-wordmark strong {
    font-size: .72rem;
    letter-spacing: -.02em;
    line-height: 1.05;
    white-space: normal;
  }

  .brand-wordmark small {
    display: none;
  }

  .source-chip {
    display: none;
  }

  .account-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
  }

  .account-button span {
    display: none;
  }

  .account-button .account-glyph {
    display: block;
    width: 18px;
    height: 18px;
  }

  .top-actions {
    gap: 5px;
  }

  .top-actions .icon-button {
    width: 44px;
    height: 44px;
    border-color: transparent;
    background: transparent;
  }

  #themeToggle {
    display: none;
  }

  .contract-trigger {
    width: 44px;
    min-height: 44px;
    padding: 0;
    justify-content: center;
    border-color: transparent;
    background: transparent;
  }

  .contract-trigger > span:not(.contract-toolbar-status) {
    display: none;
  }

  .contract-toolbar-status {
    position: absolute;
    top: 5px;
    right: 3px;
    width: 8px;
    min-width: 8px;
    height: 8px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--bg);
    background: var(--contract);
    color: transparent;
    font-size: 0;
  }

  .chat-trigger {
    width: 42px;
    min-height: 42px;
    padding: 0;
    justify-content: center;
    border-color: transparent;
    background: transparent;
  }

  .chat-trigger > span:not(.toolbar-count) {
    display: none;
  }

  .chat-trigger .toolbar-count {
    position: absolute;
    top: 5px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 3px;
    font-size: .55rem;
  }

  .chat-header {
    padding: 13px 16px 11px;
  }

  .chat-header h1 {
    max-width: 62vw;
    overflow: hidden;
    font-size: 1rem;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .chat-heading-copy p {
    max-width: 62vw;
    font-size: .65rem;
  }

  .chat-header .eyebrow {
    display: block;
    font-size: .61rem;
    line-height: 1.5;
  }

  .connection-badge {
    padding: 6px 8px;
  }

  .connection-badge span:last-child {
    display: none;
  }

  .conversation-inner,
  .welcome-card,
  .message-row {
    width: calc(100% - 24px);
  }

  .welcome-card {
    margin-top: 17px;
    margin-bottom: 24px;
    padding: 21px 18px;
    border-radius: 21px;
  }

  .welcome-icon {
    width: 44px;
    height: 44px;
    margin-bottom: 14px;
  }

  .welcome-card h2 {
    margin-top: 8px;
    font-size: 1.68rem;
  }

  .welcome-card > p {
    font-size: .9rem;
  }

  .fact-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-top: 20px;
  }

  .fact-row > span:last-child {
    display: none;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .suggestions button {
    min-height: 56px;
  }

  .message-row {
    padding: 12px 0;
  }

  .user-message {
    width: 92%;
  }

  .answer-body {
    padding: 17px 15px 13px;
    font-size: .91rem;
  }

  .answer-head,
  .answer-foot {
    padding-right: 13px;
    padding-left: 13px;
  }

  .citation-section {
    padding-right: 15px;
    padding-left: 15px;
  }

  .contract-citation-section {
    padding-right: 15px;
    padding-left: 15px;
  }

  .contract-answer-nudge {
    grid-template-columns: 28px minmax(0, 1fr);
    margin-right: 15px;
    margin-left: 15px;
  }

  .contract-answer-nudge button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .citation-list {
    grid-template-columns: 1fr;
  }

  .citation-section,
  .contract-citation-section {
    padding-right: clamp(12px, 4vw, 15px);
    padding-left: clamp(12px, 4vw, 15px);
  }

  .citation-list {
    gap: 7px;
  }

  .citation-link {
    min-height: 0;
    padding: 9px;
  }

  .contract-citation-card {
    grid-template-columns: 32px minmax(0, 1fr) 14px;
    gap: 8px;
    min-height: 0;
    padding: 10px;
  }

  .citation-copy > span {
    font-size: .72rem;
  }

  .composer-zone {
    padding: 10px 12px max(9px, env(safe-area-inset-bottom));
  }

  .composer {
    padding: 11px 11px 8px 14px;
    border-radius: 18px;
  }

  .fine-print {
    justify-content: center;
    padding-top: 6px;
    text-align: center;
  }

  .fine-print span:last-child {
    display: none;
  }

  .inspector {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: min(84dvh, 760px);
    max-height: calc(100dvh - 8px);
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 23px 23px 0 0;
    transform: translateY(105%);
  }

  .inspector.is-open {
    transform: translateY(0);
  }

  .inspector-header {
    padding: 17px 16px 13px;
  }

  .inspector-meta {
    padding: 12px 16px 9px;
  }

  .inspector-search {
    margin-right: 16px;
    margin-left: 16px;
  }

  .inspector-body {
    padding-right: 16px;
    padding-left: 16px;
  }

  .source-page {
    padding: 17px;
    font-size: .81rem;
  }

  .inspector-actions {
    padding-right: 16px;
    padding-left: 16px;
  }

  .modal-layer {
    align-items: end;
    padding: 0;
  }

  .contract-dialog {
    width: 100%;
    min-height: min(760px, 92dvh);
    max-height: 92dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 23px 23px 0 0;
  }

  .contract-dialog-header {
    padding: 16px;
  }

  .contract-replace {
    width: 40px;
    padding: 0;
  }

  .contract-replace span {
    display: none;
  }

  .contract-empty {
    min-height: 0;
    padding: 34px 19px;
  }

  .contract-filebar,
  .contract-tabs,
  .contract-reader-tools,
  .contract-dialog-footer {
    padding-right: 15px;
    padding-left: 15px;
  }

  .contract-analysis-note {
    margin-right: 15px;
    margin-left: 15px;
  }

  .contract-analysis-body {
    padding-right: 17px;
    padding-left: 17px;
  }

  .contract-reader-tools {
    flex-wrap: wrap;
  }

  .contract-reader-tools .search-control {
    max-width: none;
    flex-basis: 100%;
  }

  .contract-page-label {
    margin-left: 0;
  }

  .contract-page-label + .page-nav {
    margin-left: auto;
  }

  .contract-text-body {
    padding: 13px 14px 20px;
  }

  .contract-dialog-footer {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .contract-dialog-footer > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .contract-dialog-footer > .danger-ghost {
    align-self: flex-start;
  }

  .chat-panel {
    width: min(380px, 96vw);
    padding: 16px 12px max(12px, env(safe-area-inset-bottom));
  }

  .chat-row {
    grid-template-columns: minmax(0, 1fr) 48px;
  }

  .chat-select {
    min-height: 62px;
    gap: 9px;
    padding-right: 6px;
    padding-left: 7px;
  }

  .chat-delete {
    width: 46px;
    height: 46px;
  }

  .chat-role-details summary {
    min-height: 44px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .team-memory-card > summary {
    min-height: 44px;
    padding-right: 48px;
  }

  .team-memory-close {
    top: 4px;
    right: 4px;
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .composer-tool {
    width: 44px;
    height: 44px;
  }

.filter-pill {
    min-height: 44px;
  }

  .source-add-button {
    width: 44px;
    min-height: 44px;
  }

  .search-control {
    height: 44px;
  }

  .segmented button {
    min-height: 44px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .page-nav .icon-button {
    width: 44px;
    height: 44px;
  }

  .delete-confirmation-dialog {
    width: 100%;
    max-height: calc(100dvh - env(safe-area-inset-top));
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 23px 23px 0 0;
  }

  .delete-confirmation-dialog .dialog-header {
    padding: 17px 18px;
  }

  .delete-confirmation-dialog .dialog-header h2 {
    font-size: 1.16rem;
  }

  .delete-confirmation-message {
    padding: 18px;
    font-size: .88rem;
  }

  .delete-confirmation-footer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 9px;
    padding: 13px 16px max(16px, env(safe-area-inset-bottom));
  }

  .delete-confirmation-footer .secondary-button,
  .delete-confirm-button {
    width: 100%;
    min-width: 0;
    min-height: 50px;
    padding: 0 9px;
  }

  .source-add-button span {
    display: none;
  }

  .source-add-button {
    width: 44px;
    min-height: 44px;
    padding: 0;
  }

  .settings-dialog {
    width: 100%;
    max-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 23px 23px 0 0;
  }

  .setting-section {
    align-items: flex-start;
    flex-direction: column;
  }

  .segmented {
    width: 100%;
  }

  .account-dialog .auth-tabs {
    width: auto;
  }

  .segmented button {
    flex: 1;
  }

  .dialog-footer {
    padding-bottom: max(15px, env(safe-area-inset-bottom));
  }

  .toast {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 390px) {
  .brand-wordmark strong {
    font-size: .74rem;
  }

  .inspector-header h2 {
    font-size: 1.05rem;
  }

  .delete-confirmation-footer {
    grid-template-columns: 1fr;
  }

  .inspector-actions {
    gap: 6px;
    padding-right: 12px;
    padding-left: 12px;
  }

  .inspector-actions .primary-button,
  .inspector-actions .secondary-button {
    gap: 6px;
    min-width: 0;
    padding-right: 8px;
    padding-left: 8px;
    white-space: nowrap;
  }

  .inspector-actions .primary-button {
    font-size: .74rem;
  }

  .inspector-actions .secondary-button {
    font-size: .76rem;
  }

  .mobile-source-trigger {
    width: 44px;
    height: 44px;
    flex-basis: 44px;
  }

  .welcome-card h2 {
    font-size: 1.5rem;
  }

  .fact-row {
    grid-template-columns: 1fr;
  }

  .fact-row > span:nth-child(2) {
    display: none;
  }
}

@media (max-width: 350px) {
  .topbar {
    padding-right: 8px;
    padding-left: 8px;
  }

  .brand-cluster,
  .brand {
    gap: 6px;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
  }

  .mobile-source-trigger {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .brand-wordmark {
    display: none;
  }

  body.is-library .brand-wordmark {
    display: flex;
    min-width: 0;
  }

  body.is-library .brand-wordmark strong {
    font-size: .68rem;
    letter-spacing: -.015em;
  }

  .top-actions {
    flex: 0 0 auto;
    gap: 2px;
  }

  #themeToggle {
    display: none;
  }

  .top-actions .icon-button,
  .chat-trigger,
  .account-button {
    width: 44px;
    min-width: 44px;
    height: 44px;
    min-height: 44px;
  }

  .chat-trigger .toolbar-count {
    top: 2px;
    right: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

.program-gateway {
  position: fixed;
  z-index: 150;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow-y: auto;
  background: radial-gradient(circle at 19% 18%, rgba(124, 58, 237, .19), transparent 42%),
    radial-gradient(circle at 86% 79%, rgba(67, 216, 245, .1), transparent 38%), var(--bg);
}

.program-gateway-inner {
  width: min(760px, 100%);
  padding: clamp(24px, 5vw, 50px);
  border: 1px solid var(--line-strong);
  border-radius: 27px;
  background: color-mix(in srgb, var(--panel-elevated) 96%, transparent);
  box-shadow: var(--shadow);
}

.program-gateway-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(30px, 5vw, 54px);
  font-family: var(--display);
  font-size: .88rem;
  font-weight: 800;
  letter-spacing: .04em;
}

.program-gateway-brand > span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.program-gateway-brand small {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: .7rem;
  font-weight: 500;
  letter-spacing: 0;
}

.program-gateway h1 {
  margin: 10px 0 10px;
  font-family: var(--display);
  font-size: clamp(1.8rem, 4vw, 2.55rem);
  letter-spacing: -.055em;
  line-height: 1.13;
}

.program-gateway p {
  max-width: 560px;
  margin: 0 0 27px;
  color: var(--text-soft);
  font-size: .9rem;
}

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

.program-gateway-options button {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 17px;
  align-items: start;
  gap: 12px;
  min-height: 174px;
  padding: 19px;
  border: 1px solid var(--line-strong);
  border-radius: 19px;
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.program-gateway-options button:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--violet) 65%, var(--line));
  background: color-mix(in srgb, var(--violet) 10%, var(--surface));
}

.program-gateway-options button > svg {
  width: 17px;
  height: 17px;
  margin-top: 10px;
  color: var(--text-muted);
}

.program-choice-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--violet) 45%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--violet) 19%, var(--panel-solid));
  color: var(--violet);
  font-size: 1.05rem;
  font-weight: 800;
}

.program-choice-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.program-choice-copy strong {
  margin: 2px 0 9px;
  color: var(--text);
  font-family: var(--display);
  font-size: 1.04rem;
  line-height: 1.2;
}

.program-choice-copy small {
  color: var(--text-soft);
  font-size: .76rem;
  line-height: 1.45;
}

.program-choice-copy em {
  margin-top: 19px;
  color: var(--violet);
  font-size: .7rem;
  font-style: normal;
  font-weight: 700;
}

.program-gateway-note {
  display: block;
  margin-top: 21px;
  color: var(--text-muted);
  font-size: .73rem;
}

@media (max-width: 720px) {
  .program-gateway {
    padding: 15px;
  }

  .program-gateway-inner {
    padding: 24px 20px;
  }

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

  .program-gateway-options button {
    min-height: 112px;
  }
}

/* Notebook library. The library reuses the existing aurora and chat palette. */
.library-top-nav {
  display: none;
}

body.is-library .topbar {
  position: relative;
  z-index: 60;
  display: flex;
  height: var(--topbar);
  padding: 0 clamp(16px, 2.4vw, 32px);
}

body.is-library .program-top-nav,
body.is-library .source-chip,
body.is-library #openContract,
body.is-library #openChats,
body.is-library #themeToggle {
  display: none;
}

body.is-library .brand-cluster {
  flex: 0 0 auto;
}

body.is-library .brand-wordmark small {
  display: none;
}

body.is-library .library-top-nav {
  display: flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 0 clamp(24px, 4vw, 58px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.library-top-nav button {
  min-height: 44px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.library-top-nav button:hover {
  color: var(--text);
}

.library-top-nav button.is-active {
  border-color: color-mix(in srgb, var(--violet) 28%, var(--line));
  background: color-mix(in srgb, var(--violet) 13%, var(--panel-solid));
  color: var(--text);
}

body.is-library .top-actions {
  gap: 8px;
  margin-left: auto;
}

body.is-library #openSettings {
  color: var(--text-soft);
}

.library-settings-menu {
  position: absolute;
  z-index: 65;
  top: calc(100% + 7px);
  right: clamp(64px, 6vw, 92px);
  width: min(286px, calc(100vw - 24px));
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  background: var(--panel-elevated);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px) saturate(140%);
}

.library-settings-menu[hidden] {
  display: none;
}

.library-settings-menu button,
.library-settings-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 0 11px;
  border-radius: 11px;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  font-size: .82rem;
  text-align: left;
  transition: background 150ms ease, color 150ms ease;
}

.library-settings-menu button:hover,
.library-settings-menu a:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.library-settings-menu svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: var(--violet);
}

.library-page {
  position: relative;
  z-index: 1;
  width: 100%;
  height: calc(100dvh - var(--topbar));
  overflow: auto;
  overscroll-behavior: contain;
  padding: clamp(28px, 4vw, 54px) max(22px, calc((100vw - 1250px) / 2)) max(48px, env(safe-area-inset-bottom));
  scrollbar-color: var(--line-strong) transparent;
  scroll-padding-block: 24px;
}

.library-shell {
  width: min(100%, 1250px);
  margin: 0 auto;
}

.library-view[hidden] {
  display: none;
}

.library-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin: 0 0 clamp(27px, 4vw, 46px);
}

.library-heading-row > div {
  min-width: 0;
}

.library-heading-row .eyebrow {
  margin-bottom: 9px;
  color: var(--violet);
  letter-spacing: .14em;
}

.library-heading-row h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2rem, 4vw, 3.1rem);
  font-weight: 600;
  letter-spacing: -.055em;
  line-height: 1.12;
}

.library-heading-row p {
  max-width: 700px;
  margin: 11px 0 0;
  color: var(--text-soft);
  font-size: clamp(.9rem, 1.35vw, 1rem);
}

.library-heading-mark {
  display: grid;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  place-items: center;
  margin: 0 2px 5px 0;
  border: 1px solid color-mix(in srgb, var(--violet) 35%, var(--line));
  border-radius: 17px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--violet) 18%, var(--panel)), color-mix(in srgb, var(--cyan) 10%, var(--panel)));
  color: var(--violet);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07);
}

.library-heading-mark svg {
  width: 23px;
  height: 23px;
}

.library-section {
  margin: 0 0 clamp(38px, 5vw, 62px);
}

.library-section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 17px;
}

.library-section-heading > div {
  min-width: 0;
}

.library-section-heading h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.2rem, 2vw, 1.5rem);
  font-weight: 600;
  letter-spacing: -.03em;
}

.library-section-heading > span,
.library-section-heading p {
  color: var(--text-muted);
  font-size: .78rem;
}

.library-section-heading > span {
  flex: 0 0 auto;
}

.library-section-heading p {
  margin: 5px 0 0;
}

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

.notebook-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 224px;
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(20px, 2.4vw, 30px);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(ellipse at 95% 0%, color-mix(in srgb, var(--violet) 10%, transparent), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--panel-elevated) 94%, transparent), color-mix(in srgb, var(--panel-solid) 86%, transparent));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.045), 0 16px 42px rgba(0,0,0,.14);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.notebook-card-umnik {
  background:
    radial-gradient(ellipse at 95% 0%, color-mix(in srgb, var(--cyan) 10%, transparent), transparent 42%),
    linear-gradient(145deg, color-mix(in srgb, var(--panel-elevated) 94%, transparent), color-mix(in srgb, var(--panel-solid) 86%, transparent));
}

.notebook-card:hover {
  transform: translateY(-3px);
  border-color: color-mix(in srgb, var(--violet) 42%, var(--line-strong));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 22px 52px rgba(0,0,0,.22), 0 0 38px color-mix(in srgb, var(--violet) 9%, transparent);
}

.notebook-card-umnik:hover {
  border-color: color-mix(in srgb, var(--cyan) 42%, var(--line-strong));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 22px 52px rgba(0,0,0,.22), 0 0 38px color-mix(in srgb, var(--cyan) 8%, transparent);
}

.notebook-card:active {
  transform: translateY(-1px) scale(.995);
}

.notebook-card-top,
.notebook-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.notebook-emoji {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  font-size: 1.6rem;
  line-height: 1;
}

.notebook-open-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--text-soft);
  font-size: .74rem;
  opacity: .78;
  transition: opacity 160ms ease, border-color 160ms ease, color 160ms ease;
}

.notebook-open-hint svg {
  width: 14px;
  height: 14px;
}

.notebook-card:hover .notebook-open-hint {
  border-color: color-mix(in srgb, var(--violet) 35%, var(--line));
  color: var(--text);
  opacity: 1;
}

.notebook-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 6px;
  margin: 20px 0 18px;
}

.notebook-card-copy strong {
  overflow-wrap: anywhere;
  font-family: var(--display);
  font-size: clamp(1.14rem, 2vw, 1.55rem);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.24;
}

.notebook-card-copy small {
  max-width: 54ch;
  color: var(--text-soft);
  font-size: .84rem;
  line-height: 1.5;
}

.notebook-card-meta {
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--text-muted);
  font-size: .71rem;
}

.notebook-card-meta span:first-child {
  min-width: 0;
  overflow-wrap: anywhere;
}

.notebook-card-meta span:last-child {
  flex: 0 0 auto;
  color: var(--violet);
}

.text-link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 40px;
  flex: 0 0 auto;
  padding: 0 8px 0 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--violet);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 650;
}

.text-link-button:hover {
  background: color-mix(in srgb, var(--violet) 10%, transparent);
}

.text-link-button svg,
.faq-open-notebook svg {
  width: 15px;
  height: 15px;
}

.faq-card-grid,
.faq-full-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.faq-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--panel) 91%, transparent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.035);
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
  backdrop-filter: blur(16px);
}

.faq-card:hover {
  border-color: var(--line-strong);
  background: color-mix(in srgb, var(--panel-elevated) 90%, transparent);
}

.faq-card[open] {
  border-color: color-mix(in srgb, var(--violet) 36%, var(--line-strong));
  background: color-mix(in srgb, var(--panel-elevated) 94%, transparent);
  box-shadow: 0 14px 36px rgba(0,0,0,.15);
}

.faq-card > summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: start;
  gap: 12px;
  min-height: 130px;
  padding: 18px 18px 16px;
  cursor: pointer;
  list-style: none;
}

.faq-card > summary::-webkit-details-marker {
  display: none;
}

.faq-card-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
}

.faq-card-copy > small {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.faq-program-mark,
.faq-category-mark {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid color-mix(in srgb, var(--violet) 22%, var(--line));
  border-radius: var(--source-radius-marker);
  background: color-mix(in srgb, var(--violet) 9%, var(--surface));
  color: var(--violet);
  font-size: .65rem;
  font-weight: 650;
  line-height: 1.2;
}

.faq-program-mark.is-umnik {
  border-color: color-mix(in srgb, var(--cyan) 24%, var(--line));
  background: color-mix(in srgb, var(--cyan) 8%, var(--surface));
  color: var(--cyan);
}

.faq-category-mark {
  border-color: var(--line);
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 500;
}

.faq-card-copy > strong {
  color: var(--text);
  font-family: var(--display);
  font-size: .96rem;
  font-weight: 600;
  letter-spacing: -.018em;
  line-height: 1.38;
}

.faq-short-answer {
  display: -webkit-box;
  max-width: 68ch;
  margin-top: 7px;
  overflow: hidden;
  color: var(--text-soft);
  font-size: .79rem;
  line-height: 1.48;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.faq-expand {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-muted);
  transition: transform 170ms ease, color 170ms ease, border-color 170ms ease;
}

.faq-expand svg {
  width: 15px;
  height: 15px;
}

.faq-card[open] .faq-expand {
  transform: rotate(90deg);
  border-color: color-mix(in srgb, var(--violet) 32%, var(--line));
  color: var(--violet);
}

.faq-answer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
  color: var(--text-soft);
  font-size: .82rem;
  line-height: 1.62;
}

.faq-answer > p {
  margin: 15px 0 0;
}

.faq-answer-note,
.faq-answer-tip {
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.faq-answer-note {
  border-left: 2px solid var(--violet);
}

.faq-answer-tip {
  border-left: 2px solid var(--cyan);
}

.faq-answer-note strong,
.faq-answer-tip strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text);
  font-size: .75rem;
}

.faq-answer-note p,
.faq-answer-tip p {
  margin: 0;
}

.faq-rule-scope {
  color: var(--text-muted);
  font-size: .73rem;
}

.faq-source-labels,
.faq-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.faq-source-labels > span,
.faq-source-citation {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  max-width: 100%;
  padding: 5px 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-soft);
  font-size: .7rem;
  line-height: 1.35;
}

.faq-source-citation {
  min-height: 44px;
  cursor: pointer;
  text-align: left;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
}

.faq-source-citation:hover {
  border-color: color-mix(in srgb, var(--violet) 42%, var(--line));
  background: color-mix(in srgb, var(--violet) 10%, var(--surface));
  color: var(--text);
}

.faq-source-labels svg,
.faq-source-citation svg,
.faq-links svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  color: var(--violet);
}

.faq-links a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  padding: 6px 9px;
  border-radius: 9px;
  color: var(--violet);
  font-size: .74rem;
  line-height: 1.4;
}

.faq-links a:hover {
  background: color-mix(in srgb, var(--violet) 10%, transparent);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.faq-open-notebook {
  display: inline-flex;
  align-self: flex-start;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  margin-top: 1px;
  padding: 0 11px;
  border: 1px solid color-mix(in srgb, var(--violet) 28%, var(--line));
  border-radius: 11px;
  background: color-mix(in srgb, var(--violet) 11%, var(--surface));
  color: var(--text);
  cursor: pointer;
  font-size: .75rem;
  font-weight: 600;
}

.faq-open-notebook:hover {
  background: color-mix(in srgb, var(--violet) 18%, var(--surface));
}

.faq-controls {
  display: flex;
  align-items: center;
  gap: 13px;
  margin: -9px 0 14px;
}

.faq-search {
  width: min(390px, 100%);
  min-height: 46px;
  flex: 0 1 390px;
  border-radius: 13px;
  background: var(--surface);
}

.faq-program-filters {
  display: flex;
  min-width: 0;
  gap: 5px;
  padding: 3px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.faq-program-filters button,
.faq-category-list button {
  min-height: 38px;
  flex: 0 0 auto;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.faq-program-filters button:hover,
.faq-category-list button:hover {
  color: var(--text);
}

.faq-program-filters button.is-active,
.faq-category-list button.is-active {
  border-color: color-mix(in srgb, var(--violet) 29%, var(--line));
  background: color-mix(in srgb, var(--violet) 15%, var(--panel-solid));
  color: var(--text);
}

.faq-category-list {
  display: flex;
  gap: 6px;
  margin: 0 0 17px;
  padding: 1px 1px 5px;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.faq-program-filters::-webkit-scrollbar,
.faq-category-list::-webkit-scrollbar {
  height: 4px;
}

.faq-program-filters::-webkit-scrollbar-thumb,
.faq-category-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: var(--line-strong);
}

.faq-category-list button {
  min-height: 36px;
  padding: 0 13px;
  border-color: var(--line);
  background: var(--surface);
  font-size: .73rem;
}

.faq-disclaimer {
  max-width: 88ch;
  margin: 19px 0 0;
  color: var(--text-muted);
  font-size: .74rem;
  line-height: 1.55;
}

.faq-empty {
  grid-column: 1 / -1;
  margin: 0;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  text-align: center;
}

.library-loading {
  display: flex;
  grid-column: 1 / -1;
  justify-content: center;
  gap: 7px;
  padding: 30px;
}

.library-loading span,
.source-loading span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet);
  animation: library-loading-pulse 1.2s ease-in-out infinite;
}

.library-loading span:nth-child(2),
.source-loading span:nth-child(2) { animation-delay: .15s; }
.library-loading span:nth-child(3),
.source-loading span:nth-child(3) { animation-delay: .3s; }

@keyframes library-loading-pulse {
  50% { opacity: .25; transform: translateY(-4px); }
}

/* Source readers use the same left rail as the source list on desktop. */
.is-notebook .layout {
  grid-template-columns: clamp(318px, 25vw, 460px) minmax(0, 1fr);
}

@media (min-width: 1101px) {
  .is-notebook .layout.is-sources-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }
}

.is-notebook .inspector {
  top: var(--topbar);
  right: auto;
  bottom: 0;
  left: 0;
  width: clamp(318px, 25vw, 460px);
  border-width: 0 1px 0 0;
  border-radius: 0 20px 20px 0;
  transform: translateX(calc(-100% - 18px));
}

.is-notebook .inspector.is-open {
  transform: translateX(0);
}

.is-notebook .inspector-scrim {
  inset: var(--topbar) 0 0;
}

.inspector-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  flex: 0 0 auto;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  font-size: .74rem;
  font-weight: 600;
}

.inspector-back:hover {
  border-color: var(--line-strong);
  background: var(--surface-strong);
  color: var(--text);
}

.inspector-back svg {
  width: 15px;
  height: 15px;
  transform: rotate(180deg);
}

@media (min-width: 721px) and (max-width: 1100px) {
  body.is-library .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "library library";
    gap: 0 8px;
    padding: 6px 18px 7px;
  }

  body.is-library .brand-cluster { grid-area: brand; }
  body.is-library .top-actions { grid-area: actions; }
  body.is-library .library-top-nav {
    grid-area: library;
    justify-self: center;
    margin: 0 0 1px;
  }
}

@media (max-width: 720px) {
  body.is-library .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "brand actions" "library library";
    gap: 0 5px;
    padding: 3px 12px 6px;
  }

  body.is-library .brand-cluster { grid-area: brand; gap: 8px; }
  body.is-library .brand-logo { width: 34px; height: 34px; border-radius: 11px; }
  body.is-library .brand-wordmark strong { font-size: .8rem; }
  body.is-library .top-actions { grid-area: actions; gap: 3px; }
  body.is-library .top-actions .icon-button { width: 44px; height: 44px; }
  body.is-library #accountButton { width: 44px; min-width: 44px; height: 44px; padding: 0; }
  body.is-library #accountButton span { display: none; }
  body.is-library #accountButton .account-glyph { display: block; width: 18px; height: 18px; }
  body.is-library .library-top-nav {
    grid-area: library;
    justify-self: center;
    width: min(100%, 410px);
    gap: 3px;
    margin: 0 0 1px;
    padding: 3px;
    border-radius: 12px;
  }

  body.is-library .library-top-nav button {
    min-width: 0;
    min-height: 44px;
    flex: 1 1 0;
    padding: 0 8px;
    font-size: .72rem;
  }

  .library-settings-menu {
    top: calc(100% + 5px);
    right: 58px;
  }

  .library-page {
    padding: 25px 17px max(38px, env(safe-area-inset-bottom));
  }

  .library-heading-row {
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 28px;
  }

  .library-heading-row .eyebrow { margin-bottom: 6px; }
  .library-heading-row h1 { font-size: clamp(1.8rem, 8vw, 2.45rem); }
  .library-heading-row p { margin-top: 8px; font-size: .83rem; line-height: 1.5; }
  .library-heading-mark { width: 44px; height: 44px; border-radius: 14px; }
  .library-heading-mark svg { width: 20px; height: 20px; }
  .library-section { margin-bottom: 37px; }
  .library-section-heading { align-items: flex-start; margin-bottom: 13px; }
  .library-section-heading > span { padding-top: 4px; font-size: .68rem; }
  .notebook-grid { gap: 10px; }
  .notebook-card { min-height: 205px; padding: 16px; border-radius: 20px; }
  .notebook-card-copy { margin: 15px 0; }
  .notebook-card-copy strong { font-size: 1rem; }
  .notebook-card-copy small { font-size: .73rem; }
  .notebook-emoji { width: 40px; height: 40px; border-radius: 13px; font-size: 1.35rem; }
  .notebook-open-hint { min-height: 32px; padding: 0 8px; font-size: .68rem; }
  .notebook-card-meta { gap: 5px; padding-top: 9px; font-size: .62rem; }
  .faq-card-grid,
  .faq-full-list { grid-template-columns: minmax(0, 1fr); gap: 9px; }
  .faq-card > summary { min-height: 0; grid-template-columns: minmax(0, 1fr) 32px; gap: 8px; padding: 15px 14px; }
  .faq-card-copy > small { margin-bottom: 8px; }
  .faq-card-copy > strong { font-size: .89rem; }
  .faq-short-answer { font-size: .75rem; }
  .faq-answer { padding: 0 14px 15px; font-size: .79rem; }
  .faq-controls { align-items: stretch; flex-direction: column; gap: 8px; margin: -5px 0 12px; }
  .faq-search { width: 100%; flex-basis: auto; }
  .faq-program-filters { width: 100%; }
  .faq-program-filters button,
  .faq-category-list button { min-height: 44px; padding-inline: 10px; font-size: .7rem; }
  .faq-category-list { margin-bottom: 13px; }
  .faq-disclaimer { font-size: .69rem; }

  .is-notebook .layout { grid-template-columns: minmax(0, 1fr); }
  .is-notebook .inspector {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: min(82dvh, 760px);
    border-width: 1px 0 0;
    border-radius: 21px 21px 0 0;
    transform: translateY(calc(100% + 16px));
  }

  .is-notebook .inspector.is-open { transform: translateY(0); }
  .is-notebook .inspector-scrim { inset: 0; }
  .inspector-header { padding: 13px 15px 11px; }
  .inspector-back { min-height: 44px; padding: 0 9px; }
  .inspector-back span { font-size: .7rem; }
}

@media (max-width: 390px) {
  .library-page { padding-inline: 13px; }
  .notebook-grid { grid-template-columns: minmax(0, 1fr); }
  .notebook-card { min-height: 185px; padding: 18px; }
  .notebook-card-copy strong { font-size: 1.1rem; }
  .notebook-card-copy small { font-size: .78rem; }
  .library-heading-mark { display: none; }
  .library-section-heading h2 { font-size: 1.08rem; }
  .text-link-button { min-height: 38px; font-size: .74rem; }
  .notebook-card-meta { font-size: .68rem; }
}

@media (prefers-reduced-motion: reduce) {
  .notebook-card,
  .notebook-open-hint,
  .library-top-nav button,
  .faq-card,
  .faq-expand,
  .faq-program-filters button,
  .faq-category-list button,
  .faq-source-citation {
    transition-duration: .001ms;
  }

  .library-loading span { animation: none; }
}

