@font-face {
  font-family: "Manrope";
  src: url("./fonts/manrope-latin-wght-normal.woff2") format("woff2-variations");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  font-style: normal;
  font-weight: 500;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f4f3ee;
  --surface: #fbfaf7;
  --surface-strong: #ffffff;
  --surface-hover: #ebeae5;
  --sidebar: #171816;
  --sidebar-soft: #232420;
  --text: #171816;
  --muted: #6c706a;
  --faint: #999d96;
  --line: #deddd7;
  --line-strong: #c9c8c1;
  --accent: #1f5eff;
  --accent-hover: #174bd0;
  --accent-soft: #e8eeff;
  --success: #30d27c;
  --danger: #c83f3a;
  --danger-soft: #fae8e6;
  --code-bg: #20221f;
  --code-text: #f5f4ef;
  --shadow: 0 18px 50px rgba(20, 22, 19, 0.12);
  --sidebar-width: 276px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --topbar-content-height: 68px;
  --topbar-height: calc(var(--topbar-content-height) + var(--safe-top));
  font-family: "Manrope", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171816;
  --surface: #1d1f1c;
  --surface-strong: #252723;
  --surface-hover: #2c2e2a;
  --sidebar: #10110f;
  --sidebar-soft: #1c1d1a;
  --text: #f1f0e9;
  --muted: #a4a89f;
  --faint: #777b73;
  --line: #353832;
  --line-strong: #484b44;
  --accent: #5d86ff;
  --accent-hover: #7d9dff;
  --accent-soft: #202b4b;
  --danger: #ff7d75;
  --danger-soft: #3c2422;
  --code-bg: #10110f;
  --code-text: #f4f3ee;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
  pointer-events: none;
}

kbd,
code,
pre,
.drawer-eyebrow,
.empty-eyebrow,
.model-note,
.input-count {
  font-family: "IBM Plex Mono", monospace;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  width: 100%;
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 0;
  color: #f4f3ee;
  background: var(--sidebar);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-height);
  padding: var(--safe-top) 18px 0 max(18px, var(--safe-left));
}

.brand {
  display: inline-flex;
  gap: 11px;
  align-items: center;
  color: inherit;
  text-decoration: none;
}

.brand-mark,
.empty-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  background: var(--accent);
  font-weight: 700;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 16px;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
  line-height: 1.1;
}

.brand small {
  margin-top: 4px;
  color: #888c83;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.icon-button,
.tool-button,
.send-button,
.stop-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
}

.icon-button:hover,
.tool-button:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.sidebar .icon-button {
  color: #aeb1aa;
}

.sidebar .icon-button:hover {
  color: #ffffff;
  background: var(--sidebar-soft);
}

.sidebar-close,
.mobile-menu {
  display: none;
}

.primary-button {
  display: flex;
  align-items: center;
  border: 0;
  border-radius: 6px;
}

.new-chat-button {
  gap: 10px;
  min-height: 44px;
  margin: 8px 14px 14px;
  padding: 0 12px;
  color: #ffffff;
  background: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.new-chat-button:hover {
  background: var(--accent-hover);
}

.new-chat-button kbd {
  margin-left: auto;
  color: rgba(255, 255, 255, 0.68);
  font-size: 9px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  margin: 0 14px 18px;
  padding: 0 10px;
  color: #868a82;
  background: var(--sidebar-soft);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
}

.search-field svg {
  width: 15px;
  height: 15px;
}

.search-field input {
  min-width: 0;
  flex: 1;
  padding: 0;
  color: #f4f3ee;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 12px;
}

.search-field input::placeholder {
  color: #7f837b;
}

.search-field kbd {
  color: #686b65;
  font-size: 10px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 30px;
  color: #797d75;
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.sidebar > .section-heading {
  padding: 0 20px;
}

.session-list {
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 4px 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: #444740 transparent;
}

.session-item {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 44px;
  margin: 2px 0;
  padding: 0;
  color: #aeb1aa;
  background: transparent;
  border: 0;
  border-radius: 6px;
  text-align: left;
}

.session-open {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 7px 42px 7px 12px;
  color: inherit;
  background: transparent;
  border: 0;
  text-align: left;
}

.session-item:hover,
.session-item.active {
  color: #ffffff;
  background: var(--sidebar-soft);
}

.session-item.active::before {
  position: absolute;
  left: 0;
  width: 3px;
  height: 22px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
  content: "";
}

.session-copy {
  min-width: 0;
  display: block;
}

.session-title,
.session-time {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.session-title {
  font-size: 12px;
  font-weight: 500;
}

.session-time {
  margin-top: 3px;
  color: #73776f;
  font-size: 9px;
}

.session-delete {
  position: absolute;
  right: 7px;
  display: none;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: #858980;
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.session-item:hover .session-delete,
.session-item:focus-within .session-delete {
  display: grid;
}

.session-delete:hover {
  color: #ff8880;
  background: rgba(255, 255, 255, 0.07);
}

.session-delete svg {
  width: 14px;
  height: 14px;
}

.empty-sessions {
  padding: 24px 12px;
  color: #6f736c;
  font-size: 11px;
  text-align: center;
}

.sidebar-footer {
  padding: 14px 14px calc(14px + var(--safe-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.connection-state,
.sidebar-action {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 34px;
  font-size: 11px;
}

.connection-state {
  padding: 0 7px;
  color: #9a9e96;
}

.status-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  background: #757971;
  border-radius: 50%;
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(48, 210, 124, 0.12);
}

.status-dot.error {
  background: #ff6d64;
}

.sidebar-action {
  width: 100%;
  padding: 0 7px;
  color: #c4c7c0;
  background: transparent;
  border: 0;
  border-radius: 5px;
  text-align: left;
}

.sidebar-action:hover {
  color: #ffffff;
  background: var(--sidebar-soft);
}

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

.sidebar-footer p {
  margin: 10px 7px 0;
  color: #63675f;
  font-size: 9px;
}

.workspace {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  background-color: var(--surface);
  background-image: radial-gradient(circle, color-mix(in srgb, var(--line) 62%, transparent) 0.7px, transparent 0.8px);
  background-size: 18px 18px;
}

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: var(--safe-top) max(20px, var(--safe-right)) 0 max(24px, var(--safe-left));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-leading,
.topbar-actions {
  display: flex;
  align-items: center;
}

.topbar-leading {
  min-width: 0;
}

.topbar-actions {
  gap: 4px;
}

.conversation-identity {
  min-width: 0;
}

.conversation-identity input {
  display: block;
  width: min(36vw, 480px);
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  font-weight: 650;
  text-overflow: ellipsis;
}

.conversation-identity span {
  display: block;
  margin-top: 3px;
  color: var(--faint);
  font-size: 9px;
}

.model-control {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 158px;
  height: 38px;
  margin-right: 4px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-strong);
}

.model-control > span {
  padding-left: 11px;
  color: var(--faint);
  font-size: 9px;
}

.model-control select {
  min-width: 0;
  flex: 1;
  height: 100%;
  padding: 0 30px 0 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  appearance: none;
  font-size: 11px;
  font-weight: 600;
}

.model-control svg {
  position: absolute;
  right: 9px;
  width: 14px;
  height: 14px;
  color: var(--muted);
}

.chat-surface {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
}

.message-scroll {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
  scroll-behavior: smooth;
}

.message-list,
.empty-state,
.composer-wrap {
  width: min(100% - 40px, 850px);
  margin-inline: auto;
}

.empty-state {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 100%;
  padding: 54px 0 80px;
  animation: empty-enter 420ms ease-out both;
}

.empty-state[hidden] {
  display: none;
}

.empty-mark {
  width: 42px;
  height: 42px;
  margin-bottom: 24px;
  border-radius: 7px;
  font-size: 18px;
  box-shadow: 8px 8px 0 var(--line);
}

.empty-eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 500;
}

.empty-state h1 {
  margin: 0;
  font-size: 32px;
  line-height: 1.25;
  font-weight: 650;
}

.empty-copy {
  margin: 10px 0 32px;
  color: var(--muted);
  font-size: 14px;
}

.suggestions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.suggestions button {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  min-height: 72px;
  padding: 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border: 0;
  border-right: 1px solid var(--line);
  text-align: left;
  transition: background 150ms ease, transform 150ms ease;
}

.suggestions button:last-child {
  border-right: 0;
}

.suggestions button:hover {
  background: var(--surface-hover);
  transform: translateY(-2px);
}

.suggestions button svg:first-child {
  color: var(--accent);
}

.suggestions button svg:last-child {
  width: 15px;
  color: var(--faint);
}

.suggestions button span {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 11px;
  font-weight: 600;
}

.message-list {
  padding: 32px 0 52px;
}

.message {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 14px;
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
  animation: message-enter 260ms ease-out both;
}

.message:last-child {
  border-bottom: 0;
}

.message-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-top: 1px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.message.user .message-avatar {
  color: var(--text);
  background: var(--surface-hover);
  border: 1px solid var(--line-strong);
}

.message.assistant .message-avatar {
  color: #ffffff;
  background: var(--accent);
}

.message-main {
  min-width: 0;
}

.message-header {
  display: flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 7px;
}

.message-author {
  font-size: 11px;
  font-weight: 700;
}

.message-time {
  margin-left: 9px;
  color: var(--faint);
  font-size: 9px;
}

.message-actions {
  display: flex;
  gap: 1px;
  margin-left: auto;
  opacity: 0;
  transition: opacity 120ms ease;
}

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

.message-action {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--faint);
  background: transparent;
  border: 0;
  border-radius: 5px;
}

.message-action:hover {
  color: var(--text);
  background: var(--surface-hover);
}

.message-action svg {
  width: 14px;
  height: 14px;
}

.message-content {
  color: var(--text);
  font-size: 14px;
  line-height: 1.78;
  overflow-wrap: anywhere;
}

.message-content > :first-child {
  margin-top: 0;
}

.message-content > :last-child {
  margin-bottom: 0;
}

.message-content p,
.message-content ul,
.message-content ol,
.message-content blockquote,
.message-content pre,
.message-content table {
  margin: 0 0 14px;
}

.message-content h1,
.message-content h2,
.message-content h3 {
  margin: 24px 0 10px;
  line-height: 1.35;
}

.message-content h1 {
  font-size: 21px;
}

.message-content h2 {
  font-size: 18px;
}

.message-content h3 {
  font-size: 16px;
}

.message-content ul,
.message-content ol {
  padding-left: 24px;
}

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

.message-content a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.message-content blockquote {
  padding: 2px 0 2px 14px;
  color: var(--muted);
  border-left: 3px solid var(--line-strong);
}

.message-content :not(pre) > code {
  padding: 2px 5px;
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: 4px;
  font-size: 12px;
}

.code-block {
  overflow: hidden;
  margin: 16px 0;
  background: var(--code-bg);
  border: 1px solid color-mix(in srgb, var(--code-bg) 70%, #ffffff);
  border-radius: 7px;
}

.code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 0 8px 0 13px;
  color: #9ea299;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
}

.copy-code {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 7px;
  color: #afb2ab;
  background: transparent;
  border: 0;
  border-radius: 4px;
  font-size: 9px;
}

.copy-code:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.copy-code svg {
  width: 13px;
  height: 13px;
}

.code-block pre {
  overflow: auto;
  margin: 0;
  padding: 15px;
  scrollbar-width: thin;
}

.code-block code {
  color: var(--code-text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.65;
}

.message-content table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
}

.message-content th,
.message-content td {
  padding: 8px 11px;
  border: 1px solid var(--line);
  text-align: left;
}

.message-content th {
  background: var(--surface-hover);
}

.message-images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.message-images img {
  width: min(220px, 100%);
  height: 150px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.typing-indicator {
  display: inline-flex;
  gap: 5px;
  padding: 7px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background: var(--faint);
  border-radius: 50%;
  animation: typing 1.1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 140ms;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 280ms;
}

.message-error {
  margin-top: 10px;
  padding: 10px 12px;
  color: var(--danger);
  background: var(--danger-soft);
  border-left: 3px solid var(--danger);
  font-size: 11px;
}

.jump-bottom {
  position: absolute;
  right: 24px;
  bottom: 155px;
  z-index: 5;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  box-shadow: var(--shadow);
}

.jump-bottom[hidden] {
  display: none;
}

.composer-wrap {
  padding: 0 0 16px;
}

.composer {
  position: relative;
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: 0 10px 35px rgba(20, 22, 19, 0.08);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.composer:focus-within {
  border-color: var(--accent);
  box-shadow: 0 10px 35px rgba(31, 94, 255, 0.1);
}

.composer textarea {
  display: block;
  width: 100%;
  max-height: 180px;
  resize: none;
  padding: 15px 16px 5px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 14px;
  line-height: 1.6;
}

.composer textarea::placeholder {
  color: var(--faint);
}

.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 5px 7px 7px 9px;
}

.composer-tools,
.send-group {
  display: flex;
  align-items: center;
  gap: 5px;
}

.tool-button {
  width: 32px;
  height: 32px;
}

.tool-button svg {
  width: 16px;
  height: 16px;
}

.model-note {
  display: inline-block;
  max-width: 230px;
  overflow: hidden;
  color: var(--faint);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.input-count {
  min-width: 22px;
  color: var(--faint);
  font-size: 9px;
  text-align: right;
}

.send-button,
.stop-button {
  width: 34px;
  height: 34px;
  color: #ffffff;
  background: var(--accent);
}

.send-button:hover,
.stop-button:hover {
  background: var(--accent-hover);
}

.send-button svg,
.stop-button svg {
  width: 16px;
  height: 16px;
}

.stop-button {
  background: var(--danger);
}

.stop-button[hidden] {
  display: none;
}

.composer-footnote {
  margin: 7px 0 0;
  color: var(--faint);
  font-size: 9px;
  text-align: center;
}

.attachment-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 0 8px;
}

.attachment-strip[hidden] {
  display: none;
}

.attachment-preview {
  position: relative;
  flex: 0 0 62px;
  width: 62px;
  height: 62px;
}

.attachment-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.remove-attachment {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  color: #ffffff;
  background: #292a27;
  border: 2px solid var(--surface);
  border-radius: 50%;
}

.remove-attachment svg {
  width: 11px;
  height: 11px;
}

.scrim,
.drawer-scrim {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: none;
  width: 100%;
  height: 100%;
  padding: 0;
  background: rgba(11, 12, 10, 0.45);
  border: 0;
}

.drawer-scrim {
  z-index: 40;
}

.settings-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(420px, 100%);
  height: 100vh;
  height: 100dvh;
  color: var(--text);
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  transform: translateX(105%);
  visibility: hidden;
  transition: transform 220ms ease, visibility 220ms;
}

.settings-drawer.open {
  transform: translateX(0);
  visibility: visible;
}

body.settings-open .drawer-scrim {
  display: block;
  animation: fade-in 180ms ease both;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(88px + var(--safe-top));
  padding: calc(18px + var(--safe-top)) max(20px, var(--safe-right)) 16px max(24px, var(--safe-left));
  border-bottom: 1px solid var(--line);
}

.drawer-eyebrow {
  color: var(--accent);
  font-size: 9px;
}

.drawer-header h2 {
  margin: 5px 0 0;
  font-size: 19px;
}

.drawer-body {
  overflow-y: auto;
  padding: 24px;
}

.settings-field {
  display: block;
  margin-bottom: 28px;
}

.field-row,
.range-labels {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.field-row {
  margin-bottom: 10px;
  font-size: 12px;
}

.field-row button {
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  font-size: 10px;
}

.settings-field textarea,
.number-input {
  width: 100%;
  color: var(--text);
  background: var(--surface-strong);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.settings-field textarea {
  resize: vertical;
  min-height: 132px;
  padding: 11px 12px;
  font-size: 12px;
  line-height: 1.6;
}

.settings-field > small {
  display: block;
  margin-top: 7px;
  color: var(--faint);
  font-size: 9px;
}

.settings-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.range-labels {
  margin-top: 5px;
  color: var(--faint);
}

.number-input {
  height: 40px;
  padding: 0 11px;
  font-size: 12px;
}

.connection-details {
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.connection-details .section-heading {
  color: var(--faint);
}

.connection-details dl {
  margin: 8px 0 0;
}

.connection-details dl div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
}

.connection-details dt {
  color: var(--muted);
}

.connection-details dd {
  min-width: 0;
  margin: 0;
  overflow: hidden;
  font-family: "IBM Plex Mono", monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer-footer {
  padding: 16px max(24px, var(--safe-right)) calc(16px + var(--safe-bottom)) max(24px, var(--safe-left));
  border-top: 1px solid var(--line);
}

.danger-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  color: var(--danger);
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: 6px;
  font-size: 11px;
}

.danger-button:hover {
  background: var(--danger-soft);
}

.danger-button svg {
  width: 15px;
  height: 15px;
}

.toast-region {
  position: fixed;
  right: max(20px, var(--safe-right));
  bottom: calc(20px + var(--safe-bottom));
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(340px, calc(100% - 40px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  color: #ffffff;
  background: #20221f;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  box-shadow: var(--shadow);
  font-size: 11px;
  line-height: 1.5;
  animation: toast-in 180ms ease-out both;
}

.toast.error {
  background: #802d29;
}

.toast svg {
  flex: 0 0 auto;
  width: 15px;
  height: 15px;
  margin-top: 1px;
}

@keyframes empty-enter {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes message-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes typing {
  0%, 70%, 100% { opacity: 0.35; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(var(--sidebar-width), calc(100% - 48px));
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform 220ms ease, visibility 220ms;
  }

  .sidebar.open {
    transform: translateX(0);
    visibility: visible;
  }

  .sidebar-close,
  .mobile-menu {
    display: inline-grid;
  }

  body.sidebar-open .scrim {
    display: block;
    animation: fade-in 180ms ease both;
  }

  .topbar {
    padding-left: 12px;
  }

  .mobile-menu {
    margin-right: 5px;
  }
}

@media (max-width: 660px) {
  :root {
    --topbar-content-height: 62px;
  }

  .topbar {
    gap: 8px;
    padding-right: max(9px, var(--safe-right));
  }

  .conversation-identity input {
    width: min(31vw, 190px);
  }

  .conversation-identity span,
  .model-control > span,
  #export-button {
    display: none;
  }

  .model-control {
    min-width: 98px;
    max-width: 128px;
  }

  .model-control select {
    padding-left: 10px;
  }

  .topbar-actions {
    gap: 0;
  }

  .topbar-actions .icon-button {
    width: 40px;
    height: 40px;
  }

  .mobile-menu {
    width: 40px;
    height: 40px;
  }

  .conversation-identity input,
  .model-control select,
  .search-field input,
  .composer textarea,
  .settings-field textarea,
  .number-input {
    font-size: 16px;
  }

  .message-list,
  .empty-state,
  .composer-wrap {
    width: min(100% - 24px, 850px);
  }

  .empty-state {
    justify-content: flex-start;
    padding-top: 72px;
  }

  .empty-state h1 {
    font-size: 26px;
  }

  .suggestions {
    grid-template-columns: 1fr;
  }

  .suggestions button {
    min-height: 54px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .suggestions button:last-child {
    border-bottom: 0;
  }

  .message-list {
    padding-top: 12px;
  }

  .message {
    grid-template-columns: 30px minmax(0, 1fr);
    gap: 10px;
    padding: 18px 0;
  }

  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 9px;
  }

  .message-content {
    font-size: 13px;
  }

  .message-actions {
    opacity: 1;
  }

  .message-time {
    display: none;
  }

  .composer-wrap {
    padding-bottom: calc(9px + var(--safe-bottom));
  }

  .composer-footnote {
    display: none;
  }

  .jump-bottom {
    right: 14px;
    bottom: 105px;
  }
}

@media (display-mode: standalone) {
  .app-shell {
    min-height: 100dvh;
  }

  .brand,
  button,
  select {
    -webkit-touch-callout: none;
  }
}

@media (max-width: 410px) {
  #theme-button {
    display: none;
  }

  .conversation-identity input {
    width: 96px;
  }

  .model-control {
    min-width: 92px;
    max-width: 105px;
  }

  .model-note {
    max-width: 150px;
  }
}

@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;
  }
}
