:root {
  font-family: Inter, system-ui, sans-serif;
  color-scheme: dark;
  --bg: #0d0f12;
  --side: #14171c;
  --card: #15181d;
  --card2: #1b2027;
  --line: #292e36;
  --text: #f3f4f6;
  --muted: #8f99ad;
  --accent: #2f7df6;
  --blur-bg: #171c2754;
}
html[data-theme="light"] {  
  color-scheme: light;
  --bg: #f5f7fb;
  --side: #fff;
  --card: #fff;
  --card2: #f1f4f8;
  --line: #d9dee7;
  --text: #111827;
  --muted: #475569;
  --blur-bg: #f3f4f64b ;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  touch-action: manipulation;
}
h1,
h2,
p {
  margin: 0;
}
input {
  width: 100%;
  min-height: 44px;
  padding: 0 13px;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--card2);
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: 240px;
  display: flex;
  height: 100vh;
  height: 100dvh;
  flex-direction: column;
  justify-content: space-between;
  padding: 24px 14px;
  border-right: 1px solid var(--line);
  background: var(--side);
}
.brand,
.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}
.brand > span,
.auth-brand > span {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  color: #fff;
  border-radius: 8px;
  background: var(--accent);
}
.brand > span img,
.auth-brand > span img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.workspace {
  display: grid;
  margin: 22px 0 12px;
  padding: 0 8px 18px;
  border-bottom: 1px solid var(--line);
}
small {
  color: var(--muted);
}
nav,
.nav-group {
  display: grid;
  gap: 0px;
  border: 0px;
}
.nav-group + .nav-group {
  margin-top: 15px;
}
.nav-group > small {
  padding: 2px 10px;
  font-size: 10px;
  text-transform: uppercase;
}
.nav-group a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  color: var(--muted);
  border-radius: 7px;
  text-decoration: none;
  font-size: 13px;
}
.nav-group a.active {
  color: var(--accent);
  background: #2f7df617;
}
.theme-button {
  display: flex;
  width: 100%;
  gap: 9px;
  padding: 13px 10px;
  color: var(--muted);
  border: 0;
  border-top: 1px solid var(--line);
  background: none;
}
.profile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
}
.profile > span {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  background: var(--accent);
}
.profile > div {
  display: grid;
  min-width: 0;
  flex: 1;
}
.profile strong,
.profile small {
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
}
.profile button {
  color: var(--muted);
  border: 0;
  background: none;
}
.main {
  min-height: 100vh;
  min-height: 100dvh;
  margin-left: 240px;
  min-width: 0;
  overflow-x: hidden;
}
html[data-theme="dark"] .main {
  background:
    radial-gradient(circle at 82% 10%, rgba(47, 125, 246, .1) 0, transparent 40%),
    var(--bg);
}
.header {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 12px;
  padding: 10px 32px;
  border-bottom: none;
}
.header h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.header p {
  display: none;
}
.menu-button {
  display: none;
  color: var(--text);
  border: 0;
  background: none;
}
.page {
  width: min(1120px, 100%);
  margin: auto;
  padding: 28px 32px;
}
.panel,
.chat-panel,
.stat,
.contact-list,
.conversation {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}
.panel-title {
  display: flex;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-title h2 {
  font-size: 14px;
}
.panel-title span {
  color: var(--muted);
  font-size: 11px;
}
.primary {
  display: flex;
  min-height: 43px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 17px;
  color: #fff;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
}
.full {
  width: 100%;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(100%, 420px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
}
.auth-brand {
  margin-bottom: 28px;
}
.auth-card h1 {
  font-size: 23px;
}
.auth-card > p {
  margin: 7px 0 25px;
  color: var(--muted);
}
.auth-card label,
.channel label {
  display: grid;
  gap: 7px;
  margin-bottom: 15px;
  color: var(--muted);
  font-size: 12px;
}
.auth-switch {
  display: flex;
  justify-content: center;
  gap: 6px !important;
  margin: 20px 0 0 !important;
}
.auth-switch button {
  color: var(--accent);
  border: 0;
  background: none;
}
.dropzone {
  width: 100%;
  display: grid;
  justify-items: center;
  gap: 9px;
  margin-bottom: 20px;
  padding: 36px;
  color: var(--muted);
  border: 1px dashed #496080;
  border-radius: 10px;
  background: var(--card);
}
.document-row,
.file-row {
  display: grid;
  grid-template-columns: 25px 1fr 90px 120px 100px 30px;
  align-items: center;
  gap: 12px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.document-row > span,
.file-row > span {
  color: var(--muted);
}
.document-row button {
  color: var(--muted);
  border: 0;
  background: none;
}
.ready {
  color: #36c98a !important;
}
.chat-page {
  height: calc(100vh - 86px);
}
.chat-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
}
.messages {
  flex: 1;
  overflow: auto;
  padding: 22px;
}
.empty {
  height: 100%;
  min-height: 200px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  color: var(--muted);
}
.message {
  display: flex;
  gap: 8px;
  max-width: 75%;
  margin-bottom: 12px;
}
.message p,
.bubble {
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--card2);
}
.message.user {
  flex-direction: row-reverse;
  margin-left: auto;
}
.message.user p,
.bubble.outbound {
  color: #fff;
  background: var(--accent);
}
.composer {
  display: flex;
  gap: 9px;
  padding: 13px;
  border-top: 1px solid var(--line);
}
.composer button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  color: #fff;
  border: 0;
  border-radius: 7px;
  background: var(--accent);
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}
.stat {
  padding: 17px;
}
.stat span {
  color: var(--muted);
  font-size: 11px;
}
.stat strong {
  display: block;
  margin-top: 10px;
  font-size: 20px;
}
.inbox {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: calc(100vh - 115px);
}
.contact-list {
  border-radius: 10px 0 0 10px;
}
.contact-list button {
  width: 100%;
  display: grid;
  padding: 15px;
  color: var(--text);
  border: 0;
  border-bottom: 1px solid var(--line);
  text-align: left;
  background: none;
}
.contact-list button.selected {
  background: var(--card2);
}
.conversation {
  display: flex;
  flex-direction: column;
  border-left: 0;
  border-radius: 0 10px 10px 0;
}
.conversation header {
  display: grid;
  padding: 15px;
  border-bottom: 1px solid var(--line);
}
.bubble {
  width: max-content;
}
.bubble.outbound {
  margin-left: auto;
}
.file-row {
  grid-template-columns: 25px 1fr 180px 80px 130px;
}
.channel form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 16px;
  padding: 20px;
}
.channel .primary {
  grid-column: 1/-1;
  justify-self: start;
}
.backdrop {
  display: none;
}
@media (max-width: 800px) {
  .sidebar {
    transform: translateX(-100%);
    width: min(86vw, 300px);
    padding-top: max(20px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    transition: transform .22s ease;
    box-shadow: none;
  }
  .sidebar.open {
    transform: none;
    box-shadow: 18px 0 50px rgba(0,0,0,.25);
  }
  .backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    border: 0;
    background: #0009;
    backdrop-filter: blur(2px);
  }
  .main {
    margin: 0;
  }
  .menu-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    margin-left: 0;
    padding: 0;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 10px;
    background: color-mix(in srgb, var(--card) 82%, transparent);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
  }
  .menu-button:hover,
  .menu-button:focus-visible {
    border-color: var(--accent);
    background: var(--card2);
  }
  .menu-button:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  .header {
    position: sticky;
    top: 0;
    z-index: 15;
    min-height: 48px;
    padding: max(6px, env(safe-area-inset-top)) 16px 6px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(14px);
    border-bottom: none;
  }
  .header > div { min-width: 0; }
  .header h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
  .page {
    padding: 16px;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .inbox {
    height: auto;
    grid-template-columns: 1fr;
  }
  .channel form {
    grid-template-columns: 1fr;
  }
  .channel .primary {
    grid-column: 1;
  }
}
@media (max-width: 480px) {
  .page { padding: 12px; }
  .header { padding-inline: 12px; }
  .auth-page { padding: 14px; }
  .auth-card { padding: 24px 18px; }
  .dropzone { padding: 26px 16px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* Compact mobile workspace */
@media (max-width: 800px) {
  .header { min-height: 48px; padding: max(6px, env(safe-area-inset-top)) 12px 6px; border-bottom: none; }
  .page { padding: 12px; }
  .sidebar { width: min(90vw, 320px); padding-inline: 10px; }
  .workspace { margin: 14px 0 8px; padding-bottom: 12px; }
  .nav-group + .nav-group { margin-top: 10px; }
  .nav-group a { padding: 9px 10px; }
}
@media (max-width: 480px) {
  .header { padding-inline: 8px; }
  .page { padding: 8px; }
  .panel-title { padding: 12px; }
}
