/* مساعد الطيبات — ai.mytayibat.com
   هوية الموقع الرئيسي · ديسكتوب ≠ موبايل · 2026-07 */

:root {
  --mt-green-950: #0d2818;
  --mt-green-900: #1b4332;
  --mt-green-800: #2d6a4f;
  --mt-green-600: #40916c;
  --mt-green-500: #52b788;
  --mt-green-100: #d8f3dc;
  --mt-green-50: #f0faf4;
  --mt-gold: #c9a227;
  --mt-gold-soft: #e8d48b;
  --mt-ink: #14261c;
  --mt-muted: #5a6f63;
  --mt-line: rgba(27, 67, 50, 0.12);
  --mt-surface: #ffffff;
  --mt-surface-2: #f7fbf8;
  --mt-danger: #b42318;
  --mt-radius: 18px;
  --mt-radius-sm: 12px;
  --mt-shadow: 0 8px 32px rgba(13, 40, 24, 0.1);
  --mt-shadow-lg: 0 20px 50px rgba(13, 40, 24, 0.14);
  --mt-font: "Tajawal", system-ui, sans-serif;
  --mt-safe-b: env(safe-area-inset-bottom, 0px);
  --mt-safe-t: env(safe-area-inset-top, 0px);
  --mt-header-h: 48px;
  color-scheme: light;
}

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

html {
  height: 100%;
  height: 100dvh;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--mt-font);
  color: var(--mt-ink);
  background: var(--mt-green-50);
  line-height: 1.65;
  overflow: hidden;
}

a {
  color: var(--mt-green-800);
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--mt-green-600);
}

button,
textarea {
  font: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* ═══════════ Shell ═══════════ */
.mt-studio {
  display: grid;
  height: 100dvh;
  height: 100svh;
  position: relative;
  isolation: isolate;
}

.mt-studio__bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 100% 0%, rgba(82, 183, 136, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 40% at 0% 100%, rgba(201, 162, 39, 0.12), transparent 50%),
    linear-gradient(165deg, #eef8f1 0%, #f7fbf8 45%, #e8f5ee 100%);
}

.mt-studio__bg-pattern {
  position: absolute;
  inset: 0;
  opacity: 0.04;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 8c4 8 12 12 12 22s-8 14-12 22c-4-8-12-12-12-22s8-14 12-22z' fill='%231B4332' fill-opacity='.5'/%3E%3C/svg%3E");
  background-size: 48px 48px;
}

.mt-studio__inner {
  position: relative;
  z-index: 1;
  display: grid;
  height: 100%;
  min-height: 0;
}

/* ═══════════ Top bar (shared) ═══════════ */
.mt-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(6px + var(--mt-safe-t)) 12px 6px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--mt-line);
  min-height: var(--mt-header-h);
}

.mt-topbar__logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.mt-topbar__brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
  color: var(--mt-green-900);
}

.mt-topbar__brand strong {
  font-size: 0.95rem;
  font-weight: 800;
}

.mt-topbar__brand small {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--mt-muted);
}

.mt-topbar__logo img {
  height: 36px;
  width: auto;
  max-width: min(160px, 42vw);
  display: block;
}

.mt-topbar__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--mt-green-800);
  background: var(--mt-green-100);
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

.mt-topbar__badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  animation: mt-pulse 2s ease-in-out infinite;
}

@keyframes mt-pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

.mt-topbar__spacer {
  flex: 1;
}

.mt-topbar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mt-icon-btn {
  appearance: none;
  border: 1px solid var(--mt-line);
  background: var(--mt-surface);
  color: var(--mt-green-900);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.mt-icon-btn:hover {
  background: var(--mt-green-50);
  border-color: rgba(45, 106, 79, 0.28);
}

.mt-icon-btn:active {
  transform: scale(0.96);
}

.mt-link-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px;
  border-radius: 10px;
  border: 1px solid var(--mt-line);
  background: var(--mt-surface);
  color: var(--mt-green-900);
  font-weight: 700;
  font-size: 0.8rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.mt-link-btn:hover {
  background: var(--mt-green-50);
}

.mt-link-btn--primary {
  background: var(--mt-green-900);
  color: #fff;
  border-color: var(--mt-green-900);
}

.mt-link-btn--primary:hover {
  background: var(--mt-green-800);
  color: #fff;
}

/* ═══════════ DESKTOP (≥901px) ═══════════ */
@media (min-width: 901px) {
  .mt-studio__inner {
    grid-template-columns: 240px minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
    padding: 12px 18px 16px;
    gap: 12px;
  }

  .mt-topbar {
    grid-column: 1 / -1;
    border-radius: 14px;
    box-shadow: var(--mt-shadow);
    padding: 6px 14px;
    border: 1px solid var(--mt-line);
    min-height: 44px;
  }

  .mt-topbar__logo img {
    display: none;
  }

  /* Sidebar — أصغر وأخف */
  .mt-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 0;
    align-self: start;
    max-height: calc(var(--app-height, 100dvh) - 72px);
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid var(--mt-line);
    border-radius: 14px;
    box-shadow: var(--mt-shadow);
    padding: 12px;
    overflow: auto;
  }

  .mt-sidebar__hero {
    text-align: right;
    padding: 0 2px 2px;
  }

  .mt-sidebar__mark {
    display: none;
  }

  .mt-sidebar__title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--mt-green-900);
  }

  .mt-sidebar__sub,
  .mt-sidebar__section-label,
  .mt-sidebar__legal {
    display: none;
  }

  .mt-sidebar__topics {
    display: flex;
    flex-direction: column;
    gap: 5px;
  }

  .mt-topic {
    appearance: none;
    text-align: right;
    width: 100%;
    border: 1px solid var(--mt-line);
    background: var(--mt-surface-2);
    color: var(--mt-ink);
    padding: 7px 10px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.8rem;
    transition: border-color 0.2s, background 0.2s, transform 0.15s;
  }

  .mt-topic:hover {
    border-color: var(--mt-green-500);
    background: #fff;
    transform: translateX(-2px);
  }

  .mt-sidebar__cta {
    margin-top: 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 8px;
    border-top: 1px dashed var(--mt-line);
  }

  .mt-sidebar__cta .mt-link-btn {
    justify-content: center;
    padding: 6px 8px;
    font-size: 0.75rem;
  }

  /* Mobile-only chrome hidden on desktop */
  .mt-mobile-only {
    display: none !important;
  }

  /* Chat panel */
  .mt-chat {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid var(--mt-line);
    border-radius: var(--mt-radius);
    box-shadow: var(--mt-shadow-lg);
    overflow: hidden;
  }

  .mt-chat__head {
    display: none !important;
  }

  .mt-chat__head-avatar,
  .mt-chat__head-title,
  .mt-chat__head-meta {
    display: none !important;
  }

  .mt-chat__messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 18px 20px;
    scroll-behavior: smooth;
    background:
      linear-gradient(180deg, rgba(240, 250, 244, 0.5), transparent 80px),
      var(--mt-surface);
  }

  .mt-chat__composer-wrap {
    padding: 12px 16px calc(12px + var(--mt-safe-b));
    border-top: 1px solid var(--mt-line);
    background: #fff;
  }

  .mt-chat__toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
    background: #fff;
  }
}

/* ═══════════ MOBILE (≤900px) — تجربة تطبيق مستقلة ≠ ديسكتوب ═══════════ */
@media (max-width: 900px) {
  .mt-desktop-only {
    display: none !important;
  }

  html,
  body {
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
    overscroll-behavior: none;
  }

  body {
    background: #eef6f1;
  }

  .mt-studio {
    position: fixed;
    left: 0;
    right: 0;
    top: var(--app-offset-top, 0px);
    width: 100%;
    height: var(--app-height, 100dvh);
    max-height: var(--app-height, 100dvh);
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .mt-studio__bg {
    background:
      linear-gradient(180deg, #1b4332 0%, #1b4332 56px, transparent 56px),
      #eef6f1;
  }

  .mt-studio__bg-pattern {
    opacity: 0.025;
  }

  .mt-studio__inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    grid-template-rows: none;
    grid-template-columns: none;
  }

  .mt-topbar {
    flex: 0 0 auto;
    padding: calc(6px + var(--mt-safe-t)) 10px 8px;
    background: linear-gradient(180deg, #1b4332, #244f3c);
    border-bottom: 0;
    color: #fff;
    min-height: 52px;
  }

  .mt-topbar__logo {
    color: #fff;
    text-decoration: none;
    min-width: 0;
  }

  .mt-topbar__logo-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .mt-topbar__logo-mobile img {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  }

  .mt-topbar__logo-mobile-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
  }

  .mt-topbar__logo-mobile-text strong {
    font-size: 0.9rem;
    font-weight: 800;
  }

  .mt-topbar__logo-mobile-text small {
    font-size: 0.68rem;
    opacity: 0.85;
    font-weight: 500;
  }

  .mt-topbar .mt-icon-btn {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.22);
    color: #fff;
    width: 38px;
    height: 38px;
  }

  .mt-topbar .mt-icon-btn:active {
    background: rgba(255, 255, 255, 0.22);
  }

  .mt-account-pill {
    display: none;
  }

  .mt-sidebar {
    display: none !important;
  }

  .mt-chat {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    height: auto;
    overflow: hidden;
    background: transparent;
    position: relative;
  }

  .mt-chat__head {
    display: none;
  }

  .mt-mobile-home {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px 12px 8px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .mt-mobile-home.is-hidden {
    display: none !important;
  }

  .mt-mobile-home__hero {
    text-align: center;
    padding: 4px 6px 0;
    flex-shrink: 0;
  }

  .mt-mobile-home__mark {
    width: 52px;
    height: 52px;
    margin: 0 auto 8px;
    border-radius: 16px;
    background: linear-gradient(145deg, #1b4332, #52b788);
    display: grid;
    place-items: center;
    font-size: 1.45rem;
    color: #fff;
    box-shadow: 0 10px 22px rgba(27, 67, 50, 0.25);
  }

  .mt-mobile-home__title {
    margin: 0 0 4px;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--mt-green-900);
  }

  .mt-mobile-home__sub {
    margin: 0;
    font-size: 0.8rem;
    color: var(--mt-muted);
    line-height: 1.45;
  }

  .mt-mobile-home__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mt-mcard {
    appearance: none;
    border: 1px solid rgba(27, 67, 50, 0.1);
    background: #fff;
    border-radius: 14px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(13, 40, 24, 0.05);
    min-height: 78px;
  }

  .mt-mcard span {
    font-size: 1.35rem;
    line-height: 1;
  }

  .mt-mcard strong {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--mt-green-900);
  }

  .mt-mcard:active {
    transform: scale(0.97);
    border-color: var(--mt-green-500);
  }

  .mt-mobile-home__legal {
    margin: 2px 0 0;
    text-align: center;
    font-size: 0.68rem;
    color: var(--mt-muted);
  }

  /* أثناء المحادثة: شرائح مضغوطة ثابتة لا تكبر الصفحة */
  .mt-mobile-chips {
    display: flex;
    gap: 6px;
    padding: 6px 10px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-bottom: 1px solid var(--mt-line);
    background: rgba(255, 255, 255, 0.95);
    flex: 0 0 auto;
    max-height: 44px;
  }

  .mt-chat.is-streaming .mt-mobile-chips {
    display: none !important;
  }

  .mt-mobile-chips.is-hidden {
    display: none !important;
    height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
  }

  .mt-mobile-chips[hidden] {
    display: none !important;
  }

  .mt-mobile-chips::-webkit-scrollbar {
    display: none;
  }

  .mt-chip {
    appearance: none;
    flex: 0 0 auto;
    border: 1px solid var(--mt-line);
    background: #fff;
    color: var(--mt-green-900);
    font-weight: 700;
    font-size: 0.72rem;
    padding: 5px 10px;
    border-radius: 999px;
    white-space: nowrap;
    cursor: pointer;
  }

  .mt-chat.is-chatting .mt-chat__messages {
    display: block;
  }

  .mt-chat:not(.is-chatting) .mt-chat__messages {
    display: none;
  }

  .mt-chat__messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 10px 10px 6px;
    -webkit-overflow-scrolling: touch;
    contain: layout paint;
  }

  .mt-chat__composer-wrap {
    flex: 0 0 auto;
    padding: 8px 10px calc(8px + var(--mt-safe-b));
    background: rgba(255, 255, 255, 0.98);
    border-top: 1px solid var(--mt-line);
    box-shadow: 0 -8px 20px rgba(13, 40, 24, 0.06);
    /* يمنع تمدد الفراغ تحت الحقل */
    margin: 0;
    min-height: 0;
  }

  /* لوحة المفاتيح مفتوحة: لا تترك مسافة safe-area فارغة تحت الإدخال */
  html.mt-kb-open {
    --mt-safe-b: 0px;
  }

  html.mt-kb-open .mt-chat__composer-wrap {
    padding-bottom: 6px;
  }

  html.mt-kb-open .mt-composer__meta {
    display: none;
  }

  .mt-composer {
    border-radius: 18px;
    padding: 4px 4px 4px 6px;
    background: #fff;
    border: 1.5px solid rgba(27, 67, 50, 0.14);
    grid-template-columns: auto 1fr auto;
    align-items: end;
  }

  .mt-composer__attach {
    appearance: none;
    border: 0;
    background: transparent;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--mt-green-800);
    display: grid;
    place-items: center;
    cursor: pointer;
  }

  .mt-composer__send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
  }

  .mt-composer__input {
    min-height: 40px;
    max-height: 88px;
    padding: 8px 4px;
    font-size: 0.92rem;
  }

  .mt-composer__meta {
    margin-top: 4px;
    font-size: 0.68rem;
  }

  .mt-chat__toolbar {
    display: none;
  }

  .mt-msg {
    padding: 10px 0;
  }

  .mt-msg__row {
    gap: 8px;
    padding: 0 2px;
  }

  .mt-msg__av {
    width: 30px;
    height: 30px;
    font-size: 0.8rem;
    border-radius: 50%;
  }

  .mt-msg__name {
    font-size: 0.68rem;
  }

  .mt-msg__bubble {
    max-width: min(94%, 100%);
    font-size: 0.88rem;
    padding: 10px 12px;
    line-height: 1.65;
    border-radius: 16px;
  }

  .mt-msg--user .mt-msg__bubble {
    max-width: min(88%, 100%);
  }

  .mt-msg__actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
  }

  .mt-msg__action {
    appearance: none;
    border: 1px solid var(--mt-line);
    background: var(--mt-green-50);
    color: var(--mt-green-900);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: 8px;
    cursor: pointer;
  }

  .mt-queue-banner {
    flex: 0 0 auto;
    margin: 0 10px 6px;
    padding: 8px 10px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.78rem;
    font-weight: 700;
    display: none;
  }

  .mt-queue-banner.is-on {
    display: block;
  }

  .mt-mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(13, 40, 24, 0.5);
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
    padding-bottom: calc(12px + var(--mt-safe-b));
  }

  .mt-mobile-sheet.is-open {
    display: flex;
    animation: mt-fade 0.2s ease;
  }

  @keyframes mt-fade {
    from { opacity: 0; }
    to { opacity: 1; }
  }

  .mt-mobile-sheet__panel {
    width: min(100%, 420px);
    background: #fff;
    border-radius: 22px 22px 18px 18px;
    padding: 8px 8px 12px;
    box-shadow: var(--mt-shadow-lg);
    max-height: 80dvh;
    overflow: auto;
    animation: mt-sheet-up 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes mt-sheet-up {
    from {
      transform: translateY(24px);
      opacity: 0.6;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .mt-mobile-sheet__handle {
    width: 40px;
    height: 4px;
    border-radius: 4px;
    background: #d1d5db;
    margin: 6px auto 12px;
  }

  .mt-mobile-sheet__item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    appearance: none;
    border: 0;
    background: transparent;
    padding: 14px 14px;
    border-radius: 12px;
    font-weight: 700;
    color: var(--mt-ink);
    text-decoration: none;
    cursor: pointer;
    text-align: right;
  }

  .mt-mobile-sheet__item:active {
    background: var(--mt-green-50);
  }
}

@media (min-width: 901px) {
  .mt-mobile-home,
  .mt-topbar__logo-mobile {
    display: none !important;
  }

  .mt-composer {
    grid-template-columns: auto 1fr auto;
  }

  .mt-composer__attach {
    appearance: none;
    border: 0;
    background: transparent;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    color: var(--mt-green-800);
    display: grid;
    place-items: center;
    cursor: pointer;
  }

  .mt-composer__attach:hover {
    background: var(--mt-green-50);
  }

  .mt-msg__actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
  }

  .mt-msg__action {
    appearance: none;
    border: 1px solid var(--mt-line);
    background: var(--mt-green-50);
    color: var(--mt-green-900);
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
  }

  .mt-queue-banner {
    display: none;
    margin: 0 18px 8px;
    padding: 10px 12px;
    border-radius: 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    color: #9a3412;
    font-size: 0.85rem;
    font-weight: 700;
  }

  .mt-queue-banner.is-on {
    display: block;
  }

  .mt-account-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--mt-green-100);
    color: var(--mt-green-900);
    text-decoration: none;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.mt-plan-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 12px;
  border-radius: 999px;
  background: linear-gradient(145deg, #c9a227, #e8d48b);
  color: #1b4332 !important;
  font-weight: 800;
  font-size: 0.78rem;
  text-decoration: none !important;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(201, 162, 39, 0.35);
}

.mt-plan-btn.is-hidden,
.mt-plan-btn[hidden] {
  display: none !important;
}

.mt-plan-btn:hover {
  filter: brightness(1.05);
}

@media (max-width: 900px) {
  .mt-plan-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
    background: rgba(255, 255, 255, 0.95);
    color: #1b4332 !important;
    border: 1px solid rgba(255, 255, 255, 0.4);
  }

  .mt-topbar__actions {
    gap: 6px;
  }

  .mt-account-pill {
    display: none; /* على الموبايل: خطتي ظاهرة + القائمة */
  }

  .mt-queue-banner {
    font-size: 0.72rem;
    padding: 6px 10px;
    margin: 0 10px 4px;
  }
}
}

/* ═══════════ Messages — ChatGPT-style (هوية الطيبات) ═══════════ */
.mt-msg {
  display: block;
  width: 100%;
  margin: 0;
  padding: 14px 0;
  animation: mt-msg-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.mt-msg + .mt-msg {
  border-top: 1px solid rgba(27, 67, 50, 0.06);
}

@keyframes mt-msg-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.mt-msg__row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  width: 100%;
  max-width: 820px;
  margin: 0 auto;
  padding: 0 4px;
}

.mt-msg--user .mt-msg__row {
  flex-direction: row-reverse;
}

.mt-msg__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mt-msg--user .mt-msg__body {
  align-items: flex-end;
}

.mt-msg--bot .mt-msg__body {
  align-items: flex-start;
}

.mt-msg__name {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--mt-muted);
  padding: 0 4px;
  letter-spacing: 0.01em;
}

.mt-msg__name--bot {
  color: var(--mt-green-800);
}

.mt-msg__av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--mt-green-800), var(--mt-green-500));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(27, 67, 50, 0.18);
}

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

.mt-msg__av--initials {
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(145deg, #244f3c, #40916c);
}

.mt-msg__av--user {
  background: linear-gradient(145deg, #3d4f45, #5a6f63);
}

.mt-msg__av--bot {
  background: linear-gradient(145deg, #1b4332, #52b788);
}

.mt-msg__bubble {
  max-width: min(100%, 720px);
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 0.95rem;
  line-height: 1.75;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.mt-msg--bot .mt-msg__bubble {
  background: #fff;
  border: 1px solid rgba(27, 67, 50, 0.1);
  border-top-right-radius: 6px;
  box-shadow: 0 4px 18px rgba(13, 40, 24, 0.05);
  color: var(--mt-ink);
}

.mt-msg--user .mt-msg__bubble {
  background: linear-gradient(145deg, var(--mt-green-900), var(--mt-green-800));
  color: #fff;
  border-top-left-radius: 6px;
  box-shadow: 0 6px 18px rgba(27, 67, 50, 0.2);
  max-width: min(92%, 560px);
}

.mt-msg__bubble--typing {
  padding: 14px 18px;
  min-width: 64px;
}

.mt-msg__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(27, 67, 50, 0.08);
}

.mt-msg__action {
  appearance: none;
  border: 1px solid rgba(27, 67, 50, 0.12);
  background: var(--mt-green-50);
  color: var(--mt-green-900);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.mt-msg__action:hover {
  background: var(--mt-green-100);
  border-color: rgba(45, 106, 79, 0.3);
}

.mt-msg__bubble a {
  color: var(--mt-gold);
  font-weight: 700;
}

.mt-msg--bot .mt-msg__bubble a {
  color: var(--mt-green-800);
  background: var(--mt-green-100);
  padding: 2px 8px;
  border-radius: 8px;
  text-decoration: none;
  display: inline-block;
  margin: 2px 0;
}

.mt-msg--bot .mt-msg__bubble a:hover {
  background: var(--mt-green-500);
  color: #fff;
}

.mt-account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 200px;
}

.mt-account-pill__av,
.mt-account-pill__ini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.mt-account-pill__ini {
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.25);
  color: inherit;
}

.mt-account-pill__txt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}

.mt-account-pill.is-logged-in .mt-account-pill__ini {
  background: rgba(255, 255, 255, 0.2);
}

.mt-badge {
  display: inline-flex;
  align-items: center;
  font-weight: 800;
  font-size: 0.82rem;
  padding: 5px 12px;
  border-radius: 999px;
  margin: 4px 0 8px;
}

.mt-badge--ok {
  background: #d8f3dc;
  color: #1b4332;
}

.mt-badge--warn {
  background: #fef3c7;
  color: #92400e;
}

.mt-badge--no {
  background: #fee2e2;
  color: #991b1b;
}

.mt-md-h3 {
  margin: 0.65em 0 0.35em;
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--mt-green-900);
}

.mt-md-p {
  margin: 0.35em 0;
}

.mt-md-ul {
  margin: 0.4em 0 0.6em;
  padding-right: 1.2em;
}

.mt-md-ul li {
  margin: 0.25em 0;
}

.mt-md-strong {
  color: var(--mt-green-800);
  font-weight: 800;
}

.mt-chat-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 4px 4px 4px 0;
  padding: 8px 12px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--mt-green-900), var(--mt-green-800));
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 700;
  font-size: 0.82rem;
  box-shadow: 0 4px 12px rgba(27, 67, 50, 0.2);
  transition: transform 0.15s, filter 0.15s;
}

.mt-chat-btn:hover {
  filter: brightness(1.08);
  color: #fff !important;
}

.mt-msg--bot .mt-msg__bubble a.mt-chat-btn {
  background: linear-gradient(145deg, var(--mt-green-900), var(--mt-green-800));
  color: #fff !important;
}

.mt-msg--bot .mt-msg__bubble {
  line-height: 1.7;
}

.mt-msg--user .mt-msg__bubble strong {
  color: var(--mt-gold-soft);
}

.mt-msg__bubble ul {
  margin: 0.4em 0;
  padding-right: 1.15em;
}

.mt-msg__muted {
  margin: 0.4em 0 0;
  font-size: 0.82rem;
  color: var(--mt-muted);
}

.mt-msg__welcome {
  text-align: center;
  max-width: 420px;
  margin: 24px auto 28px;
  padding: 20px 16px;
}

.mt-msg__welcome-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: linear-gradient(145deg, var(--mt-green-900), var(--mt-green-500));
  display: grid;
  place-items: center;
  font-size: 1.8rem;
  color: #fff;
  box-shadow: 0 12px 28px rgba(27, 67, 50, 0.25);
  animation: mt-float 5s ease-in-out infinite;
}

.mt-msg__welcome h2 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  color: var(--mt-green-900);
  font-weight: 800;
}

.mt-msg__welcome p {
  margin: 0;
  color: var(--mt-muted);
  font-size: 0.92rem;
}

/* Typing + stream cursor */
.mt-typing {
  display: inline-flex;
  gap: 5px;
  padding: 4px 2px;
}

.mt-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mt-green-500);
  animation: mt-bounce 1.1s ease-in-out infinite;
}

.mt-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.mt-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

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

.mt-stream-cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-right: 2px;
  background: var(--mt-green-500);
  vertical-align: text-bottom;
  animation: mt-blink 0.85s step-end infinite;
}

.mt-stream-text {
  display: block;
  min-height: 1.2em;
}

.mt-stream-text > :first-child {
  margin-top: 0;
}

.mt-stream-text > :last-child {
  margin-bottom: 0;
}

.mt-msg__bubble.is-typing-live .mt-stream-cursor {
  margin-top: 0.2em;
}

@keyframes mt-blink {
  50% {
    opacity: 0;
  }
}

/* Composer */
.mt-composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: end;
  background: var(--mt-surface-2);
  border: 1px solid var(--mt-line);
  border-radius: 16px;
  padding: 8px 8px 8px 10px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.mt-composer:focus-within {
  border-color: var(--mt-green-500);
  box-shadow: 0 0 0 3px rgba(82, 183, 136, 0.2);
  background: #fff;
}

.mt-composer__input {
  width: 100%;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  min-height: 44px;
  max-height: 140px;
  padding: 10px 6px;
  color: var(--mt-ink);
  line-height: 1.5;
}

.mt-composer__input::placeholder {
  color: #8a9a90;
}

.mt-composer__send {
  appearance: none;
  border: 0;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--mt-green-900), var(--mt-green-700, #2d6a4f));
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s, filter 0.15s;
  box-shadow: 0 6px 16px rgba(27, 67, 50, 0.28);
}

.mt-composer__send:hover:not(:disabled) {
  filter: brightness(1.08);
}

.mt-composer__send:active:not(:disabled) {
  transform: scale(0.95);
}

.mt-composer__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.mt-composer__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--mt-muted);
}

.mt-status {
  color: var(--mt-green-800);
  font-weight: 600;
  min-height: 1.2em;
}

.mt-tool-btn {
  appearance: none;
  border: 1px solid var(--mt-line);
  background: var(--mt-surface-2);
  color: var(--mt-green-900);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}

.mt-tool-btn:hover {
  background: var(--mt-green-100);
}

.mt-tool-btn--accent {
  background: var(--mt-green-900);
  color: #fff;
  border-color: var(--mt-green-900);
}

.mt-tool-btn--accent:hover {
  background: var(--mt-green-800);
  color: #fff;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Large desktop polish */
@media (min-width: 1200px) {
  .mt-studio__inner {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 14px;
  }
}

/* Auth / Google login state */
.mt-account-pill.is-logged-in {
  background: linear-gradient(145deg, #1b4332, #2d6a4f);
  color: #fff !important;
  border-color: transparent;
}

.mt-mobile-sheet__item--google {
  font-weight: 800;
  color: #1b4332;
  background: #e9f5ef;
}

body.mt-user-logged-in .mt-mobile-sheet__item--google {
  background: #fff;
  font-weight: 700;
}
