:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --line: #d8dee7;
  --line-strong: #b9c3d1;
  --text: #18202a;
  --muted: #657386;
  --accent: #0b6bcb;
  --accent-strong: #084f99;
  --danger: #b42318;
  --success: #146c43;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.2, 0.9, 0.16, 1.08);
  --app-height: 100dvh;
  --topbar-height: 56px;
  --composer-height: 120px;
  --composer-translate-y: 0px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

body.chat-lock {
  overflow: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 56px;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.brand {
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.nav-toggle {
  display: none;
}

.topbar nav a,
.nav-form button {
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
}

.nav-form {
  margin: 0;
}

.nav-form button {
  min-height: auto;
  border: 0;
  background: transparent;
  font-weight: 400;
}

.topbar nav a:hover,
.nav-form button:hover {
  background: #eef3f8;
  text-decoration: none;
}

.page {
  width: min(1280px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: 28px;
}

h2 {
  font-size: 18px;
}

h3 {
  font-size: 15px;
  margin-top: 18px;
}

p {
  margin: 8px 0 0;
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  gap: 18px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.stats div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.stats strong {
  display: block;
  font-size: 24px;
}

.stats span {
  color: var(--muted);
  font-size: 13px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  vertical-align: top;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

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

.form label {
  display: grid;
  gap: 7px;
  color: var(--text);
  font-weight: 600;
}

.row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 9px 10px;
  font: inherit;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(11, 107, 203, 0.2);
  border-color: var(--accent);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 180ms var(--ease-out), background 180ms ease, border-color 180ms ease, color 180ms ease, box-shadow 240ms ease;
}

.button:hover,
button:hover {
  background: #eef3f8;
  text-decoration: none;
  transform: translateY(-1px);
}

.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.button.primary:hover,
button.primary:hover {
  background: var(--accent-strong);
}

.actions,
.actions-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.actions-inline form {
  display: inline;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.badge.status {
  background: #eef6ff;
  color: #164a7a;
}

.badge.warning {
  background: #fff7ed;
  color: #9a3412;
  border-color: #fed7aa;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.filters a {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #fff;
}

.filters a.active {
  color: #fff;
  border-color: var(--accent);
  background: var(--accent);
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  background: #fff;
}

.notice.success {
  border-color: rgba(20, 108, 67, 0.35);
  color: var(--success);
}

.notice.error {
  border-color: rgba(180, 35, 24, 0.35);
  color: var(--danger);
}

.empty {
  color: var(--muted);
  margin: 0;
}

.source-text {
  max-height: 640px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 12px 0 0;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
}

blockquote {
  margin: 12px 0;
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  background: #f8fafc;
}

dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 8px 12px;
  margin: 12px 0 0;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.auth-shell {
  width: min(420px, calc(100% - 32px));
}

.auth-panel {
  margin: 0;
}

.assistant-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  min-height: calc(100vh - 112px);
}

.chat-home {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 16px;
  height: calc(var(--app-height, 100dvh) - var(--topbar-height, 56px) - 56px);
  min-height: 620px;
  min-width: 0;
  animation: panel-rise 420ms var(--ease-out) both;
}

.conversation-toggle {
  display: none;
}

.conversation-rail {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
  min-width: 0;
}

.button.full {
  width: 100%;
}

.conversation-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.conversation-item-wrap {
  position: relative;
  display: block;
  align-items: stretch;
}

.conversation-item-wrap.active .conversation-item {
  border-color: var(--accent);
  background: #eef6ff;
}

.conversation-item {
  display: grid;
  gap: 3px;
  width: 100%;
  min-height: 58px;
  justify-content: start;
  border-color: var(--line);
  background: #fff;
  text-align: left;
  overflow: hidden;
  transition: transform 180ms var(--ease-out), border-color 180ms ease, background 180ms ease;
}

.conversation-item:hover {
  transform: translateX(2px);
}

.conversation-item strong,
.conversation-item span {
  max-width: 230px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.assistant-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.assistant-sidebar .panel {
  margin-bottom: 0;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.mini-stats div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.mini-stats strong {
  display: block;
  font-size: 20px;
}

.mini-stats span {
  color: var(--muted);
  font-size: 12px;
}

.compact-list {
  display: grid;
  gap: 8px;
}

.compact-list a {
  display: grid;
  gap: 2px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
}

.compact-list a:hover {
  background: #f8fafc;
  text-decoration: none;
}

.compact-list strong {
  font-size: 13px;
  line-height: 1.35;
}

.compact-list span {
  color: var(--muted);
  font-size: 12px;
}

.chat-shell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  min-height: calc(100vh - 112px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.chat-shell.immersive {
  min-height: 0;
  height: 100%;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.chat-head.compact {
  padding: 12px 16px;
  align-items: center;
}

.chat-head h1 {
  font-size: 22px;
}

.chat-messages {
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 22px 20px;
  background:
    linear-gradient(90deg, rgba(11, 107, 203, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(11, 107, 203, 0.028) 1px, transparent 1px);
  background-size: 42px 42px;
}

.chat-message {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 12px;
  margin-bottom: 18px;
  min-width: 0;
  animation: message-enter 320ms var(--ease-spring) both;
}

.chat-message.user {
  grid-template-columns: minmax(0, 1fr) 34px;
}

.chat-message.user .avatar {
  grid-column: 2;
  grid-row: 1;
}

.chat-message.user .bubble {
  grid-column: 1;
  justify-self: end;
  background: #eaf3ff;
  border-color: #c6ddf7;
}

.avatar {
  width: clamp(32px, 2.2vw, 36px);
  height: clamp(32px, 2.2vw, 36px);
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.bubble {
  position: relative;
  max-width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  backdrop-filter: blur(8px);
}

.bubble p:first-child {
  margin-top: 0;
}

.message-text {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.message-edit {
  display: flex;
  margin-top: 10px;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--muted);
  background: #f8fafc;
}

.message-edit:hover {
  color: var(--accent);
  background: #eef6ff;
}

.message-answer {
  display: grid;
  gap: 8px;
}

.message-answer:empty {
  display: none;
}

.md-paragraph {
  margin: 0;
  white-space: pre-wrap;
}

.md-heading {
  margin: 2px 0 0;
  font-weight: 760;
  line-height: 1.28;
}

.md-heading-1 {
  font-size: 18px;
}

.md-heading-2 {
  font-size: 16px;
}

.md-heading-3,
.md-heading-4,
.md-heading-5,
.md-heading-6 {
  font-size: 14px;
}

.md-list {
  margin: 0;
  padding-left: 20px;
}

.md-list li + li {
  margin-top: 3px;
}

.message-answer code {
  padding: 1px 4px;
  border-radius: 4px;
  background: #eef3f8;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
}

.md-codeblock {
  max-width: 100%;
  overflow: auto;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  white-space: pre;
}

.md-codeblock code {
  padding: 0;
  background: transparent;
}

.tool-events,
.tool-timeline {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

.tool-timeline {
  padding-left: 0;
}

.tool-timeline + .message-answer {
  margin-top: 14px;
}

.tool-card {
  display: inline-grid;
  justify-self: start;
  width: fit-content;
  max-width: 100%;
  gap: 0;
  padding: 5px 7px 5px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(248, 250, 252, 0.94);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.06);
  overflow: hidden;
  transition: border-radius 220ms var(--ease-out), width 220ms var(--ease-out), max-width 220ms var(--ease-out), background 180ms ease, transform 180ms var(--ease-out);
}

.tool-card.running {
  border-color: #b9d6f2;
  background: #f4f9ff;
}

.tool-card.done {
  border-color: rgba(20, 108, 67, 0.22);
}

.tool-card.error {
  border-color: rgba(180, 35, 24, 0.28);
  background: #fff8f7;
}

.tool-card-head {
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 8px;
  font-size: 12px;
}

.tool-card-head::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(11, 107, 203, 0.12);
}

.tool-card.running .tool-card-head::before {
  animation: pulse-dot 1.2s var(--ease-out) infinite;
}

.tool-card-head strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.tool-card-head span {
  flex: 0 0 auto;
  padding: 1px 7px;
  border-radius: 999px;
  color: #164a7a;
  background: #e6f2ff;
  font-size: 11px;
  font-weight: 700;
}

.tool-expand {
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: var(--muted);
  background: transparent;
}

.tool-expand:hover {
  color: var(--accent);
  background: rgba(11, 107, 203, 0.08);
}

.tool-card.error .tool-card-head span {
  color: var(--danger);
  background: #fff0ee;
}

.tool-card-detail {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.tool-card-body {
  display: none;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  animation: tool-expand 240ms var(--ease-out) both;
}

.tool-card.expanded {
  display: grid;
  width: min(620px, 100%);
  border-radius: 14px;
  padding: 9px 10px;
}

.tool-card.expanded .tool-card-body {
  display: grid;
  gap: 8px;
}

.tool-card.expanded .tool-expand svg {
  transform: rotate(180deg);
}

.tool-card pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 240px;
  overflow: auto;
  margin: 8px 0 0;
  font-size: 12px;
}

.tool-events details {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 8px 10px;
}

.tool-events summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tool-events pre {
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
  margin: 8px 0 0;
  font-size: 12px;
}

.chat-composer {
  border-top: 1px solid var(--line);
  padding: 14px;
  background: #fbfcfe;
  transform: translate3d(0, var(--composer-translate-y), 0);
  will-change: transform;
  box-shadow: 0 -18px 36px rgba(16, 24, 40, 0.04);
}

.chat-composer textarea {
  min-height: 68px;
  max-height: 260px;
  border-radius: 8px;
}

.chat-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}

.file-button span,
.button.full,
.conversation-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.icon-button {
  width: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 999px;
}

.ui-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  align-items: center;
  justify-content: center;
}

.ui-icon svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.selected-files,
.message-files {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.message-files {
  margin: 10px 0 0;
}

.file-card {
  position: relative;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  width: min(312px, 100%);
  min-height: 54px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.file-card.has-remove {
  padding-right: 36px;
}

a.file-card:hover {
  text-decoration: none;
  background: #f8fafc;
}

.file-card-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  background: #f1f3f6;
  font-size: 11px;
  font-weight: 700;
  overflow: hidden;
}

.file-card-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-card-body {
  display: grid;
  min-width: 0;
}

.file-type-icon {
  display: grid;
  place-items: center;
  gap: 1px;
  font-size: 9px;
  line-height: 1;
}

.file-type-icon .ui-icon {
  width: 16px;
  height: 16px;
}

.file-card-body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
}

.file-card-body span {
  color: var(--muted);
  font-size: 12px;
}

.file-card-remove {
  position: absolute;
  top: 50%;
  right: 7px;
  width: 24px;
  height: 24px;
  min-height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #151a22;
  transform: translateY(-50%);
}

.file-card-remove:hover {
  color: #fff;
  background: #2f3744;
  transform: translateY(-50%);
}

.file-card-remove .ui-icon {
  width: 14px;
  height: 14px;
}

.conversation-menu {
  position: fixed;
  z-index: 45;
  display: grid;
  gap: 4px;
  min-width: 210px;
  padding: 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.2);
  backdrop-filter: blur(14px);
  opacity: 0;
  transform: translateY(6px) scale(0.98);
  transition: opacity 160ms ease, transform 180ms var(--ease-out);
}

.conversation-menu.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.conversation-menu button {
  justify-content: flex-start;
  gap: 8px;
  min-height: 34px;
  border: 0;
  background: transparent;
}

.conversation-menu button:hover {
  background: #eef6ff;
}

.conversation-menu button.danger {
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(11, 18, 28, 0.36);
}

.confirm-dialog {
  display: grid;
  gap: 14px;
  width: min(560px, 100%);
  max-height: min(680px, calc(100dvh - 36px));
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(16, 24, 40, 0.24);
}

.confirm-dialog h2 {
  font-size: 18px;
}

.confirm-dialog p {
  margin: 0;
}

.confirm-files {
  display: grid;
  gap: 10px;
}

.confirm-file-list {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.confirm-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 14px;
}

.confirm-checkbox input {
  width: auto;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

button.danger {
  color: #fff;
  border-color: var(--danger);
  background: var(--danger);
}

button.danger:hover {
  color: #fff;
  background: #8f1d14;
}

@media (max-width: 860px) {
  .page {
    width: min(100% - 20px, 1280px);
    margin-top: 18px;
  }

  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px 12px;
    padding: 12px 16px;
  }

  .nav-toggle {
    display: inline-flex;
    min-height: 34px;
  }

  .topbar nav {
    display: none;
    grid-column: 1 / -1;
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .topbar.nav-open nav {
    display: flex;
  }

  .topbar nav a,
  .nav-form button {
    width: 100%;
    justify-content: flex-start;
  }

  .grid.two,
  .stats,
  .row,
  .assistant-layout,
  .chat-home {
    grid-template-columns: 1fr;
  }

  .page:has([data-assistant]) {
    width: 100%;
    min-height: calc(var(--app-height, 100dvh) - var(--topbar-height, 56px));
    margin: 0;
    position: fixed;
    top: var(--topbar-height, 56px);
    left: 0;
    right: 0;
    bottom: 0;
  }

  .chat-home {
    grid-template-rows: auto auto minmax(0, 1fr);
    gap: 0;
    height: calc(var(--app-height, 100dvh) - var(--topbar-height, 56px));
    min-height: 0;
  }

  .conversation-toggle {
    display: inline-flex;
    width: fit-content;
    margin: 10px 12px;
  }

  .conversation-rail {
    display: none;
    max-height: min(320px, 38vh);
    padding: 0 12px 10px;
    overflow: hidden;
  }

  .chat-home.rail-open .conversation-rail {
    display: grid;
  }

  .chat-shell {
    min-height: 0;
    height: 100%;
    border-width: 1px 0 0;
    border-radius: 0;
    display: block;
    overflow: hidden;
  }

  .chat-actions {
    align-items: center;
    flex-direction: row;
  }

  .chat-messages {
    padding: 14px 12px;
    height: 100%;
    padding-bottom: calc(var(--composer-height, 132px) + 20px + env(safe-area-inset-bottom));
  }

  .chat-message {
    grid-template-columns: 28px minmax(0, 1fr);
    gap: 8px;
    margin-bottom: 14px;
  }

  .chat-message.user {
    grid-template-columns: minmax(0, 1fr) 28px;
  }

  .avatar {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .bubble {
    max-width: min(100%, 88vw);
    padding: 10px 12px;
  }

  .chat-composer {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .chat-composer textarea {
    min-height: 48px;
    max-height: 180px;
    font-size: 16px;
  }

  .selected-files {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .file-card {
    grid-template-columns: 38px minmax(0, 1fr);
    flex: 0 0 min(300px, 82vw);
    min-height: 54px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

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

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

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 4px rgba(11, 107, 203, 0.12);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(11, 107, 203, 0.02);
  }
}

@keyframes tool-expand {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
