@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

:root {
  --background: hsl(0, 0%, 100%);
  --foreground: hsl(0, 0%, 0%);
  --border: hsl(0, 0%, 90%);
  --input: hsl(0, 0%, 96%);
  --ring: hsl(0, 0%, 0%);
  --primary: hsl(0, 0%, 0%);
  --primary-foreground: hsl(0, 0%, 100%);
  --muted: hsl(0, 0%, 96%);
  --muted-foreground: hsl(0, 0%, 40%);
  --red: hsl(0, 84%, 60%);
  --red-bg: hsl(0, 84%, 97%);
  --radius-3xl: 24px;
  --radius-2xl: 16px;
  --radius-xl: 12px;
  --radius-full: 9999px;
  --font: 'Cairo', sans-serif;
  --sidebar-width: 340px;
}

html.dark {
  --background: hsl(0, 0%, 7%);
  --foreground: hsl(0, 0%, 100%);
  --border: hsl(0, 0%, 20%);
  --input: hsl(0, 0%, 15%);
  --ring: hsl(0, 0%, 100%);
  --primary: hsl(0, 0%, 100%);
  --primary-foreground: hsl(0, 0%, 0%);
  --muted: hsl(0, 0%, 12%);
  --muted-foreground: hsl(0, 0%, 60%);
  --red-bg: hsl(0, 84%, 10%);
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--background);
  color: var(--foreground);
  direction: rtl;
  overscroll-behavior: none;
}

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

[hidden] {
  display: none !important;
}

/* Loading Screen */
.loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--background);
  z-index: 1000;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.loading-screen.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.loading-ring {
  position: relative;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ping-ring {
  position: absolute;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--border);
  animation: ping 1.5s cubic-bezier(0, 0, 0.2, 1) infinite;
  opacity: 0.3;
}

@keyframes ping {
  75%, 100% { transform: scale(1.5); opacity: 0; }
}

.logo-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--foreground);
  background: var(--background);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  z-index: 1;
}

.logo-circle span {
  font-size: 40px;
  font-weight: 700;
  color: var(--foreground);
  user-select: none;
}

.loading-screen h1 {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.loading-screen p {
  font-size: 14px;
  color: var(--muted-foreground);
  margin-top: -4px;
}

.loading-dots {
  display: flex;
  gap: 6px;
  margin-top: 16px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--foreground);
  opacity: 0.4;
  animation: bounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* App Layout — Desktop */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: 1fr;
  height: 100vh;
  height: 100dvh;
  width: 100%;
  background: var(--background);
  color: var(--foreground);
  overflow: hidden;
}

.main-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  background: var(--background);
  border-left: 1px solid var(--border);
  z-index: 10;
  overflow: hidden;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 20px;
  font-weight: 700;
  font-family: var(--font);
}

.sidebar-top .header-btn {
  display: none;
}

.sidebar-new {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.new-chat-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px;
  border-radius: var(--radius-2xl);
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: opacity 0.2s;
}

.new-chat-btn:hover {
  opacity: 0.9;
}

.new-chat-btn svg {
  width: 20px;
  height: 20px;
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  min-height: 0;
}

.sidebar-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-foreground);
  margin-bottom: 12px;
  padding: 0 8px;
}

.conversation-item {
  width: 100%;
  text-align: right;
  padding: 12px;
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 6px;
}

.conversation-item:hover {
  background: rgba(128,128,128,0.05);
}

.conversation-item.active {
  background: var(--muted);
  border-color: var(--border);
  color: var(--foreground);
}

.empty-conversations {
  text-align: center;
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 32px;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.profile-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-2xl);
  border: 1px solid transparent;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.2s;
  text-align: right;
}

.profile-btn:hover {
  background: var(--muted);
  border-color: var(--border);
  box-shadow: 0 0 24px rgba(0, 0, 0, 0.08);
}

.dark .profile-btn:hover {
  box-shadow: 0 0 24px rgba(255, 255, 255, 0.08);
}

.profile-btn:hover .profile-avatar {
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.25);
}

.profile-btn:active {
  transform: scale(0.98);
}

.profile-btn > svg:last-child {
  transition: transform 0.2s ease;
}

.profile-btn:hover > svg:last-child {
  transform: rotate(45deg);
}

.profile-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-info {
  flex: 1;
  min-width: 0;
}

.profile-name {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-plan {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-foreground);
}

.profile-btn > svg:last-child {
  width: 18px;
  height: 18px;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
}

/* Header */
.app-header {
  display: none;
}

.header-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.2s;
  margin: -8px;
}

.header-btn:hover {
  background: var(--muted);
}

.header-btn svg {
  width: 24px;
  height: 24px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font);
}

.header-spacer {
  width: 24px;
}

/* Chat Scroll */
.chat-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  scroll-behavior: smooth;
  min-height: 0;
}

/* Greeting */
.greeting {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  min-height: 0;
}

.greeting-logo {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.greeting-logo span {
  font-size: 32px;
  font-weight: 700;
  color: var(--foreground);
}

.greeting h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 12px;
}

.greeting p {
  font-size: 16px;
  font-weight: 700;
  color: var(--muted-foreground);
  max-width: 480px;
}

/* Messages */
.messages {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

.message {
  display: flex;
  max-width: 85%;
  width: fit-content;
  padding: 16px;
  font-size: 15px;
  line-height: 1.7;
  white-space: pre-wrap;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.message.user {
  align-self: flex-start;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: var(--radius-3xl);
  border-top-right-radius: 4px;
}

.message.assistant {
  align-self: flex-end;
  background: var(--muted);
  color: var(--foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-3xl);
  border-top-left-radius: 4px;
  max-width: 95%;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message-body {
  width: 100%;
}

.message-body p {
  margin: 0 0 8px 0;
}

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

.message-body strong {
  display: block;
  margin-top: 16px;
  margin-bottom: 6px;
  font-weight: 700;
  font-size: 15px;
}

.message-body strong:first-child {
  margin-top: 0;
}

/* Articles Accordion */
.articles-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
  background: none;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  margin-top: 4px;
}

.articles-toggle svg {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}

.articles-toggle.open svg {
  transform: rotate(180deg);
}

.articles-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  overflow: hidden;
}

.article-card {
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.article-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.article-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
}

.article-law {
  font-size: 13px;
  color: var(--muted-foreground);
}

.article-link {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--foreground);
  text-decoration: underline;
  white-space: nowrap;
}

.article-link:hover {
  opacity: 0.7;
}

.article-explanation {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* Analyzing Card */
.analyzing {
  align-self: flex-end;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-3xl);
  border-top-left-radius: 4px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.analyzing-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  font-weight: 700;
}

.analyzing-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.analyzing-fill {
  height: 100%;
  background: var(--primary);
  width: 0%;
  transition: width 0.1s linear;
}

.analyzing-step {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted-foreground);
}

/* Input */
.input-wrapper {
  flex-shrink: 0;
  padding: 20px 32px;
  background: var(--background);
  border-top: 1px solid var(--border);
  pointer-events: auto;
}

.input-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 1000px;
  margin: 0 auto;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 8px 8px 8px 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  pointer-events: auto;
}

.input-box textarea {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  padding: 10px 8px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--foreground);
}

.input-box textarea::placeholder {
  color: var(--muted-foreground);
}

.send-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.2s;
}

.send-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.send-btn svg {
  width: 20px;
  height: 20px;
  transform: scaleX(-1);
  margin-left: 2px;
}

/* Drawer Overlay */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 40;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

/* Drawer — Desktop Modal */
.drawer {
  position: fixed;
  top: 50%;
  left: 50%;
  right: auto;
  bottom: auto;
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  z-index: 50;
  background: var(--background);
  border-radius: var(--radius-3xl);
  padding: 24px 32px 32px;
  display: flex;
  flex-direction: column;
  transform: translate(calc(-50% + 0px), calc(-50% + var(--drag-y, 0px))) scale(0.96);
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0s linear 0.3s;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  border: 1px solid var(--border);
  --drag-y: 0px;
  touch-action: none;
  will-change: transform, opacity;
  pointer-events: none;
}

.drawer.open {
  transform: translate(calc(-50% + 0px), calc(-50% + var(--drag-y, 0px))) scale(1);
  opacity: 1;
  visibility: visible;
  transition: transform 0.3s ease, opacity 0.3s ease, visibility 0s linear 0s;
  pointer-events: auto;
}

.drawer.is-dragging {
  transition: none;
}

.drawer-handle {
  display: none;
}

.drawer-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
  font-family: var(--font);
}

/* Specialty Grid */
.specialty-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 0 4px 16px;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

.specialty-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-radius: var(--radius-3xl);
  border: 1px solid var(--border);
  background: var(--muted);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.specialty-card:hover {
  background: var(--border);
  border-color: var(--border);
}

.specialty-card .emoji {
  font-size: 32px;
  line-height: 1;
}

.specialty-card .label {
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  color: var(--foreground);
}

/* Settings */
.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.settings-label {
  font-size: 14px;
  font-weight: 700;
}

.settings-input,
.settings-textarea {
  width: 100%;
  background: var(--input);
  border: 1px solid transparent;
  border-radius: var(--radius-2xl);
  padding: 0 20px;
  height: 56px;
  font-size: 14px;
  outline: none;
  color: var(--foreground);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.settings-input:focus,
.settings-textarea:focus {
  border-color: var(--border);
  box-shadow: 0 0 0 2px var(--border);
}

.settings-input::placeholder,
.settings-textarea::placeholder {
  color: var(--muted-foreground);
}

.settings-input[readonly] {
  background: transparent;
  border-color: var(--border);
  color: var(--muted-foreground);
  cursor: not-allowed;
}

.settings-textarea {
  height: 112px;
  padding: 16px 20px;
  resize: none;
}

.theme-toggle {
  display: flex;
  gap: 8px;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 4px;
}

.theme-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-xl);
  border: none;
  background: transparent;
  color: var(--muted-foreground);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.theme-btn.active {
  background: var(--background);
  color: var(--foreground);
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.save-btn {
  width: 100%;
  height: 56px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.1s;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.save-btn:hover {
  opacity: 0.9;
}

.save-btn:active {
  transform: scale(0.98);
}

.logout-btn {
  width: 100%;
  height: 56px;
  border-radius: var(--radius-full);
  border: 1px solid var(--red);
  background: var(--background);
  color: var(--red);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
}

.logout-btn:hover {
  background: var(--red);
  color: var(--background);
}

.logout-btn svg {
  transform: scaleX(-1);
  width: 20px;
  height: 20px;
}

/* Auth Pages */
.auth-page {
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--background);
  color: var(--foreground);
}

.auth-logo {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 2px solid var(--foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 16px;
}

.auth-logo span {
  font-size: 32px;
  font-weight: 700;
}

.auth-title {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
  text-align: center;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--muted-foreground);
  margin-bottom: 24px;
  text-align: center;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-input {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--muted);
  padding: 0 20px;
  font-size: 14px;
  outline: none;
  color: var(--foreground);
  transition: border-color 0.2s;
}

.auth-input:focus {
  border-color: var(--foreground);
}

.auth-input::placeholder {
  color: var(--muted-foreground);
}

.auth-btn {
  width: 100%;
  height: 48px;
  border-radius: var(--radius-full);
  border: none;
  background: var(--foreground);
  color: var(--background);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-top: 4px;
}

.auth-btn:hover {
  opacity: 0.9;
}

.google-btn {
  width: 100%;
  max-width: 360px;
  height: 48px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border);
  background: var(--background);
  color: var(--foreground);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 8px;
}

.google-btn:hover {
  background: var(--muted);
}

.divider {
  width: 100%;
  max-width: 360px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 16px 0;
  color: var(--muted-foreground);
  font-size: 14px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-link {
  margin-top: 20px;
  font-size: 14px;
  color: var(--muted-foreground);
  text-decoration: none;
  text-align: center;
}

.auth-link span {
  font-weight: 700;
  text-decoration: underline;
  color: var(--foreground);
}

.auth-error {
  font-size: 13px;
  color: var(--red);
  text-align: center;
  padding: 0 8px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--muted-foreground);
}

/* Mobile */
@media (max-width: 920px) {
  :root {
    --sidebar-width: 288px;
  }

  .app {
    display: flex;
    flex-direction: column;
  }

  .main-content {
    height: 100dvh;
  }

  .app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(var(--background-rgb), 0.9);
    backdrop-filter: blur(8px);
    flex-shrink: 0;
    z-index: 10;
  }

  .sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    width: var(--sidebar-width);
    border-left: none;
    border-right: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 50;
  }

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

  .sidebar-top .header-btn {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

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

  .chat-scroll {
    padding: 16px;
    padding-bottom: 120px;
  }

  .greeting h2 {
    font-size: 24px;
  }

  .greeting p {
    font-size: 14px;
  }

  .messages,
  .analyzing {
    max-width: 100%;
  }

  .input-wrapper {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    padding-bottom: 24px;
    background: linear-gradient(to top, var(--background) 60%, transparent);
    border-top: none;
    pointer-events: none;
    z-index: 10;
  }

  .input-box {
    max-width: 800px;
  }

  .input-box textarea {
    font-size: 14px;
    max-height: 128px;
  }

  .message {
    font-size: 14px;
  }

  .message-body strong {
    font-size: 14px;
  }

  .specialty-grid {
    max-width: 100%;
  }

  .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-3xl) var(--radius-3xl) 0 0;
    padding: 12px 16px 32px;
    transform: translateY(calc(100% + var(--drag-y, 0px)));
    opacity: 1;
  }

  .drawer.open {
    transform: translateY(var(--drag-y, 0px));
  }

  .drawer-handle {
    display: block;
    width: 48px;
    height: 5px;
    border-radius: var(--radius-full);
    background: var(--border);
    margin: 0 auto 24px;
    flex-shrink: 0;
  }
}

/* Helper for background rgb in rgba */
html {
  --background-rgb: 255, 255, 255;
}

html.dark {
  --background-rgb: 18, 18, 18;
}
