:root {
  --bg: #f6f3fb;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --line: rgba(50, 29, 81, 0.1);
  --text: #1d1728;
  --muted: rgba(29, 23, 40, 0.62);
  --brand: #321d51;
  --brand-accent: rgb(123, 108, 224);
  --black: #000000;
  --white: #ffffff;
  --danger: #ff7b93;
  --shadow: 0 14px 36px rgba(50, 29, 81, 0.12);
  --shadow-soft: 0 3px 12px rgba(50, 29, 81, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(123, 108, 224, 0.14), transparent 28%),
    linear-gradient(180deg, #faf8fd 0%, #f3eef9 100%);
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  display: flex;
  min-height: 100vh;
  position: relative;
}

.sidebar {
  width: 344px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(37, 26, 59, 0.98), rgba(23, 16, 39, 0.98));
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease;
  overflow: hidden;
}

.shell.sidebar-collapsed .sidebar {
  width: 92px;
}

.brand {
  padding: 24px;
  border-bottom: 1px solid var(--line);
}

.shell.sidebar-collapsed .brand {
  padding: 20px 16px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: var(--shadow-soft);
}

.login-brand {
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--brand), rgba(74, 55, 114, 0.96));
  border: 1px solid rgba(50, 29, 81, 0.08);
}

.brand-image {
  display: block;
  width: 100%;
  max-width: 210px;
  height: auto;
}

.brand-image-small {
  max-width: 74px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), rgba(74, 55, 114, 0.96));
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: 0 8px 20px rgba(50, 29, 81, 0.18);
}

.brand-mark.compact {
  width: 42px;
  height: 42px;
  flex-basis: 42px;
  border-radius: 14px;
}

.brand-mark-image {
  width: 124px;
  max-width: none;
  height: auto;
  transform: translateX(-13px);
}

.brand-mark-image.compact {
  width: 42px;
  transform: none;
}

.brand-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand-meta strong {
  font-size: 14px;
  line-height: 1.2;
  color: var(--white);
}

.brand-eyebrow {
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-accent);
}

.brand-user {
  margin: 12px 6px 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.72);
}

.shell.sidebar-collapsed .brand-meta,
.shell.sidebar-collapsed .brand-user,
.shell.sidebar-collapsed .sidebar-toolbar h2,
.shell.sidebar-collapsed .chat-list-content {
  display: none;
}

.shell.sidebar-collapsed .brand-badge {
  justify-content: center;
  padding: 10px;
}

.login-copy {
  margin-top: 20px;
}

.login-copy h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: -0.02em;
}

.login-copy p {
  margin: 0;
  color: var(--muted);
}

.sidebar-toolbar {
  padding: 18px 24px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.shell.sidebar-collapsed .sidebar-toolbar {
  padding: 16px;
  justify-content: center;
}

.sidebar-toolbar h2,
.chat-header h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.sidebar-toolbar h2 {
  color: rgba(255, 255, 255, 0.92);
}

.sidebar-actions {
  display: flex;
  gap: 8px;
}

.shell.sidebar-collapsed .sidebar-actions {
  flex-direction: column;
}

.ghost-button,
.primary-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  font-weight: 600;
}

.primary-button {
  background: linear-gradient(135deg, var(--brand-accent), #6550bf);
  color: white;
  box-shadow: 0 8px 18px rgba(123, 108, 224, 0.28);
}

.ghost-button {
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.ghost-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
}

.icon-button {
  width: 40px;
  height: 40px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  font-size: 18px;
}

.chat-list {
  overflow: auto;
  padding: 0 16px 18px;
}

.shell.sidebar-collapsed .chat-list {
  padding: 0 12px 16px;
}

.chat-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 16px;
  background: transparent;
  padding: 12px 14px;
  cursor: pointer;
  margin-bottom: 8px;
  box-shadow: none;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.shell.sidebar-collapsed .chat-list-item {
  justify-content: center;
  padding: 10px;
}

.chat-list-item:hover,
.chat-list-item.active {
  background: rgba(255, 255, 255, 0.08);
  transform: translateX(3px);
  box-shadow: none;
}

.chat-list-top,
.chat-list-bottom {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.chat-list-content {
  min-width: 0;
  flex: 1;
}

.chat-list-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.chat-list-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--white);
}

.chat-list-preview,
.meta {
  color: var(--muted);
  font-size: 13px;
}

.sidebar .meta,
.sidebar .chat-list-preview {
  color: rgba(255, 255, 255, 0.64);
}

.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background:
    linear-gradient(180deg, rgba(251, 250, 254, 0.98), rgba(245, 240, 250, 0.98));
}

.chat-header {
  padding: 20px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 rgba(50, 29, 81, 0.03);
}

.chat-content {
  flex: 1;
  overflow: auto;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: radial-gradient(circle at top left, rgba(123, 108, 224, 0.05), transparent 24%);
}

.bubble {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: fit-content;
  max-width: min(680px, 78%);
  padding: 16px 18px;
  border-radius: 24px;
  box-shadow: var(--shadow-soft);
  white-space: pre-wrap;
  line-height: 1.38;
  font-size: 14px;
}

.bubble.inbound {
  align-self: flex-start;
  background: var(--panel-strong);
  border: 1px solid rgba(50, 29, 81, 0.08);
  border-top-left-radius: 10px;
}

.bubble.outbound {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--brand-accent), var(--brand));
  color: var(--white);
  border-top-right-radius: 10px;
}

.bubble-meta {
  font-size: 12px;
  opacity: 0.72;
}

.bubble-body,
.bubble-caption,
.bubble-attachment {
  margin: 0;
}

.composer {
  padding: 18px 28px 28px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.84);
}

.composer form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.composer textarea,
.login-card input {
  width: 100%;
  border: 1px solid rgba(123, 108, 224, 0.22);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  resize: none;
  min-height: 52px;
  max-height: 160px;
  box-shadow: inset 0 1px 2px rgba(50, 29, 81, 0.04);
}

.composer textarea {
  overflow-y: auto;
  line-height: 1.4;
}

.composer-send {
  height: 52px;
  flex: 0 0 auto;
}

.composer textarea:focus,
.login-card input:focus {
  outline: none;
  border-color: rgba(123, 108, 224, 0.46);
  box-shadow:
    0 0 0 4px rgba(123, 108, 224, 0.12),
    inset 0 1px 2px rgba(50, 29, 81, 0.04);
}

.composer textarea::placeholder,
.login-card input::placeholder {
  color: rgba(29, 23, 40, 0.38);
}

.empty-state,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(440px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 243, 252, 0.98));
  border: 1px solid rgba(123, 108, 224, 0.2);
  border-radius: 32px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.login-card p,
.login-card .error,
.empty-state p {
  color: var(--muted);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
}

.error {
  color: var(--danger);
  min-height: 20px;
}

.loading {
  padding: 28px;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

a.file-link {
  color: var(--brand);
}

.primary-button {
  background: linear-gradient(135deg, var(--brand-accent), var(--brand));
  color: var(--white);
}

.primary-button:hover,
.ghost-button:hover,
.chat-list-item:hover {
  box-shadow: 0 12px 30px rgba(50, 29, 81, 0.16);
}

@media (max-width: 960px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 45vh;
  }

  .shell.sidebar-collapsed .sidebar {
    width: 100%;
    max-height: 110px;
  }

  .shell.sidebar-collapsed .brand-meta,
  .shell.sidebar-collapsed .brand-user,
  .shell.sidebar-collapsed .chat-list-content,
  .shell.sidebar-collapsed .sidebar-toolbar h2 {
    display: none;
  }

  .bubble {
    max-width: 92%;
  }

  .composer form {
    flex-direction: column;
  }
}
