:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --panel-soft: #eef4f2;
  --ink: #202124;
  --muted: #667085;
  --line: #d9dee6;
  --accent: #0f766e;
  --accent-strong: #0b5d55;
  --focus: #2563eb;
  --focus-ring: rgba(37, 99, 235, 0.28);
  --assistant: #ffffff;
  --user: #21312f;
  --danger: #b42318;
  --auth-overlay: rgba(246, 247, 248, 0.96);
  --modal-overlay: rgba(32, 33, 36, 0.38);
  --hover: #f0f3f5;
  --brand-bg: #dff0ed;
  --brand-border: #9fc9c3;
  --control-soft: #e6f3f0;
  --control-soft-hover: #d5eae6;
  --status-bg: #ecf8f5;
  --status-border: #b8d7d2;
  --danger-bg: #fff1ef;
  --danger-bg-hover: #ffe4e0;
  --danger-border: #f4b6ae;
  --danger-hover: #8f1f16;
  --code-bg: #f1f5f4;
  --code-ink: #17211f;
  --inline-code-bg: rgba(15, 118, 110, 0.1);
  --attachment-bg: rgba(15, 118, 110, 0.1);
  --attachment-bg-hover: rgba(15, 118, 110, 0.18);
  --user-soft-bg: rgba(255, 255, 255, 0.16);
  --drag-bg: rgba(236, 248, 245, 0.86);
  --bubble-shadow: rgba(32, 33, 36, 0.05);
  --shadow: 0 18px 50px rgba(32, 33, 36, 0.12);
  --fast: 0.14s ease;
  --normal: 0.22s ease;
  --message-max: min(760px, 100%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101413;
    --panel: #171d1b;
    --panel-soft: #1e2b28;
    --ink: #ecefed;
    --muted: #9aa6a2;
    --line: #2b3633;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --focus-ring: rgba(96, 165, 250, 0.32);
    --assistant: #171d1b;
    --user: #0f766e;
    --danger: #f87171;
    --auth-overlay: rgba(16, 20, 19, 0.96);
    --modal-overlay: rgba(0, 0, 0, 0.58);
    --hover: #202825;
    --brand-bg: #123631;
    --brand-border: #1d6f64;
    --control-soft: #123631;
    --control-soft-hover: #174a43;
    --status-bg: #102f2b;
    --status-border: #1f6f65;
    --danger-bg: #3a1716;
    --danger-bg-hover: #501f1d;
    --danger-border: #7f2a27;
    --danger-hover: #dc2626;
    --code-bg: #0b0f0e;
    --code-ink: #e5e7eb;
    --inline-code-bg: rgba(45, 212, 191, 0.14);
    --attachment-bg: rgba(45, 212, 191, 0.12);
    --attachment-bg-hover: rgba(45, 212, 191, 0.18);
    --user-soft-bg: rgba(255, 255, 255, 0.16);
    --drag-bg: rgba(16, 47, 43, 0.88);
    --bubble-shadow: rgba(0, 0, 0, 0.16);
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101413;
  --panel: #171d1b;
  --panel-soft: #1e2b28;
  --ink: #ecefed;
  --muted: #9aa6a2;
  --line: #2b3633;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --focus-ring: rgba(96, 165, 250, 0.32);
  --assistant: #171d1b;
  --user: #0f766e;
  --danger: #f87171;
  --auth-overlay: rgba(16, 20, 19, 0.96);
  --modal-overlay: rgba(0, 0, 0, 0.58);
  --hover: #202825;
  --brand-bg: #123631;
  --brand-border: #1d6f64;
  --control-soft: #123631;
  --control-soft-hover: #174a43;
  --status-bg: #102f2b;
  --status-border: #1f6f65;
  --danger-bg: #3a1716;
  --danger-bg-hover: #501f1d;
  --danger-border: #7f2a27;
  --danger-hover: #dc2626;
  --code-bg: #0b0f0e;
  --code-ink: #e5e7eb;
  --inline-code-bg: rgba(45, 212, 191, 0.14);
  --attachment-bg: rgba(45, 212, 191, 0.12);
  --attachment-bg-hover: rgba(45, 212, 191, 0.18);
  --user-soft-bg: rgba(255, 255, 255, 0.16);
  --drag-bg: rgba(16, 47, 43, 0.88);
  --bubble-shadow: rgba(0, 0, 0, 0.16);
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
}

:root[data-theme="light"] {
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

body.auth-required {
  overflow: hidden;
}

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

button {
  cursor: pointer;
  transition:
    background-color var(--fast),
    border-color var(--fast),
    color var(--fast),
    opacity var(--fast),
    transform var(--fast);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

select,
textarea,
input {
  transition:
    background-color var(--fast),
    border-color var(--fast),
    color var(--fast),
    box-shadow var(--fast);
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: var(--auth-overlay);
  padding: 20px;
}

.auth-screen[hidden] {
  display: none;
}

.auth-panel,
.dialog-panel {
  display: grid;
  gap: 12px;
  width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-panel .brand-mark {
  margin-bottom: 4px;
}

.auth-panel h1,
.dialog-panel h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
}

.auth-panel p,
.dialog-panel p {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 14px;
}

.auth-panel input,
.dialog-panel input {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
}

.auth-panel input:focus-visible,
.dialog-panel input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.auth-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 800;
}

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

.auth-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 45;
  display: grid;
  place-items: center;
  background: var(--modal-overlay);
  padding: 20px;
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.secondary-button,
.danger-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.secondary-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
}

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

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

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

.danger-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.auth-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

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

.sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 18px;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  transition:
    background-color var(--normal),
    border-color var(--normal),
    transform var(--normal);
}

.brand-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--brand-border);
  border-radius: 8px;
  background: var(--brand-bg);
  color: var(--accent-strong);
  font-size: 17px;
  font-weight: 800;
}

.brand-text {
  min-width: 0;
}

.brand-text strong,
.brand-text span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.brand-text span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

.new-button,
.send-button,
.attach-button,
.stop-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-weight: 700;
  min-height: 40px;
}

.new-button {
  width: 40px;
  font-size: 24px;
  line-height: 1;
}

.attach-button {
  width: 44px;
  min-width: 44px;
  font-size: 24px;
  line-height: 1;
  background: var(--control-soft);
  color: var(--accent-strong);
  border: 1px solid var(--brand-border);
}

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

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

.stop-button {
  justify-self: end;
  min-height: 34px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-border);
  padding: 6px 12px;
}

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

.new-button:focus-visible,
.send-button:focus-visible,
.attach-button:focus-visible,
.stop-button:focus-visible,
.thread-button:focus-visible,
.delete-thread-button:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.thread-list {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 8px;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
  overscroll-behavior: contain;
}

.thread-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  align-items: stretch;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    background-color var(--fast),
    border-color var(--fast);
}

.thread-item:hover {
  background: var(--hover);
}

.thread-item.active {
  border-color: var(--brand-border);
  background: var(--panel-soft);
}

.thread-button {
  display: block;
  width: 100%;
  min-height: 68px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
  color: var(--ink);
}

.thread-button:hover {
  background: transparent;
}

.thread-button strong,
.thread-button span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread-button strong {
  font-size: 14px;
}

.thread-button span {
  color: var(--muted);
  font-size: 12px;
  margin-top: 6px;
}

.delete-thread-button {
  align-self: center;
  justify-self: center;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
}

.delete-thread-button:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

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

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 76px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  padding: 14px 22px;
  transition:
    background-color var(--normal),
    border-color var(--normal);
}

.title-block {
  min-width: 0;
}

.title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.title-block h1 {
  margin: 0;
  min-width: 0;
  font-size: 21px;
  line-height: 1.22;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rename-thread-button {
  flex: 0 0 auto;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  padding: 3px 8px;
}

.rename-thread-button:hover {
  background: var(--hover);
  color: var(--ink);
}

.rename-thread-button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.rename-thread-button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.title-block p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  flex: 0 0 auto;
  max-width: 36vw;
  border: 1px solid var(--status-border);
  border-radius: 999px;
  background: var(--status-bg);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill.error {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger);
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.theme-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.theme-control select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 6px 26px 6px 10px;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 28px min(7vw, 72px);
}

.empty-state {
  display: grid;
  gap: 14px;
  width: min(100%, 680px);
  margin: auto;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
}

.empty-state strong {
  color: var(--ink);
  font-size: 22px;
  line-height: 1.2;
}

.empty-workdir {
  overflow-wrap: anywhere;
}

.empty-prompts {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.prompt-chip {
  max-width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  padding: 7px 10px;
}

.prompt-chip:hover {
  background: var(--hover);
}

.message {
  display: grid;
  gap: 7px;
  max-width: var(--message-max);
  animation: message-enter 0.22s ease both;
}

.message.user {
  align-self: flex-end;
  justify-items: end;
}

.message.assistant {
  align-self: flex-start;
  justify-items: start;
}

.message-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.message-label time {
  font-weight: 600;
}

.message-bubble {
  border-radius: 8px;
  padding: 12px 15px;
  font-size: 15px;
  line-height: 1.56;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 0 var(--bubble-shadow);
  transition:
    background-color var(--normal),
    border-color var(--normal),
    box-shadow var(--normal);
}

.message-actions {
  display: flex;
  min-height: 26px;
  opacity: 0;
  transition: opacity var(--fast);
}

.message.user .message-actions {
  justify-content: flex-end;
}

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

.message-copy-button,
.scroll-bottom-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

.message-copy-button {
  min-height: 26px;
  padding: 3px 8px;
}

.message-copy-button:hover,
.scroll-bottom-button:hover {
  background: var(--hover);
}

.message-copy-button:focus-visible,
.prompt-chip:focus-visible,
.scroll-bottom-button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.message-copy-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.scroll-bottom-button {
  position: absolute;
  right: 22px;
  bottom: 104px;
  z-index: 5;
  min-height: 36px;
  box-shadow: var(--shadow);
  padding: 7px 12px;
  animation: float-in 0.18s ease both;
}

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

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

.markdown-body {
  display: grid;
  gap: 9px;
  white-space: normal;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body pre {
  margin: 0;
}

.markdown-body h1 {
  font-size: 20px;
  line-height: 1.28;
}

.markdown-body h2 {
  font-size: 18px;
  line-height: 1.32;
}

.markdown-body h3 {
  font-size: 16px;
  line-height: 1.35;
}

.markdown-body ul,
.markdown-body ol {
  display: grid;
  gap: 5px;
  padding-left: 22px;
}

.markdown-body code {
  border-radius: 6px;
  background: var(--inline-code-bg);
  color: inherit;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.92em;
  padding: 1px 5px;
}

.code-block {
  max-width: 100%;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--code-bg);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 34px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 7px 5px 10px;
}

.copy-code-button {
  min-height: 26px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: color-mix(in srgb, var(--panel) 78%, transparent);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  padding: 3px 8px;
}

.copy-code-button:hover {
  background: color-mix(in srgb, var(--panel) 92%, transparent);
}

.copy-code-button:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.code-block pre {
  overflow-x: auto;
  background: transparent;
  color: var(--code-ink);
  padding: 12px;
}

.code-block code {
  display: block;
  min-width: max-content;
  background: transparent;
  color: inherit;
  font-size: 13px;
  line-height: 1.55;
  padding: 0;
  tab-size: 2;
  white-space: pre;
}

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

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

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

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 10px;
}

.attachment-preview {
  display: grid;
  gap: 6px;
  max-width: min(100%, 360px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  overflow: hidden;
  text-decoration: none;
}

.attachment-preview img {
  display: block;
  width: 100%;
  max-height: 280px;
  object-fit: contain;
  background: var(--code-bg);
}

.attachment-preview span {
  padding: 0 9px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 700;
}

.attachment-preview:hover {
  border-color: var(--brand-border);
  background: var(--hover);
}

.attachment-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  border-radius: 8px;
  background: var(--attachment-bg);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
}

.message.user .attachment-chip {
  background: var(--user-soft-bg);
  color: #ffffff;
}

a.attachment-chip:hover {
  background: var(--attachment-bg-hover);
}

a.attachment-chip:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.message.user .message-bubble {
  background: var(--user);
  color: white;
}

.message.user .markdown-body code {
  background: var(--user-soft-bg);
}

.message.assistant .message-bubble {
  border: 1px solid var(--line);
  background: var(--assistant);
  color: var(--ink);
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 42px;
  min-height: 20px;
}

.typing-indicator span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-bounce 1s ease-in-out infinite;
}

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

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

.running-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  max-width: 100%;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: normal;
}

.message-text + .running-indicator {
  margin-top: 9px;
}

.running-indicator .typing-indicator {
  flex: 0 0 auto;
  min-width: 31px;
}

.running-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    opacity: 0.32;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  border-top: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  padding: 16px 22px 18px;
}

.composer-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
}

.reasoning-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reasoning-control select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 6px 28px 6px 10px;
}

.composer-tool-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.voice-button,
.speech-toggle {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
}

.voice-button {
  cursor: pointer;
}

.voice-button.listening {
  border-color: var(--accent);
  background: var(--status-bg);
  color: var(--accent-strong);
}

.speech-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  user-select: none;
}

.speech-toggle input {
  margin: 0;
  accent-color: var(--accent);
}

.composer-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 96px;
  gap: 10px;
  align-items: end;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 0;
}

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

.pending-attachment {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: min(100%, 360px);
  min-height: 34px;
  border: 1px solid var(--status-border);
  border-radius: 8px;
  background: var(--status-bg);
  color: var(--accent-strong);
  padding: 6px 7px 6px 10px;
  font-size: 13px;
  font-weight: 700;
}

.pending-attachment span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-attachment button {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: var(--attachment-bg);
  color: var(--accent-strong);
  font-weight: 800;
  line-height: 1;
}

textarea {
  width: 100%;
  max-height: 180px;
  min-height: 44px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 11px 12px;
  line-height: 1.45;
}

textarea:disabled,
.send-button:disabled,
.attach-button:disabled,
.voice-button:disabled,
.stop-button:disabled,
.reasoning-control select:disabled,
.theme-control select:disabled,
.speech-toggle.disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

body.dragging-file::after {
  content: "松开上传";
  position: fixed;
  inset: 16px;
  z-index: 20;
  display: grid;
  place-items: center;
  border: 2px dashed var(--accent);
  border-radius: 8px;
  background: var(--drag-bg);
  color: var(--accent-strong);
  font-size: 22px;
  font-weight: 800;
  pointer-events: none;
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .sidebar-toggle {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: var(--ink);
    font-size: 20px;
    font-weight: 800;
    line-height: 1;
  }

  .sidebar-toggle:hover {
    background: var(--hover);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: block;
    border: 0;
    border-radius: 0;
    background: var(--modal-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--normal);
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 35;
    width: min(86vw, 320px);
    max-height: none;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow);
    padding: 16px;
    transform: translateX(-105%);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .thread-list {
    flex-direction: column;
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    padding-bottom: 0;
  }

  .thread-button {
    min-height: 58px;
  }

  .thread-item {
    flex: 0 0 auto;
  }

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

  .chat-header {
    align-items: center;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 10px;
    min-height: 68px;
    padding: 12px 14px;
  }

  .title-block {
    flex: 1 1 min(220px, calc(100% - 48px));
  }

  .header-actions {
    width: 100%;
  }

  .title-block h1 {
    font-size: 18px;
  }

  .status-pill {
    max-width: 52vw;
  }

  .messages {
    padding: 20px 14px;
  }

  .scroll-bottom-button {
    right: 14px;
    bottom: 88px;
  }

  .composer {
    padding: 12px;
  }

  .composer-row {
    grid-template-columns: 42px minmax(0, 1fr) 76px;
  }

  .attach-button {
    width: 42px;
    min-width: 42px;
  }
}
