:root {
  --bg: #e9f1fb;
  --bg-2: #f5f8fd;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-strong: #ffffff;
  --panel-soft: #eef4fb;
  --panel-hover: #e4edf8;
  --text: #132033;
  --muted: #5f7188;
  --line: rgba(77, 107, 145, 0.18);
  --line-strong: rgba(77, 107, 145, 0.28);
  --accent: #4f8cff;
  --accent-2: #72a6ff;
  --danger: #ff6b6b;
  --shadow: 0 20px 60px rgba(52, 82, 120, 0.16);

  --sidebar-width: 300px;
  --topbar-height: 58px;
  --content-max: 980px;
  --composer-max: 860px;
  --radius: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(79, 140, 255, 0.16), transparent 30%),
    radial-gradient(circle at top right, rgba(114, 166, 255, 0.12), transparent 26%),
    linear-gradient(180deg, #f8fbff 0%, #e8f0fa 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, sans-serif;
}

body {
  overscroll-behavior: none;
}

button,
select,
textarea {
  font: inherit;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.app-shell {
  min-height: 100dvh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(var(--sidebar-width), 86vw);
  z-index: 50;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  border-right: 1px solid var(--line);
  background: rgba(247, 250, 255, 0.96);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

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

.sidebar-inner {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding:
    calc(16px + env(safe-area-inset-top))
    14px
    calc(14px + env(safe-area-inset-bottom));
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.sidebar-header h2 {
  margin: 4px 0 0;
  font-size: 1.25rem;
  line-height: 1.1;
}

.sidebar-kicker {
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.sidebar-footer {
  margin-top: auto;
  padding: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  border-radius: 16px;
}

.sidebar-footer-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.sidebar-footer-label {
  color: var(--muted);
  font-size: 0.68rem;
}

.settings-label {
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 600;
}

.language-picker {
  position: relative;
  width: 100%;
  max-width: 240px;
}

.language-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.80rem;
  text-align: left;
}

.language-toggle:hover,
.language-toggle:focus-visible {
  background: var(--panel-hover);
  outline: none;
}

.language-current,
.language-option {
  font-size: 0.95rem;
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 80px rgba(52, 82, 120, 0.14);
  overflow: hidden;
  z-index: 60;
  max-height: 260px;
}

.language-picker.language-picker--upward .language-menu {
  top: auto;
  bottom: calc(100% + 8px);
}

.language-option {
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}

.language-option:hover,
.language-option:focus-visible {
  background: var(--panel-soft);
  outline: none;
}

.language-option.active {
  font-weight: 700;
  color: var(--accent);
}

.language-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.14);
  color: var(--accent);
  font-size: 0.85rem;
}

.language-picker {
  position: relative;
  width: 100%;
  margin-top: 8px;
}

.language-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: 0.80rem;
  text-align: left;
}

.language-toggle:hover,
.language-toggle:focus-visible {
  background: var(--panel-hover);
  outline: none;
}

.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 80px rgba(52, 82, 120, 0.14);
  overflow: hidden;
  z-index: 60;
}

.language-option {
  width: 100%;
  padding: 6px 8px;
  border: none;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
  font-size: 0.78rem;
}

.language-option:hover,
.language-option:focus-visible {
  background: var(--panel-soft);
  outline: none;
}

.language-option.active {
  font-weight: 700;
  color: var(--accent);
}

.language-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: rgba(79, 140, 255, 0.14);
  color: var(--accent);
  font-size: 0.85rem;
}

.sidebar-footer-value {
  font-size: 0.94rem;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  background: rgba(0, 0, 0, 0.5);
}

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

.main {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--topbar-height);
  padding:
    calc(7px + env(safe-area-inset-top))
    12px
    7px;
  border-bottom: 1px solid var(--line);
  background: rgba(247, 250, 255, 0.86);
  backdrop-filter: blur(18px);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.topbar-left {
  flex: 1;
}

.topbar-right {
  flex-shrink: 0;
}

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

.sidebar-account {
  width: 100%;
  padding: 8px 10px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
}

.account-box[hidden] {
  display: none;
}

.account-name {
  max-width: 100px;
  color: var(--muted);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 0;
}

.brand-badge {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(79, 140, 255, 0.24), rgba(114, 166, 255, 0.08));
  border: 1px solid rgba(114, 166, 255, 0.3);
  color: var(--accent-2);
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

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

.brand-text h1 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.05;
  font-weight: 700;
}

.header-status {
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-line {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.status-dot.green {
  background: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.45);
}

.status-dot.red {
  background: #ef4444;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.35);
}

.status-dot.unknown {
  background: #64748b;
  box-shadow: none;
}

.status-label {
  font-size: 0.69rem;
  line-height: 1.1;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-wrap {
  min-width: 0;
}

.model-wrap.is-hidden {
  display: none;
}

#modelSelect,
.icon-btn,
.new-chat-btn,
.primary-side-btn,
.history-item,
.delete-btn,
#sendBtn,
#attachBtn,
#loginBtn {
  border: 1px solid var(--line);
  color: var(--text);
}

#modelSelect,
.icon-btn,
.new-chat-btn,
.primary-side-btn,
.history-item,
.delete-btn {
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(10px);
}

#modelSelect {
  height: 44px;
  min-width: 0;
  width: min(46vw, 420px);
  border-radius: 14px;
  padding: 0 14px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

#modelSelect:focus,
#messageInput:focus {
  border-color: rgba(114, 166, 255, 0.42);
}

.icon-btn,
.new-chat-btn,
.delete-btn {
  min-width: 38px;
  min-height: 38px;
  border-radius: 12px;
  cursor: pointer;
}

.new-chat-btn {
  padding: 0 12px;
  font-weight: 600;
  font-size: 0.9rem;
}

.primary-side-btn {
  width: 100%;
  min-height: 46px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 600;
}

.icon-btn:hover,
.new-chat-btn:hover,
.primary-side-btn:hover,
.history-item:hover,
.delete-btn:hover,
#modelSelect:hover {
  background: var(--panel-hover);
  border-color: var(--line-strong);
}

.chat {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding:
    24px
    14px
    calc(142px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: min(860px, 90%);
  border-radius: 20px;
  padding: 14px 16px;
  line-height: 1.5;
  font-size: 0.98rem;
  word-break: break-word;
  box-shadow: 0 10px 30px rgba(52, 82, 120, 0.12);
}

.message.user {
  align-self: flex-end;
  color: #ffffff;
  background: linear-gradient(135deg, #4f8cff, #3f7cff);
  border-bottom-right-radius: 8px;
}

.message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-bottom-left-radius: 8px;
  max-width: min(1080px, 96%);
}

.message.system {
  align-self: center;
  max-width: 100%;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--line-strong);
  box-shadow: none;
}

.message-content {
  min-width: 0;
  line-height: 1.65;
}

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

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

.message-content p {
  margin: 0 0 0.95em;
  white-space: normal;
}

.message-content table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
  font-size: 0.94rem;
}

.table-wrap {
  margin: 0.95em 0;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 251, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.message-content th,
.message-content td {
  padding: 11px 12px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  line-height: 1.5;
}

.message-content th {
  background: rgba(228, 237, 248, 0.85);
  font-weight: 700;
}

.message-content tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.55);
}

.message-content tbody tr:last-child td {
  border-bottom: none;
}

.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4 {
  margin: 0.3em 0 0.7em;
  line-height: 1.2;
}

.message-content h1 {
  font-size: 1.35rem;
}

.message-content h2 {
  font-size: 1.18rem;
}

.message-content h3 {
  font-size: 1.05rem;
}

.message-content h4 {
  font-size: 0.98rem;
}

.message-content ul,
.message-content ol {
  margin: 0.4em 0 0.95em 1.25em;
  padding: 0;
  white-space: normal;
}

.message-content li {
  margin: 0.2em 0;
}

.message-content li.suggestion-item {
  list-style: none;
  margin: 0.45em 0;
}

.suggestion-btn {
  width: 100%;
  display: block;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  color: var(--text);
  background: rgba(248, 251, 255, 0.92);
  cursor: pointer;
  line-height: 1.45;
}

.suggestion-btn:hover {
  border-color: rgba(79, 140, 255, 0.42);
  background: rgba(228, 237, 248, 0.9);
}

.message-content blockquote {
  margin: 0.9em 0;
  padding: 0.8em 1em;
  border-left: 3px solid rgba(114, 166, 255, 0.45);
  background: rgba(242, 247, 255, 0.95);
  border-radius: 12px;
  color: #27405e;
}

.message-content a {
  color: var(--accent-2);
  text-decoration: none;
}

.message-content a:hover {
  text-decoration: underline;
}

.message-content strong {
  font-weight: 700;
}

.message-content em {
  font-style: italic;
}

.message-content code:not(pre code) {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(228, 237, 248, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.14em 0.38em;
}

.code-toolbar {
  margin: 0.95em 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(246, 250, 255, 0.98);
}

.code-toolbar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(236, 243, 251, 0.96);
}

.code-toolbar-lang {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: lowercase;
}

.copy-code-btn {
  min-height: 32px;
  padding: 0 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  cursor: pointer;
}

.copy-code-btn:hover {
  background: var(--panel-hover);
}

.code-toolbar pre {
  margin: 0;
  padding: 14px;
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.55;
}

.code-toolbar pre code {
  color: #1d2b3f;
}

.streaming-cursor::after {
  content: "▋";
  display: inline-block;
  margin-left: 2px;
  color: var(--accent-2);
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.jump-down {
  position: fixed;
  right: 20px;
  bottom: calc(120px + env(safe-area-inset-bottom));
  z-index: 60;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, rgba(79, 140, 255, 0.98), rgba(63, 124, 255, 0.98));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(79, 140, 255, 0.18);
  cursor: pointer;
}

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

.status {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(94px + env(safe-area-inset-bottom));
  z-index: 24;
  color: var(--muted);
  font-size: 0.84rem;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  white-space: nowrap;
}

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 23;
  padding:
    12px
    12px
    calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(238, 244, 252, 0.96) 72%, transparent);
}

.composer-box {
  max-width: var(--composer-max);
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}

#messageInput {
  flex: 1;
  resize: none;
  min-height: 48px;
  max-height: 180px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  padding: 12px 12px 10px;
  line-height: 1.45;
}

#messageInput::placeholder {
  color: var(--muted);
}

#sendBtn {
  width: 48px;
  height: 48px;
  min-width: 48px;
  padding: 0;
  border-radius: 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: linear-gradient(135deg, #4f8cff, #3f7cff);
  border-color: transparent;
  box-shadow: 0 10px 24px rgba(79, 140, 255, 0.28);
}

#sendBtn.is-sending {
  background: linear-gradient(135deg, #ef4444, #d92f2f);
  box-shadow: 0 10px 24px rgba(239, 68, 68, 0.35);
}

.send-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.attach-btn {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  flex-shrink: 0;
  cursor: pointer;
  font-size: 1.45rem;
  line-height: 1;
  font-weight: 600;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.9);
}

.attach-btn:hover {
  background: var(--panel-hover);
  border-color: var(--line-strong);
}

#sendBtn:hover {
  filter: brightness(1.05);
}

#sendBtn:disabled,
#attachBtn:disabled,
.new-chat-btn:disabled,
.primary-side-btn:disabled,
#loginBtn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.attachment-list {
  width: min(var(--composer-max), calc(100vw - 24px));
  max-height: 110px;
  margin: 0 auto 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  overflow-y: auto;
}

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

.attachment-chip,
.message-attachment {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 6px 8px 6px 10px;
  font-size: 0.84rem;
}

.attachment-name {
  max-width: min(360px, 54vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-meta {
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.attachment-remove {
  width: 24px;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(248, 251, 255, 0.95);
  cursor: pointer;
}

.attachment-remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.message.user .message-attachment {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.16);
}

.composer.is-disabled {
  opacity: 0.72;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(248, 251, 255, 0.9), rgba(232, 240, 250, 0.96)),
    var(--bg);
  backdrop-filter: blur(18px);
}

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

.login-panel {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 4px;
}

.login-brand h2 {
  margin: 0;
  font-size: 1.22rem;
  line-height: 1.15;
}

.login-brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.login-panel label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: var(--muted);
  font-size: 0.86rem;
}

.login-panel input {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0 13px;
  color: var(--text);
  background: rgba(248, 251, 255, 0.96);
  outline: none;
}

.login-panel input:focus {
  border-color: rgba(114, 166, 255, 0.52);
}

#loginBtn {
  min-height: 48px;
  border-radius: 16px;
  color: #ffffff;
  background: linear-gradient(135deg, #4f8cff, #3f7cff);
  border-color: transparent;
  cursor: pointer;
  font-weight: 700;
}

.login-error {
  min-height: 20px;
  color: #b42318;
  font-size: 0.86rem;
  line-height: 1.35;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding-right: 2px;
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.history-item {
  text-align: left;
  cursor: pointer;
  padding: 8px 9px;
  border-radius: 12px;
  min-height: 44px;
}

.history-item.active {
  border-color: rgba(79, 140, 255, 0.55);
  background: rgba(79, 140, 255, 0.12);
  box-shadow: inset 0 0 0 1px rgba(79, 140, 255, 0.12);
}

.history-title {
  font-size: 0.95rem;
  font-weight: 650;
  line-height: 1.25;
}

.history-meta {
  margin-top: 5px;
  font-size: 0.76rem;
  color: var(--muted);
}

.delete-btn {
  width: 44px;
  height: 58px;
  border-radius: 16px;
  color: #ffb3b3;
  cursor: pointer;
}

.mobile-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (min-width: 900px) {
  .sidebar {
    transform: translateX(0);
    width: var(--sidebar-width);
    box-shadow: none;
  }

  .sidebar-backdrop,
  .mobile-only {
    display: none !important;
  }

  .main {
    margin-left: var(--sidebar-width);
  }

  .topbar {
    padding: 10px 20px;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  #modelSelect {
    width: min(32vw, 460px);
  }

  .chat {
    padding-left: 28px;
    padding-right: 28px;
    padding-top: 28px;
  }

  .composer {
    left: var(--sidebar-width);
    padding-left: 26px;
    padding-right: 26px;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
  }

  .topbar-right {
    justify-content: space-between;
  }

  .account-name {
    max-width: 38vw;
  }

  #modelSelect {
    width: 100%;
    max-width: none;
  }

  .model-wrap {
    flex: 1;
  }

  .new-chat-btn {
    flex-shrink: 0;
  }

  .message {
    max-width: 94%;
    font-size: 0.97rem;
  }

  .composer-box {
    padding: 8px;
    border-radius: 20px;
  }

  #sendBtn {
    min-width: 92px;
    height: 46px;
  }

  .status-label {
    font-size: 0.72rem;
  }
}
