@font-face {
  font-family: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("../fonts/readex-pro-arabic.woff2") format("woff2");
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF,
    U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC;
}
@font-face {
  font-family: "Readex Pro";
  font-style: normal;
  font-weight: 160 700;
  font-display: swap;
  src: url("../fonts/readex-pro-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304,
    U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --bg: #fbfaff;
  --surface: #ffffff;
  --soft: #f3effe;
  --text: #1a1033;
  --muted: #6b6485;
  --line: #e7e1f7;
  --accent: #7c3aed;
  --pink: #ec4899;
  --orange: #f97316;
  --brand: linear-gradient(120deg, #7c3aed 0%, #c026d3 38%, #ec4899 68%, #f97316 100%);
  --glow: 0 14px 34px -12px rgba(124, 58, 237, .55);
  --card: 0 18px 50px -24px rgba(76, 29, 149, .35);
  --dot: rgba(124, 58, 237, .13);
  --user: linear-gradient(135deg, #f1e9ff, #fde8f4);
  --code: #f6f2ff;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0a1f;
  --surface: #191130;
  --soft: #221842;
  --text: #f1ecff;
  --muted: #a79fc4;
  --line: #2e2352;
  --accent: #a78bfa;
  --glow: 0 14px 34px -12px rgba(167, 139, 250, .5);
  --card: 0 18px 50px -24px rgba(0, 0, 0, .8);
  --dot: rgba(167, 139, 250, .12);
  --user: linear-gradient(135deg, #2b1d58, #46204f);
  --code: #150d2b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Readex Pro", "Segoe UI", Tahoma, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 1.25em; height: 1.25em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Colour blobs over a dotted grid, behind everything. */
.backdrop { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background-image: radial-gradient(var(--dot) 1.2px, transparent 1.2px); background-size: 22px 22px; }
.backdrop i { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .32; }
.backdrop i:nth-child(1) { width: 420px; height: 420px; background: #7c3aed; top: -140px; inset-inline-start: -120px; }
.backdrop i:nth-child(2) { width: 360px; height: 360px; background: #ec4899; top: 30%; inset-inline-end: -160px; opacity: .22; }
.backdrop i:nth-child(3) { width: 380px; height: 380px; background: #f97316; bottom: -200px; inset-inline-start: 20%; opacity: .16; }

.app { position: relative; z-index: 1; height: 100%; display: flex; flex-direction: column; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(14px, 4vw, 28px); padding-top: calc(12px + env(safe-area-inset-top, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.logo, .hero-logo, .avatar { display: grid; place-items: center; background: var(--brand); box-shadow: var(--glow); flex: none; }
.logo { width: 42px; height: 42px; border-radius: 14px; }
.logo svg, .hero-logo svg, .avatar svg { stroke: none; width: 62%; height: 62%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 1.08rem; font-weight: 650; }
.brand-text small { color: var(--muted); font-size: .76rem; }
.top-actions { display: flex; gap: 8px; }
.ghost { display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(10px); font-size: .86rem; transition: transform .15s, border-color .15s; }
.ghost:hover { border-color: var(--accent); transform: translateY(-1px); }
.ghost.icon { width: 40px; padding: 0; justify-content: center; }

.stage { flex: 1; overflow-y: auto; padding: 8px clamp(14px, 4vw, 28px) 24px; scroll-behavior: smooth; }
.welcome, .thread { width: 100%; max-width: 780px; margin: 0 auto; }

.welcome { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 24px 0; }
.hero-logo { width: 84px; height: 84px; border-radius: 28px; animation: float 5s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-8px) rotate(-4deg); } }
.welcome h1 { font-size: clamp(1.7rem, 5.4vw, 2.6rem); font-weight: 650; margin: 22px 0 6px; line-height: 1.4; }
.grad { background: var(--brand); -webkit-background-clip: text; background-clip: text; color: transparent; }
.welcome p { color: var(--muted); margin: 0 0 26px; max-width: 30em; text-wrap: balance; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; }
.chip { text-align: start; padding: 14px 16px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface);
  box-shadow: var(--card); font-size: .9rem; line-height: 1.6; transition: transform .15s, border-color .15s; }
.chip:hover { transform: translateY(-2px); border-color: var(--accent); }

.msg { display: flex; gap: 12px; margin: 22px 0; animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: var(--user); border: 1px solid var(--line); border-radius: 24px 24px 24px 24px; border-end-end-radius: 8px;
  padding: 10px 18px; max-width: min(86%, 560px); white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.bot { align-items: flex-start; }
.avatar { width: 36px; height: 36px; border-radius: 12px; margin-top: 2px; }
.msg.bot .body { flex: 1; min-width: 0; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.thumbs img { width: 120px; height: 120px; object-fit: cover; border-radius: 16px; border: 1px solid var(--line); }
.thumbs .ghost-img { padding: 4px 12px; border-radius: 999px; background: var(--soft); font-size: .8rem; }

.prose { overflow-wrap: anywhere; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: .6em 0; }
.prose h1, .prose h2, .prose h3 { font-size: 1.08rem; font-weight: 650; margin: 1.2em 0 .4em; }
.prose ul, .prose ol { padding-inline-start: 1.4em; margin: .5em 0; }
.prose li { margin: .25em 0; }
.prose strong { font-weight: 650; }
.prose code { font-family: Consolas, "Courier New", monospace; background: var(--code); padding: 2px 7px; border-radius: 8px; font-size: .92em; direction: ltr; unicode-bidi: isolate; }
.prose pre { background: var(--code); border: 1px solid var(--line); border-radius: 16px; padding: 14px; overflow-x: auto; direction: ltr; text-align: left; }
.prose pre code { background: none; padding: 0; }
.prose blockquote { margin: .8em 0; padding: 4px 14px; border-inline-start: 3px solid var(--pink); color: var(--muted); }
.prose .table-wrap { overflow-x: auto; margin: .8em 0; border: 1px solid var(--line); border-radius: 16px; }
.prose table { border-collapse: collapse; width: 100%; font-size: .92rem; }
.prose th, .prose td { padding: 8px 14px; text-align: start; border-bottom: 1px solid var(--line); }
.prose th { background: var(--soft); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }
.prose a { color: var(--accent); }

.tools { margin-top: 10px; display: flex; gap: 6px; }
.tools button { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: none; color: var(--muted); font-size: .78rem; font-family: inherit; padding: 5px 12px; border-radius: 999px; cursor: pointer; transition: background .18s, color .18s, border-color .18s; }
.tools button svg { width: 15px; height: 15px; flex: none; }
.tools button:hover { background: var(--soft); color: var(--text); border-color: transparent; }
.tools button.done { color: #16a34a; border-color: #16a34a55; background: #16a34a14; }

.typing { display: inline-flex; gap: 5px; padding: 10px 0; }
.typing i { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: bounce 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-6px); opacity: 1; } }

.dock { padding: 0 clamp(14px, 4vw, 28px) calc(10px + env(safe-area-inset-bottom, 0px)); }
.composer { max-width: 780px; margin: 0 auto; background: var(--surface); border: 1px solid var(--line); border-radius: 28px;
  box-shadow: var(--card); padding: 8px; transition: border-color .2s, box-shadow .2s; }
.composer:focus-within { border-color: var(--accent); box-shadow: var(--card), 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent); }
.composer .row { display: flex; align-items: flex-end; gap: 6px; }
.composer textarea { flex: 1; border: 0; outline: 0; resize: none; background: transparent; padding: 10px 6px; max-height: 190px; line-height: 1.7; }
.composer textarea::placeholder { color: var(--muted); }
.attach, .send { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none; transition: transform .15s, opacity .15s; }
.attach { background: var(--soft); color: var(--accent); }
.attach:hover { transform: scale(1.06); }
.send { background: var(--brand); color: #fff; box-shadow: var(--glow); }
.send:hover:not(:disabled) { transform: translateY(-2px); }
.send:disabled { opacity: .35; box-shadow: none; cursor: not-allowed; }
.previews { display: flex; flex-wrap: wrap; gap: 8px; padding: 6px 6px 2px; }
.preview { position: relative; }
.preview img { width: 72px; height: 72px; object-fit: cover; border-radius: 14px; border: 1px solid var(--line); display: block; }
.preview button { position: absolute; top: -6px; inset-inline-end: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0;
  background: var(--text); color: var(--bg); font-size: 13px; line-height: 1; display: grid; place-items: center; }
.trap { position: absolute; inset-inline-start: -9999px; width: 1px; height: 1px; opacity: 0; }
#turnstile { max-width: 780px; margin: 8px auto 0; display: flex; justify-content: center; }
.fine { max-width: 780px; margin: 8px auto 0; text-align: center; color: var(--muted); font-size: .72rem; line-height: 1.6; }

.toast { position: fixed; z-index: 5; bottom: 150px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 20px; border-radius: 999px; font-size: .88rem; max-width: calc(100vw - 32px); text-align: center; box-shadow: var(--card); }
.drop { position: fixed; inset: 0; z-index: 6; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 22%, transparent); backdrop-filter: blur(6px); }
.drop span { padding: 22px 38px; border-radius: 28px; border: 2px dashed #fff; background: var(--brand); color: #fff; font-size: 1.2rem; font-weight: 600; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .chips { grid-template-columns: 1fr; }
  .ghost span { display: none; }
  .ghost { width: 40px; padding: 0; justify-content: center; }
  .avatar { width: 30px; height: 30px; border-radius: 10px; }
  .msg { gap: 9px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- owner pages ---------- */
.admin { position: relative; z-index: 1; max-width: 980px; margin: 0 auto; padding: 24px clamp(14px, 4vw, 28px) 60px; }
.admin h1 { font-size: 1.5rem; font-weight: 650; margin: 0; }
.admin-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; }
.admin nav { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { display: inline-flex; align-items: center; height: 40px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); text-decoration: none; color: inherit; font-size: .88rem; }
.pill.main { background: var(--brand); color: #fff; border: 0; box-shadow: var(--glow); }
.stats { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.stat { flex: 1; min-width: 150px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 14px 18px; box-shadow: var(--card); }
.stat b { display: block; font-size: 1.6rem; font-weight: 650; }
.stat span { color: var(--muted); font-size: .82rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--card); overflow-x: auto; }
.panel table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.panel th, .panel td { padding: 12px 16px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.panel th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.panel tr:last-child td { border-bottom: 0; }
.panel a { color: var(--accent); text-decoration: none; font-weight: 600; }
.mono { font-family: Consolas, monospace; direction: ltr; unicode-bidi: isolate; }
.log { display: flex; flex-direction: column; gap: 10px; }
.log .sep { margin: 18px 0 2px; color: var(--muted); font-size: .8rem; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 12px 16px; }
.entry.user { border-inline-start: 4px solid var(--accent); }
.entry.assistant { border-inline-start: 4px solid var(--orange); }
.entry header { display: flex; flex-wrap: wrap; gap: 10px; color: var(--muted); font-size: .76rem; margin-bottom: 4px; }
.entry .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.entry img { max-width: 220px; max-height: 220px; border-radius: 14px; border: 1px solid var(--line); margin: 6px 0 0 6px; }
.field { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 16px 18px; margin-bottom: 14px; box-shadow: var(--card); }
.field label { font-weight: 600; display: block; }
.field small { color: var(--muted); display: block; margin-bottom: 8px; }
.field textarea, .login input { width: 100%; border: 1px solid var(--line); border-radius: 16px; padding: 10px 14px; background: var(--bg); outline: 0; }
.field textarea:focus, .login input:focus { border-color: var(--accent); }
.login { position: relative; z-index: 1; max-width: 380px; margin: 14vh auto 0; padding: 28px; background: var(--surface); border: 1px solid var(--line); border-radius: 28px; box-shadow: var(--card); text-align: center; }
.login .pill { width: 100%; justify-content: center; margin-top: 12px; cursor: pointer; }
.error { color: #e11d48; font-size: .86rem; }
.ok { color: #059669; font-size: .9rem; }
.pager { margin-top: 16px; display: flex; gap: 10px; justify-content: center; }

.stage { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }

/* ---------- side panel: earlier conversations ---------- */
.shell { position: relative; z-index: 1; display: flex; height: 100dvh; }
.shell .app { flex: 1; min-width: 0; }
.top-start { display: flex; align-items: center; gap: 10px; }
.side { width: 290px; flex: none; display: flex; flex-direction: column; gap: 10px; padding: 14px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(16px);
  border-inline-end: 1px solid var(--line); }
.shell.side-closed .side { display: none; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding-inline-start: 6px; }
.side-head strong { font-weight: 650; }
.side-head .ghost { display: none; }
.side-new { display: flex; align-items: center; justify-content: center; gap: 8px; height: 46px; border: 0; border-radius: 999px;
  background: var(--brand); color: #fff; box-shadow: var(--glow); font-size: .92rem; transition: transform .15s; }
.side-new:hover { transform: translateY(-2px); }
.side-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.side-day { color: var(--muted); font-size: .74rem; padding: 10px 10px 2px; }
.side-item { text-align: start; border: 1px solid transparent; background: none; border-radius: 16px; padding: 9px 12px;
  font-size: .88rem; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; }
.side-item:hover { background: var(--soft); }
.side-item.active { background: var(--user); border-color: var(--line); font-weight: 600; }
.side-empty { color: var(--muted); font-size: .84rem; text-align: center; padding: 20px 10px; margin: 0; }
.scrim { position: fixed; inset: 0; z-index: 3; background: rgba(15, 10, 31, .45); backdrop-filter: blur(2px); }

@media (max-width: 900px) {
  .side { position: fixed; z-index: 4; inset-block: 0; inset-inline-start: 0; width: min(86vw, 320px);
    background: var(--surface); box-shadow: var(--card); transform: translateX(105%); transition: transform .25s ease; }
  .shell.side-open .side { transform: none; }
  .shell.side-closed .side { display: flex; }
  .side-head .ghost { display: inline-flex; }
}
@media (min-width: 901px) { .scrim { display: none !important; } }

.composer textarea:placeholder-shown { direction: rtl; }

/* ---------- owner's logo and photo ---------- */
.brand-logo { height: 54px; width: auto; display: block; }
/* The logo sits on a white plate in both themes, so it stays clear over the coloured background. */
.brand-logo { background: #fff; border-radius: 14px; padding: 4px 10px; box-shadow: 0 8px 22px -12px rgba(76, 29, 149, .45); }
.hero-photo { position: relative; width: min(100%, 340px); margin-bottom: 14px; }
.hero-photo::before { content: ""; position: absolute; inset: 6% 4% 22%; border-radius: 50%; background: var(--brand); opacity: .22; filter: blur(46px); }
.hero-photo img { position: relative; display: block; width: 100%; height: auto; max-height: 52dvh; object-fit: contain;
  filter: drop-shadow(0 22px 30px rgba(76, 29, 149, .22)); }
.avatar { background: var(--soft); border: 1px solid var(--line); overflow: hidden; border-radius: 50%; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 600px) { .brand-logo { height: 46px; } .avatar { border-radius: 50%; } }
@media (max-height: 640px) { .hero-photo { width: min(100%, 230px); } }

/* ---------- opening scene ---------- */
@font-face {
  font-family: "Amiri";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/amiri-arabic.woff2") format("woff2");
}
.intro { display: none; }
html.intro-on .intro { position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 26px; padding: 14vh clamp(18px, 6vw, 60px); color: #f6efe0; text-align: center; overflow: hidden;
  background: radial-gradient(ellipse at 50% 42%, #1b1430 0%, #0a0714 55%, #000 100%); transition: opacity .7s ease; }
html.intro-on body { overflow: hidden; }
.intro.leaving { opacity: 0; pointer-events: none; }
.intro-bar { position: absolute; inset-inline: 0; height: 0; background: #000; transition: height 1.1s cubic-bezier(.7, 0, .2, 1); z-index: 1; }
.intro-bar.top { top: 0; }
.intro-bar.bottom { bottom: 0; }
.intro.playing .intro-bar { height: 9vh; }
.intro-dust { position: absolute; inset: -20%; opacity: .5; pointer-events: none;
  background-image: radial-gradient(rgba(255, 220, 150, .5) 1px, transparent 1.4px), radial-gradient(rgba(255, 255, 255, .3) 1px, transparent 1.4px);
  background-size: 180px 180px, 260px 260px; background-position: 0 0, 90px 130px; animation: dust 40s linear infinite; }
@keyframes dust { to { transform: translate3d(-90px, -180px, 0); } }
.intro-skip { position: absolute; z-index: 2; top: calc(14px + env(safe-area-inset-top, 0px)); inset-inline-end: 18px; height: 36px; padding: 0 16px;
  border-radius: 999px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .06); color: #e9e2f5; font-size: .82rem; }
.intro-skip:hover { background: rgba(255, 255, 255, .16); }
.intro-gate { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 14px; }
.intro-gate p { margin: 0; color: #cfc6e6; font-size: .95rem; }
.intro-btn { position: relative; z-index: 2; height: 54px; padding: 0 44px; border: 0; border-radius: 999px; background: var(--brand); color: #fff;
  font-size: 1.1rem; font-weight: 600; box-shadow: 0 16px 40px -10px rgba(236, 72, 153, .7); animation: rise .5s ease both; transition: transform .15s; }
.intro-btn:hover { transform: translateY(-2px) scale(1.03); }
.intro-verse { position: relative; z-index: 2; width: 100%; min-width: 0; max-width: 900px; transition: opacity .45s ease, transform .45s ease; }
.intro-verse.away { opacity: 0; transform: translateY(-24px) scale(.97); }
.ayah { margin: 0 0 18px; font-family: "Amiri", "Traditional Arabic", "Scheherazade New", serif; font-size: clamp(1.9rem, 6.2vw, 3.6rem); line-height: 2.1;
  color: #f3d9a4; text-shadow: 0 0 34px rgba(243, 190, 90, .35); }
.ayah span { opacity: 0; filter: blur(8px); transition: opacity 1.1s ease, filter 1.1s ease; }
.ayah span.on { opacity: 1; filter: none; }
.intro-verse small { color: #a99b7c; font-size: .82rem; letter-spacing: .02em; }
.intro-type { position: relative; z-index: 2; width: 100%; max-width: 720px; max-height: 62vh; overflow-y: auto; scrollbar-width: none; text-align: start;
  font-size: clamp(1rem, 3.6vw, 1.3rem); line-height: 2; }
.intro-type::-webkit-scrollbar { display: none; }
.intro-type p { margin: 0 0 1.1em; white-space: pre-wrap; }
.caret { display: inline-block; width: 3px; height: 1.1em; margin-inline-start: 3px; vertical-align: -0.18em; background: #f3d9a4; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.intro-gate img { width: 76px; height: 76px; animation: float 3.5s ease-in-out infinite; }
.intro-gate p { font-size: 1.05rem; color: #e9e2f5; }
.intro-gate .intro-btn { height: auto; min-height: 58px; padding: 12px 30px; font-size: 1.02rem; line-height: 1.7; max-width: min(92vw, 460px); text-wrap: balance; }

.intro-type .emoji { width: 1.5em; height: 1.5em; vertical-align: -0.38em; margin-inline-start: 6px; animation: rise .4s ease both; }

/* "Who am I?" button: replays the opening scene. */
.ghost.who { text-decoration: none; color: #fff; border: 0; background: var(--brand); box-shadow: var(--glow); font-weight: 600; white-space: nowrap; }
@media (max-width: 600px) {
  .ghost.who { width: auto; padding: 0 14px; font-size: .82rem; }
  /* The side panel already has "new conversation", so the header keeps room for this button. */
  #newChat { display: none; }
}

/* ---------- opening-day celebration ---------- */
.top > .opening { margin-inline: auto; }
.ghost.opening { border: 0; color: #fff; font-weight: 600; white-space: nowrap; padding: 0 18px;
  background: linear-gradient(120deg, #f97316, #ec4899, #7c3aed, #22d3ee, #f97316); background-size: 300% 100%;
  box-shadow: var(--glow); animation: opening-shine 5s linear infinite; }
.ghost.opening span { display: inline; }
@keyframes opening-shine { to { background-position: 300% 0; } }
@media (max-width: 900px) {
  .top { flex-wrap: wrap; }
  .top > .opening { order: 3; flex: 1 0 100%; width: auto; justify-content: center; margin: 8px 0 0; }
}

.party-layer { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.party-lights { position: absolute; inset: 0; opacity: .34; mix-blend-mode: hard-light;
  background: linear-gradient(120deg, #7c3aed, #ec4899, #f97316, #facc15, #22d3ee, #4ade80, #7c3aed); background-size: 400% 400%;
  animation: lights 6s linear infinite; }
@keyframes lights { 0% { background-position: 0% 50%; } 100% { background-position: 400% 50%; } }
.party-beams i { position: absolute; top: -10%; width: 26vmax; height: 130%; transform-origin: 50% 0; opacity: .22; filter: blur(6px);
  background: linear-gradient(to bottom, #fff, transparent 85%); clip-path: polygon(46% 0, 54% 0, 100% 100%, 0 100%); mix-blend-mode: screen; }
.party-beams i:nth-child(1) { left: 5%; background-image: linear-gradient(to bottom, #f0abfc, transparent 85%); animation: beam 3.2s ease-in-out infinite alternate; }
.party-beams i:nth-child(2) { left: 30%; background-image: linear-gradient(to bottom, #fde047, transparent 85%); animation: beam 2.6s ease-in-out -1s infinite alternate-reverse; }
.party-beams i:nth-child(3) { left: 55%; background-image: linear-gradient(to bottom, #67e8f9, transparent 85%); animation: beam 3.6s ease-in-out -.5s infinite alternate; }
.party-beams i:nth-child(4) { left: 78%; background-image: linear-gradient(to bottom, #fda4af, transparent 85%); animation: beam 2.9s ease-in-out -1.6s infinite alternate-reverse; }
@keyframes beam { from { transform: rotate(-28deg); } to { transform: rotate(28deg); } }
.party-confetti { position: absolute; inset: 0; width: 100%; height: 100%; }
.party-ball { position: absolute; top: -6px; left: 50%; width: clamp(84px, 13vw, 140px); height: auto; margin-left: calc(clamp(84px, 13vw, 140px) / -2);
  transform-origin: 50% 0; animation: swing 1.6s ease-in-out infinite alternate; filter: drop-shadow(0 10px 24px rgba(236, 72, 153, .6)); }
@keyframes swing { from { transform: rotate(-12deg); } to { transform: rotate(12deg); } }
.party-banner { position: absolute; top: clamp(96px, 17vw, 160px); left: 50%; padding: 8px 26px; border-radius: 999px; white-space: nowrap;
  background: var(--brand); color: #fff; font-weight: 700; font-size: clamp(1rem, 3.6vw, 1.6rem); box-shadow: 0 16px 40px -10px rgba(236, 72, 153, .8);
  animation: banner 1s ease-in-out infinite; }
@keyframes banner { 0%, 100% { transform: translateX(-50%) scale(1) rotate(-2deg); } 50% { transform: translateX(-50%) scale(1.09) rotate(2deg); } }
.party-crew { position: absolute; inset-inline: 0; bottom: 0; display: flex; justify-content: center; align-items: flex-end; gap: clamp(0px, 1.5vw, 22px);
  padding: 0 8px; animation: crew-in .7s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes crew-in { from { transform: translateY(110%); } }
.party-crew img { width: clamp(64px, 17vw, 190px); height: auto; transform-origin: 50% 100%; filter: drop-shadow(0 12px 16px rgba(0, 0, 0, .35)); }
.party-crew .d1 { animation: dance-a .52s ease-in-out infinite alternate; }
.party-crew .d2 { animation: dance-b .52s ease-in-out -.26s infinite alternate; }
.party-crew .d3 { animation: dance-c 1.04s ease-in-out infinite; width: clamp(76px, 20vw, 220px); }
.party-crew .d4 { animation: dance-b .52s ease-in-out infinite alternate; }
.party-crew .d5 { animation: dance-a .52s ease-in-out -.26s infinite alternate; }
@keyframes dance-a { from { transform: translateY(0) rotate(-9deg); } to { transform: translateY(-22px) rotate(9deg); } }
@keyframes dance-b { from { transform: translateY(-18px) rotate(8deg) scaleX(-1); } to { transform: translateY(0) rotate(-8deg) scaleX(-1); } }
@keyframes dance-c { 0%, 100% { transform: translateY(0) scale(1) rotate(-4deg); } 25% { transform: translateY(-26px) scale(1.06) rotate(4deg); } 50% { transform: translateY(0) scale(1) rotate(-4deg); } 75% { transform: translateY(-14px) scale(1.03) rotate(6deg); } }

.party-stop { position: fixed; z-index: 40; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); height: 44px; padding: 0 22px;
  border-radius: 999px; border: 2px solid #fff; background: #1a1033; color: #fff; font-weight: 600; box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .6); }
.party-stop:hover { background: #e11d48; }

/* While the party is on: the page shakes on the beat and every button dances. */
html.party .app { animation: shake 1.04s linear infinite; }
@keyframes shake {
  0%, 30%, 100% { transform: none; }
  5% { transform: translate(-5px, 3px) rotate(-.5deg); }
  10% { transform: translate(5px, -3px) rotate(.5deg); }
  15% { transform: translate(-4px, -2px) rotate(-.3deg); }
  20% { transform: translate(4px, 2px) rotate(.3deg); }
  25% { transform: translate(-2px, 1px); }
}
html.party .ghost, html.party .attach, html.party .send, html.party .side-new { animation: jiggle .52s ease-in-out infinite alternate; }
html.party .top-actions > :nth-child(even), html.party .send { animation-delay: -.26s; }
html.party .ghost.opening { animation: jiggle .52s ease-in-out infinite alternate, opening-shine 1.5s linear infinite; }
@keyframes jiggle { from { transform: rotate(-9deg) scale(.96); } to { transform: rotate(9deg) scale(1.08); } }
html.party .brand-logo, html.party .avatar { animation: bop .52s ease-in-out infinite alternate; }
@keyframes bop { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-6px) rotate(4deg); } }
html.party .hero-photo img { animation: sway 1.04s ease-in-out infinite alternate; }
@keyframes sway { from { transform: rotate(-3deg) scale(1); } to { transform: rotate(3deg) scale(1.04); } }
html.party .composer { animation: glowbeat .52s ease-in-out infinite alternate; }
@keyframes glowbeat { from { box-shadow: 0 0 0 0 rgba(236, 72, 153, 0); } to { box-shadow: 0 0 34px 6px rgba(236, 72, 153, .55); } }
@media (prefers-reduced-motion: reduce) { html.party .app { animation: none !important; } }

/* Celebration layout fixes. */
html.party, html.party body { overflow: hidden; }
.top { row-gap: 8px; }
@media (max-width: 900px) {
  .top > .opening { flex: 0 0 auto; margin: 0 auto; }
}
.party-stop { top: auto; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); }
.party-ball { top: -6px; }
.party-crew { bottom: 74px; }

/* The line and button that start the celebration sit on their own row under the header. */
.opening-row { order: 3; flex: 1 0 100%; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 12px; text-align: center; }
.opening-row span { font-size: .9rem; font-weight: 600; color: var(--accent); }
.opening-row .opening { margin: 0; flex: 0 0 auto; width: auto; }

/* "Why stop the party?" pop-up. */
.killjoy { position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 18px; background: rgba(15, 10, 31, .6); backdrop-filter: blur(4px); }
.killjoy-card { width: min(100%, 380px); background: var(--surface); color: var(--text); border-radius: 28px; padding: 16px; text-align: center;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .7); animation: rise .3s ease both; }
.killjoy-card img { display: block; width: 100%; height: auto; max-height: 52dvh; object-fit: cover; border-radius: 18px; }
.killjoy-card p { margin: 14px 0; font-size: 1.15rem; font-weight: 700; }
.killjoy-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.killjoy-actions .pill { cursor: pointer; }

.opening-row .opening { height: auto; min-height: 40px; padding: 6px 20px; white-space: normal; line-height: 1.6; max-width: 100%; }

/* Header layout: on wide screens the celebration button sits in the middle of the header row;
   on narrow screens it drops to its own centred row underneath. */
.top { flex-wrap: wrap; }
@media (min-width: 901px) {
  .opening-row { order: 0; flex: 0 1 auto; }
}

#killjoyCheer { padding: 10px; width: min(100%, 520px); cursor: pointer; }
#killjoyCheer img { max-height: 70dvh; }

/* The reply picture shows the whole suit, so it is drawn a little larger. */
.avatar { width: 48px; height: 48px; }
@media (max-width: 600px) { .avatar { width: 40px; height: 40px; } }

/* ---------- the welcome picture under a student's first answer ---------- */
.welcome-shot { display: block; margin-top: 12px; max-width: min(420px, 100%); border-radius: 14px; border: 1px solid var(--line); }

/* ---------- the page a blocked student sees ---------- */
.shut { min-height: 100svh; display: grid; place-items: center; padding: 24px; }
.shut-card { max-width: 520px; width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 30px 26px; text-align: center; box-shadow: 0 18px 50px rgba(15, 8, 40, .12); }
.shut-card img { width: 190px; max-width: 70%; background: #fff; border-radius: 14px; padding: 10px 14px; }
.shut-card p { margin: 20px 0 0; font-size: 1.05rem; line-height: 1.9; color: var(--text); white-space: pre-wrap; }

/* ---------- admin: people, controls, tables ---------- */
.admin-search { display: flex; gap: 8px; margin: 16px 0; flex-wrap: wrap; }
.admin-search input { flex: 1 1 240px; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-family: inherit; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
.grid th, .grid td { padding: 11px 14px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.grid th { background: var(--soft); font-weight: 600; }
.grid tr:last-child td { border-bottom: 0; }
.grid td small { display: block; color: var(--muted); font-size: .72rem; direction: ltr; }
.grid tr.is-blocked { background: #ef444410; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .74rem; background: var(--soft); color: var(--muted); }
.tag.ok { color: #16a34a; background: #16a34a14; }
.tag.bad { color: #dc2626; background: #dc262614; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; margin: 18px 0; display: grid; gap: 16px; }
.panel h2 { margin: 0; font-size: 1.02rem; }
.panel label { display: grid; gap: 6px; }
.panel label > span { font-size: .88rem; font-weight: 600; }
.panel label small { color: var(--muted); font-size: .76rem; line-height: 1.7; }
.panel input[type=text], .panel input[type=number], .panel textarea { width: 100%; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-family: inherit; font-size: .92rem; }
.panel textarea { resize: vertical; line-height: 1.8; }
.panel label.check { grid-auto-flow: column; justify-content: start; align-items: center; gap: 10px; }
.panel label.check input { width: 18px; height: 18px; }
.panel .main { justify-self: start; }
.section-title { margin: 26px 0 10px; font-size: 1.05rem; }
.saved { color: #16a34a; font-weight: 600; }

/* ---------- admin: the row of counters ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.cards .card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; display: grid; gap: 4px; }
.cards .card b { font-size: 1.45rem; line-height: 1.2; overflow-wrap: anywhere; }
.cards .card span { color: var(--muted); font-size: .8rem; }

/* ---------- the notice while questions are on hold ---------- */
.paused-note { margin: 0 0 10px; padding: 12px 16px; border-radius: 16px; background: #f9731614; border: 1px solid #f9731633; color: var(--text); font-size: .92rem; line-height: 1.85; white-space: pre-line; text-align: center; }

/* ---------- the questions the doctor answered himself ---------- */
.faq-layer { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 20px; background: rgba(20, 10, 40, .45); backdrop-filter: blur(4px); }
.faq-box { width: min(720px, 100%); max-height: min(82svh, 760px); display: flex; flex-direction: column; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 20px; box-shadow: 0 24px 70px rgba(15, 8, 40, .3); }
.faq-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.faq-head h2 { margin: 0; font-size: 1.08rem; }
.faq-box input[type=search] { width: 100%; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-family: inherit; font-size: .92rem; }
.faq-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding-inline-end: 4px; }
.faq-item { flex: none; border: 1px solid var(--line); border-radius: 16px; background: var(--bg); overflow: hidden; }
.faq-box > * { flex-shrink: 0; }
.faq-box > .faq-list { flex-shrink: 1; }
.faq-item summary { cursor: pointer; padding: 13px 16px; font-weight: 600; font-size: .93rem; display: flex; align-items: center; gap: 10px; list-style: none; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::before { content: '+'; flex: none; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 50%; background: var(--soft); color: var(--muted); font-size: .9rem; }
.faq-item[open] summary::before { content: '−'; background: var(--brand); color: #fff; }
.faq-item summary i { margin-inline-start: auto; font-style: normal; font-size: .72rem; color: var(--muted); background: var(--soft); padding: 3px 10px; border-radius: 999px; flex: none; }
.faq-item .prose { padding: 0 16px 14px; }
.faq-empty { margin: 0; text-align: center; color: var(--muted); font-size: .88rem; padding: 10px; }
body.no-scroll { overflow: hidden; }

/* ---------- the strip that opens the answered questions ---------- */
.faq-strip { display: flex; align-items: center; justify-content: center; gap: 14px; width: calc(100% - 28px);
  margin: 6px 14px 8px; padding: 16px 22px; border: 0; border-radius: 20px; cursor: pointer;
  background: linear-gradient(100deg, #7c3aed, #db2777 55%, #f97316); background-size: 200% 100%;
  color: #fff; font-family: inherit; line-height: 1.5; text-align: center;
  box-shadow: 0 10px 28px rgba(219, 39, 119, .35); animation: faqGlow 3.2s ease-in-out infinite;
  transition: transform .18s, filter .18s; }
.faq-strip:hover { transform: translateY(-2px) scale(1.01); filter: brightness(1.08); }
.faq-strip-icon { font-size: 2rem; flex: none; animation: faqBob 1.6s ease-in-out infinite; }
.faq-strip-text { display: flex; flex-direction: column; gap: 2px; }
.faq-strip-text b { font-size: 1.32rem; font-weight: 800; }
.faq-strip-text small { font-size: .9rem; font-weight: 500; opacity: .93; }
.faq-strip-go { flex: none; background: #fff; color: #db2777; font-weight: 800; font-size: .95rem;
  padding: 8px 16px; border-radius: 999px; }
@keyframes faqGlow { 0%, 100% { background-position: 0 0; box-shadow: 0 10px 28px rgba(219, 39, 119, .32); }
  50% { background-position: 100% 0; box-shadow: 0 12px 36px rgba(124, 58, 237, .5); } }
@keyframes faqBob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-4px) rotate(-8deg); } }
@media (prefers-reduced-motion: reduce) { .faq-strip, .faq-strip-icon { animation: none; } }
@media (max-width: 600px) {
  .faq-strip { gap: 10px; padding: 13px 14px; flex-wrap: wrap; }
  .faq-strip-icon { font-size: 1.6rem; }
  .faq-strip-text b { font-size: 1.12rem; }
  .faq-strip-text small { font-size: .8rem; }
  .faq-strip-go { padding: 6px 14px; font-size: .88rem; }
}
.faq-none { text-align: center; padding: 26px 12px; color: var(--muted); line-height: 1.9; }
.faq-none b { display: block; color: var(--text); font-size: 1.02rem; margin-bottom: 6px; }
.faq-none p { margin: 0; font-size: .9rem; }
