:root {
  --bg: #ffffff;
  --sidebar: #f7f7f8;
  --sidebar-hover: #ececef;
  --border: #e7e7e8;
  --border-strong: #d9d9dd;
  --text: #202123;
  --muted: #6e6f73;
  --accent: #111111;
  --accent-soft: #f1f1f2;
  --danger: #d84a3f;
  --danger-soft: #fdeceb;
  --shadow: 0 8px 30px rgba(16, 24, 40, 0.06);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: 'Manrope', 'Noto Sans SC', sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

body.sidebar-open {
  overflow: hidden;
}

body.mobile-ui .mobile-sidebar-button {
  display: inline-grid;
  place-items: center;
}

body.mobile-ui .mobile-sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: block;
  background: rgba(15, 23, 42, 0.3);
}

body.mobile-ui .app-shell {
  grid-template-columns: 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100dvh;
}

body.mobile-ui .sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 80;
  width: min(72vw, 288px);
  height: 100dvh;
  max-height: none;
  gap: 10px;
  padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
  border-right: 1px solid var(--border);
  border-bottom: 0;
  box-shadow: 12px 0 36px rgba(15, 23, 42, 0.12);
  transform: translateX(-104%);
  transition: transform 0.24s ease;
  will-change: transform;
}

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

body.mobile-ui .brand-card {
  display: flex !important;
  align-items: center;
  gap: 10px;
  padding: 2px 0 6px;
}

body.mobile-ui .brand-card .eyebrow {
  display: block !important;
}

body.mobile-ui .brand-card h1 {
  font-size: 16px;
}

body.mobile-ui .mobile-sidebar-close {
  display: inline-grid;
  place-items: center;
  margin-left: auto;
}

body.mobile-ui .sidebar-actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

body.mobile-ui .topbar {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 92px;
  gap: 8px;
  padding: 6px 10px;
  align-items: center;
}

body.mobile-ui .topbar-main {
  align-items: center;
  display: contents;
}

body.mobile-ui .topbar-copy {
  min-width: 0;
  text-align: center;
}

body.mobile-ui .topbar .eyebrow,
body.mobile-ui #conversationMeta {
  display: none !important;
}

body.mobile-ui .topbar h2 {
  font-size: 14px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-ui .main-panel {
  height: 100dvh;
}

body.mobile-ui .message-list {
  padding: 8px 10px 0;
}

body.mobile-ui .composer-panel {
  padding: 4px 10px calc(6px + env(safe-area-inset-bottom));
}

body.mobile-ui .composer-topline {
  margin-bottom: 4px;
}

body.mobile-ui #composerHint {
  font-size: 10px;
}

body.mobile-ui .composer-input-shell {
  grid-template-columns: 34px minmax(0, 1fr) 64px;
  min-height: 40px;
  padding: 4px;
  border-radius: 20px;
}

body.mobile-ui textarea {
  min-height: 24px;
  max-height: 88px;
  padding: 0 8px;
  font-size: 16px;
  line-height: 1.3;
}

body.mobile-ui .plus-button,
body.mobile-ui .send-button {
  width: 30px;
  min-width: 30px;
  height: 30px;
  min-height: 30px;
  padding: 0;
}

body.mobile-ui .plus-button {
  font-size: 20px;
}

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

body.mobile-ui .message-item.user .avatar {
  order: 2 !important;
}

body.mobile-ui .message-item.user .message-body {
  order: 1 !important;
  align-items: flex-end;
}

body.mobile-ui .avatar {
  width: 28px;
  height: 28px;
}

body.mobile-ui .message-content {
  font-size: 14px;
  line-height: 1.6;
}

body.mobile-ui .message-item.user .message-content {
  padding: 9px 12px;
  border-radius: 16px;
}

body.mobile-ui .auth-modal,
body.mobile-ui .admin-modal,
body.mobile-ui .image-lightbox {
  padding: 12px;
}

body.mobile-ui .auth-card,
body.mobile-ui .admin-card {
  width: 100%;
  max-height: calc(100dvh - 24px);
  padding: 16px;
  border-radius: 16px;
}

body.mobile-ui .mobile-topbar-model {
  display: block !important;
}

body.mobile-ui .mobile-topbar-model select {
  font-size: 11px;
  padding: 6px 8px;
}

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

button {
  border: 0;
}

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

.sidebar {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
  min-height: 0;
  height: 100vh;
  padding: 14px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  overflow: hidden;
}

.main-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 0;
  height: 100vh;
  background: #fff;
  overflow: hidden;
}

.mobile-sidebar-button,
.mobile-sidebar-backdrop,
.mobile-topbar-model {
  display: none;
}

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

.topbar-main {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
}

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

.mobile-sidebar-button {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: #f3f4f6;
  color: #111827;
  font-size: 18px;
  line-height: 1;
}

.main-panel.drop-active .composer-input-shell {
  border-color: #7c8aa5;
  box-shadow: 0 0 0 4px rgba(17, 24, 39, 0.08);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
}

.small-text {
  font-size: 12px;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 2px 2px;
}

.mobile-sidebar-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.mobile-sidebar-close {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: #f3f4f6;
  color: #111827;
  font-size: 14px;
}

.mobile-model-picker {
  width: 100%;
}

.brand-mark {
  display: block;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
}

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

.brand-card h1,
.topbar h2,
.auth-card h2,
.empty-chat-state h3 {
  margin: 0;
}

.brand-card h1 {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sidebar-actions,
.bulk-actions {
  display: grid;
  gap: 6px;
}

.conversation-pane {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.conversation-pane-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding: 0 2px;
  font-size: 12px;
}

.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 0;
  overflow: auto;
  overflow-x: hidden;
}

.conversation-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px;
  gap: 6px;
  align-items: center;
  padding: 3px 4px;
  border-radius: 14px;
  min-width: 0;
}

.conversation-row.selection-mode {
  grid-template-columns: 18px minmax(0, 1fr) 32px;
}

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

.conversation-row.active {
  background: #ececf1;
}

.conversation-row.selected {
  background: var(--danger-soft);
}

.conversation-checkbox {
  margin-left: 6px;
}

.conversation-main,
.conversation-menu-button,
.ghost-button,
.primary-button,
.danger-button,
.auth-tab,
.plus-button,
.copy-code-button,
.conversation-menu button {
  border-radius: 12px;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.conversation-main,
.conversation-menu-button,
.ghost-button,
.primary-button,
.danger-button,
.auth-tab,
.plus-button,
.copy-code-button,
.conversation-menu button {
  cursor: pointer;
}

.conversation-main {
  width: 100%;
  min-width: 0;
  padding: 7px 8px 7px 10px;
  background: transparent;
  text-align: left;
}

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

.conversation-main strong {
  font-size: 12px;
  font-weight: 600;
}

.conversation-main span,
.conversation-main em {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.conversation-main em {
  font-style: normal;
}

.conversation-menu-wrap {
  position: relative;
  flex-shrink: 0;
}

.conversation-menu-button {
  width: 32px;
  height: 32px;
  background: transparent;
  color: #4b5563;
  opacity: 0.92;
}

.conversation-menu-button.open,
.conversation-row:hover .conversation-menu-button,
.conversation-row.active .conversation-menu-button {
  background: #ececf1;
}

.conversation-menu-button:hover,
.ghost-button:hover,
.auth-tab:hover,
.plus-button:hover {
  background: #ececf1;
}

.conversation-menu {
  position: absolute;
  top: 36px;
  right: 0;
  z-index: 20;
  width: 132px;
  padding: 6px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.conversation-context-menu {
  position: fixed;
  z-index: 200;
  width: 156px;
  padding: 6px;
  display: grid;
  gap: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
}

.conversation-context-menu button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

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

.conversation-menu button {
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  text-align: left;
}

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

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

.empty-state-sidebar {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  padding: 14px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.94);
}

.topbar h2 {
  font-size: 20px;
  font-weight: 700;
}

.model-picker {
  display: grid;
  gap: 4px;
  min-width: 210px;
}

.mobile-topbar-model select {
  width: 100%;
}

.model-picker span {
  color: var(--muted);
  font-size: 11px;
}

select,
textarea,
input {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  color: var(--text);
  background: #fff;
}

select,
input {
  padding: 7px 9px;
  font-size: 11px;
}

select {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

select option {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.message-list {
  overflow: auto;
  min-height: 0;
  height: 100%;
  padding: 22px 24px 0;
  overscroll-behavior: contain;
}

.empty-chat-state {
  max-width: 700px;
  margin: 90px auto 0;
  text-align: center;
}

.empty-chat-state h3 {
  font-size: 30px;
  line-height: 1.14;
  margin-bottom: 10px;
}

.empty-chat-state p {
  margin: 0;
}

.message-item {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 12px;
  max-width: 860px;
  margin: 0 auto 24px;
}

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

.message-item.user .avatar {
  order: 2;
}

.message-item.user .message-body {
  order: 1;
  align-items: flex-end;
}

.message-item.user .message-meta {
  text-align: right;
}

.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #111827;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  overflow: hidden;
}

.avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.message-item.user .avatar {
  background: #f3f4f6;
  color: #111827;
}

.message-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message-meta {
  color: var(--muted);
  font-size: 12px;
}

.message-content {
  max-width: min(760px, 100%);
  padding: 0;
  border: 0;
  background: transparent;
  line-height: 1.7;
  font-size: 15px;
}

.message-content.content-muted {
  color: var(--muted);
}

.message-content.content-pending {
  color: var(--muted);
  font-style: italic;
}

.message-item.pending .avatar {
  background: #374151;
}

.message-item.user .message-content {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: #f7f7f8;
}

.message-content p {
  margin: 0 0 12px;
}

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

.message-content code {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  background: #f1f1f2;
  font-size: 0.92em;
}

.code-card {
  margin: 12px 0;
  border: 1px solid #1f2937;
  border-radius: 16px;
  overflow: hidden;
  background: linear-gradient(180deg, #0b1220 0%, #111827 100%);
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  color: #d1d5db;
  font-size: 12px;
  background: #0f172a;
}

.copy-code-button {
  padding: 5px 8px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
}

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

.code-card pre {
  margin: 0;
  max-width: 100%;
  max-height: 420px;
  padding: 12px 14px;
  overflow: auto;
  white-space: pre;
  color: #f9fafb;
  font-size: 13px;
}

.code-card code {
  display: block;
  padding: 0;
  background: transparent;
  color: #f9fafb;
}

.message-attachments,
.pending-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.attachment-card,
.pending-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
}

.attachment-card.image {
  max-width: 520px;
}

.generated-image-card {
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.attachment-image-link {
  display: block;
  overflow: hidden;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: #f3f4f6;
  cursor: zoom-in;
}

.attachment-image,
.pending-thumb,
.attachment-card video {
  display: block;
  width: 100%;
  border-radius: 12px;
}

.generated-image-card .attachment-image {
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.attachment-card audio {
  width: 280px;
  max-width: 100%;
}

.attachment-meta {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.generated-image-card .attachment-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 32px;
}

.image-lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.74);
}

.image-lightbox-image {
  position: relative;
  z-index: 1;
  display: block;
  max-width: min(92vw, 1200px);
  max-height: 88vh;
  border-radius: 18px;
  background: white;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

.composer-panel {
  position: relative;
  flex-shrink: 0;
  padding: 8px 24px 12px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.72), #fff 22%);
}

.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(249, 250, 251, 0.74);
  backdrop-filter: blur(4px);
}

.drop-overlay-card {
  display: grid;
  gap: 6px;
  min-width: 260px;
  padding: 22px 24px;
  border: 1px dashed #94a3b8;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.96);
  text-align: center;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12);
}

.drop-overlay-card strong {
  font-size: 17px;
}

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

.composer-topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  max-width: 860px;
  margin: 0 auto;
}

.composer-topline {
  margin-bottom: 6px;
}

.composer-box {
  display: block;
  max-width: 860px;
  margin: 0 auto;
}

.composer-input-shell {
  position: relative;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 74px;
  align-items: center;
  min-width: 0;
  min-height: 42px;
  padding: 3px 8px 3px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 28px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04), inset 0 1px 1px rgba(16, 24, 40, 0.02);
  overflow: hidden;
}

.composer-plus-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.plus-button {
  width: 34px;
  height: 34px;
  border: 1px solid transparent;
  background: #f3f4f6;
  color: #4b5563;
  font-size: 22px;
  line-height: 1;
  border-radius: 999px;
}

.plus-button:hover {
  background: #e9eaec;
}

textarea {
  width: 100%;
  min-height: 26px;
  max-height: 180px;
  resize: none;
  overflow-y: auto;
  padding: 0 10px 0 8px;
  border: 0;
  background: transparent;
  line-height: 1.35;
  box-shadow: none;
  scrollbar-width: thin;
  scrollbar-color: #cfd2d8 transparent;
}

textarea:focus {
  outline: none;
}

textarea::-webkit-scrollbar {
  width: 8px;
}

textarea::-webkit-scrollbar-track {
  margin: 14px 0;
  background: transparent;
}

textarea::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: #cfd2d8;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.primary-button,
.danger-button,
.ghost-button,
.auth-tab {
  padding: 8px 10px;
  font-size: 12px;
}

.primary-button {
  background: #111827;
  color: #fff;
}

.primary-button:hover {
  background: #1f2937;
}

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

.danger-button:hover {
  background: #c73f35;
}

.ghost-button,
.auth-tab {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text);
}

.ghost-button:disabled,
.danger-button:disabled,
.primary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.send-button {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 18px;
  line-height: 1;
}

.send-button.stop-button {
  background: #b42318;
}

.send-button.stop-button:hover {
  background: #912018;
}

.composer-send-wrap {
  display: flex;
  justify-content: center;
  align-items: center;
}

.pending-card {
  align-items: start;
  max-width: 260px;
}

.pending-card-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.small-button {
  padding: 6px 8px;
  font-size: 12px;
}

.profile-card {
  display: grid;
  gap: 12px;
  padding: 8px 4px 0;
  font-size: 12px;
}

.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.profile-actions.single {
  grid-template-columns: 1fr;
}

.profile-card strong {
  font-size: 13px;
}

.profile-card .muted {
  font-size: 11px;
}

.auth-modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(17, 24, 39, 0.45);
}

.auth-modal.visible {
  display: grid;
}

.auth-card {
  width: min(460px, 100%);
  padding: 24px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-copy,
.auth-message {
  margin-bottom: 14px;
}

.auth-copy p,
.auth-message {
  line-height: 1.6;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.auth-tab.active {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.auth-form {
  display: grid;
  gap: 10px;
}

.auth-message {
  min-height: 22px;
}

.auth-message.error {
  color: var(--danger);
}

.auth-message.success {
  color: #177245;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  place-items: center;
  padding: 20px;
}

.admin-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.46);
}

.admin-card {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: 85vh;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  background: #fff;
  box-shadow: var(--shadow);
}

.admin-head,
.admin-users-head,
.admin-toggle-row,
.admin-user-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.admin-head {
  margin-bottom: 16px;
}

.admin-head h3 {
  margin: 0;
}

.admin-section {
  margin-top: 18px;
}

.admin-toggle-row span {
  white-space: nowrap;
}

.admin-users-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.toggle-group {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: #f7f7f8;
}

.toggle-chip {
  min-width: 58px;
  padding: 8px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.toggle-chip.active {
  background: #111827;
  color: #fff;
}

.admin-user-row {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafafa;
}

.admin-user-row span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.hidden {
  display: none !important;
}

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

  .sidebar {
    height: auto;
    max-height: 40dvh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

   .sidebar-top,
   .sidebar-bottom {
    display: grid;
    gap: 8px;
   }

  .conversation-pane {
    min-height: 180px;
  }

  .topbar,
  .composer-topline,
  .composer-box {
    flex-direction: column;
    align-items: stretch;
  }

  .composer-box {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .model-picker {
    min-width: 0;
    width: 100%;
  }

  .main-panel {
    height: auto;
    min-height: 0;
  }

  .message-list {
    min-height: 0;
  }
}

@media (max-width: 900px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 80;
    width: min(84vw, 320px);
    height: 100dvh;
    max-height: none;
    gap: 10px;
    padding: 12px 10px calc(12px + env(safe-area-inset-bottom));
    border-right: 1px solid var(--border);
    border-bottom: 0;
    box-shadow: 12px 0 36px rgba(15, 23, 42, 0.12);
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    will-change: transform;
  }

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

  .brand-card,
  .sidebar-actions {
    display: none;
  }

  .mobile-sidebar-head {
    display: grid !important;
    gap: 10px;
    margin-bottom: 4px;
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 70;
    background: rgba(15, 23, 42, 0.3);
  }

  .brand-card {
    gap: 8px;
    padding: 2px 0;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 8px;
  }

  .brand-card h1 {
    font-size: 17px;
  }

  .eyebrow {
    font-size: 10px;
    letter-spacing: 0.1em;
  }

  .sidebar-actions,
  .bulk-actions {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sidebar-actions {
    grid-template-columns: 1fr;
  }

  .sidebar-actions .primary-button,
  .bulk-actions .ghost-button,
  .bulk-actions .danger-button,
  .profile-card .ghost-button {
    min-height: 34px;
    padding: 6px 8px;
    font-size: 11px;
  }

  .conversation-pane-head {
    margin-bottom: 4px;
    font-size: 11px;
  }

  .conversation-list {
    gap: 4px;
  }

  .conversation-row,
  .conversation-row.selection-mode {
    grid-template-columns: minmax(0, 1fr) 28px;
    padding: 2px;
  }

  .conversation-row.selection-mode .conversation-checkbox {
    display: none;
  }

  .conversation-main {
    padding: 7px 8px;
  }

  .conversation-main strong {
    font-size: 11px;
  }

  .conversation-main span,
  .conversation-main em {
    font-size: 9px;
  }

  .conversation-menu-button {
    width: 28px;
    height: 28px;
  }

  .profile-card {
    gap: 8px;
    padding-top: 2px;
  }

  .profile-card strong {
    font-size: 12px;
  }

  .message-list {
    padding: 14px 10px 0;
  }

  .topbar,
  .composer-panel {
    padding-left: 10px;
    padding-right: 10px;
  }

  .topbar {
    gap: 10px;
    padding-top: 8px;
    padding-bottom: 8px;
    align-items: center;
  }

  .mobile-sidebar-button {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    font-size: 16px;
  }

  .topbar-main > div {
    min-width: 0;
  }

  .topbar-main {
    align-items: center;
    flex: 1;
  }

  .topbar .eyebrow,
  .topbar .small-text,
  #conversationMeta {
    display: none !important;
  }

  .topbar h2 {
    font-size: 15px;
    line-height: 1.2;
  }

  .model-picker {
    display: none !important;
  }

  .mobile-model-picker span {
    font-size: 10px;
  }

  .mobile-model-picker select {
    font-size: 11px;
    padding: 7px 8px;
  }

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

  .message-item.user .avatar,
  .message-item.user .message-body {
    order: initial;
  }

  .avatar {
    width: 28px;
    height: 28px;
    border-radius: 999px;
  }

  .message-meta {
    font-size: 11px;
  }

  .message-content {
    font-size: 14px;
    line-height: 1.6;
  }

  .message-item.user .message-content {
    padding: 9px 12px;
    border-radius: 16px;
  }

  .generated-image-card,
  .attachment-card.image,
  .pending-card {
    max-width: 100%;
  }

  .composer-panel {
    padding-top: 6px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .composer-topline {
    margin-bottom: 6px;
  }

  .composer-hint,
  .composer-topline .small-text,
  #composerHint {
    font-size: 10px;
  }

  .composer-input-shell {
    grid-template-columns: 34px minmax(0, 1fr) 64px;
    padding: 5px;
    border-radius: 20px;
  }

  .plus-button,
  .send-button {
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    font-size: 12px;
  }

  .plus-button {
    font-size: 20px;
  }

  textarea {
    min-height: 38px;
    max-height: 104px;
    padding: 5px 8px;
    font-size: 13px;
    line-height: 1.5;
  }

  textarea::-webkit-scrollbar {
    width: 6px;
  }

  textarea::-webkit-scrollbar-track {
    margin: 10px 0;
  }

  .drop-overlay {
    inset: 0 0 calc(68px + env(safe-area-inset-bottom)) 0;
  }

  .drop-overlay-card {
    min-width: 0;
    width: calc(100% - 32px);
    padding: 18px 16px;
    border-radius: 18px;
  }

  .drop-overlay-card strong {
    font-size: 15px;
  }

  .auth-modal,
  .admin-modal,
  .image-lightbox {
    padding: 12px;
  }

  .auth-card,
  .admin-card {
    width: 100%;
    max-height: calc(100dvh - 24px);
    padding: 16px;
    border-radius: 16px;
  }

  .admin-head,
  .admin-users-head,
  .admin-toggle-row,
  .admin-user-row {
    align-items: flex-start;
  }

  .admin-toggle-row,
  .admin-users-head,
  .admin-user-row {
    flex-direction: column;
  }

  .toggle-group {
    width: 100%;
    justify-content: space-between;
  }

  .toggle-chip {
    flex: 1;
    text-align: center;
  }

  .image-lightbox-image {
    max-width: 100%;
    max-height: 80dvh;
  }
}

@media (max-width: 600px) {
  .sidebar {
    max-height: 34dvh;
  }

  .sidebar-actions,
  .bulk-actions {
    grid-template-columns: 1fr 1fr;
  }

  .bulk-actions .danger-button {
    grid-column: 1 / -1;
  }

  .topbar {
    align-items: stretch;
  }

  .topbar h2 {
    font-size: 14px;
  }

  .empty-chat-state {
    margin-top: 48px;
  }

  .empty-chat-state h3 {
    font-size: 22px;
  }

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

  .message-list,
  .composer-panel,
  .topbar {
    width: 100%;
  }
}

body.mobile-ui .sidebar {
  width: min(66vw, 268px) !important;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom)) !important;
}

body.mobile-ui .brand-card {
  display: flex !important;
  padding: 0 0 4px !important;
}

body.mobile-ui .conversation-pane-head {
  display: none !important;
}

body.mobile-ui .sidebar-actions,
body.mobile-ui .bulk-actions,
body.mobile-ui .profile-actions {
  display: grid !important;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

body.mobile-ui .profile-actions.single {
  grid-template-columns: 1fr;
}

body.mobile-ui .bulk-actions {
  display: grid !important;
  grid-template-columns: 1fr;
  margin-top: 6px;
}

body.mobile-ui .sidebar-actions .primary-button,
body.mobile-ui .bulk-actions .ghost-button,
body.mobile-ui .bulk-actions .danger-button,
body.mobile-ui .profile-actions .ghost-button {
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 11px;
}

body.mobile-ui .topbar {
  display: grid !important;
  grid-template-columns: 32px minmax(0, 1fr) 86px;
  gap: 8px;
  padding: 6px 10px !important;
  align-items: center !important;
}

body.mobile-ui .topbar-main {
  display: contents !important;
}

body.mobile-ui .topbar-copy {
  min-width: 0;
  text-align: center;
}

body.mobile-ui .topbar .eyebrow,
body.mobile-ui #conversationMeta,
body.mobile-ui .composer-topline {
  display: none !important;
}

body.mobile-ui .topbar h2 {
  font-size: 14px !important;
  line-height: 1.15 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body.mobile-ui .mobile-sidebar-button,
body.mobile-ui .mobile-sidebar-close {
  display: inline-grid !important;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #f3f4f6;
  color: #111827;
}

body.mobile-ui .mobile-topbar-model {
  display: block !important;
}

body.mobile-ui .mobile-topbar-model select {
  width: 100%;
  font-size: 11px;
  padding: 6px 8px;
}

body.mobile-ui .message-list {
  padding: 8px 10px 0 !important;
}

body.mobile-ui .pending-attachments {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 2px;
  gap: 8px;
}

body.mobile-ui .pending-card {
  flex: 0 0 96px;
  width: 96px;
  max-width: 96px;
  padding: 6px;
}

body.mobile-ui .pending-card-info strong,
body.mobile-ui .pending-card-info span {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

body.mobile-ui .pending-thumb {
  width: 100%;
  max-height: 56px;
  object-fit: cover;
}

body.mobile-ui .conversation-pane {
  overflow: visible;
}

body.mobile-ui .conversation-list {
  overflow-y: auto;
  overflow-x: visible;
  padding-right: 2px;
  padding-bottom: 88px;
}

body.mobile-ui .sidebar {
  overflow: visible;
}

body.mobile-ui .conversation-row.menu-open {
  align-items: start;
}

body.mobile-ui .conversation-row.menu-open .conversation-menu-wrap {
  position: static;
}

body.mobile-ui .conversation-row.menu-open .conversation-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  width: 156px;
  margin-top: 0;
  border-radius: 16px;
  z-index: 140;
}

body.mobile-ui .message-item.user {
  grid-template-columns: minmax(0, 1fr) 28px !important;
}

body.mobile-ui .message-item.user .avatar {
  order: 2 !important;
}

body.mobile-ui .message-item.user .message-body {
  order: 1 !important;
  align-items: flex-end !important;
}

body.mobile-ui .message-item.user .message-meta {
  text-align: right !important;
}

body.mobile-ui .message-item.user .message-content {
  text-align: left;
}

body.mobile-ui .conversation-menu {
  position: fixed;
  left: 12px;
  right: 12px;
  top: auto;
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: auto;
  z-index: 125;
  border-radius: 18px;
}

body.mobile-ui .conversation-menu button {
  padding: 12px 14px;
  font-size: 15px;
}

body.mobile-ui .composer-panel {
  padding: 4px 10px calc(4px + env(safe-area-inset-bottom)) !important;
}

body.mobile-ui .composer-input-shell {
  min-height: 38px !important;
  padding: 4px !important;
  border-radius: 18px !important;
}

body.mobile-ui textarea {
  min-height: 22px !important;
  max-height: 80px !important;
  padding: 0 8px !important;
  font-size: 16px !important;
  line-height: 1.25 !important;
}
