/* ═══════════════════════════════════════════════════════════
   JTA MENTOR — one stylesheet, dark only.
   Palette (locked): #0A0913 bg · #1A1436 surface · #8B5CF6 gold
                     #34D399 success · #FB7185 error/warning
   Type: Archivo Black (display) · Space Mono (everything)
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg: #0A0913;
  --surface: #1A1436;
  --gold: #8B5CF6;
  --success: #34D399;
  --error: #FB7185;
  --ink: #ECEAFE;
  --ink-dim: rgba(236, 234, 254, 0.55);
  --ink-faint: rgba(236, 234, 254, 0.32);
  --gold-06: rgba(139, 92, 246, 0.06);
  --gold-12: rgba(139, 92, 246, 0.12);
  --gold-20: rgba(139, 92, 246, 0.20);
  --gold-40: rgba(139, 92, 246, 0.40);
  --gold-70: rgba(139, 92, 246, 0.70);
  --cyan: #22D3EE;
  --pink: #F472B6;
  /* live RGB gradient — full-spectrum, animated (see gradFlow) so nothing feels static */
  --grad: linear-gradient(110deg, #8B5CF6 0%, #EC4899 30%, #F472B6 45%, #22D3EE 72%, #8B5CF6 100%);
  --grad-soft: linear-gradient(120deg, rgba(139,92,246,0.20), rgba(236,72,153,0.14), rgba(34,211,238,0.16));
  --mono: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --display: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

@keyframes gradFlow { to { background-position: 200% center; } }

/* ── vibrant, animated gradient accents (the "wow") ── */
.wm-accent {
  background: var(--grad);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
  animation: gradFlow 9s linear infinite;
}
.gate-btn, .send-btn, .mini-btn.gold {
  background: var(--grad) !important;
  background-size: 200% auto !important;
  color: #0A0913 !important;
  animation: gradFlow 9s linear infinite;
}
.credits-pill:not(.low) { border-color: var(--gold-40); }

* { margin: 0; padding: 0; box-sizing: border-box; }

[hidden] { display: none !important; }

/* restore modal centering that the * { margin:0 } reset above cancels */
dialog { margin: auto; }

html, body { height: 100%; }

html, body { overscroll-behavior-y: none; } /* no rubber-band/pull-to-refresh page bounce */

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  color-scheme: dark; /* native date/number pickers + scrollbars render dark */
  -webkit-text-size-adjust: 100%;    /* don't auto-inflate text on rotate */
  text-size-adjust: 100%;
  /* chrome (buttons, bars, labels) shouldn't be selectable/long-press-
     calloutable — that's what reads as "a webpage" on a phone. Actual
     content (chat bubbles, inputs) opts back in below. */
  -webkit-user-select: none; user-select: none;
  -webkit-touch-callout: none;
}

/* no double-tap zoom, no tap-highlight flash → feels like a native app */
* { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }

/* content that genuinely should stay selectable/copyable */
.bubble, input, textarea {
  -webkit-user-select: text; user-select: text;
  -webkit-touch-callout: default;
}

/* logo marks: no drag-ghost on long-press */
.brand-logo, .brand-logo-sm { -webkit-user-drag: none; user-drag: none; }

/* admin console is a desktop staff tool, not something students install as
   an app — keep normal text selection everywhere (copying a phone number,
   an escalation question, an error message, etc. should just work). */
.admin-body {
  -webkit-user-select: auto; user-select: auto;
  -webkit-touch-callout: default;
}

/* Inter isn't inherently heavy — give display elements real weight */
.wordmark, .topbar-brand, .kb-title, .lang-title, .pricing-title { font-weight: 800; letter-spacing: -0.01em; }
.panel-h, .edit-title, #edit-title { font-weight: 700; }
button, input, textarea, select { font-family: inherit; }

/* native date input calendar icon → gold, visible on dark surfaces */
input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(72%) sepia(38%) saturate(700%) hue-rotate(330deg);
  cursor: pointer;
  opacity: 0.85;
}

::selection { background: var(--gold-40); color: var(--bg); }

/* ── custom scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(139, 92, 246, 0.22);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(139, 92, 246, 0.45); }
* { scrollbar-width: thin; scrollbar-color: rgba(139,92,246,0.25) transparent; }

/* ── ambient background canvas ── */
#ambient {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* soft vignette + gold breath over the void */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 70% 50% at 22% 18%, rgba(139,92,246,0.16), transparent 62%),
    radial-gradient(ellipse 70% 50% at 82% 12%, rgba(34,211,238,0.12), transparent 60%),
    radial-gradient(ellipse 90% 60% at 50% 116%, rgba(244,114,182,0.10), transparent 64%),
    radial-gradient(ellipse 120% 80% at 50% 108%, rgba(26,20,54,0.55), transparent 70%);
}

/* ═══════════════ STATE 1 · GATE ═══════════════ */

#gate {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1),
              filter 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#gate.dissolve {
  opacity: 0;
  filter: blur(8px);
  pointer-events: none;
}

.gate-card {
  width: min(400px, 100%);
  padding: 52px 40px 44px;
  border-radius: 20px;
  background: rgba(26, 20, 54, 0.38);
  border: 1px solid var(--gold-20);
  backdrop-filter: blur(24px) saturate(1.15);
  -webkit-backdrop-filter: blur(24px) saturate(1.15);
  box-shadow:
    0 40px 90px rgba(0, 0, 0, 0.65),
    0 0 120px rgba(139, 92, 246, 0.05),
    inset 0 1px 0 rgba(139, 92, 246, 0.10);
  animation: cardFloat 7s ease-in-out infinite;
  transform-origin: center;
}

@keyframes cardFloat {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.gate-card.shake {
  animation: shake 0.45s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: fadeUp 0.8s ease 0.15s both;
}

.brand-logo {
  height: clamp(30px, 8vw, 42px);
  width: auto;
  object-fit: contain;
}

/* wordmark — letter-spacing intro */
.wordmark {
  font-family: var(--display);
  font-size: clamp(1.55rem, 7vw, 2.1rem);
  text-align: center;
  color: var(--ink);
  letter-spacing: 0.10em;
  white-space: nowrap;
  animation: trackIn 1.1s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* .wm-accent gradient fill defined at top of file */

@keyframes trackIn {
  from { letter-spacing: 0.45em; opacity: 0; filter: blur(6px); }
  to   { letter-spacing: 0.10em; opacity: 1; filter: blur(0); }
}

.tagline {
  margin-top: 10px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  animation: fadeUp 0.8s ease 0.45s both;
}

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

#login-form {
  margin-top: 40px;
  animation: fadeUp 0.8s ease 0.6s both;
}

.field-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--ink-faint);
  margin: 0 0 8px 2px;
}

.pin-label { margin-top: 22px; }

#phone {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  background: rgba(10, 9, 19, 0.55);
  border: 1px solid var(--gold-12);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.08em;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}

#phone::placeholder { color: var(--ink-faint); letter-spacing: 0.04em; }

#phone:focus, .pin-box:focus {
  border-color: var(--gold-70);
  box-shadow: 0 0 0 3px var(--gold-12), 0 0 24px rgba(139, 92, 246, 0.10);
}

.pin-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.pin-box {
  width: 100%;
  min-width: 0;
  height: 56px;
  text-align: center;
  background: rgba(10, 9, 19, 0.55);
  border: 1px solid var(--gold-12);
  border-radius: 10px;
  color: var(--gold);
  font-family: var(--mono);
  font-size: 22px;
  outline: none;
  caret-color: var(--gold);
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}

.gate-error {
  min-height: 20px;
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--error);
  text-align: center;
}

.gate-btn {
  width: 100%;
  height: 54px;
  margin-top: 8px;
  border: none;
  border-radius: 10px;
  background: var(--gold);
  color: #0A0913;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.32em;
  text-indent: 0.32em;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(139, 92, 246, 0.22);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.gate-btn:hover { filter: brightness(1.07); box-shadow: 0 8px 32px rgba(139, 92, 246, 0.30); }
.gate-btn:active { transform: translateY(2px) scale(0.99); box-shadow: 0 2px 10px rgba(139, 92, 246, 0.18); }
.gate-btn:disabled { opacity: 0.55; cursor: wait; }

/* ═══════════════ NEW FLOW: Pricing → Loading → Login → Welcome ═══════════════ */

.gate-state { position: relative; z-index: 1; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; transition: opacity 0.4s ease, filter 0.4s ease; }
.gate-state.dissolve { opacity: 0; filter: blur(8px); pointer-events: none; }

/* Pricing Gate */
.pricing-intro { margin-top: 36px; text-align: center; animation: fadeUp 0.8s ease 0.6s both; }
.pricing-desc { font-size: 14px; color: var(--ink); margin-bottom: 8px; }
.pricing-subtext { font-size: 12px; color: var(--ink-dim); letter-spacing: 0.05em; }

.pricing-packs { margin-top: 32px; display: grid; gap: 14px; animation: fadeUp 0.8s ease 0.75s both; }
.pack { padding: 20px 24px; background: rgba(139, 92, 246, 0.08); border: 1px solid rgba(139, 92, 246, 0.2); border-radius: 12px; cursor: pointer; transition: all 0.2s ease; }
.pack:hover { background: rgba(139, 92, 246, 0.12); border-color: rgba(139, 92, 246, 0.4); }
.pack-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.pack-credits { font-weight: 700; color: var(--gold); font-size: 18px; }
.pack-rupees { font-size: 13px; color: var(--ink-dim); }
.pack-label { font-size: 11px; color: var(--ink-faint); letter-spacing: 0.1em; text-transform: uppercase; }

.pricing-login-link { margin-top: 6px; background: none; border: none; cursor: pointer; font: inherit; font-size: 12px; color: var(--ink-dim); letter-spacing: 0.04em; text-align: center; padding: 10px; transition: color 0.2s ease; }
.pricing-login-link:hover { color: var(--gold); }

.pricing-note { margin-top: 24px; font-size: 11px; color: var(--ink-faint); text-align: center; letter-spacing: 0.05em; animation: fadeUp 0.8s ease 0.9s both; }

/* Loading Screen */
.gate-loading-card { display: flex; flex-direction: column; align-items: center; gap: 28px; padding: 60px 40px; }

.loading-spinner { position: relative; width: 56px; height: 56px; }
.spinner { width: 100%; height: 100%; border: 3px solid rgba(139, 92, 246, 0.2); border-top-color: var(--gold); border-radius: 50%; animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.loading-title { font-size: 16px; font-weight: 700; color: var(--ink); text-align: center; }
.loading-tip { font-size: 13px; color: var(--ink-dim); text-align: center; line-height: 1.7; max-width: 300px; animation: fade-cycle 4s ease-in-out infinite; }
@keyframes fade-cycle { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }

/* Welcome Screen */
.welcome-screen { position: fixed; inset: 0; z-index: 200; display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--bg); }

.celebration { position: absolute; top: 0; left: 0; width: 100%; height: 100%; overflow: hidden; }
.balloon { position: absolute; bottom: -50px; width: 30px; height: 40px; background: var(--grad); border-radius: 50% 50% 50% 0; opacity: 0.8; animation: float-up 3s ease-in infinite; }
@keyframes float-up { to { transform: translateY(-110vh) rotate(360deg); opacity: 0; } }

.welcome-title { font-size: 48px; font-weight: 800; color: var(--gold); text-align: center; margin-bottom: 12px; animation: scaleIn 0.6s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes scaleIn { from { transform: scale(0.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.welcome-message { font-size: 14px; color: var(--ink-dim); text-align: center; margin-bottom: 32px; animation: fadeUp 0.8s ease 0.2s both; }
.welcome-spinner { animation: fadeUp 0.8s ease 0.4s both; }

/* ═══════════════ STATE 2 · CHAT ═══════════════ */

#chat {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat.live { opacity: 1; }

.topbar {
  flex: none;
  z-index: 10;
  /* logical content band stays 58px; the safe-area inset (notch/Dynamic
     Island, only nonzero when installed as a home-screen app) adds on top
     instead of squeezing the content — border-box keeps the math exact. */
  height: calc(58px + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10, 9, 19, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--gold-12);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--display);
  font-size: 14px;
  letter-spacing: 0.14em;
  color: var(--ink);
  white-space: nowrap;
}

.brand-logo-sm {
  height: 20px;
  width: auto;
  object-fit: contain;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.credits-pill {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
  border: 1px solid rgba(139, 92, 246, 0.30);
  border-radius: 999px;
  padding: 4px 13px;
  background: var(--gold-06);
  transition: color 0.3s ease, border-color 0.3s ease;
}

.credits-pill.low {
  color: var(--error);
  border-color: rgba(251, 113, 133, 0.45);
  background: rgba(251, 113, 133, 0.06);
}

.student-name {
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--ink-dim);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-logout {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  background: none;
  border: 1px solid var(--gold-12);
  border-radius: 9px;
  color: var(--ink-dim);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}
.topbar-logout svg { width: 17px; height: 17px; }
.topbar-logout:hover { color: var(--gold); border-color: var(--gold-70); }
.topbar-logout:active { transform: scale(0.94); }

#messages {
  flex: 1 1 auto;
  overflow-y: auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 18px 28px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overscroll-behavior: contain;
}

.empty-state {
  margin-top: 24vh;
  text-align: center;
  font-size: 13px;
  letter-spacing: 0.14em;
  color: var(--ink-faint);
}

.empty-state::before {
  content: '\25C8';
  display: block;
  color: var(--gold-40);
  font-size: 18px;
  margin-bottom: 14px;
}

.history-loader { text-align: center; }

.load-older {
  background: none;
  border: 1px solid var(--gold-20);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.2em;
  padding: 6px 18px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}
.load-older:hover { border-color: var(--gold-70); color: var(--gold); }

/* message bubbles */
.msg { display: flex; flex-direction: column; animation: msgIn 0.3s ease both; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.student { align-items: flex-end; }

.msg.student .bubble {
  max-width: 82%;
  background: var(--surface);
  border: 1px solid rgba(139, 92, 246, 0.08);
  border-radius: 14px 14px 4px 14px;
  padding: 12px 16px;
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg.student .bubble img {
  display: block;
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
  border: 1px solid var(--gold-12);
}

.msg.mentor { align-items: flex-start; }

.mentor-tag {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: var(--gold-70);
  margin: 0 0 6px 18px;
}

.msg.mentor .bubble {
  max-width: 94%;
  border-left: 2px solid rgba(139, 92, 246, 0.55);
  padding: 2px 0 2px 16px;
  color: rgba(236, 234, 254, 0.92);
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* streaming cursor */
.cursor {
  display: inline-block;
  width: 8px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--gold-70);
  animation: blink 0.9s steps(2, start) infinite;
}

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

/* typing indicator — three gold dots */
.typing {
  display: inline-flex;
  gap: 6px;
  padding: 8px 0 8px 16px;
  border-left: 2px solid rgba(139, 92, 246, 0.55);
}

.typing i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.typing i:nth-child(2) { animation-delay: 0.18s; }
.typing i:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotPulse {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-4px); }
}

/* copy button on mentor replies */
.copy-btn {
  align-self: flex-start;
  margin: 8px 0 0 18px;
  background: none;
  border: none;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.26em;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.2s;
}
.copy-btn:hover { color: var(--gold); }
.copy-btn.done { color: var(--gold); }

/* lock banner (credits out / expired) */
.lock-banner {
  flex: none;
  z-index: 11;
  margin: 0 auto 12px;
  width: min(600px, calc(100% - 32px));
  padding: 14px 20px;
  border-radius: 12px;
  background: rgba(26, 20, 54, 0.85);
  border: 1px solid var(--gold-40);
  backdrop-filter: blur(16px);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

/* ── composer ── */
.composer {
  flex: none;
  z-index: 10;
  background: rgba(10, 9, 19, 0.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--gold-12);
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
}

.composer-inner { max-width: 760px; margin: 0 auto; }

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.icon-btn {
  flex: 0 0 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(26, 20, 54, 0.6);
  border: 1px solid var(--gold-12);
  border-radius: 12px;
  color: var(--gold-70);
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.12s;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { border-color: var(--gold-70); color: var(--gold); }
.icon-btn:active { transform: scale(0.94); }

#input {
  flex: 1;
  min-height: 46px;
  max-height: 132px;
  padding: 12px 16px;
  background: rgba(26, 20, 54, 0.6);
  border: 1px solid var(--gold-12);
  border-radius: 12px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
  resize: none;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}

#input::placeholder { color: var(--ink-faint); }

#input:focus {
  border-color: var(--gold-70);
  box-shadow: 0 0 0 3px var(--gold-12);
}

#input:disabled { opacity: 0.45; }

.send-btn {
  flex: 0 0 46px;
  height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gold);
  border: none;
  border-radius: 12px;
  color: #0A0913;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.25);
  transition: transform 0.12s ease, filter 0.2s ease, opacity 0.2s;
}
.send-btn svg { width: 20px; height: 20px; }
.send-btn:hover { filter: brightness(1.07); }
.send-btn:active { transform: translateY(1px) scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* attach preview chip */
.attach-chip {
  position: relative;
  display: inline-block;
  margin-bottom: 10px;
}

.attach-chip img {
  height: 58px;
  border-radius: 8px;
  border: 1px solid var(--gold-40);
  display: block;
}

.attach-remove {
  position: absolute;
  top: -7px; right: -7px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--error);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}

/* system / error line in chat (infra failures — spec reserves #FB7185 for errors) */
.msg.system { align-items: flex-start; }
.system-line {
  max-width: 94%;
  border-left: 2px solid rgba(251, 113, 133, 0.55);
  padding: 2px 0 2px 16px;
  color: var(--error);
  font-size: 12.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .gate-card,
  .gate-card.shake,
  .wordmark,
  .tagline,
  #login-form,
  .msg { animation: none !important; }
  .tagline, #login-form { opacity: 1; }
  .cursor { animation: none; opacity: 1; }        /* solid cursor, no blink */
  .typing i { animation: none; opacity: 0.6; }    /* static dots */
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── small screens ── */
@media (max-width: 480px) {
  .gate-card { padding: 44px 26px 36px; }
  .student-name { display: none; }
  .msg.student .bubble { max-width: 88%; }
}

/* ═══════════════ ADMIN CONSOLE (not linked from student page) ═══════════════ */

#agate {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  transition: opacity 0.4s ease, filter 0.4s ease;
}
#agate.dissolve { opacity: 0; filter: blur(8px); pointer-events: none; }

#console { position: relative; z-index: 1; opacity: 0; transition: opacity 0.4s ease; }
#console.live { opacity: 1; }

.admin-tabs {
  position: sticky; top: 58px; z-index: 9;
  display: flex; gap: 8px;
  max-width: 1040px; margin: 0 auto;
  padding: 70px 18px 12px;
  background: linear-gradient(to bottom, var(--bg) 82%, transparent);
}

.tab {
  background: none;
  border: 1px solid var(--gold-12);
  border-radius: 999px;
  color: var(--ink-dim);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  padding: 8px 16px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.tab:hover { color: var(--gold); border-color: var(--gold-40); }
.tab.active { color: var(--gold); border-color: var(--gold-70); background: var(--gold-06); }

.admin-main { max-width: 1040px; margin: 0 auto; padding: 10px 18px 80px; }

.panel-h {
  font-family: var(--display);
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-dim);
  margin: 26px 0 12px;
}

.panel-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 14px 0;
}

.panel-note { font-size: 10px; letter-spacing: 0.08em; color: var(--ink-faint); }

.mini-btn {
  background: rgba(26, 20, 54, 0.6);
  border: 1px solid var(--gold-20);
  border-radius: 8px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  padding: 8px 14px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, transform 0.1s;
}
.mini-btn:hover { border-color: var(--gold-70); color: var(--gold); }
.mini-btn:active { transform: scale(0.97); }
.mini-btn.gold { background: var(--gold); color: #0A0913; border-color: var(--gold); font-weight: 700; }
.mini-btn.gold:hover { color: #0A0913; filter: brightness(1.07); }
.mini-btn.danger { border-color: rgba(251,113,133,0.45); }
.mini-btn.danger:hover, .mini-btn.danger.active { color: var(--error); border-color: var(--error); }
.filter-btn.active { color: var(--gold); border-color: var(--gold-70); }

.table-wrap { overflow-x: auto; border: 1px solid var(--gold-12); border-radius: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 12px; }
th {
  text-align: left;
  font-size: 9px; letter-spacing: 0.22em;
  color: var(--ink-faint);
  padding: 12px 14px;
  border-bottom: 1px solid var(--gold-12);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid rgba(139,92,246,0.05); white-space: nowrap; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(139, 92, 246, 0.03); }
td .mini-btn { padding: 4px 10px; font-size: 10px; }
.td-expired { color: var(--error); }
.td-dim { color: var(--ink-faint); }

.csv-box { margin: 0 0 14px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

textarea#csv-text, .esc-answer textarea, #edit-dialog input, #edit-dialog select {
  width: 100%;
  background: rgba(10, 9, 19, 0.55);
  border: 1px solid var(--gold-12);
  border-radius: 10px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  padding: 12px 14px;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea#csv-text:focus, .esc-answer textarea:focus,
#edit-dialog input:focus, #edit-dialog select:focus {
  border-color: var(--gold-70);
  box-shadow: 0 0 0 3px var(--gold-12);
}

/* ═══════════════ KNOWLEDGE CORE — the KB manager ═══════════════ */

.kb-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin: 8px 0 18px;
}
.kb-title {
  font-family: var(--display);
  font-size: 15px;
  letter-spacing: 0.16em;
  color: var(--ink);
}
.kb-sub {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-dim);
  display: flex; align-items: center; gap: 8px;
}
.kb-live {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 0 rgba(139, 92, 246, 0.55);
  animation: kbPulse 2.4s ease-out infinite;
}
@keyframes kbPulse {
  0%   { box-shadow: 0 0 0 0 rgba(139,92,246,0.45); }
  70%  { box-shadow: 0 0 0 7px rgba(139,92,246,0); }
  100% { box-shadow: 0 0 0 0 rgba(139,92,246,0); }
}

.kb-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 16px;
  min-height: 520px;
}

/* ── entry list ── */
.kb-list {
  display: flex; flex-direction: column; gap: 10px;
  max-height: 72vh; overflow-y: auto;
  padding-right: 4px;
}
.kb-card {
  text-align: left;
  background: linear-gradient(180deg, rgba(26,20,54,0.55), rgba(26,20,54,0.30));
  border: 1px solid var(--gold-12);
  border-radius: 12px;
  padding: 13px 15px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.12s, box-shadow 0.25s;
}
.kb-card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--gold); opacity: 0; transition: opacity 0.2s;
}
.kb-card:hover { border-color: var(--gold-40); transform: translateY(-1px); }
.kb-card.active {
  border-color: var(--gold-70);
  box-shadow: 0 0 0 1px var(--gold-40), 0 10px 30px rgba(139,92,246,0.08);
}
.kb-card.active::before { opacity: 1; }
.kb-card-title {
  font-size: 12.5px; font-weight: 700; color: var(--gold);
  letter-spacing: 0.03em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kb-card-preview {
  margin-top: 5px;
  font-size: 10.5px; line-height: 1.5; color: var(--ink-dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.kb-card-meta { margin-top: 7px; font-size: 9px; letter-spacing: 0.12em; color: var(--ink-faint); }
.kb-list-empty { font-size: 11px; color: var(--ink-faint); padding: 20px 6px; letter-spacing: 0.06em; }

/* ── editor pane ── */
.kb-editor {
  position: relative;
  border: 1px solid var(--gold-12);
  border-radius: 16px;
  background:
    radial-gradient(120% 60% at 50% -10%, rgba(139,92,246,0.06), transparent 60%),
    linear-gradient(180deg, rgba(26,20,54,0.35), rgba(10,9,19,0.35));
  box-shadow: inset 0 1px 0 rgba(139,92,246,0.08);
  padding: 20px;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.kb-editor::after { /* faint scanline sheen — the "AI working" feel */
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(139,92,246,0.012) 3px 4px);
  opacity: 0.6;
}

.kb-empty {
  margin: auto; text-align: center; max-width: 360px;
  color: var(--ink-dim);
}
.kb-empty-mark {
  font-size: 30px; color: var(--gold-40);
  margin-bottom: 14px;
  animation: kbFloat 5s ease-in-out infinite;
}
@keyframes kbFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
.kb-empty p { font-size: 13px; letter-spacing: 0.04em; }
.kb-empty-sub { margin-top: 8px; font-size: 11px; color: var(--ink-faint); }

.kb-form { display: flex; flex-direction: column; gap: 14px; position: relative; z-index: 1; height: 100%; }

.kb-name-input {
  width: 100%;
  background: rgba(10,9,19,0.5);
  border: 1px solid var(--gold-12);
  border-radius: 10px;
  color: var(--gold);
  font-family: var(--display);
  font-size: 16px;
  letter-spacing: 0.04em;
  padding: 14px 16px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.25s;
}
.kb-name-input::placeholder { color: var(--ink-faint); font-family: var(--mono); font-weight: 400; letter-spacing: 0.02em; }
.kb-name-input:focus { border-color: var(--gold-70); box-shadow: 0 0 0 3px var(--gold-12), 0 0 30px rgba(139,92,246,0.10); }

.kb-body {
  flex: 1; min-height: 320px;
  width: 100%;
  background: rgba(10,9,19,0.5);
  border: 1px solid var(--gold-12);
  border-radius: 12px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  padding: 16px;
  outline: none;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.25s;
}
.kb-body:focus { border-color: var(--gold-70); box-shadow: 0 0 0 3px var(--gold-12), inset 0 0 40px rgba(139,92,246,0.03); }

.kb-actions { display: flex; align-items: center; gap: 12px; }
.kb-status { flex: 1; font-size: 11px; letter-spacing: 0.06em; color: var(--ink-faint); }
.kb-status.saved { color: var(--gold); }
.kb-status.err { color: var(--error); }

.kb-history { margin-top: 2px; }
.kb-history summary {
  font-size: 10px; letter-spacing: 0.2em; color: var(--ink-faint);
  cursor: pointer; padding: 4px 0; list-style: none;
}
.kb-history summary::-webkit-details-marker { display: none; }
.kb-history summary:hover { color: var(--gold); }

@media (max-width: 720px) {
  .kb-layout { grid-template-columns: 1fr; }
  .kb-list { max-height: 220px; }
}
@media (prefers-reduced-motion: reduce) {
  .kb-live, .kb-empty-mark { animation: none; }
}

/* escalation cards */
.esc-card {
  border: 1px solid var(--gold-12);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 14px;
  background: rgba(26, 20, 54, 0.35);
}
.esc-card.wellbeing { border-color: rgba(251, 113, 133, 0.45); }
.esc-card.approved { border-color: rgba(52, 211, 153, 0.9); background: rgba(52, 211, 153, 0.25); }

.esc-head { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; margin-bottom: 8px; }
.esc-type {
  font-size: 9px; letter-spacing: 0.24em; font-weight: 700;
  color: var(--gold);
  border: 1px solid var(--gold-40);
  border-radius: 999px;
  padding: 2px 10px;
}
.esc-card.wellbeing .esc-type { color: var(--error); border-color: rgba(251,113,133,0.5); }
.esc-student { font-size: 12px; color: var(--ink); font-weight: 700; }
.esc-when, .esc-status { font-size: 10px; color: var(--ink-faint); letter-spacing: 0.08em; }

.esc-q { font-size: 13px; margin: 6px 0 4px; white-space: pre-wrap; }
.esc-ctx { font-size: 11px; color: var(--ink-dim); }
.esc-a { font-size: 12.5px; color: var(--ink-dim); margin-top: 10px; border-left: 2px solid var(--gold-40); padding-left: 12px; white-space: pre-wrap; }

.esc-answer { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.esc-answer textarea { min-height: 70px; }

/* usage bars */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; font-size: 11px; }
.bar-label { flex: 0 0 150px; color: var(--ink-dim); text-align: right; letter-spacing: 0.06em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 10px; border-radius: 99px; background: rgba(139,92,246,0.07); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--gold); opacity: 0.75; }
.bar-num { flex: 0 0 40px; color: var(--gold); font-weight: 700; }

/* KB version log */
.ver-row {
  display: flex; gap: 16px; align-items: baseline;
  font-size: 11px; color: var(--ink-dim);
  padding: 8px 4px;
  border-bottom: 1px solid rgba(139,92,246,0.06);
}
.ver-row b { color: var(--gold); font-weight: 700; }

/* edit dialog */
#edit-dialog {
  background: rgba(26, 20, 54, 0.92);
  border: 1px solid var(--gold-20);
  border-radius: 16px;
  padding: 28px;
  width: min(420px, calc(100vw - 40px));
  color: var(--ink);
  backdrop-filter: blur(20px);
}
#edit-dialog::backdrop { background: rgba(10, 9, 19, 0.75); backdrop-filter: blur(4px); }
#edit-dialog .field-label { margin-top: 14px; }
#edit-dialog input, #edit-dialog select { height: 42px; padding: 0 12px; }
.dialog-row { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }

/* ═══════════════ LANGUAGE PICKER ═══════════════ */
#lang-dialog {
  border: none;
  background: transparent;
  padding: 0;
  width: min(520px, calc(100vw - 40px));
}
#lang-dialog::backdrop { background: rgba(10, 9, 19, 0.82); backdrop-filter: blur(6px); }

.lang-card {
  border-radius: 22px;
  padding: 34px 30px 28px;
  background: rgba(26, 20, 54, 0.55);
  border: 1px solid var(--gold-20);
  backdrop-filter: blur(26px) saturate(1.2);
  -webkit-backdrop-filter: blur(26px) saturate(1.2);
  box-shadow: 0 40px 90px rgba(0,0,0,0.6), 0 0 120px rgba(139,92,246,0.12), inset 0 1px 0 rgba(139,92,246,0.14);
  animation: langIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
@keyframes langIn { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.lang-title {
  font-family: var(--display);
  font-size: 1.25rem;
  letter-spacing: 0.04em;
  text-align: center;
  color: var(--ink);
}
.lang-sub {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--ink-dim);
}

.lang-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.lang-chip {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 62px;
  border-radius: 13px;
  background: rgba(10, 9, 19, 0.5);
  border: 1px solid var(--gold-12);
  color: var(--ink);
  font-family: var(--mono);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.25s ease, background 0.2s ease;
}
.lang-native { font-size: 15px; letter-spacing: 0.02em; }
.lang-en { font-size: 9px; letter-spacing: 0.16em; color: var(--ink-faint); text-transform: uppercase; }
.lang-chip:hover {
  transform: translateY(-2px);
  border-color: var(--gold-70);
  box-shadow: 0 8px 26px rgba(139,92,246,0.18);
}
.lang-chip.active {
  border-color: transparent;
  background: var(--grad-soft);
  box-shadow: 0 0 0 1px var(--gold-70), 0 10px 30px rgba(139,92,246,0.20);
}
.lang-chip.active .lang-native { color: #fff; }

.lang-close {
  display: block;
  margin: 12px auto 0;
  background: none; border: none;
  color: var(--ink-faint);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.2em;
  cursor: pointer;
  padding: 16px 24px; /* text stays small; tap target is a full 44px+ */
}
.lang-close:hover { color: var(--gold); }

@media (max-width: 420px) {
  .lang-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .lang-card { animation: none; }
}

/* ═══════════════ CREDITS: tier "?" popover, pricing gate, deduction ═══════════════ */
.tier-help {
  flex: none;
  /* matches .topbar-logout's 34px so every topbar icon is an equally easy
     tap target — this used to be 22px (20px on mobile, the wrong direction
     for a finger-sized target) and was the odd one out. */
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: none;
  border: 1px solid var(--gold-40);
  color: var(--gold);
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}
.tier-help:hover { background: var(--gold); color: #0A0913; border-color: var(--gold); }

.tier-pop {
  position: fixed;
  top: calc(62px + env(safe-area-inset-top)); right: 16px;
  z-index: 30;
  width: min(320px, calc(100vw - 32px));
  padding: 14px;
  border-radius: 14px;
  background: rgba(26, 20, 54, 0.9);
  border: 1px solid var(--gold-20);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 20px 50px rgba(0,0,0,0.55), 0 0 60px rgba(139,92,246,0.1);
  animation: fadeUp 0.2s ease both;
}
.tier-pop-head { font-size: 9px; letter-spacing: 0.24em; color: var(--ink-faint); margin-bottom: 10px; }

.tier-row {
  display: grid;
  grid-template-columns: 58px 78px 1fr;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(139,92,246,0.08);
}
.tier-row:last-child { border-bottom: none; }
.tier-cost { font-weight: 700; color: var(--gold); font-size: 13px; }
.tier-name { font-size: 12px; color: var(--ink); letter-spacing: 0.04em; }
.tier-desc { font-size: 10.5px; color: var(--ink-dim); line-height: 1.4; }

.tier-pop-plans {
  margin-top: 10px;
  width: 100%;
  background: none; border: 1px solid var(--gold-20); border-radius: 8px;
  color: var(--gold); font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em;
  padding: 8px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.tier-pop-plans:hover { border-color: var(--gold-70); background: var(--gold-06); }

/* pricing gate */
#pricing-dialog { border: none; background: transparent; padding: 0; width: min(480px, calc(100vw - 40px)); }
#pricing-dialog::backdrop { background: rgba(10, 9, 19, 0.82); backdrop-filter: blur(6px); }
.pricing-card {
  border-radius: 22px;
  padding: 30px 28px 24px;
  background: rgba(26, 20, 54, 0.6);
  border: 1px solid var(--gold-20);
  backdrop-filter: blur(26px) saturate(1.2);
  -webkit-backdrop-filter: blur(26px) saturate(1.2);
  box-shadow: 0 40px 90px rgba(0,0,0,0.6), 0 0 120px rgba(139,92,246,0.12), inset 0 1px 0 rgba(139,92,246,0.14);
  animation: langIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.pricing-title { font-family: var(--display); font-size: 1.25rem; text-align: center; letter-spacing: 0.03em; color: var(--ink); }
.pricing-msg {
  margin-top: 14px; padding: 12px 14px;
  border-radius: 11px;
  background: rgba(244,114,182,0.08);
  border: 1px solid rgba(244,114,182,0.35);
  color: var(--ink);
  font-size: 12.5px; line-height: 1.55; text-align: center;
}
.pricing-section-h {
  margin: 22px 0 10px;
  font-size: 9px; letter-spacing: 0.22em; color: var(--ink-faint);
}
.tier-list { display: flex; flex-direction: column; }

.pack-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pack {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 72px;
  border-radius: 14px;
  text-decoration: none;
  background: var(--grad-soft);
  border: 1px solid var(--gold-40);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.25s ease, border-color 0.2s;
}
.pack:hover { transform: translateY(-2px); border-color: var(--gold-70); box-shadow: 0 10px 30px rgba(139,92,246,0.22); }
.pack-cr { font-size: 16px; font-weight: 700; color: var(--gold); }
.pack-rs { font-size: 12px; color: var(--ink); letter-spacing: 0.04em; }
.pack.pack-off { background: rgba(10,9,19,0.4); border-color: var(--gold-12); cursor: default; opacity: 0.8; }
.pack.pack-off:hover { transform: none; box-shadow: none; border-color: var(--gold-12); }

.pricing-foot { margin-top: 18px; text-align: center; font-size: 10.5px; color: var(--ink-faint); letter-spacing: 0.04em; }

/* inline deduction under a mentor reply */
.deduction {
  align-self: flex-start;
  margin: 8px 0 0 18px;
  font-size: 10px; letter-spacing: 0.14em;
  color: var(--ink-faint);
}

@media (max-width: 440px) {
  .pack-list { grid-template-columns: 1fr 1fr; }
  .tier-row { grid-template-columns: 50px 1fr; }
  .tier-desc { grid-column: 1 / -1; }
}

/* ═══════════════ ESCALATION DELETE + SMOOTH + CLAUDE-LIKE MOBILE ═══════════════ */
.esc-del {
  margin-left: auto;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 7px;
  background: none;
  border: 1px solid rgba(251,113,133,0.30);
  color: var(--error);
  font-size: 15px; line-height: 1; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.12s;
}
.esc-del:hover { background: rgba(251,113,133,0.12); border-color: var(--error); }
.esc-del:active { transform: scale(0.9); }

/* smoother everywhere */
html { scroll-behavior: smooth; }
#messages { -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }

/* richer, more readable message text (Claude-like) */
.msg.student .bubble, .msg.mentor .bubble { font-size: 15px; line-height: 1.65; }
.msg { animation: msgRise 0.34s cubic-bezier(0.16, 1, 0.3, 1) both; }
@keyframes msgRise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* live top accent hairline — subtle motion so the shell never feels static */
.topbar::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px;
  background: var(--grad); background-size: 200% auto;
  opacity: 0.5; animation: gradFlow 9s linear infinite;
}
.topbar { position: relative; }

/* ── mobile: make it feel like a native chat app ── */
@media (max-width: 600px) {
  body { font-size: 16px; }
  .topbar { height: calc(54px + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 14px 0; }
  .topbar-brand { font-size: 15px; gap: 6px; }
  /* the full JAWAAD lockup is already shown big on the gate screen — a
     second tiny copy next to "JTA MENTOR" here just eats width the topbar
     icons need on a phone-sized screen, so it drops out below 600px. */
  .brand-logo-sm { display: none; }
  .topbar-right { gap: 10px; }
  #messages { padding: 18px 14px 24px; gap: 18px; }
  .msg.student .bubble, .msg.mentor .bubble { font-size: 15.5px; line-height: 1.6; }
  .msg.student .bubble { max-width: 85%; border-radius: 18px 18px 5px 18px; padding: 11px 15px; }
  .msg.mentor .bubble { max-width: 100%; }
  .composer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  #input { font-size: 16px; border-radius: 22px; }          /* 16px stops iOS input-zoom */
  .icon-btn, .send-btn { width: 44px; height: 44px; border-radius: 22px; }
  .credits-pill { font-size: 11px; padding: 4px 10px; }
  .empty-state { margin-top: 30vh; }
  #phone, .pin-box, #input, textarea, select { font-size: 16px; } /* no focus-zoom on iOS */
}
