@font-face {
  font-family: AfaghSans;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/static/fonts/IRANSansWebFaNum.woff2') format('woff2');
}

@font-face {
  font-family: AfaghSans;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/static/fonts/IRANSansWebFaNum-Medium.woff2') format('woff2');
}

@font-face {
  font-family: AfaghSans;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/static/fonts/IRANSansWebFaNum-Bold.woff2') format('woff2');
}

:root {
  color-scheme: light;
  --app-height: 100svh;
  --keyboard-inset: 0px;
  --visual-offset-top: 0px;
  --font: AfaghSans, Vazirmatn, Tahoma, sans-serif;
  --ink: #101828;
  --muted: #667085;
  --muted-strong: #475467;
  --canvas: #eef5ff;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(67, 88, 122, 0.16);
  --primary: #0f6fff;
  --primary-dark: #0757d8;
  --primary-soft: rgba(15, 111, 255, 0.11);
  --accent: #17a865;
  --accent-soft: rgba(23, 168, 101, 0.12);
  --danger: #d92d20;
  --danger-soft: rgba(217, 45, 32, 0.12);
  --warning: #b7791f;
  --warning-soft: rgba(251, 191, 36, 0.2);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 16px;
  --shadow-soft: 0 30px 90px rgba(38, 59, 92, 0.16), 0 10px 28px rgba(38, 59, 92, 0.08), 0 1px 0 rgba(255, 255, 255, 0.5) inset;
  --shadow-card: 0 22px 52px rgba(38, 59, 92, 0.13), 0 6px 16px rgba(38, 59, 92, 0.08);
  --shadow-small: 0 13px 30px rgba(38, 59, 92, 0.10), 0 3px 10px rgba(38, 59, 92, 0.06);
}


/* Theme controls and dark mode */
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #eef4ff;
  --muted: #a8b3c7;
  --muted-strong: #c4cedf;
  --canvas: #0b1220;
  --surface: rgba(15, 23, 42, 0.72);
  --surface-strong: rgba(17, 25, 40, 0.9);
  --line: rgba(203, 213, 225, 0.14);
  --primary: #61a5ff;
  --primary-dark: #9ecbff;
  --primary-soft: rgba(97, 165, 255, 0.14);
  --accent: #3ddc97;
  --accent-soft: rgba(61, 220, 151, 0.14);
  --danger: #ff7a70;
  --danger-soft: rgba(255, 122, 112, 0.14);
  --warning: #ffd166;
  --warning-soft: rgba(255, 209, 102, 0.16);
  --shadow-soft: 0 30px 88px rgba(0, 0, 0, 0.40), 0 10px 26px rgba(0, 0, 0, 0.22), 0 1px 0 rgba(255, 255, 255, 0.06) inset;
  --shadow-card: 0 22px 56px rgba(0, 0, 0, 0.30), 0 6px 16px rgba(0, 0, 0, 0.20);
  --shadow-small: 0 14px 32px rgba(0, 0, 0, 0.22), 0 4px 12px rgba(0, 0, 0, 0.16);
}

.theme-toggle {
  gap: 0.35rem;
  user-select: none;
}

.header-actions-end {
  display: inline-flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.theme-toggle-icon,
.button-icon,
.eyebrow-icon,
.title-icon,
.mini-icon,
.stat-icon {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  line-height: 1;
}

.button-icon,
.eyebrow-icon,
.title-icon,
.mini-icon {
  margin-inline-end: 0.35rem;
}

.stat-icon {
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.35rem;
  border-radius: 0.85rem;
  background: var(--primary-soft);
  font-size: 1rem;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at 78% 8%, rgba(97, 165, 255, 0.2), transparent 28rem),
    radial-gradient(circle at 18% 84%, rgba(61, 220, 151, 0.12), transparent 26rem),
    linear-gradient(140deg, #070b14 0%, #0b1220 46%, #08111d 100%);
}

html[data-theme="dark"] .chat-page {
  background:
    radial-gradient(circle at 12% 15%, rgba(97, 165, 255, 0.13), transparent 18rem),
    radial-gradient(circle at 80% 12%, rgba(71, 117, 255, 0.22), transparent 25rem),
    radial-gradient(circle at 28% 88%, rgba(255, 104, 153, 0.14), transparent 24rem),
    linear-gradient(180deg, #07101d 0%, #0b1220 50%, #050914 100%);
}

html[data-theme="dark"] .admin-page {
  background:
    radial-gradient(circle at 8% 12%, rgba(97, 165, 255, 0.14), transparent 18rem),
    radial-gradient(circle at 86% 8%, rgba(61, 220, 151, 0.11), transparent 28rem),
    radial-gradient(circle at 12% 86%, rgba(255, 104, 153, 0.12), transparent 26rem),
    linear-gradient(140deg, #060b14 0%, #0b1220 54%, #07120e 100%);
}

html[data-theme="dark"] .chat-page::before {
  background:
    radial-gradient(circle at 78% 18%, rgba(97, 165, 255, 0.16), transparent 24rem),
    radial-gradient(circle at 20% 80%, rgba(61, 220, 151, 0.09), transparent 22rem);
}

html[data-theme="dark"] .grain {
  opacity: 0.22;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(255, 255, 255, 0.12) 1px, transparent 0),
    linear-gradient(135deg, rgba(97, 165, 255, 0.06) 0 1px, transparent 1px 42px);
}

html[data-theme="dark"] .glass-panel,
html[data-theme="dark"] .intro-card,
html[data-theme="dark"] .phone-shell,
html[data-theme="dark"] .info-modal-card,
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .admin-dashboard,
html[data-theme="dark"] .splus-card,
html[data-theme="dark"] .editor-card,
html[data-theme="dark"] .import-card,
html[data-theme="dark"] .list-card,
html[data-theme="dark"] .auth-card {
  border-color: rgba(226, 232, 240, 0.14);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .phone-shell {
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.88), rgba(8, 13, 24, 0.78)),
    rgba(15, 23, 42, 0.72);
}

html[data-theme="dark"] .phone-header,
html[data-theme="dark"] .composer {
  border-color: rgba(226, 232, 240, 0.1);
  background: rgba(15, 23, 42, 0.72);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

html[data-theme="dark"] .messages {
  background:
    radial-gradient(circle at 22% 18%, rgba(97, 165, 255, 0.08), transparent 16rem),
    radial-gradient(circle at 86% 86%, rgba(61, 220, 151, 0.07), transparent 17rem),
    linear-gradient(180deg, rgba(15, 23, 42, 0.38), rgba(2, 6, 23, 0.54));
}

html[data-theme="dark"] .header-action,
html[data-theme="dark"] .ghost-button,
html[data-theme="dark"] .quick-questions button,
html[data-theme="dark"] .item-actions button,
html[data-theme="dark"] .modal-close {
  color: var(--primary-dark);
  border-color: rgba(226, 232, 240, 0.14);
  background: rgba(15, 23, 42, 0.72);
  box-shadow: var(--shadow-small);
}

html[data-theme="dark"] .header-action:hover,
html[data-theme="dark"] .ghost-button:hover {
  background: rgba(30, 41, 59, 0.88);
}

html[data-theme="dark"] .composer input,
html[data-theme="dark"] .search-box input,
html[data-theme="dark"] .token-form input,
html[data-theme="dark"] .qa-form input,
html[data-theme="dark"] .qa-form textarea {
  color: var(--ink);
  border-color: rgba(226, 232, 240, 0.14);
  background: rgba(15, 23, 42, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .composer input:focus,
html[data-theme="dark"] .search-box input:focus,
html[data-theme="dark"] .token-form input:focus,
html[data-theme="dark"] .qa-form input:focus,
html[data-theme="dark"] .qa-form textarea:focus {
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 0 0 4px rgba(97, 165, 255, 0.15);
}

html[data-theme="dark"] .composer input::placeholder,
html[data-theme="dark"] .search-box input::placeholder,
html[data-theme="dark"] .qa-form input::placeholder,
html[data-theme="dark"] .qa-form textarea::placeholder {
  color: rgba(203, 213, 225, 0.5);
}

html[data-theme="dark"] .bot-message .bubble {
  color: var(--ink);
  border-color: rgba(226, 232, 240, 0.12);
  background: rgba(15, 23, 42, 0.92);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .bot-message .message-meta {
  color: rgba(196, 206, 223, 0.72);
}

html[data-theme="dark"] .autocomplete-list {
  border-color: rgba(226, 232, 240, 0.14);
  background: rgba(15, 23, 42, 0.96);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.34);
}

html[data-theme="dark"] .autocomplete-list button,
html[data-theme="dark"] .modal-info-grid div,
html[data-theme="dark"] .feature-grid div,
html[data-theme="dark"] .stats-grid div,
html[data-theme="dark"] .splus-status-card,
html[data-theme="dark"] .qa-item,
html[data-theme="dark"] .import-result-card,
html[data-theme="dark"] .splus-recent-item,
html[data-theme="dark"] .field-card,
html[data-theme="dark"] .splus-monitor-panel,
html[data-theme="dark"] .splus-form,
html[data-theme="dark"] .empty-state {
  border-color: rgba(226, 232, 240, 0.12);
  background: rgba(15, 23, 42, 0.68);
  box-shadow: var(--shadow-small);
}

html[data-theme="dark"] .autocomplete-list button:hover,
html[data-theme="dark"] .autocomplete-list button.active {
  background: rgba(97, 165, 255, 0.16);
}

html[data-theme="dark"] .splus-status-card.ok,
html[data-theme="dark"] .splus-status-card.warm,
html[data-theme="dark"] .splus-status-card.bad,
html[data-theme="dark"] .splus-status-card.off,
html[data-theme="dark"] .toggle-field {
  background: rgba(15, 23, 42, 0.74);
}

html[data-theme="dark"] .info-modal-backdrop {
  background: rgba(2, 6, 23, 0.68);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(circle at 78% 8%, rgba(15, 111, 255, 0.2), transparent 28rem),
    radial-gradient(circle at 18% 84%, rgba(23, 168, 101, 0.14), transparent 26rem),
    linear-gradient(140deg, #eef5ff 0%, #f8fbff 45%, #eef7f3 100%);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body.modal-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled,
input:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.66;
}

a {
  color: inherit;
  text-decoration: none;
}

img,
svg {
  max-width: 100%;
}

.hidden {
  display: none !important;
}

.lite-effects .ambient,
.lite-effects .chat-page::before {
  animation: none !important;
}

.lite-effects .glass-panel,
.lite-effects .intro-card,
.lite-effects .phone-shell,
.lite-effects .phone-header,
.lite-effects .composer,
.lite-effects .info-modal-card,
.lite-effects .autocomplete-list {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.lite-effects .message {
  will-change: auto;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ambient {
  position: fixed;
  z-index: -2;
  width: 30rem;
  height: 30rem;
  border-radius: 999px;
  pointer-events: none;
  opacity: 0.52;
  background: radial-gradient(circle, rgba(15, 111, 255, 0.23), transparent 68%);
  transform: translate3d(0, 0, 0);
  will-change: transform;
}

.ambient-one {
  top: -12rem;
  right: -8rem;
  animation: ambientMoveOne 34s ease-in-out infinite alternate;
}

.ambient-two,
.ambient-admin {
  bottom: -13rem;
  left: -9rem;
  background: radial-gradient(circle, rgba(255, 104, 153, 0.18), transparent 70%);
  animation: ambientMoveTwo 38s ease-in-out infinite alternate;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: -3;
  pointer-events: none;
  opacity: 0.38;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(15, 111, 255, 0.14) 1px, transparent 0),
    linear-gradient(135deg, rgba(255, 255, 255, 0.42) 0 1px, transparent 1px 42px);
  background-size: 24px 24px, 44px 44px;
  mask-image: linear-gradient(to bottom, black, transparent 84%);
}

.glass-panel,
.intro-card,
.phone-shell,
.info-modal-card {
  border: 1px solid rgba(255, 255, 255, 0.7);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  @media (min-width: 760px) and (prefers-reduced-motion: no-preference) {
    .glass-panel,
    .intro-card,
    .phone-shell,
    .phone-header,
    .composer,
    .info-modal-card,
    .autocomplete-list {
      backdrop-filter: blur(14px) saturate(145%);
      -webkit-backdrop-filter: blur(14px) saturate(145%);
    }
  }
}

.brand-mark,
.bot-avatar,
.modal-avatar {
  display: grid;
  place-items: center;
  overflow: hidden;
  color: transparent;
  font-size: 0;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(240, 247, 255, 0.9));
  border: 1px solid rgba(15, 111, 255, 0.13);
  box-shadow:
    0 12px 28px rgba(15, 111, 255, 0.16),
    0 4px 12px rgba(38, 59, 92, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.brand-mark img,
.bot-avatar img,
.modal-avatar img {
  display: block;
  width: 82%;
  height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 4px 8px rgba(8, 66, 160, 0.16));
}

html[data-theme="dark"] .brand-mark,
html[data-theme="dark"] .bot-avatar,
html[data-theme="dark"] .modal-avatar {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.98), rgba(231, 240, 255, 0.92));
  border-color: rgba(97, 165, 255, 0.22);
  box-shadow:
    0 14px 32px rgba(0, 0, 0, 0.28),
    0 0 0 1px rgba(97, 165, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
}

.eyebrow {
  display: inline-flex;
  width: fit-content;
  border: 1px solid rgba(15, 111, 255, 0.12);
  border-radius: 999px;
  padding: 0.38rem 0.72rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 0.75rem;
  font-weight: 800;
}

.ghost-button,
.solid-button,
.qa-form button,
.token-form button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.7rem;
  border-radius: 999px;
  padding: 0.65rem 1rem;
  font-weight: 800;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.ghost-button {
  color: var(--primary-dark);
  border: 1px solid rgba(15, 111, 255, 0.14);
  background: rgba(255, 255, 255, 0.72);
}

.solid-button,
.qa-form button,
.token-form button {
  color: #fff;
  border: 0;
  background: linear-gradient(135deg, var(--primary), #1788ff);
  box-shadow: 0 12px 24px rgba(15, 111, 255, 0.22);
}

.ghost-button:hover,
.solid-button:hover,
.qa-form button:hover,
.token-form button:hover {
  transform: translateY(-1px);
}

.compact {
  min-height: 2.35rem;
  padding: 0.5rem 0.82rem;
  font-size: 0.84rem;
}

.wide {
  width: 100%;
}

.reveal {
  animation: reveal 520ms cubic-bezier(0.2, 0.85, 0.2, 1) both;
}

.delay-1 { animation-delay: 70ms; }
.delay-2 { animation-delay: 120ms; }

/* Chat */
.chat-page {
  background:
    radial-gradient(circle at 12% 15%, rgba(255, 255, 255, 0.92), transparent 16rem),
    radial-gradient(circle at 80% 12%, rgba(136, 190, 255, 0.46), transparent 24rem),
    radial-gradient(circle at 28% 88%, rgba(255, 205, 226, 0.32), transparent 24rem),
    linear-gradient(180deg, #edf4ff 0%, #f8fbff 48%, #e8eff9 100%);
}

.chat-page::before {
  position: fixed;
  inset: -8% -5%;
  z-index: -4;
  content: "";
  pointer-events: none;
  background:
    radial-gradient(circle at 78% 18%, rgba(15, 111, 255, 0.16), transparent 24rem),
    radial-gradient(circle at 20% 80%, rgba(23, 168, 101, 0.1), transparent 22rem);
  transform: translate3d(0, 0, 0);
  animation: backgroundDrift 42s ease-in-out infinite alternate;
  will-change: transform;
}

.chat-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(360px, 540px);
  gap: clamp(1rem, 3vw, 2rem);
  align-items: center;
  width: min(1180px, calc(100% - 2rem));
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(1rem, 3svh, 2rem) 0;
}

.intro-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: clamp(1.25rem, 3vw, 2.25rem);
}

.intro-card::before {
  position: absolute;
  inset: -28% auto auto -14%;
  width: 22rem;
  height: 22rem;
  border-radius: 999px;
  content: "";
  pointer-events: none;
  background: radial-gradient(circle, rgba(15, 111, 255, 0.14), transparent 68%);
}

.brand-row,
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.78rem;
  min-width: 0;
}

.brand-mark {
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  border-radius: 1.12rem;
}

.brand-row .brand-mark img,
.brand .brand-mark img {
  width: 86%;
  height: 86%;
}

.brand-row strong,
.brand-row span,
.brand strong,
.brand small {
  display: block;
}

.brand-row strong,
.brand strong {
  font-size: 1rem;
}

.brand-row span,
.brand small {
  margin-top: 0.16rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.intro-copy {
  position: relative;
  z-index: 1;
  margin-top: clamp(2rem, 6vw, 4rem);
}

.intro-copy .eyebrow {
  margin-bottom: 0.85rem;
}

.intro-copy h1 {
  max-width: 13ch;
  margin: 0;
  font-size: clamp(2.4rem, 6vw, 5.25rem);
  line-height: 1.08;
  letter-spacing: -0.055em;
}

.intro-copy p {
  max-width: 56ch;
  margin: 1.1rem 0 0;
  color: var(--muted-strong);
  font-size: 0.98rem;
  line-height: 2;
}

.feature-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: clamp(1.25rem, 3vw, 2rem);
}

.feature-grid div,
.stats-grid div,
.splus-status-card,
.qa-item,
.import-result-card,
.splus-recent-item,
.field-card {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.66);
  box-shadow: var(--shadow-small);
}

.feature-grid div {
  border-radius: 1.25rem;
  padding: 1rem;
}

.feature-grid strong,
.feature-grid span,
.stats-grid strong,
.stats-grid span {
  display: block;
}

.feature-grid strong {
  color: var(--primary-dark);
  font-size: 1.28rem;
}

.feature-grid span {
  margin-top: 0.34rem;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.75;
}

.phone-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(880px, calc(100svh - clamp(2rem, 5svh, 4rem)));
  min-height: min(720px, calc(100svh - clamp(2rem, 5svh, 4rem)));
  overflow: hidden;
  border-radius: 2.35rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(246, 250, 255, 0.72)),
    rgba(255, 255, 255, 0.68);
}

.phone-header {
  display: grid;
  grid-template-columns: 2.55rem minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  min-height: 5.45rem;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(76, 100, 138, 0.12);
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 22px rgba(38, 59, 92, 0.08);
}

.header-action {
  display: grid;
  place-items: center;
  width: 2.35rem;
  height: 2.35rem;
  border: 1px solid rgba(76, 100, 138, 0.14);
  border-radius: 999px;
  padding: 0;
  color: var(--primary);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92), var(--shadow-small);
  font-size: 1.35rem;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.header-action:hover {
  border-color: rgba(15, 111, 255, 0.24);
  background: #fff;
  transform: translateY(-1px);
}

.info-dot {
  justify-self: end;
  font-size: 0.98rem;
  font-weight: 900;
}

.conversation-identity {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  min-width: 0;
}

.conversation-identity .bot-avatar {
  width: 2.7rem;
  height: 2.7rem;
  flex: 0 0 auto;
  border-radius: 999px;
  font-size: 0.95rem;
}

.conversation-identity .bot-avatar img {
  width: 84%;
  height: 84%;
}

.identity-copy {
  min-width: 0;
}

.identity-copy strong,
.identity-copy small {
  display: block;
}

.identity-copy strong {
  overflow: hidden;
  max-width: 16rem;
  font-size: 0.92rem;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-copy small {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.12rem;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.online-dot {
  display: inline-block;
  width: 0.46rem;
  height: 0.46rem;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(23, 168, 101, 0.12);
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-height: 0;
  padding: 1rem 0.92rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(100, 116, 139, 0.34) transparent;
  scrollbar-width: thin;
  background:
    radial-gradient(circle at 22% 18%, rgba(255, 255, 255, 0.68), transparent 16rem),
    radial-gradient(circle at 86% 86%, rgba(15, 111, 255, 0.08), transparent 17rem),
    linear-gradient(180deg, rgba(248, 251, 255, 0.64), rgba(239, 246, 255, 0.48));
}

.messages::-webkit-scrollbar,
.qa-list::-webkit-scrollbar,
.splus-recent-list::-webkit-scrollbar,
.autocomplete-list::-webkit-scrollbar {
  width: 0.48rem;
}

.messages::-webkit-scrollbar-thumb,
.qa-list::-webkit-scrollbar-thumb,
.splus-recent-list::-webkit-scrollbar-thumb,
.autocomplete-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.28);
}

.message {
  display: flex;
}

.user-message {
  justify-content: flex-start;
  animation: iosSendMessage 260ms cubic-bezier(0.2, 0.9, 0.22, 1) both;
}

.bot-message {
  justify-content: flex-end;
  animation: iosReceiveMessage 240ms cubic-bezier(0.2, 0.84, 0.2, 1) both;
}

.bubble {
  max-width: min(79%, 25rem);
  min-height: 2.2rem;
  border-radius: 1.35rem;
  padding: 0.62rem 0.9rem 0.68rem;
  font-size: 0.95rem;
  line-height: 1.8;
  overflow-wrap: anywhere;
}

.bubble[dir="rtl"] {
  text-align: right;
}

.bubble[dir="ltr"] {
  text-align: left;
}

.bubble.has-code {
  max-width: min(94%, 32rem);
}

.user-message .bubble {
  color: #fff;
  border-bottom-left-radius: 0.45rem;
  background: linear-gradient(180deg, #2b8cff 0%, var(--primary) 100%);
  box-shadow: 0 12px 26px rgba(15, 111, 255, 0.22);
}

.bot-message .bubble {
  color: #111827;
  border: 1px solid rgba(76, 100, 138, 0.1);
  border-bottom-right-radius: 0.45rem;
  background: #fff;
  box-shadow: 0 12px 28px rgba(38, 59, 92, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

.bubble a {
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.bot-message .bubble a { color: var(--primary-dark); }
.user-message .bubble a { color: #fff; }

.message-text-part {
  white-space: pre-line;
}

.message-meta {
  display: block;
  margin-top: 0.36rem;
  color: rgba(255, 255, 255, 0.74);
  font-size: 0.68rem;
  line-height: 1.55;
}

.bot-message .message-meta {
  color: rgba(71, 85, 105, 0.72);
}

.typing .bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.36rem;
  min-height: 2.2rem;
}

.typing .bubble span {
  display: block;
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 999px;
  background: #94a3b8;
  animation: typingDot 820ms ease-in-out infinite;
}

.typing .bubble span:nth-child(2) { animation-delay: 120ms; }
.typing .bubble span:nth-child(3) { animation-delay: 240ms; }

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  padding: 0.72rem 0.75rem calc(0.72rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(76, 100, 138, 0.12);
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 -10px 26px rgba(38, 59, 92, 0.08);
}

.composer-input-wrap {
  position: relative;
  min-width: 0;
}

.composer input,
.search-box input,
.token-form input,
.qa-form input,
.qa-form textarea {
  width: 100%;
  border: 1px solid rgba(76, 100, 138, 0.18);
  border-radius: 1.05rem;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.92);
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.composer input {
  min-height: 2.48rem;
  border-radius: 999px;
  padding: 0 0.95rem;
}

.composer input::placeholder,
.search-box input::placeholder,
.qa-form input::placeholder,
.qa-form textarea::placeholder {
  color: rgba(100, 116, 139, 0.62);
}

.composer input:focus,
.search-box input:focus,
.token-form input:focus,
.qa-form input:focus,
.qa-form textarea:focus {
  border-color: rgba(15, 111, 255, 0.48);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(15, 111, 255, 0.11);
}

.send-button {
  display: grid;
  place-items: center;
  width: 2.35rem;
  min-width: 2.35rem;
  height: 2.35rem;
  min-height: 2.35rem;
  border: 0;
  border-radius: 999px;
  padding: 0;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 12px 22px rgba(15, 111, 255, 0.24), inset 0 1px 0 rgba(255, 255, 255, 0.28);
  font-size: 1rem;
  font-weight: 900;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

.send-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.autocomplete-list {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.55rem);
  left: 0;
  z-index: 40;
  display: grid;
  gap: 0.42rem;
  max-height: min(18rem, 45svh);
  overflow-y: auto;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 1.3rem;
  padding: 0.58rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 14px 34px rgba(38, 59, 92, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.86);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 7px, 0) scale(0.985);
  transition: opacity 130ms ease, transform 130ms ease, visibility 130ms ease;
}

.autocomplete-list.hidden {
  display: grid !important;
}

.autocomplete-list.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate3d(0, 0, 0) scale(1);
}

.autocomplete-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.05rem 0.18rem 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.autocomplete-header strong { color: var(--ink); }

.autocomplete-header span {
  border-radius: 999px;
  padding: 0.18rem 0.48rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.autocomplete-list button {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0.65rem;
  align-items: center;
  width: 100%;
  border: 0;
  border-radius: 1rem;
  padding: 0.68rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.56);
  text-align: right;
  transition: background 130ms ease;
}

.autocomplete-list button:hover,
.autocomplete-list button.active {
  background: rgba(15, 111, 255, 0.1);
}

.suggestion-icon {
  display: grid;
  place-items: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 999px;
  color: #fff;
  background: var(--primary);
  font-weight: 900;
}

.suggestion-copy {
  display: grid;
  min-width: 0;
}

.suggestion-copy strong {
  overflow: hidden;
  color: inherit;
  font-size: 0.88rem;
  line-height: 1.7;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.suggestion-copy small {
  color: var(--muted);
  font-size: 0.67rem;
  line-height: 1.5;
}

.suggestion-copy mark {
  border-radius: 0.4rem;
  padding: 0 0.12rem;
  color: var(--primary-dark);
  background: rgba(15, 111, 255, 0.12);
}

.code-block {
  text-align: left;
  direction: ltr;
  margin: 0.62rem 0;
  overflow: hidden;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 1rem;
  background: #0f172a;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.16);
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.45rem 0.7rem;
  color: #cbd5e1;
  background: rgba(255, 255, 255, 0.06);
  font: 0.72rem/1.4 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.code-block-header button {
  border: 0;
  border-radius: 999px;
  padding: 0.25rem 0.58rem;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.12);
  font: inherit;
}

.code-block-header button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.code-block pre {
  margin: 0;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.9rem;
}

.code-block code {
  color: #e2e8f0;
  font: 0.82rem/1.8 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  white-space: pre;
}

.user-message .code-block {
  text-align: left;
  background: #111827;
}

.info-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 1rem;
  visibility: hidden;
  opacity: 0;
  transition: opacity 170ms ease, visibility 0s linear 170ms;
}

.info-modal.hidden {
  display: grid !important;
}

.info-modal.is-open {
  visibility: visible;
  opacity: 1;
  transition-delay: 0s;
}

.info-modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  padding: 0;
  background: rgba(15, 23, 42, 0.28);
}

.info-modal-card {
  position: relative;
  z-index: 1;
  width: min(94vw, 29rem);
  border-radius: 1.7rem;
  padding: 1.25rem;
  transform: translate3d(0, 12px, 0) scale(0.985);
  transition: transform 170ms ease;
}

.info-modal.is-open .info-modal-card {
  transform: translate3d(0, 0, 0) scale(1);
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  left: 0.8rem;
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 0;
  border-radius: 999px;
  color: var(--muted-strong);
  background: rgba(255, 255, 255, 0.8);
  font-size: 1.2rem;
}

.modal-avatar {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 1.2rem;
}

.modal-avatar img {
  width: 88%;
  height: 88%;
}

.modal-eyebrow {
  display: inline-flex;
  margin-top: 1rem;
  color: var(--primary-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

.info-modal-card h2 {
  margin: 0.45rem 0 0;
  font-size: 1.35rem;
}

.info-modal-card p {
  margin: 0.75rem 0 0;
  color: var(--muted-strong);
  line-height: 2;
}

.modal-info-grid {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.modal-info-grid div {
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.72rem;
  background: rgba(255, 255, 255, 0.62);
}

.modal-info-grid strong,
.modal-info-grid span {
  display: block;
}

.modal-info-grid span {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.8;
}

/* Admin */
.admin-page {
  background:
    radial-gradient(circle at 8% 12%, rgba(255, 255, 255, 0.86), transparent 18rem),
    radial-gradient(circle at 86% 8%, rgba(15, 111, 255, 0.16), transparent 28rem),
    radial-gradient(circle at 12% 86%, rgba(255, 104, 153, 0.13), transparent 26rem),
    linear-gradient(140deg, #eef5ff 0%, #fff8f1 52%, #f1faf4 100%);
}

.topbar {
  position: sticky;
  top: 1rem;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1220px, calc(100% - 2rem));
  margin: 1rem auto 0;
  border-radius: 999px;
  padding: 0.75rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-layout {
  display: grid;
  grid-template-areas:
    "dashboard dashboard"
    "auth auth"
    "splus splus"
    "editor list"
    "import list";
  grid-template-columns: minmax(320px, 0.95fr) minmax(420px, 1.25fr);
  gap: 1rem;
  align-items: start;
  width: min(1220px, calc(100% - 2rem));
  margin: 1rem auto 2rem;
}

.admin-dashboard,
.splus-card,
.editor-card,
.import-card,
.list-card,
.auth-card {
  border-radius: var(--radius-xl);
  padding: clamp(1.1rem, 3vw, 2rem);
}

.admin-dashboard {
  grid-area: dashboard;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(18rem, 28rem);
  gap: 1rem;
  align-items: center;
}

.auth-card {
  grid-area: auth;
  width: min(100%, 36rem);
  justify-self: center;
}

.splus-card { grid-area: splus; }
.editor-card { grid-area: editor; }
.import-card { grid-area: import; }

.list-card {
  display: flex;
  position: sticky;
  top: 6.2rem;
  grid-area: list;
  flex-direction: column;
  max-height: calc(100svh - 7.6rem);
  min-height: 32rem;
  overflow: hidden;
}

.admin-dashboard h1 {
  max-width: 17ch;
  margin: 0.7rem 0 0;
  font-size: clamp(1.8rem, 4vw, 3.3rem);
  line-height: 1.15;
  letter-spacing: -0.045em;
}

.admin-dashboard p,
.auth-card p,
.helper-text,
.section-subtitle {
  color: var(--muted-strong);
  line-height: 1.9;
}

.admin-dashboard p,
.auth-card p {
  max-width: 58ch;
  margin: 1rem 0 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.72rem;
}

.stats-grid div {
  border-radius: 1.2rem;
  padding: 0.95rem;
}

.stats-grid strong {
  color: var(--primary-dark);
  font-size: 1.55rem;
}

.stats-grid span {
  margin-top: 0.24rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.section-title,
.splus-form-head,
.mini-title,
.qa-item header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.splus-titlebar {
  align-items: flex-start;
  margin-bottom: 1rem;
}

.section-title {
  margin-bottom: 1rem;
}

.section-title h2,
.auth-card h2 {
  margin: 0.45rem 0 0;
  font-size: 1.35rem;
}

.section-subtitle {
  max-width: 70ch;
  margin: 0.42rem 0 0;
  font-size: 0.88rem;
}

.helper-text {
  margin: 0 0 1rem;
}

.qa-form,
.token-form {
  display: grid;
  gap: 0.75rem;
}

.qa-form label,
.token-form label {
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.qa-form input,
.token-form input,
.search-box input {
  min-height: 3rem;
  padding: 0 0.92rem;
}

.qa-form textarea {
  min-height: 8rem;
  padding: 0.9rem;
  resize: vertical;
  line-height: 1.9;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  width: fit-content;
  border-radius: 999px;
  padding: 0.52rem 0.68rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 800;
}

.switch-row input,
.toggle-field input {
  width: 1.05rem;
  min-height: auto;
  accent-color: var(--primary);
}

.form-divider {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.75rem;
  align-items: center;
  margin: 1.1rem 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.form-divider::before,
.form-divider::after {
  height: 1px;
  content: "";
  background: var(--line);
}

.search-box {
  width: min(100%, 18rem);
}

.splus-console {
  display: grid;
  grid-template-columns: minmax(18rem, 0.9fr) minmax(26rem, 1.35fr);
  gap: 1rem;
  align-items: start;
}

.splus-monitor-panel,
.splus-form {
  border: 1px solid var(--line);
  border-radius: 1.55rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: var(--shadow-small);
}

.splus-status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 1rem 0;
}

.splus-status-card {
  display: grid;
  gap: 0.25rem;
  min-height: 5rem;
  border-radius: 1.15rem;
  padding: 0.82rem;
}

.splus-status-card strong {
  overflow: hidden;
  color: var(--primary-dark);
  font-size: 0.9rem;
  line-height: 1.6;
  text-overflow: ellipsis;
}

.splus-status-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.splus-status-card.ok {
  border-color: rgba(23, 168, 101, 0.22);
  background: rgba(232, 249, 240, 0.78);
}

.splus-status-card.warm {
  border-color: rgba(251, 191, 36, 0.3);
  background: rgba(255, 248, 222, 0.78);
}

.splus-status-card.bad,
.splus-status-card.off {
  border-color: rgba(217, 45, 32, 0.18);
  background: rgba(255, 238, 236, 0.78);
}

.splus-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
}

.field-card {
  display: grid;
  gap: 0.42rem;
  min-width: 0;
  margin: 0;
  border-radius: 1.15rem;
  padding: 0.72rem;
}

.field-card > span {
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 900;
}

.wide-field {
  grid-column: 1 / -1;
}

.toggle-field {
  display: flex;
  align-items: center;
  min-height: 4.7rem;
  color: var(--primary-dark);
  font-size: 0.84rem;
  font-weight: 900;
  background: linear-gradient(135deg, rgba(216, 236, 255, 0.9), rgba(238, 249, 240, 0.72));
}

.splus-recent {
  display: grid;
  gap: 0.72rem;
  margin-top: 1rem;
}

.mini-title strong {
  color: var(--primary-dark);
}

.mini-title span {
  border-radius: 999px;
  padding: 0.24rem 0.55rem;
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.splus-recent-list,
.qa-list {
  display: grid;
  gap: 0.65rem;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: rgba(100, 116, 139, 0.28) transparent;
  scrollbar-width: thin;
}

.splus-recent-list {
  max-height: 18rem;
}

.qa-list {
  flex: 1;
  padding-inline-end: 0.08rem;
}

.splus-recent-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.25rem 0.65rem;
  align-items: center;
  border-radius: 1rem;
  padding: 0.72rem;
}

.splus-recent-item strong,
.splus-recent-item span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.splus-recent-item strong {
  font-size: 0.84rem;
  line-height: 1.7;
  white-space: nowrap;
}

.splus-recent-item span {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 0.7rem;
}

.splus-recent-item em {
  border-radius: 999px;
  padding: 0.18rem 0.5rem;
  color: #0d6b38;
  background: rgba(40, 190, 110, 0.16);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
}

.splus-recent-item em.off {
  color: var(--danger);
  background: var(--danger-soft);
}

.import-result {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.import-result-card,
.qa-item {
  border-radius: 1.2rem;
  padding: 0.92rem;
}

.import-result-card strong {
  display: block;
  margin-bottom: 0.32rem;
  line-height: 1.8;
}

.import-result-card p,
.qa-item p {
  margin: 0;
  color: var(--muted-strong);
  line-height: 1.9;
  white-space: pre-line;
}

.qa-item {
  display: grid;
  gap: 0.72rem;
}

.qa-item h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.8;
}

.keyword-row,
.item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.keyword-row span,
.status-badge {
  border-radius: 999px;
  padding: 0.26rem 0.52rem;
  font-size: 0.7rem;
  font-weight: 800;
}

.keyword-row span {
  color: var(--primary-dark);
  background: var(--primary-soft);
}

.status-badge {
  color: var(--primary-dark);
  background: var(--accent-soft);
  white-space: nowrap;
}

.status-badge.off {
  color: var(--danger);
  background: var(--danger-soft);
}

.item-actions button {
  border: 0;
  border-radius: 999px;
  padding: 0.52rem 0.82rem;
  color: var(--primary-dark);
  background: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.item-actions .toggle.on {
  color: #0d6b38;
  background: rgba(40, 190, 110, 0.16);
}

.item-actions .toggle.off {
  color: var(--warning);
  background: var(--warning-soft);
}

.item-actions .delete {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-state {
  border: 1px dashed rgba(15, 111, 255, 0.24);
  border-radius: 1.2rem;
  padding: 1.1rem;
  color: var(--muted);
  text-align: center;
  background: rgba(255, 255, 255, 0.5);
  line-height: 1.9;
}

.compact-empty {
  padding: 0.8rem;
  font-size: 0.82rem;
}

.toast {
  position: fixed;
  right: 50%;
  bottom: 1rem;
  z-index: 140;
  width: fit-content;
  min-width: min(90vw, 19rem);
  max-width: min(92vw, 34rem);
  border-radius: 999px;
  padding: 0.8rem 1rem;
  color: #fff;
  text-align: center;
  background: var(--primary-dark);
  box-shadow: 0 14px 34px rgba(8, 58, 79, 0.24);
  transform: translate3d(50%, 140%, 0);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}

.toast.show {
  transform: translate3d(50%, 0, 0);
  opacity: 1;
}

.toast.error {
  background: var(--danger);
}


/* Polished review fixes: softer rounded shadows, safer paint, and aligned icons */
.glass-panel,
.intro-card,
.phone-shell,
.info-modal-card,
.topbar,
.admin-dashboard,
.splus-card,
.editor-card,
.import-card,
.list-card,
.auth-card {
  position: relative;
  isolation: isolate;
  box-shadow: var(--shadow-soft);
}

.feature-grid div,
.stats-grid div,
.splus-monitor-panel,
.splus-form,
.splus-status-card,
.qa-item,
.import-result-card,
.splus-recent-item,
.field-card,
.modal-info-grid div,
.autocomplete-list {
  box-shadow: var(--shadow-small);
}

.intro-card,
.phone-shell,
.info-modal-card,
.topbar,
.admin-dashboard,
.splus-card,
.editor-card,
.import-card,
.list-card,
.auth-card,
.feature-grid div,
.stats-grid div,
.splus-monitor-panel,
.splus-form,
.splus-status-card,
.qa-item,
.import-result-card,
.splus-recent-item,
.field-card,
.modal-info-grid div,
.autocomplete-list,
.bubble {
  background-clip: padding-box;
}

.phone-shell {
  box-shadow: 0 34px 95px rgba(38, 59, 92, 0.20), 0 14px 36px rgba(38, 59, 92, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

html[data-theme="dark"] .phone-shell {
  box-shadow: 0 34px 95px rgba(0, 0, 0, 0.48), 0 14px 34px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.user-message .bubble {
  box-shadow: 0 16px 34px rgba(15, 111, 255, 0.22), 0 5px 14px rgba(15, 111, 255, 0.14);
}

.bot-message .bubble {
  box-shadow: 0 15px 34px rgba(38, 59, 92, 0.12), 0 4px 12px rgba(38, 59, 92, 0.06), inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.phone-header {
  grid-template-columns: 5.3rem minmax(0, 1fr) 5.3rem;
}

.back-link {
  justify-self: start;
}

.header-actions-end {
  justify-self: end;
  align-items: center;
}

.header-action,
.send-button,
.modal-close {
  flex: 0 0 auto;
  line-height: 1;
}

.theme-toggle-icon,
.button-icon,
.eyebrow-icon,
.title-icon,
.mini-icon,
.stat-icon {
  width: 1.35em;
  height: 1.35em;
  margin: 0 !important;
  line-height: 1;
  transform: translateY(0.015em);
}

.ghost-button,
.solid-button,
.qa-form button,
.token-form button,
.eyebrow,
.mini-title strong,
.section-title h2,
.auth-card h2,
.switch-row {
  gap: 0.45rem;
}

.stat-icon {
  width: 2.15rem;
  height: 2.15rem;
  margin-bottom: 0.38rem !important;
  transform: none;
}

.item-actions button,
.keyword-row span,
.status-badge,
.mini-title span,
.autocomplete-header span {
  box-shadow: 0 4px 12px rgba(38, 59, 92, 0.06);
}

.messages {
  contain: layout style;
}

.message {
  transform-origin: 50% 100%;
}

@media (max-width: 640px) {
  .phone-header {
    grid-template-columns: 4.85rem minmax(0, 1fr) 4.85rem;
  }

  .header-actions-end {
    gap: 0.28rem;
  }
}

@media (max-width: 420px) {
  .phone-header {
    grid-template-columns: 4.55rem minmax(0, 1fr) 4.55rem;
  }

  .identity-copy strong {
    max-width: 10.5rem;
  }
}

@keyframes reveal {
  from { opacity: 0; transform: translate3d(0, 14px, 0) scale(0.99); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes iosSendMessage {
  from { opacity: 0; transform: translate3d(-12px, 10px, 0) scale(0.96); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes iosReceiveMessage {
  from { opacity: 0; transform: translate3d(12px, 8px, 0) scale(0.975); }
  to { opacity: 1; transform: translate3d(0, 0, 0) scale(1); }
}

@keyframes typingDot {
  0%, 100% { transform: translate3d(0, 0, 0); opacity: 0.42; }
  50% { transform: translate3d(0, -4px, 0); opacity: 1; }
}

@keyframes ambientMoveOne {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(-34px, 28px, 0) scale(1.05); }
}

@keyframes ambientMoveTwo {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(38px, -24px, 0) scale(1.04); }
}

@keyframes backgroundDrift {
  from { transform: translate3d(-1.2%, -0.8%, 0) scale(1); }
  to { transform: translate3d(1.4%, 1.2%, 0) scale(1.03); }
}

@media (max-width: 1100px) {
  .admin-layout {
    grid-template-areas:
      "dashboard"
      "auth"
      "splus"
      "editor"
      "import"
      "list";
    grid-template-columns: 1fr;
  }

  .list-card {
    position: static;
    max-height: none;
  }
}

@media (max-width: 980px) {
  .chat-layout {
    grid-template-columns: 1fr;
    align-items: stretch;
    width: min(720px, calc(100% - 1.2rem));
  }

  .intro-card {
    padding: 1.2rem;
  }

  .intro-copy {
    margin-top: 1.55rem;
  }

  .intro-copy h1 {
    max-width: 100%;
    font-size: clamp(2rem, 7vw, 3.2rem);
  }

  .phone-shell {
    height: min(760px, calc(100svh - 1.2rem));
    min-height: 640px;
  }

  .admin-dashboard,
  .splus-console {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    position: static;
    border-radius: 1.5rem;
    flex-direction: column;
    align-items: stretch;
  }

  .top-actions {
    width: 100%;
  }

  .top-actions a {
    flex: 1;
  }

  .admin-layout {
    width: min(100% - 1rem, 1220px);
    margin-top: 0.7rem;
  }

  .admin-dashboard,
  .splus-card,
  .editor-card,
  .import-card,
  .list-card,
  .auth-card {
    border-radius: 1.45rem;
    padding: 1rem;
  }

  .stats-grid,
  .splus-status-grid,
  .splus-field-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .grain,
  .intro-card {
    display: none;
  }

  .chat-layout {
    width: min(100% - 0.7rem, 720px);
    padding: 0.35rem 0;
  }

  .phone-shell {
    height: calc(100svh - 0.7rem);
    min-height: calc(100svh - 0.7rem);
    max-height: calc(100svh - 0.7rem);
    border-radius: 1.55rem;
  }

  .phone-header {
    min-height: 5rem;
    padding: 0.62rem;
  }

  .conversation-identity {
    gap: 0.55rem;
  }

  .conversation-identity .bot-avatar {
    width: 2.45rem;
    height: 2.45rem;
  }

  .messages {
    padding: 0.9rem 0.72rem;
  }

  .bubble {
    max-width: 88%;
    font-size: 0.92rem;
  }

  .bubble.has-code {
    max-width: 96%;
  }

  .composer {
    gap: 0.45rem;
    padding-inline: 0.55rem;
  }

  .send-button {
    width: 2.2rem;
    min-width: 2.2rem;
    height: 2.2rem;
    min-height: 2.2rem;
  }

  .autocomplete-list {
    max-height: 42svh;
    border-radius: 1.15rem;
  }

  .suggestion-copy strong {
    white-space: normal;
  }

  .ambient {
    width: 22rem;
    height: 22rem;
    opacity: 0.34;
  }
}

@media (max-width: 420px) {
  .phone-header {
    grid-template-columns: 2.25rem minmax(0, 1fr) 2.25rem;
  }

  .header-action {
    width: 2.15rem;
    height: 2.15rem;
  }

  .identity-copy strong {
    max-width: 12rem;
  }

  .section-title,
  .splus-form-head,
  .qa-item header {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-box {
    width: 100%;
  }
}

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

@media (update: slow), (prefers-reduced-motion: reduce) {
  .ambient,
  .chat-page::before {
    animation: none !important;
  }

  .glass-panel,
  .intro-card,
  .phone-shell,
  .phone-header,
  .composer,
  .info-modal-card,
  .autocomplete-list {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}


.back-link {
  text-decoration: none;
}

.admin-theme-toggle {
  border: 1px solid rgba(15, 111, 255, 0.14);
}

.ghost-button .button-icon,
.solid-button .button-icon,
.qa-form button .button-icon,
.token-form button .button-icon {
  margin-inline-end: 0.35rem;
}

.section-title h2 .title-icon,
.auth-card h2 .title-icon {
  margin-inline-end: 0.45rem;
}

@media (max-width: 420px) {
  .phone-header {
    grid-template-columns: 2.25rem minmax(0, 1fr) auto;
  }

  .header-actions-end {
    gap: 0.32rem;
  }
}


.top-actions > * {
  flex: 0 0 auto;
}

@media (max-width: 760px) {
  .top-actions > * {
    flex: 1;
  }
}


/* Final alignment guard */
.ghost-button .button-icon,
.solid-button .button-icon,
.qa-form button .button-icon,
.token-form button .button-icon,
.section-title h2 .title-icon,
.auth-card h2 .title-icon {
  margin: 0 !important;
}

@media (max-width: 420px) {
  .phone-header {
    grid-template-columns: 4.55rem minmax(0, 1fr) 4.55rem;
  }
}


/* Composer UX refresh */
html[data-theme="dark"] .composer {
  background: rgba(8, 13, 24, 0.74);
}

html[data-theme="dark"] .composer-box {
  border-color: rgba(226, 232, 240, 0.14);
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(15, 23, 42, 0.82));
  box-shadow:
    0 18px 42px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

html[data-theme="dark"] .composer textarea {
  color: var(--ink);
}

html[data-theme="dark"] .composer textarea::placeholder {
  color: rgba(203, 213, 225, 0.52);
}

html[data-theme="dark"] .composer-helper {
  color: rgba(203, 213, 225, 0.5);
}

.composer {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.42rem;
  padding: 0.72rem 0.75rem calc(0.72rem + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(76, 100, 138, 0.11);
  background: rgba(255, 255, 255, 0.74);
}

.composer-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: end;
  border: 1px solid rgba(76, 100, 138, 0.16);
  border-radius: 1.65rem;
  padding: 0.52rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 251, 255, 0.9));
  box-shadow:
    0 18px 42px rgba(38, 59, 92, 0.13),
    0 6px 16px rgba(38, 59, 92, 0.07),
    inset 0 1px 0 rgba(255, 255, 255, 0.92);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

.composer.is-focused .composer-box {
  border-color: rgba(15, 111, 255, 0.38);
  box-shadow:
    0 22px 52px rgba(15, 111, 255, 0.14),
    0 8px 18px rgba(38, 59, 92, 0.08),
    0 0 0 4px rgba(15, 111, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.95);
}

html[data-theme="dark"] .composer.is-focused .composer-box {
  border-color: rgba(97, 165, 255, 0.42);
  box-shadow:
    0 22px 52px rgba(0, 0, 0, 0.34),
    0 0 0 4px rgba(97, 165, 255, 0.11),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.composer-input-wrap {
  position: relative;
  min-width: 0;
}

.composer textarea {
  display: block;
  width: 100%;
  height: auto;
  min-height: 2.5rem;
  max-height: 10.5rem;
  margin: 0;
  border: 0;
  border-radius: 1.2rem;
  outline: none;
  resize: none;
  overflow-y: hidden;
  padding: 0.58rem 0.82rem 0.56rem;
  color: var(--ink);
  background: transparent;
  box-shadow: none;
  font-size: 0.94rem;
  line-height: 1.85;
  scrollbar-width: thin;
  scrollbar-color: rgba(100, 116, 139, 0.34) transparent;
}

.composer textarea::placeholder {
  color: rgba(100, 116, 139, 0.66);
}

.composer textarea:focus {
  background: transparent;
  box-shadow: none;
}

.composer textarea::-webkit-scrollbar {
  width: 0.42rem;
}

.composer textarea::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.3);
}

.composer-helper {
  min-height: 1rem;
  padding-inline: 0.65rem;
  color: rgba(100, 116, 139, 0.72);
  font-size: 0.68rem;
  line-height: 1.35;
  text-align: start;
  opacity: 0.86;
  user-select: none;
}

.send-button {
  align-self: end;
  width: 2.32rem;
  min-width: 2.32rem;
  height: 2.32rem;
  min-height: 2.32rem;
  margin-bottom: 0.08rem;
  transform: scale(0.92);
  opacity: 0.56;
  background: #94a3b8;
  box-shadow: none;
}

.composer.has-text .send-button {
  opacity: 1;
  transform: scale(1);
  background: var(--primary);
  box-shadow:
    0 14px 24px rgba(15, 111, 255, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.28);
}

.send-button:disabled {
  cursor: default;
  opacity: 0.56;
}

.composer.has-text .send-button:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.03);
}

.composer.is-sending .send-button {
  animation: sendPulse 820ms ease-in-out infinite;
}

.autocomplete-list {
  bottom: calc(100% + 0.75rem);
  border-radius: 1.35rem;
}

@keyframes sendPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(0.94); }
}

@media (max-width: 640px) {
  .composer {
    padding: 0.58rem 0.58rem calc(0.58rem + env(safe-area-inset-bottom));
  }

  .composer-box {
    border-radius: 1.35rem;
    padding: 0.44rem;
  }

  .composer textarea {
    min-height: 2.35rem;
    max-height: 8.5rem;
    padding: 0.5rem 0.72rem;
    font-size: 0.92rem;
  }

  .composer-helper {
    display: none;
  }

  .send-button {
    width: 2.18rem;
    min-width: 2.18rem;
    height: 2.18rem;
    min-height: 2.18rem;
  }
}


/* Android and mobile keyboard viewport fix */
@supports (height: 100dvh) {
  :root {
    --app-height: 100dvh;
  }
}

@media (max-width: 640px) {
  html {
    height: var(--app-height);
    overflow: hidden;
  }

  body.chat-page {
    height: var(--app-height);
    min-height: var(--app-height);
    overflow: hidden;
    overscroll-behavior: none;
  }

  .chat-layout {
    height: var(--app-height);
    min-height: var(--app-height);
    max-height: var(--app-height);
    align-items: stretch;
    padding: 0.35rem 0;
  }

  .phone-shell {
    height: calc(var(--app-height) - 0.7rem);
    min-height: calc(var(--app-height) - 0.7rem);
    max-height: calc(var(--app-height) - 0.7rem);
  }

  .messages {
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-padding-bottom: 1rem;
  }

  .composer {
    position: relative;
    z-index: 8;
    flex-shrink: 0;
    transform: translateZ(0);
  }

  .composer-box {
    will-change: auto;
  }

  html.keyboard-open .phone-header {
    min-height: 4.35rem;
    padding-block: 0.46rem;
  }

  html.keyboard-open .identity-copy small {
    display: none;
  }

  html.keyboard-open .messages {
    padding-top: 0.62rem;
    padding-bottom: 0.62rem;
  }

  html.keyboard-open .composer {
    padding-top: 0.45rem;
    padding-bottom: calc(0.45rem + env(safe-area-inset-bottom));
  }

  html.keyboard-open .composer textarea {
    max-height: min(7rem, calc(var(--app-height) * 0.24));
  }

  html.keyboard-open .autocomplete-list {
    max-height: min(12rem, calc(var(--app-height) * 0.34));
  }

  html.keyboard-open .ambient,
  html.keyboard-open body.chat-page::before {
    animation-play-state: paused;
  }
}

@media (max-width: 900px) and (max-height: 540px) {
  .chat-layout {
    height: var(--app-height);
    min-height: var(--app-height);
    max-height: var(--app-height);
    padding-block: 0.25rem;
  }

  .phone-shell {
    height: calc(var(--app-height) - 0.5rem);
    min-height: calc(var(--app-height) - 0.5rem);
    max-height: calc(var(--app-height) - 0.5rem);
  }

  .phone-header {
    min-height: 4rem;
  }

  .composer textarea {
    max-height: min(6rem, calc(var(--app-height) * 0.26));
  }
}
