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

:root {
  --av-bg: #101816;
  --av-bg-deep: #0c1311;
  --av-surface: #17211e;
  --av-surface-raised: #1c2622;
  --av-surface-soft: #202b27;
  --av-surface-glass: rgba(18, 29, 25, 0.92);
  --av-text: #f1f4f1;
  --av-text-soft: #dfe5e1;
  --av-muted: #b7c1bc;
  --av-faint: #8f9c96;
  --av-border: rgba(205, 229, 218, 0.16);
  --av-border-strong: rgba(205, 229, 218, 0.28);
  --av-primary: #36c797;
  --av-primary-hover: #49d5a7;
  --av-primary-ink: #07120e;
  --av-success: #55c995;
  --av-warning: #dfbd6e;
  --av-error: #ef8b88;
  --av-focus: #82e4bf;
  --av-shadow: 0 16px 40px rgba(0, 0, 0, 0.24);
  --av-radius-sm: 6px;
  --av-radius: 8px;
  --av-control-height: 46px;
  --av-sidebar-width: 228px;
  --av-reading-width: 780px;
  --av-composer-width: 780px;
  --av-page-gutter: 30px;
  --av-motion-fast: 170ms;
  --av-motion: 240ms;
}

html[data-resolved-theme="light"] {
  --av-bg: #f3f1e9;
  --av-bg-deep: #e8e5da;
  --av-surface: #fbfaf5;
  --av-surface-raised: #ffffff;
  --av-surface-soft: #ecefe8;
  --av-surface-glass: rgba(250, 249, 244, 0.94);
  --av-text: #17332a;
  --av-text-soft: #29473d;
  --av-muted: #607269;
  --av-faint: #788980;
  --av-border: rgba(18, 63, 48, 0.14);
  --av-border-strong: rgba(18, 63, 48, 0.25);
  --av-primary: #167a58;
  --av-primary-hover: #106947;
  --av-primary-ink: #ffffff;
  --av-success: #167a58;
  --av-warning: #8b651f;
  --av-error: #b6403d;
  --av-focus: #167a58;
  --av-shadow: 0 16px 36px rgba(25, 54, 44, 0.12);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--av-bg);
  color: var(--av-text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--av-bg);
  color: var(--av-text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.58;
  letter-spacing: 0;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

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

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

button,
summary,
a {
  transition: color var(--av-motion-fast) ease, background-color var(--av-motion-fast) ease,
    border-color var(--av-motion-fast) ease, opacity var(--av-motion-fast) ease,
    transform var(--av-motion-fast) ease;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--av-focus) !important;
  outline-offset: 2px;
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.is-hidden,
[hidden] {
  display: none !important;
}

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

/* Shared controls */
.primary-action,
.primary-button,
.auth-submit,
.public-primary,
.context-action-primary,
.library-primary-action {
  min-height: var(--av-control-height);
  border: 1px solid transparent;
  border-radius: var(--av-radius);
  background: var(--av-primary);
  color: var(--av-primary-ink);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
}

.primary-action:hover:not(:disabled),
.primary-button:hover:not(:disabled),
.auth-submit:hover:not(:disabled),
.public-primary:hover:not(:disabled),
.context-action-primary:hover:not(:disabled),
.library-primary-action:hover:not(:disabled) {
  background: var(--av-primary-hover);
}

.ghost-button,
.secondary-action,
.context-action,
.public-secondary,
.auth-switch {
  min-height: 42px;
  border: 1px solid var(--av-border-strong);
  border-radius: var(--av-radius);
  background: transparent;
  color: var(--av-text-soft);
  font-weight: 500;
  cursor: pointer;
}

.ghost-button:hover:not(:disabled),
.secondary-action:hover:not(:disabled),
.context-action:hover:not(:disabled),
.public-secondary:hover:not(:disabled),
.auth-switch:hover:not(:disabled) {
  border-color: var(--av-primary);
  color: var(--av-text);
  background: var(--av-surface-soft);
}

input,
select,
textarea {
  min-height: var(--av-control-height);
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-soft);
  color: var(--av-text);
  font-size: 1rem;
}

input::placeholder,
textarea::placeholder {
  color: var(--av-faint);
  opacity: 1;
}

input:hover,
select:hover,
textarea:hover {
  border-color: var(--av-border-strong);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--av-primary);
  box-shadow: 0 0 0 1px var(--av-primary);
}

.theme-segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: rgba(0, 0, 0, 0.16);
}

html[data-resolved-theme="light"] .theme-segmented {
  background: rgba(18, 63, 48, 0.06);
}

.theme-segmented button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--av-muted);
  font-size: 0.76rem;
  font-weight: 500;
  cursor: pointer;
}

.theme-segmented button:hover,
.theme-segmented button.is-active {
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.theme-segmented button.is-active {
  box-shadow: inset 0 0 0 1px var(--av-border-strong);
}

/* Authentication */
.auth-screen {
  position: relative;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #101816;
  background-image: none;
  color: #f2f4f0;
  isolation: isolate;
}

.auth-screen::after {
  content: "";
  position: fixed;
  z-index: -2;
  inset: 34% 0 0;
  background: url("assets/soybean-sunset.webp") center 50% / cover no-repeat;
  pointer-events: none;
}

.auth-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 15, 12, 0.84) 0%, rgba(7, 17, 14, 0.67) 54%, rgba(5, 13, 10, 0.5) 100%);
}

html[data-resolved-theme="light"] .auth-screen::before {
  background: rgba(235, 235, 225, 0.75);
}

html[data-resolved-theme="light"] .auth-screen::after {
  display: none;
}

html[data-resolved-theme="light"] .auth-screen {
  color: #17332a;
}

.auth-stage {
  position: relative;
  z-index: 1;
  width: min(1380px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 28px 42px 38px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
}

.auth-site-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.auth-site-logo,
.side-brand-row img,
.workspace-brand,
.public-logo {
  display: block;
  width: 184px;
  height: auto;
  max-height: 62px;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 0 3px rgba(242, 244, 240, 0.22));
  opacity: 0;
}

.auth-site-logo.has-transparent-background,
.side-brand-row img.has-transparent-background,
.workspace-brand.has-transparent-background,
.public-logo.has-transparent-background,
.auth-site-logo.is-logo-fallback,
.side-brand-row img.is-logo-fallback,
.workspace-brand.is-logo-fallback,
.public-logo.is-logo-fallback {
  opacity: 1;
  background: transparent;
}

.auth-site-logo.is-logo-fallback,
.side-brand-row img.is-logo-fallback,
.workspace-brand.is-logo-fallback,
.public-logo.is-logo-fallback {
  mix-blend-mode: multiply;
  filter: drop-shadow(0 0 4px rgba(9, 16, 13, 0.3));
}

.auth-global-actions > .theme-segmented {
  display: inline-grid;
  background: rgba(8, 18, 15, 0.42);
}

.auth-global-actions .language-picker {
  min-width: 72px;
  padding: 0;
  border: 0;
  background: transparent;
}

.auth-global-actions .language-picker .language-flag {
  display: none;
}

.auth-global-actions .language-picker strong {
  position: relative;
  width: 72px;
  overflow: hidden;
  color: transparent;
  font-size: 0;
}

.auth-global-actions .language-picker strong::before {
  content: "PT  |  ES";
  color: var(--av-text-soft);
  font-size: 0.78rem;
  font-weight: 500;
}

.auth-global-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.language-picker {
  min-width: 54px;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-glass);
  color: var(--av-text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
}

.language-picker > span:first-child {
  display: none;
}

.language-flag {
  width: 20px;
  height: 14px;
  object-fit: cover;
}

.language-picker strong {
  font-size: 0.78rem;
  font-weight: 600;
}

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(350px, 420px);
  grid-template-areas:
    "intro card"
    "preview card";
  align-content: center;
  align-items: center;
  gap: 28px 7vw;
  padding: 12px 4vw 36px;
}

.auth-intro {
  grid-area: intro;
  max-width: 650px;
  align-self: end;
}

.auth-intro h1 {
  margin: 0;
  color: inherit;
  font-size: 3rem;
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: 0;
}

.auth-intro h1 span,
.auth-intro h1 strong {
  display: block;
}

.auth-intro h1 strong {
  color: #3bd3a0;
  font-weight: 600;
}

html[data-resolved-theme="light"] .auth-intro h1 strong {
  color: #167a58;
}

.auth-intro > p {
  max-width: 590px;
  margin: 18px 0 0;
  color: rgba(242, 244, 240, 0.82);
  font-size: 1.12rem;
  line-height: 1.6;
}

html[data-resolved-theme="light"] .auth-intro > p {
  color: #415c52;
}

.auth-preview {
  grid-area: preview;
  width: min(560px, 100%);
  align-self: start;
  padding: 18px;
  border: 1px solid rgba(213, 234, 224, 0.2);
  border-radius: var(--av-radius);
  background: rgba(13, 25, 21, 0.82);
  box-shadow: var(--av-shadow);
  backdrop-filter: blur(14px);
}

html[data-resolved-theme="light"] .auth-preview {
  border-color: var(--av-border);
  background: rgba(255, 255, 255, 0.88);
}

.auth-preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.auth-preview-heading h2 {
  margin: 0;
  color: inherit;
  font-size: 0.94rem;
  font-weight: 600;
}

.auth-preview-heading span {
  padding: 4px 9px;
  border: 1px solid var(--av-border);
  border-radius: 999px;
  color: var(--av-muted);
  font-size: 0.72rem;
}

.auth-preview-messages {
  display: grid;
  gap: 10px;
}

.auth-preview-messages p {
  width: fit-content;
  max-width: min(82%, 390px);
  margin: 0;
  padding: 10px 13px;
  border-radius: 10px;
  font-size: 0.88rem;
  line-height: 1.48;
}

.auth-preview-messages .is-user {
  justify-self: end;
  background: #124f3b;
  color: #f2f4f0;
}

.auth-preview-messages .is-assistant {
  justify-self: start;
  border: 1px solid var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
}

.auth-card {
  grid-area: card;
  width: 100%;
  align-self: center;
  border: 1px solid rgba(213, 234, 224, 0.2);
  border-radius: 18px;
  background: rgba(13, 24, 20, 0.9);
  box-shadow: var(--av-shadow);
  backdrop-filter: blur(18px);
}

html[data-resolved-theme="light"] .auth-card {
  border-color: var(--av-border);
  background: rgba(255, 255, 255, 0.92);
}

.auth-content {
  width: 100%;
  padding: 30px;
}

.auth-mode-title {
  margin: 0 0 24px;
  color: inherit;
  font-size: 1.45rem;
  line-height: 1.25;
  font-weight: 600;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: var(--av-text-soft);
  font-size: 0.86rem;
  font-weight: 500;
}

.auth-form input {
  width: 100%;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(31, 44, 39, 0.92);
  color: var(--av-text);
  -webkit-text-fill-color: var(--av-text);
}

.auth-form input:-webkit-autofill,
.auth-form input:-webkit-autofill:hover,
.auth-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--av-text);
  box-shadow: 0 0 0 1000px var(--av-surface-soft) inset;
  caret-color: var(--av-text);
}

html[data-resolved-theme="light"] .auth-form input {
  background: #f5f5f0;
}

.password-input-wrap {
  position: relative;
}

.password-input-wrap input {
  padding-right: 82px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  min-width: 68px;
  min-height: 38px;
  padding: 0 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: var(--av-muted);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transform: translateY(-50%);
}

.password-toggle:hover {
  color: var(--av-text);
  background: rgba(255, 255, 255, 0.05);
}

.auth-submit {
  width: 100%;
  margin-top: 4px;
}

.auth-forgot {
  display: block;
  width: fit-content;
  min-height: 38px;
  margin: 7px 0 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--av-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}

.auth-message,
.auth-confirmation-status {
  min-height: 0;
  margin: 12px 0 0;
  color: var(--av-error);
  font-size: 0.84rem;
}

.auth-message:empty,
.auth-confirmation-status:empty {
  display: none;
}

.auth-switch-label {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 10px;
  color: var(--av-muted);
  font-size: 0.78rem;
  text-align: center;
  white-space: nowrap;
}

.auth-switch-label::before,
.auth-switch-label::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--av-border);
}

.auth-switch {
  width: 100%;
}

.auth-support {
  display: none;
}

.auth-legal-links {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
}

.auth-legal-links a {
  color: var(--av-muted);
  font-size: 0.78rem;
  text-decoration: none;
}

.auth-legal-links a:hover {
  color: var(--av-text);
}

.auth-confirmation {
  color: var(--av-text-soft);
}

.auth-confirmation p {
  margin: 8px 0;
}

.auth-confirmation-email {
  display: block;
  overflow-wrap: anywhere;
  color: var(--av-text);
}

/* Public entry remains available with ?welcome=1. */
.public-landing {
  min-height: 100dvh;
  background: var(--av-bg);
  color: var(--av-text);
}

.public-header,
.public-footer,
.public-hero,
.public-product-preview,
.public-tools {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.public-header {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.public-header-actions,
.public-hero-actions,
.public-footer {
  display: flex;
  align-items: center;
  gap: 12px;
}

.public-login-link {
  min-height: 42px;
  border: 0;
  background: transparent;
  color: var(--av-text);
  font-weight: 500;
  cursor: pointer;
}

.public-hero {
  min-height: 64vh;
  display: flex;
  align-items: center;
  background-image: url("assets/soybean-sunset.webp");
  background-position: center bottom;
  background-size: cover;
  position: relative;
}

.public-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(8, 20, 16, 0.64);
}

.public-hero-content {
  position: relative;
  max-width: 620px;
  padding: 54px;
  color: #f2f4f0;
}

.public-kicker,
.eyebrow {
  margin: 0 0 8px;
  color: var(--av-primary);
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
}

.public-hero h1 {
  margin: 0;
  font-size: 3rem;
  line-height: 1.08;
  font-weight: 600;
}

.public-hero p:not(.public-kicker) {
  margin: 16px 0 24px;
  font-size: 1.05rem;
}

.public-primary,
.public-secondary {
  padding: 0 18px;
}

.public-product-preview,
.public-tools {
  padding: 70px 0;
}

.public-product-preview img {
  width: min(760px, 100%);
  height: auto;
  border: 1px solid var(--av-border);
}

.public-tool-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-top: 24px;
  background: var(--av-border);
}

.public-tool-list article {
  padding: 24px;
  background: var(--av-surface);
}

.public-tool-list h3 {
  margin: 8px 0;
}

.public-tool-list p {
  margin: 0;
  color: var(--av-muted);
}

.public-footer {
  min-height: 76px;
  border-top: 1px solid var(--av-border);
  color: var(--av-muted);
  font-size: 0.82rem;
}

.public-footer a {
  color: inherit;
}

/* Product shell */
.av-shell {
  width: 100%;
  height: var(--chat-viewport-height, 100dvh);
  min-height: 0;
  display: grid;
  grid-template-columns: var(--av-sidebar-width) minmax(0, 1fr);
  overflow: hidden;
  background: var(--av-bg);
  color: var(--av-text);
}

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

.av-shell .side-panel {
  position: relative;
  z-index: 30;
  width: var(--av-sidebar-width);
  min-width: var(--av-sidebar-width);
  height: var(--chat-viewport-height, 100dvh);
  padding: 22px 16px 18px;
  border: 0;
  border-right: 1px solid var(--av-border);
  border-radius: 0;
  background: rgba(9, 19, 16, 0.88);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  transition: transform var(--av-motion) ease, opacity var(--av-motion) ease;
}

html[data-resolved-theme="light"] .av-shell .side-panel {
  background: rgba(249, 248, 243, 0.98);
}

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

.side-brand-row {
  flex: 0 0 auto;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  order: 0;
}

.side-brand-row img {
  width: 158px;
  max-height: 54px;
  filter: brightness(1.28) saturate(1.06);
}

.sidebar-close,
.sidebar-toggle,
.mobile-new-chat,
.mobile-weather-button {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-glass);
  color: var(--av-text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.sidebar-close:hover,
.sidebar-toggle:hover,
.mobile-new-chat:hover,
.mobile-weather-button:hover {
  border-color: var(--av-border-strong);
  color: var(--av-text);
  background: var(--av-surface-soft);
}

.sidebar-close span {
  font-size: 1.55rem;
  line-height: 1;
}

.menu-icon {
  position: relative;
  display: block;
  width: 19px;
  height: 14px;
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.menu-icon::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 19px;
  height: 2px;
  background: currentColor;
  transform: translateY(-50%);
}

.brand-visual {
  display: none !important;
}

.tool-nav {
  order: 2;
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  border: 0;
}

.tool-nav .nav-button {
  width: 100%;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 0 var(--av-radius) var(--av-radius) 0;
  background: transparent;
  color: var(--av-muted);
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.tool-nav .nav-button > span:last-child {
  min-width: 0;
  white-space: nowrap;
}

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

.tool-nav .nav-button:hover,
.tool-nav .nav-button.is-active {
  color: var(--av-text);
  background: rgba(229, 242, 235, 0.08);
}

.tool-nav .nav-button.is-active {
  border-color: transparent;
  box-shadow: inset 2px 0 0 var(--av-primary);
}

.nav-symbol {
  position: relative;
  width: 19px;
  height: 19px;
  flex: 0 0 19px;
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
}

.nav-button .nav-icon,
.sidebar-settings summary .nav-icon {
  color: currentColor;
}

.tool-nav .nav-button .lucide,
.sidebar-settings summary .lucide {
  width: 100%;
  height: 100%;
}

.nav-symbol-chat {
  border: 1.7px solid currentColor;
  border-radius: 50%;
}

.nav-symbol-chat::after {
  content: "";
  position: absolute;
  left: 1px;
  bottom: -3px;
  width: 6px;
  height: 6px;
  border-left: 1.7px solid currentColor;
  transform: rotate(38deg);
}

.nav-symbol-library {
  border: 1.7px solid currentColor;
  border-radius: 3px;
}

.nav-symbol-library::before,
.nav-symbol-library::after {
  content: "";
  position: absolute;
  background: currentColor;
}

.nav-symbol-library::before {
  inset: 4px auto 4px 5px;
  width: 1px;
}

.nav-symbol-library::after {
  inset: 7px 3px auto 9px;
  height: 1px;
}

.nav-symbol-settings {
  border: 1.7px solid currentColor;
  border-radius: 50%;
}

.nav-symbol-settings::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.ai-thread-pane {
  display: contents;
}

.av-shell .side-panel > .ai-thread-pane {
  display: contents !important;
}

.ai-new-thread-button {
  order: 1;
  width: 100%;
  min-height: 50px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--av-radius);
  background: transparent;
  color: var(--av-text);
  font-size: 0.9rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

.ai-new-thread-button::before {
  content: "+";
  display: inline-block;
  width: 24px;
  margin-right: 8px;
  color: var(--av-primary);
  font-size: 1.35rem;
  line-height: 1;
  text-align: center;
  vertical-align: -1px;
  height: 24px;
  border: 0;
  border-radius: 0;
  background: transparent;
  font-weight: 400;
}

.ai-new-thread-button:hover {
  border-color: var(--av-border);
  background: var(--av-surface-soft);
}

.ai-thread-heading {
  order: 3;
  margin: 7px 4px 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.ai-thread-heading strong {
  color: var(--av-text-soft);
  font-size: 0.78rem;
  font-weight: 600;
}

.ai-thread-heading span {
  display: none;
}

#aiHistorySearch {
  order: 4;
  width: 100%;
  min-height: 40px;
  padding: 0 11px;
  font-size: 0.84rem;
  background: transparent;
}

.ai-thread-list {
  order: 5;
  min-height: 48px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.ai-thread-item {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  align-items: center;
  min-height: 44px;
  margin: 2px 0;
  border: 1px solid transparent;
  border-radius: var(--av-radius-sm);
  background: transparent;
}

.ai-thread-item.is-active {
  border-color: var(--av-border);
  background: var(--av-surface-soft);
}

.ai-thread-select,
.ai-thread-open {
  width: 100%;
  min-height: 42px;
  padding: 7px 34px 7px 10px;
  border: 1px solid transparent;
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-muted);
  display: grid;
  gap: 1px;
  text-align: left;
  cursor: pointer;
}

.ai-thread-select strong,
.ai-thread-open strong {
  overflow: hidden;
  color: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-thread-select span,
.ai-thread-open span {
  color: var(--av-faint);
  font-size: 0.7rem;
}

.ai-thread-select:hover,
.ai-thread-open:hover,
.ai-thread-item.is-active .ai-thread-select,
.ai-thread-item.is-active .ai-thread-open {
  border-color: var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
}

.ai-thread-delete {
  position: absolute;
  top: 4px;
  right: 3px;
  width: 34px;
  height: 34px;
  border: 0;
  background: transparent;
  color: var(--av-faint);
  cursor: pointer;
}

.ai-thread-empty {
  margin: 8px 4px;
  color: var(--av-faint);
  font-size: 0.78rem;
}

.side-utilities {
  order: 6;
  margin-top: auto;
}

.side-utilities > .language-picker {
  display: none;
}

.weather-widget {
  position: relative;
  align-self: start;
}

.weather-chip {
  width: auto;
  max-width: 260px;
  min-height: 46px;
  padding: 0 13px;
  border: 1px solid var(--av-border);
  border-radius: 999px;
  background: rgba(16, 27, 23, 0.9);
  color: var(--av-text);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

.weather-chip:hover {
  border-color: var(--av-border-strong);
  background: rgba(27, 42, 36, 0.9);
}

.weather-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #c5d0ca;
}

.weather-icon .lucide {
  width: 100%;
  height: 100%;
  stroke-width: 1.8;
}

.weather-tone-sun {
  color: #f2c45f;
}

.weather-tone-moon {
  color: #b7cdc7;
}

.weather-tone-rain {
  color: #79b8d3;
}

.weather-tone-thunder {
  color: #e4bf58;
}

.weather-tone-cloud {
  color: #c5d0ca;
}

.weather-chip strong {
  color: var(--av-text);
  font-size: 0.84rem;
  font-weight: 500;
}

.weather-chip > span:last-child {
  overflow: hidden;
  color: var(--av-muted);
  font-size: 0.78rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.weather-chip.has-weather #weatherCity::before {
  content: "\00b7";
  margin-right: 7px;
  color: var(--av-faint);
}

.weather-popover {
  position: fixed;
  z-index: 80;
  top: 92px;
  right: 28px;
  left: auto;
  bottom: auto;
  width: min(360px, calc(100vw - 36px));
  max-height: min(640px, calc(100dvh - 36px));
  overflow-y: auto;
  padding: 18px;
  border: 1px solid var(--av-border-strong);
  border-radius: var(--av-radius);
  background: var(--av-surface-glass);
  color: var(--av-text);
  box-shadow: var(--av-shadow);
  backdrop-filter: blur(18px);
  animation: av-panel-in var(--av-motion) ease both;
}

.weather-popover-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.weather-popover-close:hover {
  border-color: var(--av-border-strong);
  background: var(--av-surface-raised);
  color: var(--av-text);
}

.weather-current {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-right: 48px;
}

.weather-icon-detail {
  width: 38px;
  height: 38px;
  flex-basis: 38px;
}

.weather-current strong {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
}

.weather-current span {
  display: block;
  color: var(--av-muted);
}

.weather-location-detail {
  font-size: 0.78rem;
}

.weather-details {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 16px 0;
  background: var(--av-border);
}

.weather-details div {
  padding: 10px;
  background: var(--av-surface-raised);
}

.weather-details dt,
.weather-details dd {
  margin: 0;
}

.weather-details dt {
  color: var(--av-faint);
  font-size: 0.7rem;
}

.weather-details dd {
  color: var(--av-text-soft);
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
}

.weather-search input {
  width: 100%;
  padding: 0 12px;
}

.weather-status,
.weather-updated {
  margin: 10px 0 0;
  color: var(--av-muted);
  font-size: 0.76rem;
}

.weather-status.is-error {
  color: var(--av-error);
}

.weather-suggestions {
  margin-top: 4px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  overflow: hidden;
}

.weather-suggestion {
  width: 100%;
  min-height: 40px;
  padding: 7px 10px;
  border: 0;
  border-bottom: 1px solid var(--av-border);
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
  text-align: left;
}

.weather-suggestion:last-child {
  border-bottom: 0;
}

.sidebar-settings {
  order: 7;
  position: relative;
}

.sidebar-settings > summary,
.catalog-admin-link {
  min-height: 44px;
  padding: 0 11px;
  border: 1px solid transparent;
  border-radius: var(--av-radius);
  color: var(--av-muted);
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 0.88rem;
  font-weight: 500;
  list-style: none;
  cursor: pointer;
}

.sidebar-settings > summary::-webkit-details-marker {
  display: none;
}

.sidebar-settings > summary:hover,
.sidebar-settings[open] > summary,
.catalog-admin-link:hover {
  border-color: var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.catalog-admin-link {
  margin-top: 12px;
  padding-block: 8px;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.catalog-admin-link[hidden] {
  display: none;
}

.catalog-admin-link .lucide {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.sidebar-settings-panel {
  position: absolute;
  z-index: 90;
  left: 0;
  bottom: 50px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--av-border-strong);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  box-shadow: var(--av-shadow);
  animation: av-panel-in var(--av-motion) ease both;
}

.settings-label {
  display: block;
  margin-bottom: 7px;
  color: var(--av-muted);
  font-size: 0.74rem;
  font-weight: 500;
}

.theme-segmented-sidebar {
  width: 100%;
}

.settings-language-slot,
.settings-account-slot,
.settings-links-slot {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--av-border);
}

.settings-language-slot .language-picker {
  width: 100%;
  justify-content: flex-start;
}

.user-panel {
  display: grid;
  gap: 5px;
}

.sidebar-settings-panel .user-panel,
.sidebar-settings-panel .support-link {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-muted);
  box-shadow: none;
}

.user-panel span {
  color: var(--av-faint);
  font-size: 0.7rem;
}

.user-panel strong {
  overflow: hidden;
  color: var(--av-text-soft);
  font-size: 0.8rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-button {
  min-height: 38px;
  margin-top: 5px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-text-soft);
  cursor: pointer;
}

.support-link,
.app-legal-links {
  color: var(--av-muted);
  font-size: 0.72rem;
  text-decoration: none;
}

.support-link {
  display: grid;
}

.support-link strong {
  color: var(--av-text-soft);
  font-weight: 500;
}

.app-legal-links {
  display: flex;
  gap: 12px;
  margin-top: 8px;
}

.app-legal-links a {
  color: inherit;
}

.sidebar-backdrop {
  display: none;
}

/* Workspace and conversation */
.workspace {
  position: relative;
  min-width: 0;
  height: var(--chat-viewport-height, 100dvh);
  overflow: hidden;
  background-color: var(--av-bg);
  background-image: none;
  isolation: isolate;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
}

.workspace::after {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background: url("assets/soybean-sunset.webp") center top / cover no-repeat;
  transform: scale(1.26);
  transform-origin: top center;
  pointer-events: none;
}

.workspace::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(180deg, rgba(5, 13, 11, 0.9) 0%, rgba(6, 15, 12, 0.82) 48%, rgba(5, 13, 10, 0.7) 100%);
  pointer-events: none;
}

html[data-resolved-theme="light"] .workspace {
  background-color: var(--av-bg);
  background-image: none;
}

html[data-resolved-theme="light"] .workspace::before {
  background: transparent;
}

html[data-resolved-theme="light"] .workspace::after {
  display: none;
}

.work-context-bar {
  position: relative;
  z-index: 20;
  min-height: 96px;
  padding: 20px var(--av-page-gutter) 5px;
  border: 0;
  border-bottom: 0;
  border-radius: 0;
  background: transparent;
  color: var(--av-text);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "toggle context weather";
  align-items: start;
  gap: 18px;
  box-shadow: none;
  backdrop-filter: none;
}

.work-context-bar > .sidebar-toggle {
  grid-area: toggle;
}

.work-context-bar > .work-context-main {
  grid-area: context;
}

.work-context-bar > .weather-widget {
  grid-area: weather;
}

html[data-resolved-theme="light"] .work-context-bar {
  background: transparent;
}

html[data-resolved-theme="light"] .work-context-summary,
html[data-resolved-theme="light"] .weather-chip {
  background: rgba(255, 255, 255, 0.84);
}

.workspace-section-title {
  flex: 0 0 auto;
  color: var(--av-text);
  font-size: 1.18rem;
  font-weight: 600;
}

.work-context-main {
  min-width: 0;
  display: grid;
  justify-items: start;
  gap: 6px;
}

.work-context-row {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.workspace-brand {
  display: none;
  width: 132px;
  max-height: 44px;
  filter: brightness(1.28) saturate(1.06);
}

.work-context-summary {
  min-width: 0;
  min-height: 38px;
  margin: 0;
  padding: 0 12px 0 34px;
  border: 1px solid var(--av-border);
  border-radius: 999px;
  background: rgba(16, 29, 24, 0.72);
  display: flex;
  align-items: center;
  gap: 7px;
  position: relative;
  backdrop-filter: blur(10px);
}

.work-context-summary::before {
  content: "";
  position: absolute;
  left: 14px;
  width: 10px;
  height: 16px;
  border: solid var(--av-primary);
  border-width: 0 0 2px 2px;
  border-radius: 0 0 0 9px;
  transform: rotate(-18deg);
}

.work-context-kicker {
  display: none;
}

.work-context-summary strong {
  overflow: hidden;
  color: var(--av-text);
  font-size: 0.82rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-context-summary > span:last-child {
  overflow: hidden;
  color: var(--av-faint);
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.work-context-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.work-context-actions .context-action {
  min-height: 38px;
  padding: 0 11px;
  font-size: 0.76rem;
}

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

.av-shell.is-assistant-active .work-context-summary > span:last-child {
  display: none;
}

.av-shell.is-assistant-active #editWorkContext {
  position: relative;
  width: 38px;
  min-width: 38px;
  height: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.av-shell.is-assistant-active #editWorkContext::before {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
}

.mobile-weather-button,
.mobile-new-chat {
  display: none;
}

.calc-panel {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - (var(--av-page-gutter) * 2)));
  height: auto;
  min-height: 0;
  margin: 14px auto;
  padding: 24px;
  overflow-y: auto;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-glass);
  color: var(--av-text);
  box-shadow: var(--av-shadow);
  backdrop-filter: blur(18px);
  animation: av-panel-in var(--av-motion) ease both;
}

.calc-panel:not(.is-active) {
  display: none !important;
}

.calc-panel h2,
.calc-panel h3,
.calc-panel h4,
.calc-panel strong,
.calc-panel label {
  color: var(--av-text);
}

.calc-panel p,
.calc-panel small {
  color: var(--av-muted);
}

.panel-heading,
.library-heading,
.dashboard-welcome,
.workflow-launcher-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.panel-heading h3,
.library-heading h3,
.dashboard-welcome h3 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.25;
  font-weight: 600;
}

.ai-panel {
  width: 100%;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

.ai-panel-heading {
  position: absolute;
  z-index: 12;
  top: 88px;
  right: var(--av-page-gutter);
  margin: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.ai-panel-title {
  display: none;
}

.ai-shell,
.ai-chat-pane {
  width: 100%;
  height: 100%;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.ai-shell {
  display: block;
  grid-template-columns: none;
  min-height: 0;
}

.ai-chat-pane {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  padding: 0 var(--av-page-gutter) max(18px, env(safe-area-inset-bottom));
}

.ai-messages {
  width: min(var(--av-reading-width), 100%);
  min-height: 0;
  margin: 0 auto;
  padding: 22px 0 24px;
  overflow-y: auto;
  scroll-behavior: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scroll-padding-bottom: 26px;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.ai-panel.has-conversation .ai-messages {
  padding-top: 8px;
}

.ai-welcome {
  max-width: 610px;
  margin: clamp(38px, 9vh, 88px) auto 0;
  text-align: center;
  animation: av-message-in 360ms ease both;
}

.ai-panel:not(.has-conversation) .ai-chat-pane {
  grid-template-rows: auto auto minmax(24px, 1fr) auto auto;
}

.ai-panel:not(.has-conversation) .ai-messages {
  grid-row: 1;
  overflow: visible;
  padding-bottom: 16px;
}

.ai-panel:not(.has-conversation) .ai-suggestions {
  grid-row: 2;
  margin-bottom: 0;
}

.ai-panel:not(.has-conversation) .ai-composer {
  grid-row: 4;
}

.ai-panel:not(.has-conversation) .ai-disclaimer {
  grid-row: 5;
}

.ai-welcome h4 {
  margin: 0 0 8px;
  color: var(--av-text);
  font-size: 1.55rem;
  line-height: 1.3;
  font-weight: 600;
}

.ai-welcome p {
  margin: 0;
  color: var(--av-muted);
  font-size: 1rem;
}

.ai-message {
  width: 100%;
  max-width: none;
  align-self: auto;
  display: flex;
  flex-direction: column;
  margin: 0 0 18px;
  animation: av-message-in var(--av-motion) ease both;
}

.ai-message.is-user {
  align-items: flex-end;
  justify-content: flex-end;
}

.ai-message.is-assistant {
  align-items: flex-start;
  justify-content: flex-start;
}

.ai-message.is-assistant::before {
  display: none !important;
  content: none !important;
}

.ai-message.is-pending,
#aiTypingMessage {
  animation: none;
}

.ai-response-live {
  white-space: normal !important;
}

.ai-response-live .ai-stream-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ai-generation-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  gap: 8px;
  color: var(--av-text-soft);
  font-size: 0.82rem;
  line-height: 1.4;
}

.ai-generation-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.ai-generation-dots > span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--av-primary);
  animation: av-generation-dot 1.15s ease-in-out infinite;
}

.ai-generation-dots > span:nth-child(2) { animation-delay: 0.14s; }
.ai-generation-dots > span:nth-child(3) { animation-delay: 0.28s; }

@keyframes av-generation-dot {
  0%, 70%, 100% { opacity: 0.35; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-generation-dots > span {
    animation: none;
    opacity: 0.78;
    transform: none;
  }
}

.ai-message-body {
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--av-text);
  display: block;
  font-size: 1rem;
  line-height: 1.58;
  white-space: normal;
}

.ai-message.is-user .ai-message-body {
  width: fit-content;
  max-width: min(72%, 590px);
  padding: 10px 14px;
  border: 1px solid rgba(84, 199, 155, 0.12);
  border-radius: 18px 18px 6px 18px;
  background: rgba(11, 80, 57, 0.9);
  color: #f1f4f1;
  white-space: pre-wrap;
}

html[data-resolved-theme="light"] .ai-message.is-user .ai-message-body {
  border-color: rgba(18, 79, 59, 0.2);
  background: #dceee5;
  color: #17332a;
}

.ai-message.is-assistant .ai-message-body {
  width: 100%;
  padding: 2px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--av-text);
  box-shadow: none;
}

.ai-message.is-compact {
  margin-bottom: 15px;
}

.ai-message.is-error .ai-message-body {
  padding: 13px;
  border-left: 3px solid var(--av-error);
  background: rgba(126, 38, 35, 0.18);
}

.ai-message-body > div:first-child > :first-child {
  margin-top: 0;
}

.ai-message-body > div:first-child > :last-child {
  margin-bottom: 0;
}

.ai-message-body p,
.ai-message-body ul,
.ai-message-body ol,
.ai-message-body table,
.ai-message-body pre,
.ai-message-body blockquote {
  margin: 0 0 12px;
}

.ai-message-body ul,
.ai-message-body ol {
  padding-left: 22px;
}

.ai-message-body li + li {
  margin-top: 5px;
}

.ai-message-body a {
  color: var(--av-primary);
}

.ai-message-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.ai-message-body th,
.ai-message-body td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--av-border);
  text-align: left;
}

.ai-message-body th {
  color: var(--av-text);
  font-weight: 600;
}

.ai-message-body code,
.ai-message-body pre {
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: var(--av-bg-deep);
  color: var(--av-text-soft);
}

.ai-message-body code {
  padding: 2px 5px;
}

.ai-message-body pre {
  padding: 12px;
  overflow-x: auto;
}

.ai-message-tools {
  min-height: 36px;
  margin-top: 7px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  opacity: 0.8;
  transition: opacity var(--av-motion-fast) ease;
}

.ai-message:hover .ai-message-tools,
.ai-message-tools:focus-within {
  opacity: 1;
}

.ai-message-tools button,
.ai-export-menu summary {
  min-height: 36px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-muted);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ai-message-tools .lucide,
.ai-export-menu .lucide {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke-width: 1.8;
}

.ai-message-tools button:hover,
.ai-export-menu summary:hover {
  border-color: var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.ai-user-tools {
  width: fit-content;
  min-height: 28px;
  margin-top: 2px;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: auto;
}

.ai-message.is-user:hover .ai-user-tools,
.ai-message.is-user:focus-within .ai-user-tools {
  opacity: 1;
}

.ai-user-menu {
  display: block;
}

.ai-user-menu-toggle {
  display: none !important;
}

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

.ai-export-menu summary {
  display: flex;
  align-items: center;
  list-style: none;
}

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

.ai-export-menu[open] {
  z-index: 15;
}

.ai-export-menu[open] button {
  display: block;
  width: 142px;
  border-color: var(--av-border);
  background: var(--av-surface-raised);
  text-align: left;
}

.ai-export-menu[open] > button {
  position: absolute;
  z-index: 4;
  right: 0;
  top: calc(100% + 4px);
  box-shadow: var(--av-shadow);
}

.ai-export-menu[open] > button + button {
  top: calc(100% + 40px);
}

.ai-follow-up,
.ai-interrupted-note {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: rgba(19, 31, 27, 0.58);
  color: var(--av-text-soft);
  font-size: 0.84rem;
  line-height: 1.5;
}

.ai-calculation {
  margin-top: 12px;
  border-top: 1px solid var(--av-border);
}

.ai-calculation summary {
  min-height: 38px;
  color: var(--av-muted);
  font-size: 0.78rem;
  cursor: pointer;
}

.ai-calculation-data {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 16px;
  margin: 0;
  padding: 10px 0;
  font-size: 0.82rem;
}

.ai-calculation-data dt,
.ai-calculation-data dd {
  margin: 0;
}

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

.ai-typing {
  min-height: 38px;
  color: var(--av-muted);
}

.ai-typing::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--av-primary);
  animation: av-pulse 1.1s ease-in-out infinite;
}

.ai-suggestions {
  width: min(var(--av-reading-width), 100%);
  margin: 0 auto 12px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

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

.ai-suggestions button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--av-border);
  border-radius: 999px;
  background: rgba(27, 39, 34, 0.86);
  color: var(--av-text-soft);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

html[data-resolved-theme="light"] .ai-suggestions button {
  background: rgba(255, 255, 255, 0.9);
}

.ai-suggestions button:hover {
  border-color: var(--av-primary);
  color: var(--av-text);
  transform: translateY(-1px);
}

.ai-composer {
  width: min(var(--av-composer-width), 100%);
  min-height: 56px;
  margin: 0 auto;
  padding: 4px 6px 4px 16px;
  border: 1px solid var(--av-border-strong);
  border-radius: 20px;
  background: rgba(23, 33, 30, 0.98);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 10px;
  box-sizing: border-box;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.13);
  backdrop-filter: blur(10px);
  transition: border-color var(--av-motion-fast) ease, background-color var(--av-motion) ease;
}

html[data-resolved-theme="light"] .ai-composer {
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 10px 28px rgba(25, 54, 44, 0.12);
}

.ai-composer:focus-within {
  border-color: rgba(82, 211, 163, 0.72);
  box-shadow: 0 0 0 2px rgba(54, 199, 151, 0.12);
}

.ai-composer textarea {
  width: 100%;
  min-height: 46px;
  max-height: 140px;
  padding: 11px 0;
  overflow-y: auto;
  resize: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--av-text);
  box-sizing: border-box;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}

.ai-composer textarea:focus {
  box-shadow: none;
}

.ai-composer textarea:focus-visible {
  outline: 0 !important;
}

.ai-composer-footer {
  display: contents;
}

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

.ai-composer-controls {
  position: relative;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  align-items: center;
  align-self: end;
  justify-content: center;
}

.ai-send-button,
.ai-stop-button {
  position: absolute;
  inset: 0;
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(248, 252, 249, 0.96);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: opacity 150ms ease, transform 150ms ease;
}

.ai-send-button::before,
.ai-stop-button::before {
  position: absolute;
  z-index: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #167a58;
  content: "";
}

.ai-send-button .lucide,
.ai-stop-icon {
  position: relative;
  z-index: 1;
}

.ai-send-button .lucide {
  width: 19px;
  height: 19px;
  stroke-width: 2;
}

.ai-stop-icon {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: currentColor;
}

.ai-send-button:disabled {
  opacity: 1;
  color: rgba(235, 244, 239, 0.48);
}

.ai-send-button:disabled::before {
  background: rgba(89, 111, 102, 0.72);
}

.ai-send-button:hover:not(:disabled)::before,
.ai-stop-button:hover::before {
  background: #1c8d67;
}

.ai-send-label,
.ai-stop-label {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
}

.ai-send-button:active:not(:disabled),
.ai-stop-button:active {
  transform: scale(0.95);
}

.ai-stop-button {
  opacity: 0;
  pointer-events: none;
}

.ai-composer[aria-busy="true"] .ai-send-button {
  opacity: 0;
  pointer-events: none;
}

.ai-composer[aria-busy="true"] .ai-stop-button {
  opacity: 1;
  pointer-events: auto;
}

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

.ai-scroll-bottom {
  position: absolute;
  z-index: 12;
  left: 50%;
  bottom: 94px;
  min-height: 38px;
  padding: 0 11px;
  transform: translateX(-50%);
  border: 1px solid var(--av-border-strong);
  border-radius: 999px;
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
  box-shadow: var(--av-shadow);
}

/* Calculators and agricultural library */
.form-grid,
.library-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.form-grid label,
.library-form label {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 6px 8px;
  font-size: 0.82rem;
  font-weight: 500;
}

.library-form label {
  align-items: center;
  gap: 6px 10px;
  font-size: 0.875rem;
}

.form-grid input,
.form-grid select,
.library-form input,
.library-form select {
  grid-column: 1 / -1;
  width: 100%;
  padding: 0 12px;
  border-color: var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.field-unit {
  color: var(--av-faint);
  font-size: 0.72rem;
  font-weight: 500;
}

.field-error,
.library-field-error,
.validation-error {
  grid-column: 1 / -1;
  color: var(--av-error) !important;
  font-size: 0.74rem;
}

.sub-tabs,
.crop-tabs,
.library-view-switch,
.library-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sub-tab,
.crop-tabs button,
.library-view-switch button,
.library-groups button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-muted);
  font-weight: 500;
}

.sub-tab.is-active,
.crop-tabs button.is-active,
.library-view-switch button.is-active,
.library-groups button.is-active {
  border-color: var(--av-primary);
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.crop-selector {
  margin-bottom: 18px;
}

.crop-selector-label {
  display: block;
  margin-bottom: 7px;
  color: var(--av-muted);
  font-size: 0.78rem;
}

.calc-actions,
.library-actions,
.integration-form-actions,
.integration-modal-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.result-card,
.result-box,
.library-result,
.formula-builder,
.workflow-launcher,
.saved-item,
.history-item {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  box-shadow: none;
}

.metrics,
.result-grid,
.dashboard-tools,
.workflow-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1px;
  background: var(--av-border);
}

.metric,
.result-metric,
.dashboard-tools > button,
.workflow-grid > button {
  min-width: 0;
  padding: 15px;
  border: 0;
  border-radius: 0;
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
  text-align: left;
}

.metric strong,
.result-metric strong {
  display: block;
  font-size: 1.08rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.metric.is-accent,
.result-metric.is-accent {
  background: var(--av-surface-soft);
}

.library-panel {
  padding: 0;
  overflow: hidden;
  background: var(--av-surface-glass);
}

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

.library-heading,
.library-toolbar,
.library-groups {
  padding-inline: 22px;
}

.library-heading {
  padding-top: 22px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--av-border);
  background: transparent;
}

.library-heading > div:first-child > p:last-child {
  color: var(--av-muted);
}

.library-count {
  border-color: var(--av-border);
  border-radius: var(--av-radius-sm);
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
  font-weight: 600;
}

.library-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--av-border);
  background: transparent;
}

.library-search {
  position: relative;
}

.library-search input {
  width: 100%;
  padding: 0 44px 0 40px;
  border-color: var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.library-search::before {
  border-color: var(--av-muted);
}

.library-search::after {
  background: var(--av-muted);
}

#libraryClearSearch {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-muted);
}

.library-groups {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--av-border);
  background: transparent;
}

.library-view-switch {
  border-color: var(--av-border);
  border-radius: var(--av-radius-sm);
  background: var(--av-surface-soft);
}

.library-view-switch button,
.library-groups button {
  border-radius: var(--av-radius-sm);
  color: var(--av-muted);
  font-weight: 500;
}

.library-view-switch button:hover,
.library-view-switch button:focus-visible,
.library-view-switch button.is-active,
.library-groups button:hover,
.library-groups button:focus-visible,
.library-groups button.is-active {
  border-color: var(--av-border-strong);
  background: var(--av-surface-raised);
  color: var(--av-text);
  box-shadow: none;
}

.library-groups button span {
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
  box-shadow: inset 0 0 0 1px var(--av-border);
}

.library-groups button.is-active span {
  background: var(--av-primary);
  color: var(--av-primary-ink);
}

.library-layout {
  min-height: 0;
  height: auto;
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  background: transparent;
}

.library-catalog {
  min-height: 0;
  padding: 4px 10px 10px;
  overflow-y: auto;
  border-right: 1px solid var(--av-border);
  background: rgba(10, 20, 17, 0.28);
  scrollbar-width: thin;
}

html[data-resolved-theme="light"] .library-catalog {
  background: rgba(232, 237, 230, 0.52);
}

.library-tool-row {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: stretch;
  min-height: 76px;
  margin: 0;
  border: 0;
  border-bottom: 1px solid var(--av-border);
  border-radius: 10px;
  background: transparent;
  box-shadow: inset 3px 0 0 transparent;
}

.library-tool-row:hover {
  background: rgba(38, 74, 58, 0.22);
}

.library-tool-row.is-active {
  border-bottom-color: transparent;
  background: rgba(35, 105, 76, 0.28);
  box-shadow: inset 3px 0 0 var(--av-primary);
}

html[data-resolved-theme="light"] .library-tool-row:hover {
  background: rgba(37, 103, 75, 0.06);
}

html[data-resolved-theme="light"] .library-tool-row.is-active {
  background: rgba(37, 103, 75, 0.12);
}

.library-tool-open {
  width: 100%;
  min-height: 76px;
  padding: 12px 6px 12px 14px;
  border: 0;
  background: transparent;
  color: var(--av-text-soft);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  text-align: left;
}

.library-tool-mark {
  display: none;
}

.library-tool-open strong,
.library-tool-name {
  overflow: visible;
  font-size: 1rem;
  font-weight: 600;
  white-space: normal;
}

.library-tool-open small,
.library-tool-copy small {
  overflow: visible;
  color: var(--av-muted);
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.45;
  white-space: normal;
}

.library-tool-name em {
  color: var(--av-faint);
  font-size: 0.68rem;
  font-style: normal;
}

.library-tool-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.library-tool-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 7px;
  min-width: 0;
}

.library-tool-name strong {
  min-width: 0;
}

.library-featured-badge,
.library-tool-name em {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 18px;
  padding: 2px 6px;
  border: 1px solid var(--av-border-strong);
  border-radius: 999px;
  background: var(--av-surface-soft);
  color: var(--av-muted);
  font-size: 0.62rem;
  font-style: normal;
  font-weight: 600;
  line-height: 1;
  text-transform: uppercase;
}

.library-favorite {
  position: static;
  align-self: center;
  justify-self: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--av-muted);
}

.library-favorite:hover,
.library-favorite:focus-visible,
.library-favorite.is-active {
  background: var(--av-surface-raised);
  color: var(--av-primary);
}

.library-workspace,
.library-history {
  min-width: 0;
  overflow-y: auto;
  padding: 22px;
  background: transparent;
  scrollbar-width: thin;
}

.library-mobile-back {
  display: none;
}

.library-tool-heading {
  border-color: var(--av-border);
  gap: 12px;
  padding-bottom: 12px;
}

.library-tool-heading h4 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.library-tool-heading p {
  margin-top: 4px;
  color: var(--av-muted);
  font-size: 0.875rem;
  line-height: 1.45;
}

.library-tool-heading .library-featured-badge {
  margin: 4px 0 0;
}

.library-filter-notice,
.library-example-notice,
.library-empty {
  margin: 10px 0;
  padding: 11px 12px;
  border-left: 3px solid var(--av-warning);
  background: rgba(128, 94, 31, 0.12);
  color: var(--av-muted);
  font-size: 0.78rem;
}

.library-form input,
.library-form select {
  min-height: 46px;
  padding: 0 13px;
  border-color: var(--av-border);
  border-radius: 12px;
  background: var(--av-surface-soft);
  color: var(--av-text);
  font-size: 16px;
  line-height: 1.35;
}

.library-form input:focus,
.library-form select:focus {
  border-color: var(--av-primary);
  border-width: 2px;
  box-shadow: none;
}

.library-form input:focus-visible,
.library-form select:focus-visible {
  outline: 0 !important;
}

.library-form input:-webkit-autofill,
.library-form input:-webkit-autofill:hover,
.library-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--av-text);
  box-shadow: 0 0 0 1000px var(--av-surface-soft) inset;
  caret-color: var(--av-text);
}

.library-result,
.library-result.is-empty {
  border-color: var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
}

.library-result > * + * {
  margin-top: 12px;
}

.library-result-title {
  color: var(--av-primary);
  font-weight: 600;
}

.library-result-summary,
.library-method {
  border-color: var(--av-primary);
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
}

.library-result .metrics {
  border-color: var(--av-border);
  background: var(--av-border);
}

.library-result .metric,
.library-result .metric.is-accent {
  background: var(--av-surface-raised);
}

/* The legacy stylesheet still assigns dark ink directly to metric text. */
.library-result .metric span {
  color: var(--av-muted);
}

.library-result .metric strong {
  color: var(--av-text);
}

.library-result .metric small,
.library-history-row time,
.library-history-row p {
  color: var(--av-muted);
}

.library-history,
.library-history-header,
.library-history-row {
  border-color: var(--av-border);
}

.library-history-actions button,
.library-favorite-large,
.library-empty span {
  border-color: var(--av-border);
  background: var(--av-surface-soft);
  color: var(--av-text-soft);
}

.library-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 6px;
  min-height: 48px;
  padding: 8px 4px 2px;
}

.library-pagination button {
  width: 44px;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--av-border);
  border-radius: 10px;
  background: transparent;
  color: var(--av-text-soft);
}

.library-pagination span {
  min-width: 52px;
  color: var(--av-muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* Keep the current library layout in charge when an older modern-shell rule is present. */
.app-shell.modern-shell .library-catalog {
  border-color: var(--av-border);
  background: rgba(10, 20, 17, 0.28);
}

html[data-resolved-theme="light"] .app-shell.modern-shell .library-catalog {
  background: rgba(232, 237, 230, 0.52);
}

.app-shell.modern-shell .library-tool-row,
.app-shell.modern-shell .library-tool-row.is-featured {
  min-height: 76px;
  border: 0;
  border-bottom: 1px solid var(--av-border);
  border-radius: 10px;
  background: transparent;
  box-shadow: inset 3px 0 0 transparent;
}

.app-shell.modern-shell .library-tool-row.is-active,
.app-shell.modern-shell .library-tool-row.is-featured.is-active {
  border-bottom-color: transparent;
  background: rgba(35, 105, 76, 0.28);
  box-shadow: inset 3px 0 0 var(--av-primary);
}

html[data-resolved-theme="light"] .app-shell.modern-shell .library-tool-row.is-active,
html[data-resolved-theme="light"] .app-shell.modern-shell .library-tool-row.is-featured.is-active {
  background: rgba(37, 103, 75, 0.12);
}

.app-shell.modern-shell .library-tool-row.is-featured .library-tool-name {
  align-items: center;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 5px 7px;
}

.app-shell.modern-shell .library-tool-row.is-featured .library-tool-open strong {
  display: block;
  overflow: visible;
  white-space: normal;
  -webkit-line-clamp: unset;
}

.app-shell.modern-shell .library-result .metric,
.app-shell.modern-shell .library-result .metric.is-accent {
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
}

.app-shell.modern-shell .library-result .metric span {
  color: var(--av-muted);
}

.app-shell.modern-shell .library-result .metric strong {
  color: var(--av-text);
}

/* Dialogs, loading, consent and feedback */
.integration-modal,
.notebook-modal {
  position: fixed;
  z-index: 120;
  inset: 0;
  padding: 24px;
  background: rgba(4, 10, 8, 0.7);
  display: grid;
  place-items: center;
}

.integration-modal-panel,
.notebook-modal-panel {
  width: min(620px, 100%);
  max-height: min(760px, calc(100dvh - 48px));
  overflow-y: auto;
  padding: 22px;
  border: 1px solid var(--av-border-strong);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  color: var(--av-text);
  box-shadow: var(--av-shadow);
  animation: av-panel-in var(--av-motion) ease both;
}

.integration-modal-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.integration-modal-heading h3 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
}

.integration-modal-close {
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: transparent;
  color: var(--av-text);
  font-size: 1.3rem;
}

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

.integration-form label {
  display: grid;
  gap: 6px;
  color: var(--av-muted);
  font-size: 0.8rem;
}

.integration-form input,
.integration-form select {
  width: 100%;
  padding: 0 12px;
}

.integration-form-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.loading-overlay {
  position: fixed;
  z-index: 200;
  inset: 0;
  background: rgba(8, 17, 14, 0.82);
  display: grid;
  place-items: center;
}

.loading-card {
  padding: 16px 20px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--av-border);
  border-top-color: var(--av-primary);
  border-radius: 50%;
  animation: av-spin 0.8s linear infinite;
}

.connection-banner {
  position: fixed;
  z-index: 150;
  top: 10px;
  left: 50%;
  width: min(620px, calc(100% - 32px));
  padding: 9px 12px;
  transform: translateX(-50%);
  border: 1px solid var(--av-warning);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
  font-size: 0.78rem;
}

.consent-banner {
  position: fixed;
  z-index: 140;
  right: 18px;
  bottom: 18px;
  width: min(520px, calc(100% - 36px));
  padding: 16px;
  border: 1px solid var(--av-border-strong);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  color: var(--av-text);
  box-shadow: var(--av-shadow);
}

.consent-banner p {
  margin: 5px 0;
  color: var(--av-muted);
  font-size: 0.78rem;
}

.consent-banner a {
  color: var(--av-primary);
  font-size: 0.76rem;
}

.consent-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.consent-actions button {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--av-border);
  border-radius: var(--av-radius-sm);
  background: transparent;
  color: var(--av-text-soft);
}

.consent-accept {
  border-color: var(--av-primary) !important;
  background: var(--av-primary) !important;
  color: var(--av-primary-ink) !important;
}

.toast {
  position: fixed;
  z-index: 220;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100% - 32px));
  padding: 10px 14px;
  transform: translate(-50%, 18px);
  border: 1px solid var(--av-border-strong);
  border-radius: var(--av-radius);
  background: var(--av-surface-raised);
  color: var(--av-text);
  box-shadow: var(--av-shadow);
  opacity: 0;
  pointer-events: none;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

@keyframes av-panel-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes av-message-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes av-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.88); }
  50% { opacity: 1; transform: scale(1); }
}

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

@media (max-width: 1100px) {
  :root {
    --av-sidebar-width: 206px;
    --av-page-gutter: 20px;
  }

  .work-context-summary > span:last-child {
    display: none;
  }

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

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

@media (min-width: 901px) {
  .auth-intro,
  .auth-preview {
    transform: translateY(clamp(-150px, -16vh, -90px));
  }

  .av-shell:not(.is-sidebar-collapsed) .sidebar-close {
    display: none;
  }

  .av-shell:not(.is-sidebar-collapsed) .sidebar-toggle {
    display: none;
  }

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

@media (max-width: 900px) {
  :root {
    --av-page-gutter: 16px;
  }

  .auth-stage {
    padding: 18px 22px 32px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "intro"
      "card"
      "preview";
    gap: 24px;
    padding: 18px 0 20px;
  }

  .auth-intro,
  .auth-preview,
  .auth-card {
    width: min(560px, 100%);
    margin-inline: auto;
  }

  .auth-intro h1 {
    font-size: 2.3rem;
  }

  .auth-intro > p {
    font-size: 1rem;
  }

  .auth-card {
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    backdrop-filter: none;
  }

  html[data-resolved-theme="light"] .auth-card {
    border: 0;
    background: transparent;
  }

  .auth-content {
    padding: 0;
  }

  .auth-screen[data-auth-mode="login"] .auth-mode-title {
    display: none;
  }

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

  .av-shell .side-panel,
  .av-shell.is-sidebar-collapsed .side-panel {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 110;
    width: min(304px, calc(100vw - 54px));
    min-width: 0;
    height: var(--chat-viewport-height, 100dvh);
    transform: translateX(-102%);
    opacity: 1;
    pointer-events: auto;
  }

  .av-shell.is-sidebar-open .side-panel {
    transform: none;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: 100;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(3, 8, 6, 0.68);
    opacity: 0;
    pointer-events: none;
    display: block;
  }

  .av-shell.is-sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

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

  .workspace {
    width: 100%;
  }

  .workspace.is-library-active {
    display: block;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
  }

  .work-context-bar {
    min-height: 126px;
    padding: max(12px, env(safe-area-inset-top)) 16px 10px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    grid-template-areas:
      "toggle brand mobile-weather"
      "context context context";
    align-content: center;
    gap: 9px 10px;
    background: rgba(7, 16, 13, 0.18);
  }

  .sidebar-toggle {
    grid-area: toggle;
  }

  .work-context-main {
    grid-area: context;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
    gap: 10px;
    min-width: 0;
  }

  .workspace-brand {
    grid-area: brand;
    display: block;
    width: 118px;
    max-height: 42px;
  }

  .workspace-section-title {
    display: block;
    min-width: 0;
    overflow: visible;
    font-size: 1rem;
    line-height: 1.25;
    text-overflow: clip;
    white-space: normal;
  }

  .work-context-row {
    width: 100%;
    max-width: none;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .work-context-summary {
    flex: 1 1 160px;
    max-width: none;
  }

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

  .work-context-summary strong {
    display: block;
    max-width: none;
    color: var(--av-text);
    font-size: 0.84rem;
    line-height: 1.35;
    text-overflow: clip;
    white-space: normal;
  }

  .work-context-actions {
    display: flex;
    flex: 0 0 auto;
    justify-content: flex-end;
  }

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

  .mobile-weather-button {
    grid-area: mobile-weather;
    display: inline-flex;
    flex: 0 0 44px;
  }

  .mobile-new-chat,
  .work-context-bar > .weather-widget {
    display: none;
  }

  .mobile-weather-button {
    width: auto;
    padding: 0 9px;
    gap: 5px;
  }

  .mobile-weather-button strong {
    color: var(--av-text);
    font-size: 0.78rem;
  }

  .mobile-weather-button > span:last-child {
    display: none;
  }

  .mobile-weather-button .weather-icon {
    width: 20px;
    height: 20px;
    flex-basis: 20px;
  }

  .weather-popover {
    position: fixed;
    z-index: 160;
    top: auto;
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    width: auto;
    max-height: min(72dvh, 640px);
    border-radius: 12px 12px var(--av-radius) var(--av-radius);
  }

  .calc-panel {
    width: calc(100% - 24px);
    height: auto;
    min-height: 0;
    margin: 12px;
    padding: 18px;
  }

  .ai-panel {
    width: 100%;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .ai-panel-heading {
    top: 112px;
    right: 12px;
  }

  .ai-status {
    font-size: 0;
    min-width: 10px;
    width: 10px;
    height: 10px;
    min-height: 10px;
    padding: 0;
    border: 0;
    background: var(--av-success);
  }

  .ai-chat-pane {
    padding: 0 16px max(12px, env(safe-area-inset-bottom));
  }

  .ai-messages {
    padding-top: 24px;
  }

  .ai-panel.has-conversation .ai-messages {
    padding-top: 18px;
  }

  .ai-welcome {
    margin-top: 28px;
    text-align: left;
  }

  .ai-welcome h4 {
    font-size: 1.3rem;
  }

  .ai-suggestions {
    justify-content: flex-start;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 3px;
    scrollbar-width: none;
  }

  .ai-suggestions::-webkit-scrollbar {
    display: none;
  }

  .ai-suggestions button {
    flex: 0 0 auto;
  }

  .ai-message.is-user .ai-message-body {
    max-width: 86%;
  }

  .ai-user-tools {
    min-height: 44px;
    margin-top: 0;
    opacity: 0.82;
    pointer-events: auto;
  }

  .ai-user-menu {
    position: relative;
    display: block;
  }

  .ai-user-menu .ai-user-menu-toggle {
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    color: var(--av-muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    list-style: none;
    cursor: pointer;
    display: inline-flex !important;
  }

  .ai-user-menu > [data-ai-edit] {
    display: none;
  }

  .ai-user-menu.is-open > [data-ai-edit] {
    position: absolute;
    z-index: 6;
    right: 0;
    top: 42px;
    width: max-content;
    min-height: 44px;
    border-color: var(--av-border);
    background: var(--av-surface-raised);
    color: var(--av-text);
    display: inline-flex;
    box-shadow: var(--av-shadow);
  }

  .ai-message-body {
    font-size: 1rem;
  }

  .ai-message-body > div:first-child {
    overflow-x: auto;
  }

  .ai-composer {
    min-height: 56px;
    padding: 4px 6px 4px 16px;
    border-radius: 20px;
  }

  .ai-send-button {
    min-width: 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .ai-stop-button {
    min-width: 44px;
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
  }

  .ai-message-tools {
    gap: 4px 6px;
  }

  .ai-calculator-action {
    flex-basis: 100%;
    justify-content: flex-start;
  }

  .ai-disclaimer {
    display: none;
  }

  .library-panel {
    padding: 0;
    overflow: visible;
  }

  .library-panel.is-active {
    display: block;
  }

  .library-layout {
    height: auto;
    min-height: 0;
    display: block;
    overflow: visible;
  }

  .library-catalog {
    max-height: none;
    padding: 2px 14px 8px;
    overflow-y: visible;
    border-right: 0;
    border-bottom: 1px solid var(--av-border);
  }

  .library-tool-row {
    min-height: 76px;
  }

  .library-tool-open {
    min-width: 0;
    min-height: 76px;
    padding-inline: 12px 4px;
  }

  .library-workspace {
    padding-top: 18px;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }

  .library-workspace,
  .library-history {
    overflow: visible;
  }

  .library-mobile-back {
    position: sticky;
    top: max(8px, env(safe-area-inset-top));
    z-index: 3;
    width: fit-content;
    min-height: 44px;
    margin: 8px 0 12px;
    padding: 0 8px;
    border: 0;
    border-radius: 0;
    background: var(--av-surface-glass);
    color: var(--av-text-soft);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 0.88rem;
    font-weight: 500;
  }

  .library-mobile-back:hover,
  .library-mobile-back:focus-visible {
    color: var(--av-text);
  }

  .library-panel.is-mobile-detail .library-heading,
  .library-panel.is-mobile-detail .library-toolbar,
  .library-panel.is-mobile-detail .library-groups,
  .library-panel.is-mobile-detail .library-catalog {
    display: none;
  }

  .library-panel.is-mobile-detail .library-layout {
    display: block;
  }

  .library-panel.is-mobile-detail .library-workspace {
    padding-top: 14px;
  }

  .library-pagination {
    justify-content: center;
    padding-bottom: 10px;
  }

  .library-toolbar {
    grid-template-columns: 1fr;
  }

  .integration-modal {
    align-items: end;
    padding: 0;
  }

  .integration-modal-panel {
    width: 100%;
    max-height: 88dvh;
    padding: 20px 16px max(20px, env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: 14px 14px 0 0;
  }
}

@media (max-width: 620px) {
  .auth-stage {
    padding: 14px 16px 28px;
  }

  .auth-site-header {
    min-height: auto;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 10px;
  }

  .auth-site-logo {
    width: 118px;
    max-height: 44px;
  }

  .auth-global-actions {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(178px, 1fr) auto;
    align-items: center;
    gap: 8px;
  }

  .auth-global-actions .theme-segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    min-width: 178px;
  }

  .auth-global-actions .theme-segmented button {
    display: block;
    min-width: 0;
    padding: 0 4px;
    font-size: 0.72rem;
    white-space: nowrap;
  }

  .auth-global-actions .language-picker {
    min-width: 72px;
    padding: 0;
  }

  .language-flag {
    display: none;
  }

  .password-input-wrap input {
    padding-right: 96px;
  }

  .password-toggle {
    right: 6px;
    min-width: 78px;
  }

  .auth-layout {
    padding-top: 8px;
  }

  .auth-intro h1 {
    font-size: 2rem;
  }

  .auth-intro > p {
    margin-top: 12px;
  }

  .auth-content {
    padding: 23px 18px;
  }

  .auth-preview {
    padding: 15px;
  }

  .auth-preview-messages p {
    max-width: 90%;
  }

  .theme-segmented-sidebar button {
    padding-inline: 5px;
    font-size: 0.7rem;
  }

  .workspace-brand {
    width: 112px;
    max-height: 38px;
  }

  .work-context-summary {
    display: flex;
  }

  .mobile-weather-button {
    margin-left: 0;
  }

  .form-grid,
  .library-form,
  .integration-form {
    grid-template-columns: 1fr;
  }

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

  .panel-heading,
  .library-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .ai-chat-pane {
    padding-inline: 16px;
  }

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

  .ai-message.is-user .ai-message-body {
    max-width: 91%;
  }

  .ai-composer {
    border-radius: 20px;
  }

  .consent-banner {
    right: 10px;
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100% - 20px);
  }

  .consent-actions {
    flex-direction: column-reverse;
  }

  .consent-actions button {
    width: 100%;
  }
}

@media (max-height: 720px) and (max-width: 900px) {
  .auth-stage {
    gap: 10px;
  }

  .auth-layout {
    gap: 18px;
  }

  .auth-intro h1 {
    font-size: 1.8rem;
  }

  .auth-intro > p {
    margin-top: 8px;
  }
}

/* Responsive integrity pass: keep the existing product composition intact while
   making mobile navigation, weather and contextual forms usable at narrow heights. */
.weather-chip:focus-visible,
.weather-chip[aria-expanded="true"] {
  border-color: var(--av-primary);
  background: rgba(27, 42, 36, 0.94);
  color: var(--av-text);
  box-shadow: 0 0 0 3px rgba(54, 199, 151, 0.18);
}

html[data-resolved-theme="light"] .weather-chip:focus-visible,
html[data-resolved-theme="light"] .weather-chip[aria-expanded="true"] {
  background: var(--av-surface-raised);
}

.weather-chip #weatherTemperature,
#weatherDetailTemperature {
  color: var(--av-text);
  font-variant-numeric: tabular-nums;
}

.weather-search input,
.integration-form input,
.integration-form select {
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.weather-search input:focus,
.integration-form input:focus,
.integration-form select:focus {
  background: var(--av-surface-soft);
  color: var(--av-text);
}

.weather-search input:-webkit-autofill,
.weather-search input:-webkit-autofill:hover,
.weather-search input:-webkit-autofill:focus,
.integration-form input:-webkit-autofill,
.integration-form input:-webkit-autofill:hover,
.integration-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--av-text);
  box-shadow: 0 0 0 1000px var(--av-surface-soft) inset;
  caret-color: var(--av-text);
}

.sidebar-settings-panel .language-picker,
.sidebar-settings-panel .language-picker :is(span, strong) {
  color: var(--av-text-soft);
}

html[data-resolved-theme="light"] .ai-suggestions button {
  border-color: var(--av-border-strong);
  background: var(--av-surface-raised);
  color: var(--av-text-soft);
}

.ai-thread-item.is-active {
  border-color: transparent;
}

.ai-thread-item.is-active .ai-thread-open,
.ai-thread-item.is-active .ai-thread-select {
  border-color: transparent;
  background: transparent;
}

.ai-thread-open,
.ai-thread-select {
  padding-right: 8px;
}

.ai-thread-delete {
  position: static;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  line-height: 1;
}

@media (max-width: 900px) {
  .av-shell .side-panel,
  .av-shell.is-sidebar-collapsed .side-panel {
    display: flex;
    width: min(340px, calc(100vw - 32px));
    height: var(--chat-viewport-height, 100dvh);
    max-height: var(--chat-viewport-height, 100dvh);
    padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    gap: 10px;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .av-shell .side-brand-row {
    min-height: 54px;
    padding: 0;
  }

  .av-shell .side-brand-row img {
    width: min(166px, calc(100% - 52px));
    max-height: 46px;
  }

  .av-shell .tool-nav {
    display: grid;
    width: 100%;
    flex: 0 0 auto;
    grid-template-columns: minmax(0, 1fr);
    grid-auto-flow: row;
    gap: 4px;
    padding: 2px 0;
  }

  .av-shell .tool-nav .nav-button {
    width: 100%;
    min-height: 48px;
    padding: 8px 10px;
    white-space: normal;
  }

  .av-shell .tool-nav .nav-button > span:last-child {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .av-shell .ai-thread-heading,
  .av-shell #aiHistorySearch,
  .av-shell .ai-thread-list,
  .av-shell .sidebar-settings {
    width: 100%;
  }

  .av-shell .ai-thread-list {
    flex: 0 0 auto;
    max-height: none;
    overflow: visible;
  }

  .av-shell .sidebar-settings {
    flex: 0 0 auto;
    margin-top: 4px;
  }

  .av-shell .sidebar-settings-panel {
    position: static;
    width: 100%;
    max-width: none;
    max-height: none;
    margin-top: 8px;
    overflow: visible;
    overscroll-behavior: auto;
    box-sizing: border-box;
  }

  .av-shell .theme-segmented-sidebar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .av-shell .theme-segmented-sidebar button {
    min-width: 0;
    min-height: 38px;
    padding: 4px 3px;
    font-size: 0.76rem;
    line-height: 1.15;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .av-shell .sidebar-settings-panel .user-panel {
    grid-template-columns: minmax(0, 1fr);
    align-items: start;
  }

  .av-shell .user-panel strong {
    overflow: visible;
    overflow-wrap: anywhere;
    text-overflow: clip;
    white-space: normal;
  }

  .av-shell .logout-button {
    width: 100%;
    margin-top: 8px;
  }

  .av-shell .support-link strong,
  .av-shell .app-legal-links {
    overflow-wrap: anywhere;
  }

  .av-shell .app-legal-links {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .integration-modal {
    inset: auto 0 0;
    height: var(--chat-viewport-height, 100dvh);
    min-height: 0;
    padding: 0;
    align-items: end;
  }

  .integration-modal-panel {
    width: 100%;
    max-height: calc(var(--chat-viewport-height, 100dvh) - 8px);
    padding: 20px 16px max(20px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
