@font-face {
  font-family: "Inter";
  src: url("assets/Inter-variable.ttf") format("truetype");
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
}

:root {
  --font-body: Inter, "Segoe UI", Arial, sans-serif;
  --font-display: var(--font-body);
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-strong: #eef1f0;
  --ink: #1e2924;
  --muted: #5b6962;
  --line: #d9dfdc;
  --leaf: #207a48;
  --leaf-dark: #155936;
  --blue: #2b6576;
  --amber: #9a6a14;
  --danger: #ad343b;
  --shadow: 0 1px 3px rgba(20, 34, 27, 0.08), 0 10px 28px rgba(20, 34, 27, 0.05);
  --radius: 8px;
  --av-sidebar-width: 280px;
  --av-content-width: 780px;
  --av-control-height: 44px;
}

html {
  background: var(--bg);
  color-scheme: light;
}

body {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  letter-spacing: 0;
}

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

button {
  font-weight: 600;
}

:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgba(43, 101, 118, 0.32);
  outline-offset: 2px;
}

.av-shell :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 3px solid rgba(43, 101, 118, 0.38);
  outline-offset: 2px;
}

:where(input, select, textarea):focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(43, 101, 118, 0.12);
}

input,
.metric strong,
.ai-markdown td,
.ai-markdown th {
  font-variant-numeric: tabular-nums;
}

/* Public product presentation */
.public-landing {
  background: var(--surface);
  color: var(--ink);
}

.public-header {
  min-height: 72px;
  padding: 12px max(24px, calc((100% - 1180px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.public-logo {
  width: 182px;
  height: 50px;
  object-fit: contain;
}

.public-header :is(button, .language-picker),
.public-hero-actions button {
  min-height: var(--av-control-height);
  border-radius: 8px;
  box-shadow: none;
}

.public-hero {
  position: relative;
  display: flex;
  min-height: min(660px, calc(100svh - 72px));
  align-items: flex-end;
  padding: 72px max(24px, calc((100% - 1180px) / 2)) 64px;
  overflow: hidden;
  background-color: #16382a;
  background-position: center 48%;
  background-size: cover;
}

.public-hero::before {
  position: absolute;
  inset: 0;
  background: rgba(9, 31, 21, 0.48);
  content: "";
}

.public-hero-content {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-width: 680px;
  color: #ffffff;
  text-shadow: none;
}

.public-hero h1 {
  max-width: 100%;
  margin: 8px 0 16px;
  color: #ffffff;
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 650;
  line-height: 1.05;
  letter-spacing: 0;
}

.public-hero-content > p:last-of-type {
  max-width: 620px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  line-height: 1.65;
}

.public-kicker {
  color: #d8f0df;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
}

.public-primary {
  border-color: #ffffff;
  background: #ffffff;
  color: var(--leaf-dark);
}

.public-secondary {
  border-color: rgba(255, 255, 255, 0.58);
  background: rgba(9, 31, 21, 0.2);
  color: #ffffff;
}

.public-product-preview,
.public-tools {
  width: min(1180px, calc(100% - 48px));
  max-width: 1180px;
  margin: 0 auto;
  padding: 64px 0;
}

.public-product-preview img {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.public-tool-list article {
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

/* Authentication */
.auth-screen {
  padding: 24px;
  background: #f4f6f5;
}

.auth-card {
  width: min(520px, 100%);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-content {
  gap: 16px;
}

.auth-brand-logo-large {
  width: min(300px, 84%);
  max-width: 300px;
}

.auth-card .auth-mode-title {
  color: var(--ink);
  font-size: 24px;
  font-weight: 620;
  line-height: 1.3;
}

.auth-form {
  gap: 14px;
}

.auth-form label > span {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.auth-form input {
  min-height: 48px;
  border: 1px solid #bfc9c4;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.auth-card :is(.auth-submit, .auth-switch) {
  min-height: 48px;
  border-radius: 8px;
  box-shadow: none;
}

.auth-submit {
  border-color: var(--leaf);
  background: var(--leaf);
}

/* Product shell */
.app-shell.av-shell {
  display: grid;
  grid-template-columns: var(--av-sidebar-width) minmax(0, 1fr);
  min-width: 0;
  min-height: 100dvh;
  background: var(--bg);
}

.app-shell.av-shell.is-assistant-active {
  height: var(--chat-viewport-height, 100dvh);
  min-height: 0;
  overflow: hidden;
}

.av-shell .side-panel {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  width: var(--av-sidebar-width);
  height: 100dvh;
  min-height: 0;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px 12px;
  overflow: hidden;
  border: 0;
  border-right: 1px solid var(--line);
  background: #f7f8f6;
  color: var(--ink);
  box-shadow: none;
  transition: none;
}

.av-shell .side-brand-row {
  display: flex;
  order: 1;
  min-height: 48px;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px 8px 7px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.av-shell .side-brand-row img {
  display: block;
  width: 174px;
  height: 44px;
  object-fit: contain;
  object-position: left center;
}

.sidebar-close,
.sidebar-toggle,
.mobile-new-chat {
  display: grid;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.sidebar-close:hover,
.sidebar-toggle:hover,
.mobile-new-chat:hover {
  border-color: var(--line);
  background: var(--surface-strong);
  color: var(--ink);
}

.sidebar-close span {
  font-size: 30px;
  font-weight: 400;
  line-height: 1;
}

.sidebar-toggle {
  display: none;
}

.menu-icon,
.menu-icon::before,
.menu-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  content: "";
}

.menu-icon {
  position: relative;
}

.menu-icon::before {
  position: absolute;
  top: -6px;
}

.menu-icon::after {
  position: absolute;
  top: 6px;
}

.workspace-brand,
.mobile-new-chat,
.sidebar-backdrop {
  display: none;
}

.av-shell .brand-visual,
.av-shell .support-link {
  display: none;
}

.av-shell .tool-nav {
  display: grid;
  order: 2;
  gap: 4px;
  padding: 4px 0 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.av-shell .nav-button:not([data-target="assistente"]):not([data-target="biblioteca"]) {
  display: none;
}

.av-shell .nav-button {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 7px 9px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #34413a;
  font-size: 14px;
  font-weight: 570;
  text-align: left;
  box-shadow: none;
}

.av-shell .nav-button:hover,
.av-shell .nav-button:focus-visible {
  background: #ecefed;
  color: var(--ink);
}

.av-shell .nav-button.is-active {
  background: #e2eee7;
  color: var(--leaf-dark);
  box-shadow: inset 3px 0 0 var(--leaf);
}

.nav-symbol {
  position: relative;
  display: grid;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  place-items: center;
  border: 1px solid #cfd8d3;
  border-radius: 7px;
  background: #ffffff;
  color: var(--leaf-dark);
  font-size: 12px;
  font-weight: 700;
}

.nav-symbol-chat::before {
  width: 14px;
  height: 11px;
  border: 1.5px solid currentColor;
  border-radius: 4px;
  content: "";
}

.nav-symbol-chat::after {
  position: absolute;
  bottom: 6px;
  left: 8px;
  width: 5px;
  height: 5px;
  border-bottom: 1.5px solid currentColor;
  border-left: 1.5px solid currentColor;
  background: #ffffff;
  content: "";
  transform: skewY(-34deg);
}

.nav-symbol-library::before {
  width: 15px;
  height: 14px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
  content: "";
}

.nav-symbol-library::after {
  position: absolute;
  top: 7px;
  bottom: 7px;
  left: 50%;
  width: 1.5px;
  background: currentColor;
  content: "";
  transform: translateX(-50%);
}

.av-shell .ai-thread-pane {
  display: flex;
  order: 3;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 10px;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
}

.av-shell .ai-new-thread-button {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border: 1px solid #b8c8c0;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  box-shadow: none;
}

.av-shell .ai-new-thread-button::before {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border-radius: 6px;
  background: #e2eee7;
  color: var(--leaf-dark);
  content: "+";
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}

.av-shell .ai-new-thread-button:hover,
.av-shell .ai-new-thread-button:focus-visible {
  border-color: var(--leaf);
  background: #f9fbfa;
}

.av-shell .ai-new-thread-button:disabled,
.mobile-new-chat:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.av-shell .ai-thread-heading {
  display: grid;
  gap: 2px;
  padding: 6px 8px 0;
}

.av-shell .ai-thread-heading strong {
  color: var(--ink);
  font-size: 12px;
  font-weight: 650;
  text-transform: none;
}

.av-shell .ai-thread-heading span,
.av-shell .ai-thread-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.av-shell #aiHistorySearch {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  margin: 0;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 14px;
}

.av-shell .ai-thread-list {
  display: grid;
  min-height: 0;
  gap: 3px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.av-shell .ai-thread-item {
  display: grid;
  min-height: 44px;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
}

.av-shell .ai-thread-item:hover {
  background: #ecefed;
}

.av-shell .ai-thread-item.is-active {
  background: #e2eee7;
}

.av-shell .ai-thread-open,
.av-shell .ai-thread-delete {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

.av-shell .ai-thread-open {
  display: grid;
  gap: 2px;
  padding: 8px 6px 8px 10px;
  text-align: left;
}

.av-shell .ai-thread-open :is(strong, span) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.av-shell .ai-thread-open strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 570;
}

.av-shell .ai-thread-open span {
  color: var(--muted);
  font-size: 11px;
}

.av-shell .ai-thread-delete {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  font-size: 20px;
}

.av-shell .ai-thread-delete:hover {
  background: #f4e7e7;
  color: var(--danger);
}

.av-shell .side-utilities {
  display: grid;
  order: 4;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 7px;
}

.av-shell .side-utilities :is(.language-picker, .weather-chip),
.av-shell .user-panel,
.av-shell .logout-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: none;
}

.av-shell .side-utilities :is(.language-picker, .weather-chip) {
  min-height: 42px;
}

.av-shell .side-utilities :is(.language-picker, .weather-chip) :is(strong, span, b) {
  color: var(--ink);
}

.av-shell .user-panel {
  order: 5;
  margin: 0;
  padding: 8px 9px;
}

.av-shell .user-panel span {
  color: var(--muted);
  font-size: 10px;
}

.av-shell .user-panel strong {
  color: var(--ink);
  font-size: 13px;
}

.av-shell .logout-button {
  min-height: 34px;
  padding: 5px 9px;
  color: var(--leaf-dark);
}

.av-shell .app-legal-links {
  order: 6;
  padding: 0 4px;
}

.av-shell .app-legal-links a {
  color: var(--muted);
  font-size: 11px;
}

.av-shell .weather-popover {
  z-index: 80;
  right: 0;
  width: min(244px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.av-shell .workspace {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 16px;
  padding: 16px;
  background: var(--bg);
}

.av-shell.is-assistant-active .workspace {
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  align-content: stretch;
  gap: 0;
  padding: 0;
  overflow: hidden;
  background: #ffffff;
}

.av-shell.is-sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.av-shell.is-sidebar-collapsed .side-panel {
  visibility: hidden;
  opacity: 0;
  transform: translateX(-100%);
  pointer-events: none;
}

.av-shell.is-sidebar-collapsed .sidebar-toggle {
  display: grid;
}

/* Current work bar */
.av-shell .work-context-bar {
  display: flex;
  min-width: 0;
  min-height: 58px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px 9px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
}

.av-shell.is-assistant-active .work-context-bar {
  min-height: 54px;
  padding: 7px 16px;
  border-width: 0 0 1px;
  border-radius: 0;
  background: #ffffff;
}

.av-shell .work-context-summary {
  display: grid;
  min-width: 0;
  flex: 1 1 auto;
  gap: 1px;
}

.av-shell .work-context-kicker {
  color: var(--leaf);
  font-size: 11px;
  font-weight: 650;
  text-transform: none;
}

.av-shell .work-context-summary strong,
.av-shell .work-context-summary > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.av-shell .work-context-summary strong {
  color: var(--ink);
  font-size: 14px;
  font-weight: 620;
}

.av-shell .work-context-summary > span:last-child {
  color: var(--muted);
  font-size: 12px;
}

.av-shell .work-context-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.av-shell .context-action {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  box-shadow: none;
}

.av-shell .context-action:hover {
  border-color: #aebcb5;
  background: var(--surface-strong);
}

.av-shell.is-assistant-active #applyWorkContext,
.av-shell.is-assistant-active #saveWorkNotebook,
.av-shell.is-assistant-active #openWorkNotebook {
  display: none;
}

/* Assistant */
.av-shell .ai-panel {
  min-width: 0;
  min-height: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #ffffff;
  box-shadow: none;
}

.av-shell.is-assistant-active .ai-panel.is-active {
  display: grid;
  height: 100%;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
}

.av-shell .ai-panel-heading {
  display: flex;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
  border: 0;
  border-bottom: 1px solid #e6eae8;
  background: #ffffff;
}

.av-shell .ai-panel-title {
  display: block;
  min-width: 0;
}

.av-shell .ai-panel-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 630;
  line-height: 1.25;
}

.av-shell .ai-panel-heading #aiEyebrow {
  margin: 1px 0 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
}

.av-shell .ai-status {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  gap: 7px;
  padding: 4px 9px;
  border: 1px solid #d4e6da;
  border-radius: 999px;
  background: #f1f8f3;
  color: var(--leaf-dark);
  font-size: 11px;
  font-weight: 620;
  white-space: nowrap;
}

.av-shell .ai-status::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2d9a59;
  content: "";
}

.av-shell .ai-status.is-busy {
  border-color: #ead8ae;
  background: #fff9eb;
  color: #77500e;
}

.av-shell .ai-status.is-busy::before {
  background: #c58c26;
}

.av-shell .ai-status.is-error {
  border-color: #efcece;
  background: #fff4f3;
  color: #8b2b30;
}

.av-shell .ai-status.is-error::before {
  background: var(--danger);
}

.av-shell .ai-shell {
  display: block;
  min-width: 0;
  min-height: 0;
  background: #ffffff;
}

.av-shell .ai-chat-pane {
  position: relative;
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
}

.av-shell .ai-messages {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 28px;
  padding: 30px max(20px, calc((100% - var(--av-content-width)) / 2)) 24px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-padding-bottom: 24px;
  scrollbar-gutter: stable;
}

.av-shell .ai-panel:not(.has-conversation) .ai-messages {
  min-height: 0;
  flex: 0 0 auto;
  justify-content: flex-start;
  padding-top: clamp(54px, 10vh, 96px);
  padding-bottom: 20px;
}

.av-shell .ai-panel:not(.has-conversation) .ai-chat-pane {
  justify-content: flex-start;
  overflow-y: auto;
}

.av-shell .ai-welcome {
  width: min(620px, 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 0;
  text-align: center;
}

.av-shell .ai-welcome::before {
  display: grid;
  width: 44px;
  height: 44px;
  margin: 0 auto 16px;
  place-items: center;
  border: 1px solid #c9ddd1;
  border-radius: 50%;
  background: #edf6f0;
  color: var(--leaf-dark);
  content: "A";
  font-size: 17px;
  font-weight: 680;
}

.av-shell .ai-welcome h4 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 28px;
  font-weight: 610;
  line-height: 1.25;
  letter-spacing: 0;
}

.av-shell .ai-welcome p {
  max-width: 540px;
  margin: 0 auto;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.av-shell .ai-suggestions {
  display: grid;
  width: min(var(--av-content-width), calc(100% - 40px));
  flex: 0 0 auto;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 auto 12px;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
}

.av-shell .ai-panel.has-conversation .ai-suggestions {
  display: none;
}

.av-shell .ai-suggestions button {
  min-height: 50px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #34413a;
  font-size: 13px;
  font-weight: 520;
  line-height: 1.4;
  text-align: left;
  white-space: normal;
  box-shadow: none;
}

.av-shell .ai-suggestions button:hover,
.av-shell .ai-suggestions button:focus-visible {
  border-color: #b6c3bd;
  background: #f7f9f8;
  color: var(--ink);
}

.av-shell .ai-message {
  display: flex;
  width: min(var(--av-content-width), 100%);
  max-width: none;
  margin: 0 auto;
}

.av-shell .ai-message.is-user {
  justify-content: flex-end;
}

.av-shell .ai-message.is-assistant {
  display: block;
  align-self: auto;
}

.av-shell .ai-message.is-assistant::before {
  content: none;
}

.av-shell .ai-message-body {
  display: grid;
  min-width: 0;
  gap: 10px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.av-shell .ai-message.is-user .ai-message-body {
  width: fit-content;
  max-width: min(650px, 86%);
  padding: 10px 15px;
  border: 1px solid #e0e5e2;
  border-radius: 18px;
  background: #f0f2f1;
  color: #26322c;
}

.av-shell .ai-message.is-error .ai-message-body {
  padding: 12px 14px;
  border: 1px solid #ebc7c8;
  border-radius: 8px;
  background: #fff6f5;
  color: #7d2a2f;
}

.av-shell .ai-message.is-interrupted .ai-message-body {
  padding-left: 12px;
  border-left: 3px solid #d1a04a;
}

.ai-interrupted-note {
  margin: 4px 0 0;
  color: #77500e;
  font-size: 12px;
  line-height: 1.45;
}

.av-shell .ai-message-tools,
.av-shell .ai-user-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;
  margin-top: 2px;
}

.av-shell .ai-user-tools {
  justify-content: flex-end;
  margin-top: 0;
}

.av-shell .ai-message-tools :is(button, summary) {
  width: auto;
  min-height: 34px;
  padding: 5px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 530;
  line-height: 1.35;
  list-style: none;
  box-shadow: none;
  cursor: pointer;
}

.av-shell .ai-message-tools :is(button, summary):hover,
.av-shell .ai-message-tools :is(button, summary):focus-visible {
  background: var(--surface-strong);
  color: var(--ink);
}

.av-shell .ai-export-menu {
  position: relative;
}

.av-shell .ai-export-menu > summary::-webkit-details-marker {
  display: none;
}

.av-shell .ai-export-menu[open] {
  z-index: 6;
}

.av-shell .ai-export-menu[open] > button {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  display: block;
  min-width: 132px;
  border: 1px solid var(--line);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.av-shell .ai-export-menu[open] > button:last-child {
  bottom: calc(200% + 5px);
}

.av-shell .ai-follow-up {
  padding-left: 12px;
  border-left: 2px solid #c7d8cf;
  color: var(--muted);
  font-size: 14px;
}

.av-shell .ai-calculation {
  margin: 4px 0 0;
  font-size: 13px;
}

.av-shell .ai-calculation summary {
  color: var(--blue);
  cursor: pointer;
}

.av-shell .ai-calculation-data {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 16px;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9f8;
}

.av-shell .ai-calculation-data dt {
  color: var(--muted);
}

.av-shell .ai-calculation-data dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.av-shell .ai-stream-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.av-shell .ai-stream-text:empty::after,
.av-shell #aiTypingMessage .ai-stream-text:not(:empty)::after {
  display: inline-block;
  width: 7px;
  height: 16px;
  margin-left: 3px;
  background: var(--leaf);
  content: "";
  vertical-align: -2px;
  animation: ai-cursor 900ms steps(2, jump-none) infinite;
}

@keyframes ai-cursor {
  50% { opacity: 0; }
}

.av-shell .ai-scroll-bottom {
  position: absolute;
  z-index: 8;
  right: 50%;
  bottom: 142px;
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  box-shadow: var(--shadow);
  transform: translateX(50%);
}

.av-shell .ai-scroll-bottom[hidden] {
  display: none;
}

.av-shell .ai-composer {
  display: grid;
  width: min(var(--av-content-width), calc(100% - 40px));
  min-height: 86px;
  flex: 0 0 auto;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  margin: 0 auto 8px;
  padding: 9px 9px 8px 14px;
  border: 1px solid #aebbb4;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(20, 34, 27, 0.08);
}

.av-shell .ai-composer:focus-within {
  border-color: var(--leaf);
  box-shadow: 0 0 0 3px rgba(32, 122, 72, 0.12), 0 3px 10px rgba(20, 34, 27, 0.07);
}

.av-shell .ai-composer textarea {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 40px;
  max-height: 160px;
  margin: 0;
  padding: 8px 4px 4px;
  resize: none;
  overflow-y: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  box-shadow: none;
}

.av-shell .ai-composer textarea:focus {
  outline: 0;
  box-shadow: none;
}

.av-shell .ai-composer textarea::placeholder {
  color: #748079;
  opacity: 1;
}

.av-shell .ai-composer-footer {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.av-shell .ai-composer-help {
  padding: 0 4px 2px;
  color: #79857f;
  font-size: 11px;
  line-height: 1.3;
}

.av-shell .ai-composer-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.av-shell .ai-send-button,
.av-shell #aiStop {
  display: flex;
  height: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--leaf-dark);
  border-radius: 10px;
  background: var(--leaf);
  color: #ffffff;
  font-size: 13px;
  font-weight: 630;
  line-height: 1;
  box-shadow: none;
  transition: none;
}

.av-shell .ai-send-button > [aria-hidden] {
  font-size: 21px;
  font-weight: 500;
}

.av-shell .ai-send-button:hover:not(:disabled) {
  background: var(--leaf-dark);
}

.av-shell .ai-send-button:disabled {
  border-color: #c9d0cc;
  background: #e8ebe9;
  color: #68736d;
  cursor: not-allowed;
  opacity: 1;
}

.av-shell #aiStop {
  width: 44px;
  padding: 0;
  border-color: #2a3430;
  background: #2a3430;
}

.av-shell #aiStop::before {
  display: block;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  background: #ffffff;
  content: "";
}

.av-shell #aiStop[hidden],
.av-shell #aiForm[aria-busy="true"] #aiSend {
  display: none;
}

.av-shell .ai-disclaimer {
  width: min(var(--av-content-width), calc(100% - 40px));
  flex: 0 0 auto;
  margin: 0 auto;
  padding: 0 12px 12px;
  color: #707c76;
  font-size: 11px;
  line-height: 1.45;
  text-align: center;
}

/* Safe response formatting */
.ai-markdown {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
}

.ai-markdown p {
  margin: 0 0 12px;
}

.ai-markdown p:last-child {
  margin-bottom: 0;
}

.ai-markdown :is(h4, h5) {
  margin: 20px 0 8px;
  color: var(--ink);
  font-weight: 640;
  line-height: 1.35;
}

.ai-markdown h4 {
  font-size: 18px;
}

.ai-markdown h5 {
  font-size: 16px;
}

.ai-markdown :is(ul, ol) {
  margin: 7px 0 14px;
  padding-left: 24px;
}

.ai-markdown li {
  margin: 4px 0;
}

.ai-markdown :not(pre) > code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #edf1ef;
  color: #24342c;
  font-size: 0.92em;
}

.ai-markdown pre {
  max-width: 100%;
  margin: 12px 0;
  padding: 14px;
  overflow: auto;
  border: 1px solid #d7dedb;
  border-radius: 8px;
  background: #202824;
  color: #f4f7f5;
  font-size: 13px;
  line-height: 1.55;
}

.ai-markdown blockquote {
  margin: 12px 0;
  padding: 3px 0 3px 14px;
  border-left: 3px solid #b8c9c0;
  color: var(--muted);
}

.ai-table-scroll {
  max-width: 100%;
  margin: 12px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ai-markdown table {
  width: 100%;
  min-width: 480px;
  border-collapse: collapse;
  font-size: 14px;
}

.ai-markdown :is(th, td) {
  padding: 9px 11px;
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.ai-markdown th {
  background: #f1f4f2;
  color: #34413a;
  font-weight: 630;
}

.ai-markdown tbody tr:last-child td {
  border-bottom: 0;
}

/* Calculators and library use the same visual language */
.av-shell:not(.is-assistant-active) .workspace {
  min-height: 100dvh;
}

.av-shell .calc-panel:not(.ai-panel) {
  min-width: 0;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: none;
}

.av-shell :is(.panel-heading, .library-heading) h3 {
  color: var(--ink);
  font-size: 22px;
  font-weight: 630;
  line-height: 1.3;
}

.av-shell .eyebrow {
  color: var(--leaf);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
}

.av-shell .form-grid label > span:first-child,
.av-shell .library-form label > span:first-child {
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
}

.av-shell :is(.form-grid, .library-form) :is(input, select) {
  min-height: 46px;
  border: 1px solid #bfcac4;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 16px;
}

.av-shell .field-unit {
  color: var(--muted);
  font-size: 12px;
}

.av-shell :is(.primary-action, .ghost-button, .copy-button) {
  min-height: 42px;
  border-radius: 8px;
  box-shadow: none;
}

.av-shell .primary-action {
  background: var(--leaf);
}

.av-shell .library-panel {
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.av-shell .library-heading,
.av-shell .library-toolbar,
.av-shell .library-groups {
  border-color: var(--line);
  background: #ffffff;
}

.av-shell .library-heading {
  padding: 20px 22px;
}

.av-shell .library-count {
  border: 1px solid #c9ddd1;
  border-radius: 8px;
  background: #edf6f0;
  color: var(--leaf-dark);
}

.av-shell .library-toolbar {
  gap: 12px;
  padding: 14px 22px;
  background: #fafbfa;
}

.av-shell .library-search {
  position: relative;
}

.av-shell .library-search input {
  min-height: 46px;
  padding-right: 50px;
  border: 1px solid #bfcac4;
  border-radius: 8px;
  background: #ffffff;
}

.av-shell #libraryClearSearch {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 22px;
  transform: translateY(-50%);
}

.av-shell .library-view-switch {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  box-shadow: none;
}

.av-shell .library-view-switch button,
.av-shell .library-groups button {
  border-radius: 7px;
}

.av-shell .library-groups {
  flex-wrap: wrap;
  padding: 10px 22px;
  overflow: visible;
  background: #f5f7f6;
}

.av-shell .library-groups button.is-active {
  border-color: #b9cfc1;
  background: #ffffff;
  color: var(--leaf-dark);
}

.av-shell .library-layout {
  align-items: start;
  grid-template-columns: minmax(280px, 320px) minmax(0, 1fr);
  background: #ffffff;
}

.av-shell .library-catalog {
  max-height: none;
  overflow: visible;
  border-color: var(--line);
  background: #f8faf9;
}

.av-shell .library-tool-row {
  min-height: 74px;
  border-color: #e3e8e5;
  background: transparent;
}

.av-shell .library-tool-row:hover {
  background: #f0f3f1;
}

.av-shell .library-tool-row.is-active {
  border-left-color: var(--leaf);
  background: #e8f1eb;
  box-shadow: inset 3px 0 0 var(--leaf);
}

.av-shell .library-tool-open {
  grid-template-columns: minmax(0, 1fr);
}

.av-shell .library-tool-open strong {
  overflow: visible;
  text-overflow: clip;
  white-space: normal;
}

.av-shell .library-tool-copy small {
  display: block;
  overflow: visible;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-overflow: clip;
  white-space: normal;
  -webkit-line-clamp: unset;
}

.av-shell .library-tool-name {
  flex-wrap: wrap;
}

.av-shell .library-tool-name em {
  display: none;
}

.av-shell .library-workspace,
.av-shell .library-history {
  min-width: 0;
  background: #ffffff;
}

.av-shell .library-tool-heading h4 {
  color: var(--ink);
  font-size: 21px;
  font-weight: 630;
}

.av-shell .library-result {
  border: 1px solid #cfd9d4;
  border-radius: 8px;
  background: #f6f8f7;
}

.av-shell .library-result.is-empty {
  background: #fafbfa;
}

.av-shell .library-result .metrics {
  border-radius: 7px;
  background: #dce5e0;
}

.av-shell .library-result .metric {
  background: #ffffff;
}

.av-shell .library-result .metric.is-accent {
  background: #e7f2eb;
}

.av-shell .metric strong {
  color: var(--ink);
  font-size: 22px;
  font-weight: 620;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.av-shell .metric :is(span, small) {
  color: var(--muted);
  font-size: 12px;
}

.library-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 12px;
  color: var(--muted);
}

.library-pagination button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  font-size: 20px;
}

.library-pagination button:disabled {
  opacity: 0.42;
}

.library-filter-notice {
  padding: 10px 12px;
  border-left: 3px solid #b37b1f;
  background: #fff8e9;
  color: #6e4a0f;
  font-size: 13px;
}

.library-example-notice {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.field-error {
  display: block;
  grid-column: 1 / -1;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.45;
}

.field-error[hidden],
.library-filter-notice[hidden] {
  display: none;
}

.av-shell input[aria-invalid="true"],
.av-shell select[aria-invalid="true"] {
  border-color: var(--danger);
}

.av-shell .library-actions button:disabled {
  background: #e7ebe8;
  color: #68736d;
  cursor: not-allowed;
  opacity: 1;
}

/* Dialogs and supporting content */
.integration-modal-panel,
.loading-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(20, 34, 27, 0.18);
}

.integration-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.ai-confirm-panel {
  max-width: 540px;
}

.ai-confirm-message {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
  white-space: pre-line;
}

#aiConfirmAccept.is-danger {
  border-color: var(--danger);
  background: var(--danger);
}

.legal-main {
  max-width: 850px;
}

.legal-main :is(p, li) {
  font-size: 16px;
  line-height: 1.75;
}

@media (max-width: 1100px) {
  :root {
    --av-sidebar-width: 252px;
  }

  .av-shell .library-layout {
    grid-template-columns: minmax(250px, 290px) minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell.av-shell,
  .app-shell.av-shell.is-assistant-active {
    display: grid;
    height: var(--chat-viewport-height, 100dvh);
    min-height: 0;
    grid-template-columns: minmax(0, 1fr);
    overflow: hidden;
  }

  .av-shell:not(.is-assistant-active) {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .av-shell .side-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 90;
    width: min(320px, calc(100vw - 48px));
    height: var(--chat-viewport-height, 100dvh);
    padding-top: max(12px, env(safe-area-inset-top));
    visibility: hidden;
    opacity: 0;
    transform: translateX(-104%);
    box-shadow: 18px 0 48px rgba(20, 34, 27, 0.18);
    pointer-events: none;
  }

  .av-shell.is-sidebar-open .side-panel {
    visibility: visible;
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
  }

  .av-shell .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: none;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(20, 29, 25, 0.42);
  }

  .av-shell.is-sidebar-open .sidebar-backdrop {
    display: block;
  }

  .av-shell .weather-popover {
    position: fixed;
    top: max(64px, calc(env(safe-area-inset-top) + 52px));
    right: auto;
    left: 24px;
    width: min(280px, calc(100vw - 48px));
    max-height: calc(var(--chat-viewport-height, 100dvh) - 78px);
    overflow-y: auto;
  }

  body.sidebar-modal-open {
    overflow: hidden;
  }

  .av-shell .sidebar-toggle,
  .av-shell.is-sidebar-collapsed .sidebar-toggle {
    display: grid;
  }

  .av-shell .workspace-brand {
    display: block;
    width: 132px;
    height: 36px;
    flex: 0 0 132px;
    object-fit: contain;
  }

  .av-shell .mobile-new-chat {
    display: grid;
    margin-left: auto;
    color: var(--leaf-dark);
    font-size: 24px;
    font-weight: 400;
  }

  .av-shell .workspace {
    min-height: 100dvh;
    padding: 12px;
  }

  .av-shell.is-assistant-active .workspace {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
    padding: 0;
  }

  .av-shell .work-context-bar,
  .av-shell.is-assistant-active .work-context-bar {
    min-height: 56px;
    gap: 8px;
    padding: max(7px, env(safe-area-inset-top)) 8px 7px;
    border-width: 0 0 1px;
    border-radius: 0;
  }

  .av-shell .work-context-kicker,
  .av-shell .work-context-summary > span:last-child {
    display: none;
  }

  .av-shell .work-context-summary strong {
    font-size: 12px;
  }

  .av-shell .work-context-actions {
    width: auto;
  }

  .av-shell .work-context-actions .context-action:not(#editWorkContext) {
    display: none;
  }

  .av-shell .context-action {
    min-height: 36px;
    padding: 5px 9px;
  }

  .av-shell .ai-panel-heading {
    min-height: 48px;
    padding: 7px 12px;
  }

  .av-shell .ai-panel-heading #aiEyebrow {
    display: none;
  }

  .av-shell .ai-messages {
    gap: 22px;
    padding: 22px 16px 18px;
    scrollbar-gutter: auto;
  }

  .av-shell .ai-panel:not(.has-conversation) .ai-messages {
    justify-content: flex-start;
    padding-top: 44px;
    padding-bottom: 18px;
  }

  .av-shell .ai-welcome::before {
    width: 40px;
    height: 40px;
    margin-bottom: 13px;
  }

  .av-shell .ai-welcome h4 {
    font-size: 24px;
  }

  .av-shell .ai-welcome p {
    font-size: 14px;
  }

  .av-shell .ai-suggestions,
  .av-shell .ai-composer,
  .av-shell .ai-disclaimer {
    width: calc(100% - 24px);
  }

  .av-shell .ai-message.is-user .ai-message-body {
    max-width: 90%;
  }

  .av-shell .ai-message-tools :is(button, summary) {
    min-height: 40px;
    padding: 7px 9px;
  }

  .av-shell .ai-composer {
    min-height: 78px;
    margin-bottom: max(7px, env(safe-area-inset-bottom));
  }

  .av-shell .ai-composer textarea {
    max-height: 120px;
  }

  .av-shell .ai-composer-help {
    display: none;
  }

  .av-shell .ai-composer-footer {
    justify-content: flex-end;
  }

  .av-shell .ai-send-button {
    width: 44px;
    padding: 0;
  }

  .av-shell .ai-send-label {
    display: none;
  }

  .av-shell .ai-scroll-bottom {
    bottom: 124px;
  }

  .av-shell .ai-disclaimer {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    font-size: 10px;
  }

  .av-shell .library-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .av-shell .library-catalog {
    max-height: none;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
}

@media (max-width: 600px) {
  .public-header {
    min-height: 64px;
    padding: 8px 14px;
  }

  .public-logo {
    width: 146px;
    height: 42px;
  }

  .public-header-actions .language-picker span,
  .public-header-actions .public-login-link {
    font-size: 12px;
  }

  .public-hero {
    min-height: min(600px, calc(100svh - 64px));
    padding: 48px 18px 42px;
  }

  .public-hero h1 {
    font-size: 44px;
  }

  .public-hero-content > p:last-of-type {
    font-size: 16px;
  }

  .public-hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .public-product-preview,
  .public-tools {
    width: calc(100% - 32px);
    padding: 44px 0;
  }

  .auth-screen {
    padding: 12px;
  }

  .auth-card {
    padding: 22px 17px;
  }

  .av-shell .workspace-brand {
    width: 116px;
    flex-basis: 116px;
  }

  .av-shell .work-context-summary {
    display: none;
  }

  .av-shell .work-context-actions {
    margin-left: auto;
  }

  .av-shell .ai-panel-heading {
    padding-inline: 10px;
  }

  .av-shell .ai-status {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .av-shell .ai-messages {
    padding-inline: 12px;
  }

  .av-shell .ai-welcome h4 {
    font-size: 22px;
  }

  .av-shell .ai-suggestions {
    grid-template-columns: minmax(0, 1fr);
  }

  .av-shell .ai-suggestions button {
    min-height: 48px;
  }

  .av-shell .ai-message-body {
    font-size: 15px;
    line-height: 1.65;
  }

  .av-shell .ai-message.is-user .ai-message-body {
    max-width: 94%;
  }

  .av-shell .ai-composer,
  .av-shell .ai-suggestions,
  .av-shell .ai-disclaimer {
    width: calc(100% - 16px);
  }

  .av-shell .ai-disclaimer {
    max-height: 34px;
    overflow-y: auto;
  }

  .av-shell .calc-panel:not(.ai-panel) {
    padding: 16px;
  }

  .av-shell .library-heading,
  .av-shell .library-toolbar,
  .av-shell .library-groups,
  .av-shell .library-workspace {
    padding-inline: 14px;
  }
}

@media (max-width: 900px) and (max-height: 640px) {
  .av-shell .ai-panel-heading {
    display: none;
  }

  .av-shell .ai-panel:not(.has-conversation) .ai-messages {
    min-height: 96px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .av-shell .ai-welcome::before,
  .av-shell .ai-welcome p,
  .av-shell .ai-suggestions,
  .av-shell .ai-disclaimer {
    display: none;
  }

  .av-shell .ai-welcome h4 {
    font-size: 20px;
  }
}

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