/* AIC chat · Menifa · RTL · Mercury shell (continuous bg + glass, PR #49) */
:root {
  --aic-blue: #5BAFD8;
  --aic-blue-user: #5BAFD8;
  --aic-ink: #0E3C5C;
  --aic-white: #fff;
  --menifa-ink: #0E3C5C;
  --menifa-accent: #5BAFD8;
  --menifa-champ: #C4A574;
  --mercury-night: #081420;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --dock-h: auto;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
body.aic-shell {
  font-family: "Heebo", system-ui, -apple-system, sans-serif;
  color: #fff;
  background: var(--mercury-night);
  min-height: 100%;
  height: 100%;
  direction: rtl;
  overflow: hidden;
}
/* Continuous Mercury atmosphere — fixed full-viewport, no mid-page slabs */
.aic-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background-color: var(--mercury-night);
  background-image:
    radial-gradient(ellipse 70% 50% at 20% 20%, rgba(91, 175, 216, .18) 0%, transparent 55%),
    radial-gradient(ellipse 60% 45% at 85% 70%, rgba(196, 165, 116, .12) 0%, transparent 50%),
    radial-gradient(ellipse 80% 55% at 50% 40%, rgba(6, 16, 28, .25) 0%, transparent 60%),
    linear-gradient(180deg, rgba(6, 16, 28, .55) 0%, rgba(6, 16, 28, .42) 35%, rgba(8, 20, 32, .72) 70%, rgba(6, 14, 22, .88) 100%),
    url("../bg/mercury-hero.jpg");
  background-size: cover;
  background-position: center 30%;
  background-repeat: no-repeat;
}
.aic-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 90% 60% at 50% 0%, transparent 0%, rgba(6, 14, 22, .35) 100%),
    linear-gradient(180deg, transparent 0%, rgba(6, 14, 22, .15) 40%, rgba(6, 14, 22, .55) 100%);
  pointer-events: none;
}
.aic-frame {
  position: relative;
  z-index: 1;
  max-width: 560px;
  margin: 0 auto;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px 14px 0;
  display: flex;
  flex-direction: column;
  background: transparent;
}
.aic-top {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  padding: 4px 0;
}
.aic-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  text-shadow: 0 2px 16px rgba(0, 0, 0, .45);
}
.aic-brand img.aic-logo {
  width: auto;
  height: 44px;
  max-width: none;
  aspect-ratio: 1547 / 557;
  object-fit: contain;
  border: 0;
  border-radius: 0;
  background: transparent;
  flex-shrink: 0;
}
.aic-back {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(255, 255, 255, .12);
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: none;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.aic-back:hover { background: rgba(255, 255, 255, .2); }
.aic-back[hidden] { display: none !important; }

/* Scrollable chat history — never under dock */
.aic-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 2px 16px;
  -webkit-overflow-scrolling: touch;
  scroll-padding-bottom: 24px;
  background: transparent;
}
.aic-card {
  background: rgba(8, 20, 32, .48);
  color: #fff;
  border-radius: 18px;
  padding: 14px 14px 12px;
  border: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 16px 48px rgba(0, 0, 0, .28), inset 0 1px 0 rgba(255, 255, 255, .08);
  backdrop-filter: blur(22px) saturate(150%);
  -webkit-backdrop-filter: blur(22px) saturate(150%);
  position: relative;
  z-index: 1;
  max-width: 92%;
  align-self: flex-start;
  flex-shrink: 0;
}
.aic-card__row { display: flex; gap: 10px; align-items: flex-start; }
.aic-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, .22);
}
.aic-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--menifa-ink);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}
.aic-card p { margin: 0 0 8px; line-height: 1.45; font-size: 15px; color: rgba(255, 255, 255, .94); }
.aic-card p:last-child { margin-bottom: 0; }
.aic-card strong { font-weight: 700; color: #fff; }
.aic-user {
  align-self: flex-end;
  background: rgba(91, 175, 216, .28);
  color: #fff;
  border: 1px solid rgba(91, 175, 216, .45);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 14px;
  max-width: 78%;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.aic-time {
  font-size: 11px;
  color: rgba(255, 255, 255, .55);
  align-self: flex-end;
  margin-top: -6px;
  flex-shrink: 0;
}

/* Dock stays frosted so the photo continues behind the chips */
.aic-dock {
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  margin: 0 -14px 0;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(8, 20, 32, 0) 0%, rgba(8, 20, 32, .55) 28%, rgba(8, 20, 32, .72) 100%);
  border-top: 1px solid rgba(255, 255, 255, .1);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
}
.aic-hint {
  color: rgba(255, 255, 255, .78);
  font-size: 13px;
  margin: 0 2px 8px;
  min-height: 1.2em;
}
.aic-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-start;
  align-items: stretch;
}
.aic-chip {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, .18);
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  transition: transform .12s var(--ease), background .12s var(--ease);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.aic-chip:hover { background: rgba(91, 175, 216, .32); border-color: rgba(91, 175, 216, .5); }
.aic-chip:active { transform: scale(.98); }
.aic-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 14px;
  padding: 6px;
  align-items: center;
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
.aic-input-row input {
  flex: 1;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 15px;
  padding: 10px 8px;
  direction: ltr;
  text-align: right;
  background: transparent;
  color: #fff;
}
.aic-input-row input::placeholder { color: rgba(255, 255, 255, .5); }
.aic-send {
  appearance: none;
  border: 0;
  background: var(--menifa-accent);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 4px 18px rgba(91, 175, 216, .38);
}
.aic-send svg { width: 20px; height: 20px; }
.aic-foot {
  margin-top: 8px;
  text-align: center;
  color: rgba(255, 255, 255, .5);
  font-size: 11px;
}
@media (max-width: 480px) {
  .aic-card { max-width: 100%; }
  .aic-chip { flex: 1 1 calc(50% - 10px); text-align: center; }
  .aic-chip:only-child,
  .aic-replies .aic-chip:first-child:nth-last-child(n + 3),
  .aic-replies .aic-chip:first-child:nth-last-child(n + 3) ~ .aic-chip {
    flex: 1 1 100%;
  }
}
/* Soft-scroll focus target — next question sits comfortably above dock */
.aic-card.aic-focus {
  scroll-margin-top: 72px;
  scroll-margin-bottom: 140px;
}
.aic-dock {
  scroll-margin-bottom: 8px;
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
