:root {
  color-scheme: light;
  --ink: #173f52;
  --ink-deep: #102a36;
  --ink-soft: #536a74;
  --paper: #f3f5f4;
  --sheet: #ffffff;
  --surface-muted: #e9eeec;
  --line: #d6ddda;
  --line-strong: #b8c5c1;
  --signal: #d3a62c;
  --teal: #2d756a;
  --teal-soft: #e8f2ef;
  --danger: #a54235;
  --danger-soft: #fbefed;
  --warning: #755d18;
  --warning-soft: #faf5e6;
  --focus: #0d6e82;
  --brand-contrast: #ffffff;
  --channel-whatsapp: #176b4a;
  --channel-whatsapp-surface: #f1eee8;
  --channel-whatsapp-composer: #ebe7df;
  --channel-whatsapp-message: #d9fdd3;
  --channel-whatsapp-line: #b4d2ad;
  --channel-telegram: #2478ad;
  --channel-telegram-text: #216f9f;
  --channel-telegram-surface: #e4ebef;
  --channel-telegram-composer: #dce5ea;
  --channel-telegram-line: #c9d6dd;
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --header-height: 68px;
  --shadow-overlay: 0 16px 40px rgb(16 42 54 / 16%);
  --layer-header: 20;
  --layer-popover: 30;
  --layer-scrim: 40;
  --layer-drawer: 50;
  font-family: Aptos, "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

html {
  background: var(--paper);
  scroll-padding-top: var(--header-height);
}

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink-deep);
  font-size: 15px;
  line-height: 1.5;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled),
[role="button"],
summary,
label[for] {
  cursor: pointer;
  touch-action: manipulation;
}

button:active:not(:disabled),
.answer-action:active,
summary:active {
  filter: brightness(0.96);
}

:where(button, input, textarea, select, a, summary):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--ink-deep);
  color: white;
  transform: translateY(-150%);
  transition: transform 140ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

[hidden] {
  display: none !important;
}

.app-shell {
  height: 100vh;
  height: 100dvh;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: var(--header-height) minmax(0, 1fr);
  overflow: hidden;
}

.topbar {
  position: relative;
  z-index: var(--layer-header);
  display: grid;
  grid-template-columns: minmax(240px, 320px) 1fr minmax(240px, 320px);
  align-items: center;
  min-height: var(--header-height);
  padding: 0 var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--sheet);
}

.brand {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  width: fit-content;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm) var(--radius-lg) var(--radius-sm) var(--radius-sm);
  background: var(--ink);
  box-shadow: inset 0 -4px 0 var(--signal);
  color: var(--brand-contrast);
  font: 700 20px/1 Georgia, serif;
}

.brand-mark.has-custom-logo {
  border: 1px solid var(--line-strong);
  background-color: white;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  color: transparent;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font: 600 17px/1.2 Georgia, "Times New Roman", serif;
}

.brand small {
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 12px;
}

.view-switcher {
  justify-self: center;
  display: flex;
  align-self: stretch;
  gap: var(--space-5);
}

.view-tab {
  position: relative;
  min-height: 44px;
  padding: 0 2px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
}

.view-tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--ink);
  content: "";
  opacity: 0;
}

.view-tab:hover {
  color: var(--ink-deep);
}

.view-tab.is-active {
  color: var(--ink);
}

.view-tab.is-active::after {
  opacity: 1;
}

.company-badge {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
}

.workspace {
  grid-row: 2;
  min-height: 0;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  overflow: hidden;
}

.library {
  z-index: 10;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: var(--space-5) var(--space-4) var(--space-4);
  border-right: 1px solid var(--line);
  background: var(--paper);
}

.library-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  padding: 0 var(--space-2) var(--space-4);
}

.eyebrow {
  margin: 0 0 var(--space-1);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
}

.library h2,
.dialog-header h2 {
  margin: 0;
  font-family: inherit;
  font-weight: 650;
}

.library h2 {
  font-size: 22px;
}

.icon-button {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--sheet);
}

.icon-button:hover {
  border-color: var(--ink-soft);
  background: var(--surface-muted);
}

.icon-button svg,
.library-search svg,
.voice-button svg,
.send-button svg,
.security-mark svg {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.75;
}

.mobile-menu,
.mobile-close {
  display: none;
}

.library-search {
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-4);
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--sheet);
  color: var(--ink-soft);
}

.library-search:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgb(13 110 130 / 14%);
}

.library-search input {
  min-width: 0;
  flex: 1;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-deep);
  font-size: 14px;
}

.library-search kbd {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 11px;
}

.library-groups {
  min-height: 0;
  overflow-y: auto;
  padding: 0 4px var(--space-5) 0;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

.library-loading,
.library-empty {
  margin: 0;
  padding: var(--space-5) var(--space-2);
  color: var(--ink-soft);
  font-size: 14px;
}

.library-loading::before {
  width: 100%;
  height: 8px;
  display: block;
  margin-bottom: var(--space-3);
  background: var(--surface-muted);
  content: "";
  animation: loading-pulse 1.2s ease-in-out infinite alternate;
}

.document-group + .document-group {
  margin-top: var(--space-5);
}

.category-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin: 0 var(--space-2) var(--space-2);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 650;
}

.category-label span {
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.document-list {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-button {
  position: relative;
  width: 100%;
  min-height: 54px;
  padding: 9px 10px 9px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.document-button:hover {
  background: var(--surface-muted);
}

.document-button[aria-current="true"] {
  border-left-color: var(--signal);
  background: var(--sheet);
}

.document-title {
  display: block;
  color: var(--ink-deep);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.document-meta {
  display: flex;
  gap: var(--space-2);
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 12px;
}

.document-meta span + span::before {
  margin-right: var(--space-2);
  content: "·";
}

.library-footer {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-2) 0;
  border-top: 1px solid var(--line);
}

.security-mark {
  width: 32px;
  height: 32px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: var(--radius-sm);
  background: var(--teal-soft);
  color: var(--teal);
}

.security-mark svg {
  width: 17px;
}

.library-footer strong,
.library-footer small {
  display: block;
}

.library-footer strong {
  font-size: 12px;
}

.library-footer small {
  color: var(--ink-soft);
  font-size: 12px;
}

.chat-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  background: var(--sheet);
}

.chat-panel.has-conversation {
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}

.stats-strip {
  display: flex;
  align-items: center;
  min-height: 42px;
  padding: 0 clamp(20px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--sheet);
  color: var(--ink-soft);
  font-size: 12px;
}

.stat-primary,
.stat-item,
.phase-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.stat-primary,
.stat-item {
  padding-right: var(--space-4);
}

.stat-item {
  padding-left: var(--space-4);
  border-left: 1px solid var(--line);
}

.stat-number,
.stat-item strong {
  color: var(--ink-deep);
  font: inherit;
  font-weight: 650;
  white-space: nowrap;
}

.stat-primary strong,
.stat-primary small,
.stat-item span {
  display: inline;
  margin: 0;
}

.stat-primary small {
  display: none;
}

.phase-badge {
  margin-left: auto;
  color: var(--teal);
  font-weight: 600;
}

.phase-badge span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--teal);
}

.channel-toolbar {
  position: relative;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 56px;
  padding: 7px clamp(20px, 3vw, 40px);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
}

.channel-intro {
  min-width: 188px;
}

.channel-intro strong,
.channel-intro span {
  display: block;
}

.channel-intro strong {
  font-size: 13px;
  font-weight: 650;
}

.channel-intro span {
  color: var(--ink-soft);
  font-size: 12px;
}

.channel-toggle {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--sheet);
}

.channel-option {
  min-height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.channel-option:hover {
  background: var(--surface-muted);
  color: var(--ink-deep);
}

.channel-option.is-active {
  background: var(--ink);
  color: var(--brand-contrast);
}

.mobile-entry-label {
  margin-left: auto;
  color: var(--teal);
  font-size: 12px;
  font-weight: 600;
}

.capability-details,
.mobile-qr {
  position: relative;
}

.capability-details {
  margin-left: auto;
}

.mobile-entry-label:not([hidden]) + .capability-details {
  margin-left: 0;
}

.capability-details summary,
.mobile-qr summary {
  min-height: 40px;
  display: flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--sheet);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  list-style: none;
}

.capability-details summary::-webkit-details-marker,
.mobile-qr summary::-webkit-details-marker {
  display: none;
}

.capability-details summary::after,
.mobile-qr summary::after {
  margin-left: var(--space-2);
  content: "+";
  font-size: 16px;
  font-weight: 400;
}

.capability-details[open] summary,
.mobile-qr[open] summary {
  border-color: var(--ink);
}

.capability-details[open] summary::after,
.mobile-qr[open] summary::after {
  content: "×";
}

.capability-popover,
.mobile-qr-popover {
  position: absolute;
  z-index: var(--layer-popover);
  top: calc(100% + 8px);
  right: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--sheet);
  box-shadow: var(--shadow-overlay);
}

.capability-popover {
  width: min(560px, calc(100vw - 32px));
}

.mobile-qr-popover {
  width: 240px;
  padding: var(--space-4);
  text-align: center;
}

.capability-details:not([open]) .capability-popover,
.mobile-qr:not([open]) .mobile-qr-popover {
  display: none;
}

.capability-surfaces {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.badge-surface {
  min-width: 0;
  padding: var(--space-5);
}

.badge-surface + .badge-surface {
  border-left: 1px solid var(--line);
}

.badge-surface-heading h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.badge-surface-heading p {
  margin: var(--space-1) 0 var(--space-4);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.45;
}

.integration-badges,
.compliance-badges {
  margin: 0;
  padding: 0;
  list-style: none;
}

.integration-badges li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: var(--space-3);
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.integration-badges strong {
  font-size: 13px;
}

.integration-badges span {
  color: var(--ink-soft);
  font-size: 12px;
}

.compliance-badges li {
  position: relative;
  padding: 9px 0 9px 24px;
  border-top: 1px solid var(--line);
  color: var(--ink-deep);
  font-size: 13px;
}

.compliance-badges li::before {
  position: absolute;
  left: 1px;
  color: var(--teal);
  content: "✓";
  font-weight: 700;
}

.qr-code {
  width: 188px;
  height: 188px;
  margin: 0 auto;
  padding: var(--space-1);
  border: 1px solid var(--line);
  background: white;
}

.qr-code svg {
  width: 100%;
  height: 100%;
  display: block;
}

.mobile-qr-popover p {
  margin: var(--space-3) 0 var(--space-2);
  color: var(--ink-soft);
  font-size: 13px;
}

.mobile-qr-popover a {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  color: var(--focus);
  font-size: 13px;
  font-weight: 650;
}

.chat-thread {
  grid-row: 3;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-6) clamp(20px, 5vw, 64px);
  scroll-behavior: smooth;
}

.empty-state,
.message-list {
  width: min(880px, 100%);
  margin: 0 auto;
}

.channel-context {
  width: min(720px, 100%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 auto var(--space-5);
  padding: 0 0 var(--space-3);
  border-bottom: 1px solid rgb(16 42 54 / 16%);
}

.channel-avatar {
  width: 40px;
  height: 40px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--ink);
  color: white;
  font-size: 15px;
  font-weight: 700;
}

.channel-context-copy,
.channel-context-copy strong,
.channel-context-copy span {
  display: block;
}

.channel-context-copy {
  min-width: 0;
}

.channel-context-copy strong {
  color: var(--ink-deep);
  font-size: 14px;
  font-weight: 650;
}

.channel-context-copy span {
  color: var(--ink-soft);
  font-size: 12px;
}

.empty-state {
  text-align: left;
}

.channel-welcome {
  width: min(720px, 100%);
  margin: 0 auto;
}

.channel-intro-message {
  width: min(560px, 88%);
  padding: 14px var(--space-4);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
  color: var(--ink-deep);
}

.channel-sender {
  display: block;
  margin-bottom: 3px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
}

.channel-intro-message p {
  margin: 0;
  font-size: 15px;
  line-height: 1.55;
}

.channel-intro-message small {
  display: block;
  margin-top: var(--space-2);
  color: var(--ink-soft);
  font-size: 12px;
}

.channel-prompt-section {
  width: min(560px, 88%);
  margin-top: var(--space-4);
}

.channel-prompt-section .prompt-label {
  padding-top: 0;
}

.channel-prompt-chips {
  gap: var(--space-2);
}

.channel-prompt-chips .prompt-chip {
  padding: 10px 12px;
  border: 1px solid rgb(16 42 54 / 18%);
  border-radius: var(--radius-lg);
  background: rgb(255 255 255 / 86%);
}

.channel-prompt-chips .prompt-chip:hover {
  padding-left: var(--space-4);
  background: white;
}

.empty-state .eyebrow {
  margin-bottom: var(--space-2);
  color: var(--teal);
  font-weight: 600;
}

.empty-state h1 {
  margin: 0;
  color: var(--ink-deep);
  font: 650 clamp(26px, 3vw, 32px)/1.2 inherit;
  letter-spacing: -0.015em;
}

.welcome-copy {
  max-width: 620px;
  margin: var(--space-2) 0 0;
  color: var(--ink-soft);
  font-size: 15px;
}

.prompt-section {
  max-width: 720px;
  margin-top: var(--space-6);
  border-top: 1px solid var(--line);
}

.prompt-label {
  display: block;
  padding: var(--space-3) 0 var(--space-2);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.prompt-chips {
  display: grid;
}

.prompt-chip {
  min-height: 44px;
  padding: 10px 32px 10px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  text-align: left;
}

.prompt-chip::after {
  float: right;
  color: var(--ink-soft);
  content: "→";
}

.prompt-chip:hover {
  padding-left: var(--space-2);
  background: var(--paper);
}

.message {
  width: min(720px, 92%);
  animation: message-arrival 180ms ease both;
}

.message + .message {
  margin-top: var(--space-5);
}

.message-user {
  margin-left: auto;
}

.message-assistant {
  margin-right: auto;
}

.message-label {
  display: block;
  margin: 0 0 var(--space-1) 1px;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.message-user .message-label {
  text-align: right;
}

.message-bubble {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--sheet);
}

.message-user .message-bubble {
  border-color: var(--ink);
  border-radius: var(--radius-lg) var(--radius-sm) var(--radius-lg) var(--radius-lg);
  background: var(--ink);
  color: var(--brand-contrast);
}

.message-content {
  margin: 0;
  padding: 14px var(--space-4);
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.message-assistant .message-content:empty {
  min-height: 76px;
  background: linear-gradient(
    var(--surface-muted) 0 0
  ) 16px 18px / 68% 8px no-repeat,
  linear-gradient(var(--surface-muted) 0 0) 16px 38px / 84% 8px no-repeat,
  linear-gradient(var(--surface-muted) 0 0) 16px 58px / 48% 8px no-repeat;
  animation: loading-pulse 800ms ease-in-out infinite alternate;
}

.message-assistant.is-streaming .message-content:not(:empty)::after {
  width: 2px;
  height: 1em;
  display: inline-block;
  margin-left: 3px;
  background: var(--signal);
  content: "";
  vertical-align: -0.14em;
  animation: cursor-pulse 850ms steps(1) infinite;
}

.message-assistant.is-fallback .message-bubble {
  border-color: #d6c78f;
  background: var(--warning-soft);
}

.message-assistant.has-error .message-bubble {
  border-color: #d7aaa4;
  background: var(--danger-soft);
}

.source-section,
.answer-actions {
  padding: 0 var(--space-4) var(--space-3);
  border-top: 1px solid var(--line);
}

.source-heading,
.answer-actions-heading {
  margin: 0;
  padding: var(--space-3) 0 var(--space-2);
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
}

.source-cards {
  display: block;
  border-bottom: 1px solid var(--line);
}

.source-card {
  border-top: 1px solid var(--line);
  background: transparent;
}

.source-card summary {
  min-height: 52px;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: 7px 0;
  list-style: none;
}

.source-card summary::-webkit-details-marker {
  display: none;
}

.source-card summary:hover {
  background: var(--paper);
}

.source-icon {
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  text-align: center;
}

.source-identity {
  min-width: 0;
}

.source-identity strong,
.source-identity small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-identity strong {
  font-size: 13px;
}

.source-identity small {
  color: var(--ink-soft);
  font-size: 12px;
}

.source-relevance {
  color: var(--teal);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

.source-snippet {
  margin: 0;
  padding: var(--space-3) var(--space-4) var(--space-4) 40px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.answer-action-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.answer-action {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--sheet);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.answer-action:hover {
  border-color: var(--ink-soft);
  background: var(--paper);
}

.answer-action-status {
  min-height: 18px;
  margin: var(--space-2) 0 0;
  color: var(--ink-soft);
  font-size: 12px;
}

.feedback-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid #ddcf9e;
  color: var(--ink-soft);
  font-size: 13px;
}

.feedback-buttons {
  display: flex;
  gap: var(--space-2);
}

.feedback-buttons button {
  width: 40px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: white;
}

.feedback-buttons button.is-selected {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.composer-wrap {
  grid-row: 4;
  padding: var(--space-3) clamp(20px, 5vw, 64px) var(--space-4);
  border-top: 1px solid var(--line);
  background: var(--sheet);
}

.composer {
  max-width: 880px;
  min-height: 56px;
  display: flex;
  align-items: end;
  gap: var(--space-2);
  margin: 0 auto;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: white;
}

.composer:focus-within {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgb(13 110 130 / 14%);
}

.composer textarea {
  min-height: 40px;
  max-height: 130px;
  flex: 1;
  overflow-y: hidden;
  resize: none;
  padding: 9px 4px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink-deep);
  line-height: 1.45;
}

.composer textarea::placeholder {
  color: #667b84;
}

.voice-button,
.send-button {
  min-height: 40px;
  flex: 0 0 auto;
  border: 0;
  border-radius: var(--radius-md);
}

.voice-button {
  width: 40px;
  display: grid;
  place-items: center;
  background: var(--paper);
  color: var(--ink-soft);
}

.voice-button:not(:disabled):hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.voice-button.is-listening {
  background: var(--danger-soft);
  color: var(--danger);
  animation: voice-pulse 1.2s ease infinite;
}

.send-button {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0 14px;
  background: var(--ink);
  color: var(--brand-contrast);
  font-size: 13px;
  font-weight: 650;
}

.send-button:hover:not(:disabled) {
  filter: brightness(0.9);
}

.send-button svg {
  width: 17px;
}

.turnstile-shell {
  width: min(880px, 100%);
  margin: 6px auto 0;
  display: flex;
  justify-content: flex-end;
}

.turnstile-shell:empty {
  display: none;
}

.composer-note {
  min-height: 18px;
  margin: 6px auto 0;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: left;
  width: min(880px, 100%);
}

.chat-panel[data-channel="whatsapp"] .channel-option[data-channel-option="whatsapp"] {
  background: var(--channel-whatsapp);
  color: white;
}

.chat-panel[data-channel="whatsapp"] .chat-thread {
  background: var(--channel-whatsapp-surface);
}

.chat-panel[data-channel="whatsapp"] .channel-avatar,
.chat-panel[data-channel="whatsapp"] .send-button {
  background: var(--channel-whatsapp);
}

.chat-panel[data-channel="whatsapp"] .channel-sender {
  color: var(--channel-whatsapp);
}

.chat-panel[data-channel="whatsapp"] .composer-wrap {
  background: var(--channel-whatsapp-composer);
}

.chat-panel[data-channel="whatsapp"] .message-user .message-bubble {
  border-color: var(--channel-whatsapp-line);
  background: var(--channel-whatsapp-message);
  color: #17231d;
}

.chat-panel[data-channel="whatsapp"] .message-assistant .message-bubble {
  border-color: #d8d3ca;
}

.chat-panel[data-channel="telegram"] .channel-option[data-channel-option="telegram"] {
  background: var(--channel-telegram);
  color: white;
}

.chat-panel[data-channel="telegram"] .chat-thread {
  background: var(--channel-telegram-surface);
}

.chat-panel[data-channel="telegram"] .channel-avatar,
.chat-panel[data-channel="telegram"] .send-button {
  background: var(--channel-telegram);
}

.chat-panel[data-channel="telegram"] .channel-sender {
  color: var(--channel-telegram-text);
}

.chat-panel[data-channel="telegram"] .composer-wrap {
  background: var(--channel-telegram-composer);
}

.chat-panel[data-channel="telegram"] .message-user .message-bubble {
  border-color: var(--channel-telegram);
  background: var(--channel-telegram);
  color: white;
}

.chat-panel[data-channel="telegram"] .message-assistant .message-bubble {
  border-color: var(--channel-telegram-line);
}

.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .empty-state,
.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .message-list {
  width: min(720px, 100%);
}

.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .message {
  width: min(560px, 88%);
}

.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .message + .message {
  margin-top: var(--space-3);
}

.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .message-label {
  display: none;
}

.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .composer {
  max-width: 720px;
  border-color: rgb(16 42 54 / 22%);
}

.chat-panel:is([data-channel="whatsapp"], [data-channel="telegram"]) .composer-note {
  width: min(720px, 100%);
}

.document-dialog,
.ticket-dialog {
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: white;
  color: var(--ink-deep);
  box-shadow: var(--shadow-overlay);
}

.document-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: min(86vh, 780px);
}

.ticket-dialog {
  width: min(650px, calc(100vw - 32px));
  max-height: min(88vh, 760px);
}

.document-dialog::backdrop,
.ticket-dialog::backdrop {
  background: rgb(16 42 54 / 48%);
}

.dialog-sheet {
  max-height: inherit;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
}

.ticket-sheet {
  max-height: inherit;
  overflow-y: auto;
}

.dialog-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-5);
  border-bottom: 1px solid var(--line);
}

.dialog-header h2 {
  max-width: 580px;
  font-size: 24px;
  line-height: 1.25;
}

.dialog-meta {
  padding: 10px var(--space-5);
  border-bottom: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-soft);
  font-size: 13px;
}

.document-body {
  overflow-y: auto;
  padding: var(--space-5) var(--space-5) var(--space-6);
}

.document-body p {
  max-width: 72ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.72;
}

.document-body p + p {
  margin-top: 1em;
}

.ticket-disclaimer {
  margin: 0;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid #ddcf9e;
  background: var(--warning-soft);
  color: var(--warning);
  font-size: 13px;
}

.ticket-fields {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
}

.ticket-fields label,
.ticket-fields label > span {
  display: block;
}

.ticket-fields label > span {
  margin-bottom: 6px;
  color: var(--ink-deep);
  font-size: 13px;
  font-weight: 600;
}

.ticket-fields input,
.ticket-fields textarea,
.ticket-fields select {
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  outline: 0;
  background: white;
  color: var(--ink-deep);
  line-height: 1.5;
}

.ticket-fields textarea {
  resize: vertical;
}

.ticket-fields :is(input, textarea, select):focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 2px rgb(13 110 130 / 14%);
}

.ticket-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 12px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-md);
  background: var(--ink);
  color: var(--brand-contrast);
  font-size: 13px;
  font-weight: 650;
}

.agency-panel {
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-6) clamp(24px, 4vw, 56px) 48px;
  background: var(--sheet);
}

.agency-header,
.agency-grid {
  max-width: 1240px;
  margin-right: auto;
  margin-left: auto;
}

.agency-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 360px);
  gap: var(--space-6);
  align-items: end;
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--line-strong);
}

.agency-header h1 {
  margin: 0;
  color: var(--ink-deep);
  font: 650 clamp(26px, 3vw, 30px)/1.25 inherit;
  letter-spacing: -0.015em;
}

.agency-header > div > p:last-child {
  max-width: 680px;
  margin: var(--space-2) 0 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.demo-notice {
  padding-left: var(--space-4);
  border-left: 3px solid var(--signal);
  color: var(--ink-soft);
  font-size: 13px;
}

.demo-notice strong,
.demo-notice span {
  display: block;
}

.demo-notice strong {
  margin-bottom: 2px;
  color: var(--ink-deep);
}

.agency-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
}

.agency-card {
  min-width: 0;
  padding: var(--space-6) 0;
  border-bottom: 1px solid var(--line);
}

.usage-card,
.branding-card {
  padding-right: var(--space-6);
  border-right: 1px solid var(--line);
}

.gaps-card,
.upload-card {
  padding-left: var(--space-6);
}

.agency-card-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-4);
}

.agency-card-header h2 {
  margin: 0;
  color: var(--ink-deep);
  font-size: 18px;
  font-weight: 650;
  line-height: 1.3;
}

.usage-total {
  flex: 0 0 auto;
  text-align: right;
}

.usage-total strong,
.usage-total span {
  display: block;
}

.usage-total strong {
  color: var(--ink);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.usage-total span {
  color: var(--ink-soft);
  font-size: 12px;
}

.chart-wrap {
  height: 240px;
  margin-top: var(--space-5);
}

.chart-note,
.card-intro,
.control-status {
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.chart-note,
.control-status {
  margin: var(--space-2) 0 0;
}

.card-intro {
  margin: var(--space-2) 0 var(--space-5);
}

.gap-count,
.mock-label,
.confidence {
  flex: 0 0 auto;
  color: var(--ink-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.mock-label {
  color: var(--warning);
}

.gap-list {
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}

.gap-list li {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-top: 1px solid var(--line);
}

.gap-list strong,
.gap-list div > span {
  display: block;
}

.gap-list strong {
  font-size: 13px;
  line-height: 1.4;
}

.gap-list div > span {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 12px;
}

.confidence-low {
  color: var(--danger);
}

.confidence-medium {
  color: var(--warning);
}

.branding-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(160px, 0.5fr);
  gap: var(--space-5);
}

.file-control,
.color-control {
  min-width: 0;
  display: grid;
  align-content: start;
  gap: var(--space-2);
}

.file-control > span,
.color-control > span:first-child {
  font-size: 13px;
  font-weight: 600;
}

.file-control input,
.upload-input {
  min-width: 0;
  width: 100%;
  color: var(--ink-soft);
  font-size: 13px;
}

::file-selector-button {
  min-height: 40px;
  margin-right: var(--space-2);
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: white;
  color: var(--ink);
  font-weight: 600;
}

.file-control small {
  color: var(--ink-soft);
  font-size: 12px;
}

.color-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.color-input-row input {
  width: 52px;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  background: white;
}

.color-input-row output {
  color: var(--ink-soft);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.branding-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.text-button {
  min-height: 40px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.text-button:hover {
  background: var(--paper);
}

.upload-zone {
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  background: var(--paper);
}

.upload-zone.is-dragging {
  border-color: var(--ink);
  background: var(--teal-soft);
}

.upload-zone label {
  min-height: 108px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: var(--space-1);
  padding: var(--space-5) var(--space-5) var(--space-3);
  text-align: center;
}

.upload-input {
  width: calc(100% - 48px);
  min-height: 40px;
  display: block;
  margin: 0 auto var(--space-4);
}

.upload-zone strong {
  font-size: 14px;
}

.upload-zone label > span:last-child {
  color: var(--ink-soft);
  font-size: 13px;
}

.upload-icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 24px;
}

.indexing-state {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.indexing-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-3);
}

.indexing-heading strong,
.indexing-heading span {
  display: block;
}

.indexing-heading strong {
  max-width: 340px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.indexing-heading span,
.indexing-heading output {
  color: var(--ink-soft);
  font-size: 12px;
}

.indexing-state progress {
  width: 100%;
  height: 8px;
  margin-top: var(--space-3);
  overflow: hidden;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-muted);
  accent-color: var(--ink);
}

.indexing-state progress::-webkit-progress-bar {
  background: var(--surface-muted);
}

.indexing-state progress::-webkit-progress-value,
.indexing-state progress::-moz-progress-bar {
  background: var(--ink);
}

@keyframes message-arrival {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
}

@keyframes cursor-pulse {
  50% { opacity: 0; }
}

@keyframes voice-pulse {
  50% { background: #f4ded9; }
}

@keyframes loading-pulse {
  to { opacity: 0.55; }
}

@media (max-width: 1100px) {
  .topbar {
    grid-template-columns: minmax(190px, 1fr) auto;
  }

  .company-badge {
    display: none;
  }

  .workspace {
    grid-template-columns: 288px minmax(0, 1fr);
  }

  .channel-intro span {
    display: none;
  }

  .channel-intro {
    min-width: auto;
  }

  .agency-grid {
    grid-template-columns: 1fr;
  }

  .usage-card,
  .branding-card,
  .gaps-card,
  .upload-card {
    padding-right: 0;
    padding-left: 0;
    border-right: 0;
  }
}

@media (max-width: 900px) {
  body {
    overscroll-behavior-y: none;
  }

  .app-shell {
    grid-template-rows: calc(60px + env(safe-area-inset-top)) minmax(0, 1fr);
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
    min-height: calc(60px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  }

  .mobile-menu,
  .mobile-close {
    width: 44px;
    height: 44px;
    display: grid;
  }

  .brand {
    min-width: 44px;
    justify-content: center;
  }

  .brand > span:not(.brand-mark) {
    display: none;
  }

  .brand-mark {
    width: 32px;
    height: 36px;
    font-size: 18px;
  }

  .view-switcher {
    gap: var(--space-3);
  }

  .view-tab {
    min-height: 44px;
    font-size: 12px;
  }

  .workspace {
    display: block;
    min-height: 0;
  }

  .library {
    position: fixed;
    z-index: var(--layer-drawer);
    inset: 0 auto 0 0;
    width: min(360px, 92vw);
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    box-shadow: var(--shadow-overlay);
    transform: translateX(-105%);
    transition: transform 180ms ease;
  }

  .library.is-open {
    transform: translateX(0);
  }

  .drawer-scrim {
    position: fixed;
    z-index: var(--layer-scrim);
    inset: 0;
    background: rgb(16 42 54 / 44%);
  }

  .chat-panel {
    height: 100%;
  }

  .stats-strip {
    min-height: 40px;
    padding: 0 max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
    overflow-x: auto;
    scrollbar-width: none;
  }

  .stats-strip::-webkit-scrollbar {
    display: none;
  }

  .stat-primary,
  .stat-item {
    flex: 0 0 auto;
  }

  .phase-badge {
    display: none;
  }

  .channel-toolbar {
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
  }

  .channel-intro {
    flex: 1;
  }

  .channel-toggle {
    order: 3;
    width: 100%;
  }

  .channel-option {
    min-height: 44px;
    min-width: 0;
    flex: 1;
    padding: 0 7px;
  }

  .mobile-entry-label {
    margin-left: 0;
  }

  .mobile-qr {
    margin-left: auto;
  }

  .capability-details summary,
  .mobile-qr summary,
  .mobile-qr-popover a {
    min-height: 44px;
  }

  .capability-popover {
    width: min(560px, calc(100vw - 24px));
  }

  .capability-surfaces {
    grid-template-columns: 1fr;
  }

  .badge-surface + .badge-surface {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .chat-thread {
    padding: var(--space-5) max(14px, env(safe-area-inset-right)) var(--space-5) max(14px, env(safe-area-inset-left));
    overscroll-behavior: contain;
  }

  .message {
    width: 96%;
  }

  .answer-action-controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .answer-action,
  .feedback-buttons button {
    min-height: 44px;
  }

  .feedback-buttons button {
    width: 44px;
  }

  .composer-wrap {
    padding: 9px max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }

  .composer textarea {
    min-height: 44px;
    padding: 10px 2px;
    font-size: 16px;
  }

  .voice-button,
  .send-button {
    width: 44px;
    min-height: 44px;
  }

  .send-button {
    justify-content: center;
    padding: 0;
  }

  .send-button span {
    display: none;
  }

  .document-dialog,
  .ticket-dialog {
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }

  .agency-panel {
    padding: var(--space-5) 16px max(40px, env(safe-area-inset-bottom));
  }

  .agency-header {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .branding-controls {
    grid-template-columns: 1fr;
  }

  body[data-mobile-entry="true"] .app-shell {
    grid-template-rows: calc(56px + env(safe-area-inset-top)) minmax(0, 1fr);
  }

  body[data-mobile-entry="true"] .topbar {
    grid-template-columns: auto 1fr;
    min-height: calc(56px + env(safe-area-inset-top));
  }

  body[data-mobile-entry="true"] .view-switcher,
  body[data-mobile-entry="true"] .company-badge,
  body[data-mobile-entry="true"] .stats-strip,
  body[data-mobile-entry="true"] .channel-intro,
  body[data-mobile-entry="true"] .mobile-entry-label,
  body[data-mobile-entry="true"] .capability-details,
  body[data-mobile-entry="true"] .mobile-qr {
    display: none;
  }

  body[data-mobile-entry="true"] .channel-toolbar {
    min-height: 60px;
    flex-wrap: nowrap;
    padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  }

  body[data-mobile-entry="true"] .channel-toggle {
    order: initial;
    width: 100%;
  }

  body[data-mobile-entry="true"] .channel-option {
    min-height: 48px;
  }
}

@media (max-width: 430px) {
  .topbar {
    padding-right: 8px;
    padding-left: 8px;
  }

  .view-switcher {
    gap: 8px;
  }

  .view-tab {
    font-size: 11px;
  }

  .channel-intro {
    display: none;
  }

  .capability-details,
  .mobile-qr {
    width: calc(50% - 3px);
  }

  .capability-details summary,
  .mobile-qr summary {
    justify-content: center;
  }

  .capability-popover {
    right: auto;
    left: 0;
  }

  .mobile-qr-popover {
    right: 0;
  }

  .empty-state h1 {
    font-size: 25px;
  }

  .composer {
    min-height: 70px;
  }

  .composer textarea {
    min-height: 56px;
  }

  .source-snippet {
    padding-left: 0;
  }

  .agency-card-header,
  .gap-list li {
    align-items: start;
  }
}

@media (max-height: 500px) and (min-width: 600px) and (max-width: 900px) {
  .app-shell {
    grid-template-rows: calc(54px + env(safe-area-inset-top)) minmax(0, 1fr);
  }

  .topbar {
    min-height: calc(54px + env(safe-area-inset-top));
  }

  .stats-strip,
  .channel-intro,
  .mobile-entry-label {
    display: none;
  }

  .channel-toolbar {
    min-height: 52px;
    flex-wrap: nowrap;
  }

  .chat-panel {
    grid-template-rows: auto auto minmax(0, 1fr) auto;
  }

  .channel-toggle {
    order: initial;
    width: auto;
    flex: 1;
  }

  .chat-thread {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .composer-note {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
