:root {
  --bg-main: #050509;
  --bg-elevated: #11121a;
  --bg-elevated-soft: #171827;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.16);
  --accent-strong: #22d3ee;
  --danger: #f97373;
  --text-main: #f9fafb;
  --text-soft: #9ca3af;
  --border-subtle: rgba(148, 163, 184, 0.35);
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-pill: 999px;
  --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.8);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  font-family: 'Tajawal', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: radial-gradient(circle at top, #020617, #020617 40%, #020617 100%);
  color: var(--text-main);
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image: linear-gradient(to right, rgba(148, 163, 184, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(148, 163, 184, 0.06) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: 0.4;
  pointer-events: none;
  z-index: -2;
}

.bg-glow {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 10% 0%, rgba(56, 189, 248, 0.25), transparent 50%),
    radial-gradient(circle at 90% 90%, rgba(249, 115, 22, 0.18), transparent 55%);
  filter: blur(40px);
  opacity: 0.75;
  pointer-events: none;
  z-index: -3;
}

.btn {
  border: none;
  border-radius: var(--radius-pill);
  padding: 0.75rem 1.3rem;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.18s ease;
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
}

.btn.primary {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.btn.primary:hover {
  background: rgba(56, 189, 248, 0.18);
}

.btn.accent {
  background: linear-gradient(120deg, #22c55e, #22d3ee);
  color: #0b1220;
  box-shadow: 0 12px 32px rgba(34, 211, 238, 0.4);
}

.btn.accent:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 16px 40px rgba(34, 211, 238, 0.55);
}

.btn.ghost {
  background: transparent;
  border: 1px solid rgba(148, 163, 184, 0.5);
  color: var(--text-main);
}

.btn.ghost:hover {
  background: rgba(15, 23, 42, 0.7);
}

.btn.icon span {
  margin-inline-start: 0.3rem;
}

.btn.full {
  width: 100%;
}

.btn.tiny {
  padding: 0.45rem 0.9rem;
  font-size: 0.88rem;
}

.toast {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-main);
  padding: 0.7rem 1.2rem;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(148, 163, 184, 0.55);
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: all 0.18s ease;
  z-index: 40;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.page-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.auth-layout {
  width: 100%;
  max-width: 480px;
  padding: 1.5rem;
}

.auth-card {
  background: radial-gradient(circle at top left, rgba(56, 189, 248, 0.15), transparent 40%),
    radial-gradient(circle at bottom right, rgba(249, 115, 22, 0.1), transparent 45%),
    rgba(15, 23, 42, 0.95);
  border-radius: 24px;
  padding: 1.8rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(148, 163, 184, 0.45);
  backdrop-filter: blur(22px);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 1.2rem;
}

.logo-mark {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  background: radial-gradient(circle at 20% 0%, #22d3ee, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: 0.06em;
  color: #0f172a;
}

.logo-mark img {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  object-fit: cover;
  display: block;
}

.auth-header h1 {
  margin: 0;
  font-size: 1.3rem;
}

.auth-header p {
  margin: 0.1rem 0 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.auth-form h2 {
  margin: 0 0 0.7rem;
  font-size: 1.1rem;
}

.auth-note {
  margin: 0 0 1rem;
  color: var(--text-soft);
  font-size: 0.86rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-bottom: 0.9rem;
}

.field span {
  font-size: 0.86rem;
  color: var(--text-soft);
}

.field input {
  border-radius: var(--radius-md);
  border: 1px solid rgba(148, 163, 184, 0.6);
  padding: 0.65rem 0.8rem;
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-family: inherit;
  outline: none;
  font-size: 0.92rem;
}

.field input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.4);
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.6rem 0 0.9rem;
  color: var(--text-soft);
  font-size: 0.8rem;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(148, 163, 184, 0.4);
}

.hint {
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--text-soft);
}

.auth-footer {
  margin-top: 1.4rem;
  font-size: 0.8rem;
  color: var(--text-soft);
  text-align: center;
}

.page-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: linear-gradient(to bottom, rgba(15, 23, 42, 0.98), rgba(15, 23, 42, 0.9));
  border-bottom: 1px solid rgba(30, 64, 175, 0.7);
  backdrop-filter: blur(24px);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-weight: 700;
  font-size: 0.98rem;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.nav-link {
  font-size: 0.9rem;
  color: var(--text-soft);
  text-decoration: none;
  padding: 0.35rem 0.7rem;
  border-radius: var(--radius-pill);
  transition: all 0.18s ease;
}

.nav-link:hover {
  color: var(--text-main);
  background: rgba(30, 64, 175, 0.4);
}

.nav-link.active {
  color: #bfdbfe;
  background: rgba(30, 64, 175, 0.8);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.plan-pill {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(52, 211, 153, 0.5);
  background: rgba(15, 118, 110, 0.24);
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  color: #a7f3d0;
}

.avatar-btn {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.6);
  background: radial-gradient(circle at top, #38bdf8, #1e293b);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0b1220;
  font-weight: 800;
  cursor: pointer;
}

.shell-main {
  flex: 1;
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
}

.sidebar {
  width: 260px;
  min-width: 220px;
  max-width: 280px;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 20px;
  border: 1px solid rgba(31, 41, 55, 0.95);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.sidebar.narrow {
  width: 230px;
}

.sidebar h2 {
  margin: 0 0 0.4rem;
  font-size: 0.98rem;
}

.conv-list {
  flex: 1;
  overflow-y: auto;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.conv-item {
  border-radius: 14px;
  border: 1px solid rgba(55, 65, 81, 0.8);
  padding: 0.5rem 0.6rem;
  background: rgba(15, 23, 42, 0.95);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  transition: all 0.16s ease;
}

.conv-item:hover {
  border-color: rgba(59, 130, 246, 0.7);
  background: rgba(15, 23, 42, 1);
}

.conv-item-title {
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-item-meta {
  font-size: 0.75rem;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
}

.quota-box {
  margin-top: 0.6rem;
  border-radius: 16px;
  border: 1px dashed rgba(148, 163, 184, 0.7);
  padding: 0.6rem 0.7rem;
  background: rgba(15, 23, 42, 0.9);
}

.quota-box h3 {
  margin: 0 0 0.3rem;
  font-size: 0.9rem;
}

.quota-line {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.quota-bar {
  margin-top: 0.4rem;
  height: 7px;
  border-radius: 999px;
  background: rgba(30, 64, 175, 0.7);
  overflow: hidden;
}

.quota-fill {
  height: 100%;
  width: 12%;
  border-radius: inherit;
  background: linear-gradient(90deg, #22c55e, #22d3ee);
}

.quota-label {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-soft);
  display: flex;
  justify-content: space-between;
}

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-card {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(135deg, rgba(30, 64, 175, 0.95), rgba(8, 47, 73, 0.98));
  border-radius: 24px;
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow-soft);
}

.hero-card h1 {
  margin: 0 0 0.4rem;
  font-size: 1.4rem;
}

.hero-card p {
  margin: 0;
  font-size: 0.88rem;
  color: #e5e7eb;
}

.hero-tags {
  margin-top: 0.7rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.tag {
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.4);
  color: #e0f2fe;
}

.hero-badge {
  min-width: 140px;
  max-width: 170px;
  border-radius: 18px;
  border: 1px solid rgba(248, 250, 252, 0.5);
  background: rgba(15, 23, 42, 0.7);
  padding: 0.7rem 0.8rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-badge span {
  font-weight: 800;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
}

.hero-badge small {
  margin-top: 0.3rem;
  font-size: 0.75rem;
  color: #cbd5f5;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.section-header h2 {
  margin: 0;
  font-size: 1rem;
}

.link-inline {
  font-size: 0.85rem;
  color: #93c5fd;
  text-decoration: none;
}

.conv-cards {
  margin-top: 0.6rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

.conv-card {
  background: rgba(15, 23, 42, 0.95);
  border-radius: 18px;
  border: 1px solid rgba(30, 64, 175, 0.7);
  padding: 0.8rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.conv-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.9);
}

.conv-card-title {
  font-size: 0.92rem;
  font-weight: 600;
}

.conv-card-preview {
  font-size: 0.8rem;
  color: var(--text-soft);
  height: 2.2em;
  overflow: hidden;
}

.conv-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.77rem;
  color: var(--text-soft);
}

/* تخطيط شات عام (لصفحات ثانية لو استخدمته) */
.chat-layout {
  flex: 1;
  display: flex;
  gap: 1rem;
  padding: 1rem 1.5rem 1.5rem;
}

.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 22px;
  border: 1px solid rgba(31, 41, 55, 0.95);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.chat-header {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(30, 64, 175, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.chat-header h1 {
  margin: 0 0 0.2rem;
  font-size: 1.05rem;
}

.chat-header p {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-soft);
}

.chat-feed {
  flex: 1;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.message {
  max-width: 80%;
  padding: 0.75rem 0.9rem;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.7;
}

.msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(37, 99, 235, 0.9));
  color: #eff6ff;
  border-bottom-left-radius: 4px;
}

.msg-bot {
  align-self: flex-start;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(55, 65, 81, 0.9);
  border-bottom-right-radius: 4px;
}

.chat-input-area {
  border-top: 1px solid rgba(30, 64, 175, 0.7);
  padding: 0.7rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.18), rgba(15, 23, 42, 0.98));
}

.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: rgba(15, 23, 42, 0.98);
  border-radius: 999px;
  border: 1px solid rgba(55, 65, 81, 1);
  padding: 0.2rem 0.3rem 0.2rem 0.4rem;
}

#user-input {
  flex: 1;
  border: none;
  background: transparent;
  resize: none;
  padding: 0.5rem 0.7rem;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text-main);
  outline: none;
  max-height: 140px;
}

.input-hints {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-soft);
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.5rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(30, 64, 175, 0.9);
  font-size: 0.75rem;
  color: #e5e7eb;
}

.typing-indicator.hidden {
  display: none;
}

.typing-indicator .dot {
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #93c5fd;
  animation: bounce 1s infinite ease-in-out;
}

.typing-indicator .dot:nth-child(1) {
  animation-delay: 0s;
}
.typing-indicator .dot:nth-child(2) {
  animation-delay: 0.18s;
}
.typing-indicator .dot:nth-child(3) {
  animation-delay: 0.36s;
}

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

pre {
  margin: 0.4rem 0 0;
  border-radius: 14px;
  background: #020617;
  padding: 0.6rem 0.6rem 0.5rem;
  overflow-x: auto;
  position: relative;
}

pre code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-size: 0.8rem;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-inline: 0.3rem 0.4rem;
  padding-block: 0.1rem 0.3rem;
}

.code-lang {
  font-size: 0.75rem;
  color: #a5b4fc;
}

.copy-btn {
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.7);
  background: transparent;
  color: #e5e7eb;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  cursor: pointer;
}

.copy-btn:hover {
  background: rgba(30, 64, 175, 0.7);
}

/* Billing */

.billing-layout {
  flex: 1;
  padding: 1.2rem 1.5rem 1.8rem;
  max-width: 1040px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.billing-hero h1 {
  margin: 0 0 0.3rem;
  font-size: 1.4rem;
}

.billing-hero p {
  margin: 0;
  color: var(--text-soft);
  font-size: 0.9rem;
}

.billing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
  margin-top: 0.7rem;
}

.plan-card {
  border-radius: 22px;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(31, 41, 55, 0.95);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.plan-card.free {
  background: radial-gradient(circle at top, rgba(56, 189, 248, 0.15), transparent 60%), rgba(15, 23, 42, 0.96);
}

.plan-card.pro {
  background: radial-gradient(circle at top, rgba(34, 197, 94, 0.18), transparent 60%), rgba(15, 23, 42, 0.96);
}

.plan-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.plan-price {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.plan-list {
  list-style: none;
  padding: 0;
  margin: 0.3rem 0 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.83rem;
  color: #e5e7eb;
}

.plan-list li::before {
  content: '• ';
  color: #38bdf8;
}

.billing-note {
  font-size: 0.78rem;
  color: var(--text-soft);
}

/* ريسبونسف عام */

@media (max-width: 900px) {
  .shell-main,
  .chat-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-width: none;
    order: 2;
  }

  .chat-section,
  .content {
    order: 1;
  }
}

@media (max-width: 720px) {
  .topbar {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .topbar-nav {
    order: 3;
    width: 100%;
    justify-content: center;
  }

  .topbar-right {
    margin-inline-start: auto;
  }

  .hero-card {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.4rem 1rem 1.2rem;
  }

  .shell-main,
  .chat-layout,
  .billing-layout {
    padding-inline: 0.9rem;
  }

  .chat-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .message {
    max-width: 100%;
  }

  .conv-delete {
    background: transparent;
    border: none;
    color: #ff8da1;
    cursor: pointer;
    font-size: 0.85rem;
  }
  .conv-delete:hover {
    color: #ff4d6a;
  }

  .thinking .dot {
    width: 6px;
    height: 6px;
    background: #aaa;
    border-radius: 50%;
    display: inline-block;
    margin: 0 2px;
    animation: blink 1s infinite alternate;
  }
  .thinking .dot:nth-child(2) { animation-delay: .2s; }
  .thinking .dot:nth-child(3) { animation-delay: .4s; }

  @keyframes blink {
    from { opacity: .3; transform: translateY(0); }
    to   { opacity: 1; transform: translateY(-2px); }
  }
}

/* كروت إحصائيات الادمن */

.admin-stats-card {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border-radius: 0.9rem;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.admin-stats-card h2 {
  font-size: 0.95rem;
  margin-bottom: 0.3rem;
  color: #e5e7eb;
}

.admin-stats-values {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.admin-stat-pill {
  font-size: 0.8rem;
  color: #cbd5f5;
  background: rgba(37, 99, 235, 0.18);
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}

/* سويتش اختيار الموديل */

.model-switch {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  font-size: 0.8rem;
}

.model-switch label {
  color: #9ca3af;
}

.model-switch select {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  color: #e5e7eb;
  outline: none;
}

.model-switch select:focus {
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.35);
}

/* تحسين شكل لوقو */

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 0.85rem;
}

/* موبايل auth/chat/billing */

@media (max-width: 480px) {

  body {
    font-size: 14px;
  }

  .page-auth {
    align-items: flex-start;
  }

  .auth-layout {
    padding: 0.75rem;
    max-width: 100%;
  }

  .auth-card {
    margin-top: 1rem;
    border-radius: 18px;
    padding: 1.25rem 1rem 1rem;
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.6);
  }

  .auth-header {
    gap: 0.6rem;
  }

  .auth-header h1 {
    font-size: 1rem;
  }

  .auth-header p {
    font-size: 0.8rem;
  }

  .auth-form h2 {
    font-size: 0.95rem;
  }

  .form-row {
    gap: 0.5rem;
  }

  .form-row label {
    font-size: 0.8rem;
  }

  .form-row input {
    font-size: 0.85rem;
    padding: 0.55rem 0.7rem;
  }

  .btn-primary {
    padding: 0.55rem 0.8rem;
    font-size: 0.9rem;
  }

  .shell-main,
  .chat-layout,
  .billing-layout {
    padding-inline: 0.75rem;
    padding-block: 0.75rem;
  }

  .sidebar {
    margin-bottom: 0.75rem;
  }

  .chat-main {
    padding: 0.75rem;
  }

  .chat-message {
    max-width: 100%;
  }
}

@media (min-width: 481px) and (max-width: 900px) {
  .auth-layout {
    max-width: 420px;
    padding: 1rem;
  }

  .auth-card {
    padding: 1.5rem 1.2rem 1.2rem;
  }

  .logo-mark {
    width: 34px;
    height: 34px;
  }
}


.model-switch {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-pill);
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.55);
}

.model-switch label {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.model-switch select {
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  padding: 0;
}


.plan-pill {
  border-radius: var(--radius-pill);
  border: 1px solid rgba(52, 211, 153, 0.5);
  background: rgba(15, 118, 110, 0.24);
  padding: 0.25rem 0.7rem;
  font-size: 0.8rem;
  color: #a7f3d0;
  white-space: nowrap;
}


@media (max-width: 768px) {

  .shell-main {
    padding: 0.6rem;
  }

  .chat-layout {
    flex-direction: column;
    gap: 0.7rem;
    padding: 0;
  }

  .sidebar {
    width: 100%;
    max-width: none;
    padding: 0.7rem 0.8rem;
    border-radius: 16px;
    box-shadow: none;
    order: 2;
  }

  .chat-section {
    order: 1;
    border-radius: 18px;
    box-shadow: none;
  }

  .chat-header {
    padding: 0.6rem 0.8rem 0.4rem;
  }

  .chat-header h1 {
    font-size: 0.95rem;
  }

  .chat-header p {
    font-size: 0.8rem;
  }

  .chat-feed {
    padding: 0.7rem 0.8rem;
  }

  .chat-input-area {
    padding: 0.5rem 0.8rem 0.7rem;
    gap: 0.3rem;
  }

  .input-wrapper textarea {
    font-size: 0.88rem;
    min-height: 44px;
    max-height: 140px;
  }

  .message {
    max-width: 100%;
    font-size: 0.88rem;
    padding: 0.6rem 0.75rem;
  }

  .conv-item {
    padding: 0.4rem 0.5rem;
    font-size: 0.82rem;
  }

  .conv-item-title {
    font-size: 0.82rem;
  }

  .conv-item-meta {
    font-size: 0.75rem;
  }
}


body.chat-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body.chat-page .page-main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 1rem 1.5rem 1.5rem;
  min-height: 0;           
}

body.chat-page .chat-section {
  flex: 1;
  width: 100%;
  max-width: 1400px;       
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.96);
  border-radius: 22px;
  border: 1px solid rgba(31, 41, 55, 0.95);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

body.chat-page .chat-header {
  flex-shrink: 0;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(30, 64, 175, 0.6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

body.chat-page .chat-feed {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

body.chat-page .chat-input-area {
  flex-shrink: 0;
  border-top: 1px solid rgba(30, 64, 175, 0.7);
  padding: 0.7rem 0.9rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: radial-gradient(circle at top, rgba(37, 99, 235, 0.18), rgba(15, 23, 42, 0.98));
}

@media (max-width: 768px) {
  body.chat-page .page-main {
    padding: 0.75rem;
  }

  body.chat-page .chat-section {
    max-width: 100%;
  }

  /* ===== أنيميشن الخلفية الناعمة ===== */
.bg-glow {
  animation: glowFloat 18s ease-in-out infinite alternate;
}

@keyframes glowFloat {
  0% {
    opacity: 0.45;
    transform: translate3d(0, 0, 0) scale(1);
    filter: blur(40px);
  }
  50% {
    opacity: 0.9;
    transform: translate3d(0, -14px, 0) scale(1.05);
    filter: blur(46px);
  }
  100% {
    opacity: 0.5;
    transform: translate3d(0, 6px, 0) scale(1.08);
    filter: blur(52px);
  }
}

/* ===== أنيميشن ظهور الرسائل ===== */
.message-row {
  animation: chatFadeIn 0.22s ease-out;
  transform-origin: bottom;
}

@keyframes chatFadeIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}



/* ===== هوفر الأزرار (إرسال / الأزرار الرئيسية) ===== */
.btn,
button,
.chat-input-area .btn {
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease,
    border-color 0.15s ease;
}

.btn.primary:hover,
.btn.accent:hover,
.btn.icon:hover {
  transform: translateY(-1px) scale(1.01);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.7);
}

/* لمسات بسيطة على زر الإرسال في الشات */
body.chat-page #send-button {
  border-radius: 999px;
}

body.chat-page #send-button span {
  font-size: 0.85rem;
}

/* هوفر خفيف على العناصر في قائمة المحادثات */
.conv-item {
  transition:
    background 0.15s ease,
    transform 0.15s ease,
    border-color 0.15s ease;
}

.conv-item:hover {
  background: rgba(15, 23, 42, 0.8);
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.7);
}

}
