/* Chat Studio — intentionally simple, dependency-free UI styling. */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-muted: #f6f7fa;
  --surface-hover: #f1f2f7;
  --text: #202632;
  --text-sub: #5f6878;
  --text-muted: #88909e;
  --border: #e9ebef;
  --border-strong: #dfe3e9;
  --shadow:
    0 7px 30px rgba(22, 33, 55, 0.045), 0 2px 7px rgba(22, 33, 55, 0.035);
  --accent: #6366f1;
  --accent-contrast: #ffffff;
  --accent-soft: rgba(99, 102, 241, 0.075);
  --accent-border: rgba(99, 102, 241, 0.24);
  --user-bubble: #f1f2fb;
  --code-bg: #f6f7fa;
  --font-content: 15.5px;
  --radius-lg: 17px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14161c;
  --surface: #171a20;
  --surface-raised: #1e222b;
  --surface-muted: #20242c;
  --surface-hover: #2a2e38;
  --text: #eceef3;
  --text-sub: #b5bac7;
  --text-muted: #8c92a1;
  --border: #2b303a;
  --border-strong: #393f4b;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.15);
  --accent-soft: color-mix(in srgb, var(--accent) 15%, transparent);
  --accent-border: color-mix(in srgb, var(--accent) 30%, transparent);
  --user-bubble: #252936;
  --code-bg: #20252d;
}
:root[data-accent="teal"] {
  --accent: #0d9488;
  --accent-soft: rgba(13, 148, 136, 0.08);
  --accent-border: rgba(13, 148, 136, 0.26);
}
:root[data-accent="rose"] {
  --accent: #df526c;
  --accent-soft: rgba(223, 82, 108, 0.075);
  --accent-border: rgba(223, 82, 108, 0.27);
}
:root[data-accent="amber"] {
  --accent: #b7791f;
  --accent-soft: rgba(183, 121, 31, 0.09);
  --accent-border: rgba(183, 121, 31, 0.28);
}
:root[data-font="small"] {
  --font-content: 14px;
}
:root[data-font="large"] {
  --font-content: 17.5px;
}
* {
  box-sizing: border-box;
}
html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}
body {
  font:
    14px/1.55 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Inter,
    Roboto,
    Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
button,
input,
textarea {
  font: inherit;
}
button {
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid var(--accent-border);
  outline-offset: 2px;
}
a {
  color: inherit;
}
button svg,
.brand svg,
.starter-icon svg,
.welcome-symbol svg,
.composer-left svg,
.history-item svg,
.text-action svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.hidden {
  display: none !important;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.svg-defs {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100svh;
  height: 100svh;
}
.app-header {
  position: relative;
  flex: 0 0 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 27px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  gap: 15px;
  z-index: 4;
}
.header-left,
.header-right {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}
.header-right {
  gap: 12px;
}
.icon-button {
  border: 0;
  background: transparent;
  color: var(--text-sub);
  border-radius: 10px;
  min-width: 37px;
  width: 37px;
  height: 37px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  transition:
    background 0.15s,
    color 0.15s;
}
.icon-button:hover {
  background: var(--surface-muted);
  color: var(--text);
}
.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.header-separator {
  height: 24px;
  width: 1px;
  background: var(--border-strong);
  margin: 0 5px 0 1px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-size: 16px;
  font-weight: 720;
  letter-spacing: -0.5px;
  white-space: nowrap;
}
.brand-mark {
  display: grid;
  place-items: center;
  color: white;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  background: var(--accent);
}
.brand-mark svg {
  width: 19px;
  height: 19px;
  stroke-width: 1.9;
}
.brand-subtitle {
  color: var(--text-muted);
  font-size: 12px;
  border-left: 1px solid var(--border-strong);
  padding-left: 14px;
  margin-left: 1px;
  white-space: nowrap;
}
.demo-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-sub);
  font-size: 12px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 100px;
  padding: 6px 11px;
  white-space: nowrap;
}
.status-dot {
  width: 6px;
  height: 6px;
  background: #8ca2b4;
  border-radius: 100%;
}
.main-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg);
  --composer-dock-height: 112px;
}
.conversation-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  scrollbar-color: var(--border-strong) transparent;
  scrollbar-width: thin;
}
.conversation-scroll:focus {
  outline: none;
}
.scroll-down-button {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: calc(var(--composer-dock-height) + 12px);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 2px solid #242424;
  border-radius: 50%;
  color: #f1f1f1;
  background: #090909;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  transform: translateX(-50%);
  transition:
    color 0.15s,
    border-color 0.15s,
    background 0.15s,
    transform 0.15s;
}
.scroll-down-button:hover {
  color: #fff;
  border-color: #3b3b3b;
  background: #181818;
  transform: translate(-50%, -2px);
}
.scroll-down-button:active {
  transform: translate(-50%, 0);
}
.scroll-down-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.empty-state {
  max-width: 880px;
  min-height: 100%;
  margin: 0 auto;
  padding: min(10vh, 96px) 26px 45px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.welcome-symbol {
  display: grid;
  place-items: center;
  border-radius: 21px;
  width: 60px;
  height: 60px;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 24px;
}
.welcome-symbol svg {
  width: 31px;
  height: 31px;
  stroke-width: 1.6;
}
.welcome-kicker {
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 2.3px;
  color: var(--accent);
  margin: 0 0 9px;
}
.empty-state h1 {
  font-size: clamp(25px, 3vw, 37px);
  letter-spacing: -1.5px;
  font-weight: 710;
  line-height: 1.23;
  margin: 0;
}
.welcome-detail {
  color: var(--text-sub);
  font-size: 14px;
  line-height: 1.8;
  margin: 15px 0 37px;
}
.starter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 780px;
}
.starter-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: relative;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 15px;
  padding: 18px 19px 17px;
  min-height: 148px;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s,
    background 0.15s;
}
.starter-card:hover {
  border-color: var(--accent-border);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}
.starter-icon {
  display: grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
}
.starter-icon svg {
  width: 18px;
  height: 18px;
}
.starter-card strong,
.starter-card small {
  display: block;
}
.starter-card strong {
  font-size: 13.5px;
  font-weight: 660;
}
.starter-card small {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-top: 3px;
}
.starter-arrow {
  position: absolute;
  right: 17px;
  top: 21px;
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}
.message-list {
  max-width: 828px;
  margin: 0 auto;
  padding: 40px 29px 30px;
}
.message {
  width: 100%;
  animation: messageIn 0.23s ease-out;
}
@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.message + .message {
  margin-top: 33px;
}
.message.user {
  display: flex;
  justify-content: flex-end;
}
.user-message-content {
  background: var(--user-bubble);
  border-radius: 18px 18px 5px 18px;
  max-width: min(90%, 620px);
  padding: 13px 18px;
  line-height: 1.6;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  font-size: var(--font-content);
}
.message.assistant {
  display: flex;
  align-items: flex-start;
  gap: 13px;
}
.assistant-avatar {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 9px;
  color: var(--accent);
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.assistant-avatar svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.assistant-content {
  min-width: 0;
  flex: 1;
}
.assistant-name {
  font-weight: 720;
  font-size: 12.5px;
  color: var(--text);
  margin: 4px 0 10px;
}
.markdown {
  font-size: var(--font-content);
  line-height: 1.83;
  color: var(--text);
  overflow-wrap: anywhere;
}
.markdown > :first-child {
  margin-top: 0 !important;
}
.markdown > :last-child {
  margin-bottom: 0 !important;
}
.markdown h1,
.markdown h2,
.markdown h3,
.markdown h4 {
  font-weight: 730;
  line-height: 1.35;
  letter-spacing: -0.025em;
  margin: 1.55em 0 0.55em;
}
.markdown h1 {
  font-size: 1.65em;
}
.markdown h2 {
  font-size: 1.36em;
}
.markdown h3 {
  font-size: 1.14em;
}
.markdown h4 {
  font-size: 1.03em;
}
.markdown p {
  margin: 0.15em 0 1em;
}
.markdown strong,
.markdown b {
  font-weight: 740;
}
.markdown em {
  font-style: italic;
}
.markdown a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.markdown ul,
.markdown ol {
  padding-left: 1.45em;
  margin: 0.45em 0 1em;
}
.markdown li {
  padding-left: 0.15em;
  margin: 0.2em 0;
}
.markdown li > p {
  margin: 0.15em 0;
}
.markdown blockquote {
  border-left: 3px solid var(--accent);
  background: var(--surface-muted);
  border-radius: 0 8px 8px 0;
  margin: 1.15em 0;
  padding: 10px 16px;
  color: var(--text-sub);
}
.markdown blockquote > :last-child {
  margin-bottom: 0;
}
.markdown hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.7em 0;
}
.markdown :not(pre) > code {
  border-radius: 5px;
  background: var(--surface-muted);
  font-size: 0.9em;
  padding: 0.13em 0.32em;
  border: 1px solid var(--border);
  word-break: break-word;
}
.markdown .table-wrap {
  overflow-x: auto;
  max-width: 100%;
  margin: 1.05em 0 1.35em;
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
  -webkit-overflow-scrolling: touch;
}
.markdown .table-wrap:focus-visible {
  outline: 2px solid var(--accent-border);
  outline-offset: 2px;
}
.markdown table {
  border-collapse: collapse;
  width: 100%;
  min-width: max(100%, calc(var(--table-columns, 3) * 128px));
  font-size: 0.92em;
  line-height: 1.55;
}
.markdown th,
.markdown td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  min-width: 112px;
  overflow-wrap: normal;
  word-break: normal;
  hyphens: none;
}
.markdown th:first-child,
.markdown td:first-child {
  min-width: 160px;
}
.markdown th:nth-child(2),
.markdown td:nth-child(2) {
  min-width: 72px;
}
.markdown th {
  background: var(--surface-muted);
  font-weight: 740;
}
.markdown tbody tr:last-child td {
  border-bottom: 0;
}
.markdown tbody tr:hover {
  background: var(--accent-soft);
}
.markdown th[align="center"],
.markdown td[align="center"] {
  text-align: center;
}
.markdown th[align="right"],
.markdown td[align="right"] {
  text-align: right;
}
.markdown .code-wrap {
  margin: 1.15em 0 1.35em;
  border: 1px solid var(--border-strong);
  background: var(--code-bg);
  border-radius: 12px;
  overflow: hidden;
}
.markdown .code-topbar {
  height: 39px;
  border-bottom: 1px solid var(--border);
  padding: 0 12px 0 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: var(--text-sub);
}
.markdown .code-wrap pre {
  overflow-x: auto;
  max-width: 100%;
  padding: 16px;
  margin: 0;
  line-height: 1.65;
  font-size: 0.85em;
}
.markdown .code-wrap code {
  font-size: 1em;
  background: transparent;
  white-space: pre;
  border: 0;
}
.code-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  color: var(--text-sub);
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  font-size: 11px;
}
.code-copy:hover {
  background: var(--surface-hover);
  color: var(--text);
}
.code-copy svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.markdown img {
  max-width: 100%;
  border-radius: 10px;
}
.message-tools {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 13px;
}
.tool-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  padding: 6px 8px;
  border-radius: 7px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.tool-button:hover {
  background: var(--surface-muted);
  color: var(--text-sub);
}
.tool-button svg {
  height: 15px;
  width: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.typing-dots {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 0 16px;
}
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.1s infinite;
}
.typing-dots span:nth-child(2) {
  animation-delay: 0.16s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes typing {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-4px);
  }
}
.composer-dock {
  flex: 0 0 auto;
  padding: 13px 26px 16px;
  background: var(--bg);
}
.composer {
  width: 100%;
  max-width: 817px;
  margin: 0 auto;
  border: 1px solid var(--border-strong);
  background: var(--surface-raised);
  border-radius: 18px;
  box-shadow: var(--shadow);
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.composer:focus-within {
  border-color: var(--accent-border);
  box-shadow:
    0 5px 25px rgba(22, 33, 55, 0.065),
    0 0 0 3px var(--accent-soft);
}
.composer textarea {
  display: block;
  width: 100%;
  resize: none;
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  padding: 18px 20px 8px;
  line-height: 1.55;
  min-height: 53px;
  max-height: 195px;
  overflow-y: auto;
  font-size: 14.5px;
}
.composer textarea:focus-visible {
  outline: 0;
}
.composer textarea::placeholder {
  color: var(--text-muted);
}
.product-image-preview {
  display: flex;
  align-items: center;
  gap: 11px;
  margin: 12px 14px 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--surface);
}
.product-image-preview img {
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  object-fit: contain;
  border-radius: 9px;
  background: #fff;
}
.product-image-preview-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}
.product-image-preview-copy strong,
.product-image-preview-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-image-preview-copy strong {
  color: var(--text);
  font-size: 12.5px;
}
.product-image-preview-copy small {
  color: var(--text-muted);
  font-size: 10.5px;
}
.product-image-remove {
  width: 30px;
  height: 30px;
  margin-left: auto;
  display: grid;
  flex: 0 0 30px;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--text-muted);
  background: transparent;
  cursor: pointer;
}
.product-image-remove:hover {
  color: var(--text);
  background: var(--surface-hover);
}
.product-image-remove svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.product-image-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--accent-border);
  border-radius: 10px;
  color: var(--accent);
  background: var(--accent-soft);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.product-image-button:hover {
  border-color: var(--accent);
}
.product-image-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.composer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 10px 10px 17px;
}
.composer-left {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.composer-left svg {
  width: 15px;
  height: 15px;
}
.ai-provider-control {
  flex: 0 0 auto;
}
.ai-provider-control select {
  width: auto;
  max-width: 190px;
  height: 32px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: 0;
  background: var(--surface-raised);
  color: var(--text-sub);
  font: inherit;
  font-weight: 680;
  cursor: pointer;
}
.ai-provider-control select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.ai-provider-control select:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.composer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.user-image-attachment {
  display: block;
  width: min(280px, 68vw);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.24);
  font-size: 11px;
  white-space: normal;
}
.user-image-preview {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 11px;
  background: #fff;
  cursor: zoom-in;
}
.user-image-preview img {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  background: #fff;
}
.user-image-attachment figcaption {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 7px;
  opacity: 0.9;
  overflow-wrap: anywhere;
}
.user-image-attachment svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.product-image-match {
  width: fit-content;
  padding: 4px 7px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 10.5px;
  font-weight: 700;
}
.keyboard-hint {
  color: var(--text-muted);
  font-size: 11px;
}
.send-button {
  border: 0;
  background: var(--accent);
  border-radius: 11px;
  color: var(--accent-contrast);
  height: 35px;
  width: 35px;
  display: grid;
  place-items: center;
  transition:
    opacity 0.15s,
    transform 0.15s;
}
.send-button:hover:not(:disabled) {
  transform: translateY(-1px);
}
.send-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.send-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.composer-note {
  color: var(--text-muted);
  text-align: center;
  font-size: 10.5px;
  line-height: 1.5;
  margin: 10px 0 0;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 16, 27, 0.38);
  z-index: 10;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.side-drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100svh;
  width: min(390px, calc(100vw - 28px));
  background: var(--surface);
  z-index: 11;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: 8px 0 35px rgba(0, 0, 0, 0.07);
  animation: slideIn 0.2s ease-out;
}
#settingsDrawer {
  left: auto;
  right: 0;
  border-right: 0;
  border-left: 1px solid var(--border);
  animation: slideFromRight 0.2s ease-out;
}
@keyframes slideIn {
  from {
    transform: translateX(-15px);
    opacity: 0.5;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
@keyframes slideFromRight {
  from {
    transform: translateX(15px);
    opacity: 0.5;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
.drawer-header {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.drawer-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 730;
  letter-spacing: -0.4px;
}
.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 23px 20px;
}
.drawer-create {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--accent);
  color: white;
  border-radius: 10px;
  border: 0;
  height: 42px;
  font-weight: 650;
}
.drawer-create svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
}
.drawer-section-title {
  color: var(--text-muted);
  font-weight: 730;
  font-size: 10px;
  letter-spacing: 1.3px;
  margin: 28px 5px 10px;
}
.history-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.history-item {
  display: flex;
  align-items: center;
  gap: 7px;
  border-radius: 8px;
}
.history-select {
  flex: 1;
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-sub);
  padding: 10px 12px;
  text-align: left;
  font-size: 13px;
}
.history-item.current {
  background: var(--accent-soft);
}
.history-item.current .history-select {
  color: var(--accent);
  font-weight: 700;
}
.history-item:hover {
  background: var(--surface-muted);
}
.history-delete {
  background: transparent;
  color: var(--text-muted);
  border: 0;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  margin-right: 3px;
}
.history-delete:hover {
  color: #d45c5c;
  background: var(--surface-hover);
}
.history-delete svg {
  width: 15px;
  height: 15px;
}
.empty-history {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.7;
  padding: 14px 10px;
}
.drawer-footer {
  border-top: 1px solid var(--border);
  padding: 17px 22px 21px;
}
.drawer-footer p {
  color: var(--text-muted);
  font-size: 11px;
  margin: 8px 0 0;
}
.text-action {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--text-sub);
  background: transparent;
  border: 0;
  font-size: 12px;
}
.text-action svg {
  width: 16px;
  height: 16px;
}
.text-action:hover {
  color: var(--accent);
}
.text-action.danger:hover {
  color: #df5d5d;
}
.settings-body {
  padding-top: 4px;
}
.setting-group {
  padding: 24px 0 27px;
  border-bottom: 1px solid var(--border);
}
.setting-group:last-child {
  border-bottom: 0;
}
.setting-heading h3 {
  font-size: 13px;
  margin: 0;
  font-weight: 730;
}
.setting-heading p {
  margin: 4px 0 18px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}
.theme-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.theme-choice {
  padding: 7px 7px 11px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-sub);
  border-radius: 10px;
  font-size: 11.5px;
}
.theme-choice.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 710;
}
.theme-preview {
  display: grid;
  place-items: center;
  height: 55px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.theme-preview svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.light-preview {
  color: #596376;
  background: #f1f2f6;
}
.dark-preview {
  color: #e1e2ea;
  background: #252a35;
}
.system-preview {
  color: #9499ac;
  background: linear-gradient(115deg, #f1f2f6 50%, #252a35 50%);
}
.accent-options {
  display: flex;
  align-items: center;
  gap: 12px;
}
.accent-choice {
  width: 35px;
  height: 35px;
  border: 3px solid var(--surface);
  outline: 1px solid transparent;
  border-radius: 50%;
  background: var(--swatch);
  display: grid;
  place-items: center;
  color: white;
}
.accent-choice svg {
  display: none;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
}
.accent-choice.active {
  outline-color: var(--swatch);
}
.accent-choice.active svg {
  display: block;
}
.font-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 3px;
  gap: 3px;
}
.font-choice {
  background: transparent;
  color: var(--text-sub);
  border: 0;
  border-radius: 7px;
  padding: 9px;
  font-size: 12px;
}
.font-choice.active {
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.09);
  font-weight: 700;
}
.input-label {
  display: block;
  color: var(--text-sub);
  font-size: 11.5px;
  font-weight: 670;
  margin: 0 0 6px;
}
.settings-input {
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--text);
  padding: 11px 12px;
  width: 100%;
  border-radius: 8px;
  outline: 0;
  font-size: 12px;
}
.settings-input:focus {
  border-color: var(--accent);
}
.save-api-button {
  background: var(--surface-muted);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 9px 13px;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.save-api-button:hover {
  border-color: var(--accent-border);
}
.api-guidance {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.65;
  margin-top: 12px;
}
.api-guidance code {
  font-size: 10px;
  overflow-wrap: anywhere;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 107px;
  transform: translateX(-50%);
  padding: 11px 17px;
  z-index: 30;
  border-radius: 10px;
  background: #252a35;
  color: white;
  font-size: 12px;
  box-shadow: 0 7px 20px rgba(0, 0, 0, 0.16);
  animation: fadeIn 0.2s;
  max-width: calc(100vw - 40px);
  text-align: center;
}
@media (max-width: 740px) {
  .app-header {
    padding: 0 14px;
    flex-basis: 62px;
  }
  .brand-subtitle {
    display: none;
  }
  .header-separator {
    margin: 0;
  }
  .header-left,
  .header-right {
    gap: 5px;
  }
  .demo-indicator {
    margin-right: 3px;
    font-size: 0;
    padding: 8px;
  }
  .status-dot {
    width: 8px;
    height: 8px;
  }
  .empty-state {
    padding: min(10vh, 72px) 17px 30px;
  }
  .starter-grid {
    grid-template-columns: 1fr;
    gap: 9px;
    max-width: 450px;
  }
  .starter-card {
    min-height: 79px;
    padding: 12px;
    flex-direction: row;
    gap: 12px;
    align-items: center;
  }
  .starter-icon {
    margin: 0;
    flex: 0 0 39px;
    width: 39px;
    height: 39px;
  }
  .starter-arrow {
    top: 30px;
    right: 14px;
  }
  .welcome-detail {
    margin-bottom: 25px;
  }
  .message-list {
    padding: 25px 16px;
  }
  .message + .message {
    margin-top: 26px;
  }
  .message.assistant {
    gap: 9px;
  }
  .assistant-avatar {
    width: 25px;
    height: 25px;
    flex-basis: 25px;
  }
  .markdown {
    line-height: 1.75;
  }
  .composer-dock {
    padding: 10px 13px 11px;
  }
  .keyboard-hint {
    display: none;
  }
  .composer-note {
    font-size: 9.5px;
    margin-top: 8px;
  }
  .composer {
    border-radius: 15px;
  }
  .composer textarea {
    padding: 14px 15px 8px;
  }
}
@media (max-width: 390px) {
  .brand-text {
    font-size: 14px;
  }
  .brand-mark {
    width: 27px;
    height: 27px;
  }
  .header-new {
    display: none;
  }
  .desktop-break {
    display: none;
  }
  .empty-state h1 {
    font-size: 24px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* RAG Client integration */
select {
  font: inherit;
}
.demo-indicator .status-dot {
  background: #20b981;
  box-shadow: 0 0 0 3px rgba(32, 185, 129, 0.12);
}
.demo-indicator.offline .status-dot {
  background: #e05d5d;
  box-shadow: 0 0 0 3px rgba(224, 93, 93, 0.12);
}

.scope-panel {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
}
.scope-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: min(410px, 42vw);
  height: 30px;
  padding: 0 9px;
  border: 1px solid var(--accent-border);
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.scope-toggle:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.scope-toggle span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scope-toggle svg {
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}
.scope-toggle .scope-chevron {
  width: 13px;
  height: 13px;
  transition: transform 0.18s ease;
}
.scope-toggle[aria-expanded="true"] .scope-chevron {
  transform: rotate(180deg);
}
.scope-controls {
  position: absolute;
  z-index: 8;
  bottom: calc(100% + 12px);
  left: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  width: min(360px, calc(100vw - 52px));
  padding: 15px;
  border: 1px solid var(--border-strong);
  border-radius: 13px;
  background: var(--surface-raised);
  box-shadow:
    0 18px 48px rgba(22, 33, 55, 0.16),
    0 3px 10px rgba(22, 33, 55, 0.08);
}
.scope-controls[hidden] {
  display: none;
}
.scope-popover-heading {
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.scope-popover-heading strong,
.scope-popover-heading small {
  display: block;
}
.scope-popover-heading strong {
  color: var(--text);
  font-size: 13px;
}
.scope-popover-heading small {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 500;
}
.scope-field-level {
  display: inline-block;
  margin-right: 6px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}
.scope-controls label,
.document-filters label {
  color: var(--text-sub);
  font-size: 10.5px;
  font-weight: 700;
}
.scope-controls select,
.document-filters select {
  display: block;
  width: 100%;
  height: 38px;
  margin-top: 5px;
  padding: 0 34px 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  outline: 0;
  background: var(--surface-raised);
  color: var(--text);
  font-size: 12px;
}
.scope-controls select:focus,
.document-filters select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.composer-left {
  min-width: 0;
}
.composer-context-hint {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.message-time {
  margin-left: auto;
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
.rag-references {
  margin-top: 19px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.rag-reference-heading {
  color: var(--text);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.1px;
}
.rag-reference-scope {
  margin: 3px 0 10px;
  color: var(--text-muted);
  font-size: 11.5px;
}
.rag-source-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}
.rag-source-chip {
  max-width: 100%;
  overflow: hidden;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-sub);
  font-size: 10.5px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rag-source-chip:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent);
}
.rag-asset-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
  margin-top: 13px;
}
.rag-asset-gallery figure {
  min-width: 0;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}
.rag-asset-gallery img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 340px;
  object-fit: contain;
  border-radius: 7px;
  cursor: zoom-in;
}
.rag-asset-gallery figcaption {
  margin-top: 7px;
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.rag-retrieval {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
}
.rag-retrieval summary {
  padding: 10px 12px;
  color: var(--text-sub);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 700;
}
.rag-retrieval[open] summary {
  border-bottom: 1px solid var(--border);
}
.rag-retrieval-query {
  margin: 10px 12px 0;
  color: var(--text-sub);
  font-size: 11px;
}
.rag-retrieval pre {
  max-height: 330px;
  margin: 8px 12px 12px;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-raised);
  color: var(--text-sub);
  font:
    11px/1.65 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  white-space: pre-wrap;
}

.product-references {
  margin-top: 19px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
}
.product-source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(245px, 1fr));
  gap: 10px;
  margin-top: 9px;
}
.product-source-card {
  display: block;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-muted);
}
.product-source-card.has-gallery {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
}
.product-gallery-trigger {
  position: relative;
  display: block;
  width: 100%;
  min-height: 112px;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--border);
  background: #fff;
  cursor: zoom-in;
}
.product-gallery-trigger img {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 112px;
  object-fit: contain;
  background: #fff;
  transition: transform 180ms ease;
}
.product-gallery-trigger:hover img {
  transform: scale(1.035);
}
.product-gallery-label {
  position: absolute;
  right: 6px;
  bottom: 6px;
  left: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 27px;
  padding: 4px 7px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 7px;
  background: rgba(17, 24, 39, 0.82);
  color: #fff;
  font-size: 10px;
  font-weight: 720;
  backdrop-filter: blur(5px);
}
.product-gallery-label svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.product-source-body {
  display: flex;
  min-width: 0;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 10px;
}
.product-source-body strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.product-source-code {
  color: var(--accent);
  font-size: 11px;
  font-weight: 760;
}
.product-source-body small {
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.45;
}
.product-page-link {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 7px;
  padding: 5px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 750;
  text-decoration: none;
}
.product-page-link:hover {
  border-color: var(--accent);
  text-decoration: none;
}
.product-load-more {
  display: block;
  min-height: 38px;
  margin: 12px auto 0;
  padding: 8px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-raised);
  color: var(--accent);
  font: inherit;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}
.product-load-more:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.product-load-more:disabled {
  cursor: wait;
  opacity: 0.65;
}

.wide-drawer {
  width: min(520px, calc(100vw - 28px));
}
.documents-body {
  padding-top: 16px;
}
.document-search {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-raised);
}
.document-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.document-search svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 1.8;
}
.document-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
}
.document-filters {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}
.document-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drawer-loading {
  padding: 20px 5px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}
.document-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 11px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
}
.document-item:hover {
  border-color: var(--accent-border);
  background: var(--accent-soft);
}
.document-item-icon {
  display: grid;
  place-items: center;
  width: 35px;
  height: 35px;
  flex: 0 0 35px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}
.document-item-icon svg,
.document-item > svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}
.document-item > svg {
  flex: 0 0 auto;
  color: var(--text-muted);
}
.document-item-text {
  min-width: 0;
  flex: 1;
}
.document-item-text strong,
.document-item-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.document-item-text strong {
  font-size: 12.5px;
  font-weight: 680;
}
.document-item-text small {
  margin-top: 3px;
  color: var(--text-muted);
  font-size: 10.5px;
}

.document-dialog {
  width: min(850px, calc(100vw - 30px));
  max-height: min(82vh, 760px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.22);
}
.document-dialog::backdrop {
  background: rgba(10, 16, 27, 0.48);
}
.document-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--border);
}
.document-dialog-header h2 {
  margin: 0;
  font-size: 16px;
}
.document-dialog-header p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
.document-dialog-state {
  margin: 15px 20px 0;
  color: var(--text-sub);
  font-size: 12px;
}
.document-dialog pre {
  max-height: calc(82vh - 135px);
  margin: 12px 20px 20px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text);
  font:
    12px/1.7 ui-monospace,
    SFMono-Regular,
    Consolas,
    monospace;
  white-space: pre-wrap;
}

.product-gallery-dialog {
  width: min(920px, calc(100vw - 32px));
  max-height: min(88dvh, 820px);
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.28);
}
.product-gallery-dialog::backdrop {
  background: rgba(10, 16, 27, 0.7);
  backdrop-filter: blur(3px);
}
.product-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}
.product-gallery-header > div {
  min-width: 0;
}
.product-gallery-header h2 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.product-gallery-header p {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 10.5px;
}
.product-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  max-height: calc(88dvh - 72px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 16px;
}
.product-gallery-grid figure {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #fff;
}
.product-gallery-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #fff;
}
.product-gallery-grid figcaption {
  padding: 7px 9px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 10px;
  text-align: center;
}

@media (max-width: 740px) {
  .document-filters {
    grid-template-columns: 1fr;
  }
  .scope-toggle {
    max-width: min(210px, 52vw);
  }
  .scope-controls {
    max-height: 190px;
    overflow-y: auto;
  }
  .composer-context-hint {
    display: none;
  }
  .rag-source-chip {
    white-space: normal;
    text-align: left;
  }
  .rag-asset-gallery {
    grid-template-columns: 1fr;
  }
  .wide-drawer {
    width: calc(100vw - 18px);
  }
}

/* Responsive layout: desktop, tablet, phone and touch devices */
html,
body {
  overflow: hidden;
}
.app-shell {
  min-height: 100svh;
  height: 100dvh;
  max-width: 100vw;
  overflow: hidden;
}
.main-panel,
.conversation-scroll,
.composer-dock,
.composer,
.message-list,
.assistant-content {
  min-width: 0;
}

@media (max-width: 1024px) {
  .app-header {
    padding-inline: 18px;
  }
  .empty-state {
    max-width: 820px;
    padding-top: min(8vh, 72px);
  }
  .message-list {
    max-width: 790px;
  }
  .composer-dock {
    padding-inline: 18px;
  }
  .composer {
    max-width: 790px;
  }
  .brand-subtitle {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

@media (max-width: 740px) {
  .app-header {
    flex-basis: 60px;
    min-height: 60px;
    padding: env(safe-area-inset-top) 10px 0;
    gap: 5px;
  }
  .header-left,
  .header-right {
    gap: 4px;
  }
  .header-left {
    flex: 1 1 auto;
    overflow: hidden;
  }
  .header-right {
    flex: 0 0 auto;
  }
  .header-separator,
  .brand-subtitle {
    display: none;
  }
  .brand {
    min-width: 0;
    gap: 7px;
  }
  .brand-text {
    overflow: hidden;
    font-size: 14px;
    text-overflow: ellipsis;
  }
  .brand-mark {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 9px;
  }
  .icon-button {
    min-width: 36px;
    width: 36px;
    height: 36px;
  }
  .demo-indicator {
    min-width: 30px;
    height: 30px;
    margin: 0 2px;
    padding: 0 10px;
  }

  .empty-state {
    width: 100%;
    min-height: auto;
    padding: clamp(30px, 7vh, 58px) 14px 24px;
  }
  .welcome-symbol {
    width: 50px;
    height: 50px;
    margin-bottom: 16px;
    border-radius: 17px;
  }
  .welcome-symbol svg {
    width: 27px;
    height: 27px;
  }
  .welcome-kicker {
    margin-bottom: 7px;
    font-size: 9.5px;
    letter-spacing: 1.8px;
  }
  .empty-state h1 {
    max-width: 100%;
    font-size: clamp(24px, 7vw, 30px);
    letter-spacing: -0.9px;
    overflow-wrap: anywhere;
  }
  .welcome-detail {
    max-width: 520px;
    margin: 11px 0 23px;
    font-size: 12.5px;
    line-height: 1.65;
  }
  .desktop-break {
    display: none;
  }
  .starter-grid {
    width: 100%;
    max-width: 520px;
    gap: 8px;
  }
  .starter-card {
    min-height: 72px;
    padding: 10px 42px 10px 10px;
    border-radius: 12px;
  }
  .starter-card strong {
    font-size: 13px;
  }
  .starter-card small {
    font-size: 10.5px;
  }
  .starter-icon {
    width: 38px;
    height: 38px;
    flex-basis: 38px;
    border-radius: 9px;
  }
  .starter-arrow {
    top: 27px;
    right: 13px;
  }

  .message-list {
    width: 100%;
    padding: 20px 12px 24px;
  }
  .message + .message {
    margin-top: 24px;
  }
  .message.assistant {
    gap: 8px;
  }
  .assistant-avatar {
    width: 25px;
    height: 25px;
    flex-basis: 25px;
    border-radius: 8px;
  }
  .assistant-name {
    margin: 2px 0 8px;
  }
  .user-message-content {
    max-width: 94%;
    padding: 11px 14px;
    border-radius: 16px 16px 5px 16px;
  }
  .markdown {
    font-size: min(var(--font-content), 15.5px);
    line-height: 1.7;
  }
  .markdown h1 {
    font-size: 1.4em;
  }
  .markdown h2 {
    font-size: 1.25em;
  }
  .markdown h3 {
    font-size: 1.1em;
  }
  .markdown ul,
  .markdown ol {
    padding-left: 1.25em;
  }
  .markdown .table-wrap {
    margin-inline: 0;
    border-radius: 9px;
    -webkit-overflow-scrolling: touch;
  }
  .markdown table {
    min-width: max(100%, calc(var(--table-columns, 3) * 112px));
    font-size: 0.88em;
  }
  .markdown th,
  .markdown td {
    padding: 9px 10px;
    min-width: 100px;
  }
  .markdown th:first-child,
  .markdown td:first-child {
    min-width: 140px;
  }
  .markdown th:nth-child(2),
  .markdown td:nth-child(2) {
    min-width: 64px;
  }
  .markdown .code-wrap pre {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }
  .message-tools {
    flex-wrap: wrap;
  }
  .message-time {
    margin-left: 0;
  }

  .composer-dock {
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
  .scroll-down-button {
    width: 38px;
    height: 38px;
    bottom: calc(var(--composer-dock-height) + 8px);
  }
  .composer {
    width: 100%;
    border-radius: 15px;
  }
  .composer textarea {
    min-height: 50px;
    max-height: min(34dvh, 180px);
    padding: 14px 14px 7px;
    font-size: 16px;
  }
  .composer-bottom {
    gap: 7px;
    padding: 2px 8px 8px 10px;
  }
  .composer-left {
    flex: 1 1 auto;
    min-width: 0;
  }
  .composer-actions {
    flex: 0 0 auto;
    gap: 5px;
  }
  .send-button {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }
  .scope-panel {
    max-width: 100%;
  }
  .scope-toggle {
    max-width: min(100%, calc(100vw - 78px));
    height: 32px;
    padding-inline: 8px;
  }
  .ai-provider-control select {
    max-width: 118px;
    padding-left: 7px;
    font-size: 10.5px;
  }
  .scope-controls {
    position: fixed;
    z-index: 20;
    right: 10px;
    bottom: calc(104px + env(safe-area-inset-bottom));
    left: 10px;
    width: auto;
    max-height: min(55dvh, 380px);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px;
  }
  .composer-context-hint,
  .keyboard-hint {
    display: none;
  }
  .composer-note {
    margin: 6px 8px 0;
    font-size: 9px;
    line-height: 1.35;
  }

  .rag-references {
    margin-top: 15px;
    padding-top: 12px;
  }
  .product-references {
    margin-top: 15px;
    padding-top: 12px;
  }
  .product-source-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .rag-source-chips {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }
  .rag-source-chip {
    width: 100%;
    white-space: normal;
    text-align: left;
  }
  .rag-asset-gallery {
    grid-template-columns: minmax(0, 1fr);
  }
  .rag-asset-gallery img {
    max-height: 48dvh;
  }
  .rag-retrieval pre {
    max-height: 42dvh;
    margin: 8px;
    padding: 10px;
    font-size: 10px;
  }
  .rag-retrieval-query {
    margin-inline: 9px;
  }

  .side-drawer,
  .wide-drawer,
  #settingsDrawer {
    width: 100vw;
    max-width: 100vw;
    border-right: 0;
    border-left: 0;
  }
  .drawer-header {
    height: calc(60px + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 14px 0;
  }
  .drawer-body {
    padding: 16px 14px;
  }
  .drawer-footer {
    padding: 13px 14px calc(15px + env(safe-area-inset-bottom));
  }
  .document-filters {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .document-item {
    padding: 10px;
  }

  .document-dialog {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    border-radius: 13px;
  }
  .document-dialog-header {
    padding: 13px 14px;
  }
  .document-dialog-header > div {
    min-width: 0;
  }
  .document-dialog-header h2,
  .document-dialog-header p {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .document-dialog-state {
    margin: 12px 14px 0;
  }
  .document-dialog pre {
    max-height: calc(100dvh - 150px);
    margin: 10px 14px 14px;
    padding: 12px;
    font-size: 11px;
  }
  .toast {
    bottom: calc(94px + env(safe-area-inset-bottom));
    width: max-content;
    max-width: calc(100vw - 24px);
  }
}

@media (max-width: 480px) {
  .app-header {
    padding-inline: 7px;
  }
  .header-new {
    display: none;
  }
  .header-left,
  .header-right {
    gap: 2px;
  }
  .brand-text {
    max-width: 78px;
  }
  .demo-indicator {
    padding-inline: 8px;
  }
  .empty-state {
    padding-inline: 12px;
  }
  .empty-state h1 {
    font-size: clamp(23px, 7.4vw, 28px);
  }
  .welcome-detail {
    font-size: 12px;
  }
  .starter-card {
    padding-right: 36px;
  }
  .composer-note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .scope-toggle {
    max-width: calc(100vw - 76px);
  }
}

@media (max-width: 360px) {
  .brand-mark {
    display: none;
  }
  .brand-text {
    max-width: 64px;
  }
  .demo-indicator {
    display: none;
  }
  .icon-button {
    min-width: 34px;
    width: 34px;
    height: 34px;
  }
  .empty-state h1 {
    font-size: 23px;
  }
  .assistant-avatar {
    display: none;
  }
  .composer-note {
    display: none;
  }
  .scope-controls {
    bottom: calc(88px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 650px) and (min-width: 600px) {
  .empty-state {
    padding-top: 22px;
  }
  .welcome-symbol {
    width: 44px;
    height: 44px;
    margin-bottom: 10px;
  }
  .welcome-detail {
    margin: 8px 0 16px;
  }
  .starter-card {
    min-height: 94px;
    padding-block: 12px;
  }
  .composer-note {
    display: none;
  }
}

@media (hover: none) and (pointer: coarse) {
  button,
  select {
    touch-action: manipulation;
  }
  .icon-button {
    min-width: 42px;
    min-height: 42px;
  }
  .starter-card:hover,
  .send-button:hover:not(:disabled) {
    transform: none;
  }
}

/* Phone hardening: keep every interactive element inside the visual viewport. */
@media (max-width: 480px) {
  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }
  body,
  .app-shell,
  .main-panel,
  .conversation-scroll,
  .empty-state,
  .message-list,
  .composer-dock {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
  }
  .app-header {
    width: 100%;
    max-width: 100%;
  }
  .header-left {
    flex: 1 1 0;
  }
  .header-right {
    flex: 0 0 auto;
  }
  .brand-text {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .empty-state h1,
  .welcome-detail {
    width: 100%;
    max-width: 100%;
    text-align: center;
    overflow-wrap: anywhere;
  }
  .starter-grid,
  .starter-card,
  .starter-card > span:last-of-type {
    min-width: 0;
    max-width: 100%;
  }
  .starter-card strong,
  .starter-card small {
    overflow-wrap: anywhere;
  }

  .message,
  .assistant-content,
  .markdown,
  .rag-references,
  .product-references,
  .product-source-card {
    min-width: 0;
    max-width: 100%;
  }
  .table-wrap,
  .code-wrap,
  .rag-retrieval {
    width: 100%;
    max-width: 100%;
  }

  .composer-dock {
    padding-inline: 8px;
  }
  .composer {
    width: 100%;
    max-width: 100%;
  }
  .composer-bottom {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    width: 100%;
  }
  .composer-left {
    display: flex;
    width: 100%;
    min-width: 0;
    flex-wrap: wrap;
  }
  .scope-panel {
    min-width: 0;
    max-width: 100%;
    flex: 1 1 128px;
  }
  .scope-toggle {
    width: 100%;
    max-width: 100%;
  }
  .ai-provider-control {
    min-width: 0;
    max-width: 104px;
    flex: 0 1 104px;
  }
  .ai-provider-control select {
    width: 100%;
    max-width: 100%;
  }
  .product-image-button {
    min-width: 0;
    max-width: calc(100vw - 88px);
    overflow: hidden;
  }
  .product-image-button span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .composer-actions {
    min-width: 38px;
    align-self: end;
  }
  .composer-note {
    max-width: 100%;
    padding-inline: 4px;
    overflow: visible;
    white-space: normal;
  }

  .product-source-card.has-gallery {
    grid-template-columns: 92px minmax(0, 1fr);
  }
  .product-gallery-trigger,
  .product-gallery-trigger img {
    min-height: 108px;
  }
  .product-gallery-label {
    right: 4px;
    bottom: 4px;
    left: 4px;
    padding-inline: 4px;
    font-size: 9px;
  }
  .product-gallery-dialog {
    width: calc(100vw - 12px);
    max-height: calc(100dvh - 12px);
    border-radius: 13px;
  }
  .product-gallery-header {
    padding: 12px 13px;
  }
  .product-gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    max-height: calc(100dvh - 76px);
    padding: 8px;
  }
}

@media (max-width: 360px) {
  .composer-bottom {
    gap: 5px;
    padding-inline: 7px;
  }
  .composer-left {
    gap: 5px;
  }
  .scope-panel {
    flex-basis: 116px;
  }
  .ai-provider-control {
    max-width: 94px;
    flex-basis: 94px;
  }
}
