/* ==========================================================================
   LOKY AI Next — dark, mobile-first UI
   No framework, no build step. Design tokens first, then primitives,
   then layout, then components.
   ========================================================================== */

:root {
  /* palette */
  --bg: #030806;
  --bg-elev: #07110d;
  --bg-elev-2: #0b1a14;
  --surface: rgba(16, 185, 129, 0.04);
  --surface-strong: rgba(16, 185, 129, 0.08);
  --border: rgba(52, 211, 153, 0.14);
  --border-strong: rgba(52, 211, 153, 0.28);
  --text: #e6f5ee;
  --text-dim: #9fbfb0;
  --text-faint: #688277;

  --accent: #19e68c;
  --accent-2: #34d399;
  --accent-soft: rgba(25, 230, 140, 0.16);
  --gradient: linear-gradient(135deg, #19e68c 0%, #10b981 45%, #34d399 100%);

  --danger: #ff6b81;
  --danger-soft: rgba(255, 107, 129, 0.12);
  --warn: #ffc46b;
  --warn-soft: rgba(255, 196, 107, 0.12);
  --ok: #4ade80;

  /* metrics */
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sidebar-w: 292px;
  --topbar-h: 58px;
  --shell-max: 900px;

  --shadow: 0 18px 48px -18px rgba(0, 0, 0, 0.9), 0 0 24px -12px rgba(25, 230, 140, 0.25);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  --safe-b: env(safe-area-inset-bottom, 0px);

  /* App shell height. JS keeps this in sync with the visual viewport so the
     composer stays visible when the Android keyboard opens. */
  --app-h: 100vh;

  /* Height of the top section switch (AI Assistant / Messages). */
  --nav-h: 54px;
}

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

html,
body {
  height: 100%;
}

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}

/* ambient background glow */
body::before {
  content: "";
  position: fixed;
  inset: -20% -10% auto -10%;
  height: 70vh;
  background:
    radial-gradient(60% 60% at 20% 0%, rgba(25, 230, 140, 0.22), transparent 70%),
    radial-gradient(50% 50% at 85% 10%, rgba(16, 185, 129, 0.14), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
  border-radius: 6px;
}

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

.skip-link {
  position: absolute;
  left: 50%;
  top: -60px;
  transform: translateX(-50%);
  z-index: 100;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--accent);
  color: #050d0a;
  font-weight: 600;
  text-decoration: none;
  transition: top 0.18s ease;
}
.skip-link:focus {
  top: 0;
}

/* ============================== app shell ============================== */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  height: var(--app-h, 100vh);
  min-height: 0;
  overflow: hidden;
  animation: fade 0.45s ease both;
}

/* The assistant shell is hidden (not unmounted) while the Messages section is
   open, so switching back keeps the live chat and its history intact. */
.app[hidden] {
  display: none;
}

/* -------------------------------- sidebar ------------------------------- */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(var(--sidebar-w), 86vw);
  padding: 16px 14px calc(16px + var(--safe-b));
  background: linear-gradient(180deg, #0c0e16 0%, #0a0c13 100%);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.26s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  overflow: hidden;
}

.sidebar.is-open {
  transform: translateX(0);
  box-shadow: 28px 0 70px -30px rgba(0, 0, 0, 0.95);
}

.sidebar__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand__mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 12px;
  background: linear-gradient(160deg, rgba(25, 230, 140, 0.22), rgba(16, 185, 129, 0.12));
  border: 1px solid var(--border-strong);
}

.brand__text {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}
.brand__text strong {
  font-size: 0.98rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand__accent {
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand__text small {
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.02em;
}

.sidebar__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 4px 0;
}
.sidebar__heading h2 {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.sidebar__heading-actions {
  display: flex;
  gap: 10px;
}

.history-wrap {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0 2px 8px;
  list-style: none;
}

.history__item {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}

.history__btn {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  text-align: left;
  color: var(--text-dim);
  font-size: 0.855rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.history__btn:hover {
  background: var(--surface);
  color: var(--text);
}
.history__item.is-active .history__btn {
  background: var(--accent-soft);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(25, 230, 140, 0.28);
}
.history__title {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.history__text {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.history__time {
  font-size: 0.66rem;
  line-height: 1.35;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history__item.is-active .history__time {
  color: rgba(255, 255, 255, 0.6);
}
.history__icon {
  flex: 0 0 auto;
  color: var(--text-faint);
}

/* inline rename editor */
.history__input {
  width: 100%;
  min-width: 0;
  padding: 2px 6px;
  border-radius: 7px;
  background: var(--bg-elev-2);
  border: 1px solid var(--accent);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1.4;
  outline: none;
}
.history__input:focus {
  box-shadow: 0 0 0 3px rgba(25, 230, 140, 0.18);
}
.history__item.is-editing .history__btn {
  cursor: default;
}

.history__rename {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.history__item:hover .history__rename,
.history__rename:focus-visible {
  opacity: 1;
}
.history__rename:hover {
  background: var(--surface-strong);
  color: var(--text);
}

.history__del {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border-radius: 8px;
  color: var(--text-faint);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.history__item:hover .history__del,
.history__del:focus-visible {
  opacity: 1;
}
.history__del:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.history__empty {
  margin: 10px 6px;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-faint);
}

.sidebar__foot {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.sidebar__note {
  font-size: 0.68rem;
  color: var(--text-faint);
}

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(4, 5, 9, 0.66);
  backdrop-filter: blur(2px);
  animation: fade 0.2s ease;
}

/* --------------------------------- main -------------------------------- */

.main {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  height: auto;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--topbar-h);
  padding: 0 12px;
  flex: 0 0 auto;
  background: rgba(8, 9, 15, 0.72);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.topbar__title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-dim);
}
.topbar__title span:first-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar__badge {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.topbar__badge.is-ready {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.16);
}
.topbar__badge.is-busy {
  background: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.18);
  animation: pulse 1.2s ease-in-out infinite;
}
.topbar__badge.is-error {
  background: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* ------------------------------- messages ------------------------------ */

.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
  padding: 20px 14px 8px;
  scrollbar-width: thin;
}

.messages__inner {
  max-width: var(--shell-max);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* --------------------------------- intro -------------------------------- */
/* Opening animation — plays once on app open (see app.js playIntro).      */
/* The overlay covers the app while it animates, then fades out to reveal  */
/* the chat screen.                                                          */

.intro {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 45%, #101322 0%, var(--bg) 62%);
  opacity: 0;
  pointer-events: none;
}

.intro--play {
  animation: introFade 2s ease forwards;
  /* the splash must never swallow taps */
  pointer-events: none;
}

.intro__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.intro__glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 260px;
  height: 260px;
  margin: -130px 0 0 -130px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(25, 230, 140, 0.34) 0%, rgba(16, 185, 129, 0.12) 45%, transparent 70%);
  filter: blur(6px);
  opacity: 0;
  pointer-events: none;
}

.intro__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 28px;
  background: linear-gradient(160deg, rgba(25, 230, 140, 0.24), rgba(16, 185, 129, 0.1));
  border: 1px solid var(--border-strong);
  opacity: 0;
}

.intro__title {
  position: relative;
  font-size: clamp(1.9rem, 8vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
}

.intro__title span {
  font-weight: 600;
}

.intro__sub {
  position: relative;
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  opacity: 0;
}

.intro__bar {
  position: relative;
  width: 132px;
  height: 2px;
  margin-top: 6px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.07);
  opacity: 0;
}

.intro__bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 2px;
  background: var(--gradient);
  animation: none;
}

.intro--play .intro__glow { animation: introGlow 2s ease forwards; }
.intro--play .intro__mark { animation: introMark 2s cubic-bezier(0.22, 0.9, 0.3, 1) forwards; }
.intro--play .intro__title { animation: introText 2s ease forwards; }
.intro--play .intro__sub { animation: introText 2s ease 0.15s forwards; }
.intro--play .intro__bar { animation: introText 2s ease 0.1s forwards; }
.intro--play .intro__bar span { animation: introBar 2s cubic-bezier(0.4, 0, 0.2, 1) forwards; }

@keyframes introFade {
  0% { opacity: 0; }
  12% { opacity: 1; }
  72% { opacity: 1; }
  100% { opacity: 0; visibility: hidden; }
}

@keyframes introGlow {
  0% { opacity: 0; transform: scale(0.6); }
  25% { opacity: 1; transform: scale(1); }
  70% { opacity: 0.85; transform: scale(1.08); }
  100% { opacity: 0; transform: scale(1.25); }
}

@keyframes introMark {
  0% { opacity: 0; transform: translateY(12px) scale(0.86); }
  22% { opacity: 1; transform: translateY(0) scale(1); }
  75% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-6px) scale(0.97); }
}

@keyframes introText {
  0% { opacity: 0; transform: translateY(8px); }
  28% { opacity: 1; transform: translateY(0); }
  78% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes introBar {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(140%); }
  100% { transform: translateX(280%); }
}

/* Reduced motion: no intro at all. app.js also removes the overlay. */
@media (prefers-reduced-motion: reduce) {
  .intro {
    display: none;
  }
  .intro__mark,
  .intro__title,
  .intro__sub,
  .intro__bar,
  .intro__glow {
    animation: none !important;
    opacity: 0;
  }
}

/* --------------------------------- hero -------------------------------- */

.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: clamp(14px, 4vh, 44px) 4px 8px;
  text-align: center;
  animation: rise 0.4s ease both;
}

/* Compact brand lockup: logo beside the wordmark, credit as a subtitle. */
.hero__lockup {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
}

.hero__mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(25, 230, 140, 0.26), rgba(16, 185, 129, 0.12));
  border: 1px solid var(--border-strong);
  box-shadow: 0 18px 44px -22px rgba(25, 230, 140, 0.85);
  animation: markIn 0.5s cubic-bezier(0.22, 0.9, 0.3, 1) both,
    markGlow 3.6s ease-in-out 0.7s infinite;
}

.hero__title {
  margin: 0;
  font-size: clamp(1.45rem, 6vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
}
.hero__title em {
  font-style: normal;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero__sub {
  margin: 0;
  max-width: 46ch;
  font-size: 0.92rem;
  color: var(--text-dim);
}

.hero__brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
}
.hero__wordmark {
  font-size: clamp(1.6rem, 7vw, 2.35rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hero__credit {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.hero__credit strong {
  color: var(--text-dim);
  font-weight: 600;
}

.starters {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  width: 100%;
  max-width: 560px;
  margin-top: 6px;
}

.starter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.875rem;
  text-align: left;
  transition: transform 0.16s ease, border-color 0.16s ease, background 0.16s ease,
    color 0.16s ease;
}
.starter:hover {
  transform: translateY(-1px);
  background: var(--surface-strong);
  border-color: rgba(25, 230, 140, 0.4);
  color: var(--text);
}
.starter__emoji {
  font-size: 1rem;
  flex: 0 0 auto;
}

/* ------------------------------ message row ---------------------------- */

.msg {
  display: flex;
  gap: 10px;
}

/* Only freshly created messages animate - reopening history stays calm. */
.msg--enter {
  animation: rise 0.32s cubic-bezier(0.22, 0.9, 0.3, 1) both;
}
.msg--user {
  flex-direction: row-reverse;
}

.msg__avatar {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-top: 2px;
  border-radius: 9px;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.msg--assistant .msg__avatar {
  background: linear-gradient(160deg, rgba(25, 230, 140, 0.3), rgba(16, 185, 129, 0.16));
  border-color: rgba(25, 230, 140, 0.32);
  color: #fff;
}
.msg--user .msg__avatar {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(16, 185, 129, 0.28);
  color: #b8f4ff;
}

.msg__body {
  min-width: 0;
  max-width: min(100%, 74ch);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.msg--user .msg__body {
  align-items: flex-end;
}

.msg__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  text-uppercase: none;
}
.msg--user .msg__meta {
  flex-direction: row-reverse;
}

.msg__copy {
  opacity: 0;
  transition: opacity 0.15s ease;
  font-size: 0.7rem;
}
.msg:hover .msg__copy,
.msg__copy:focus-visible {
  opacity: 1;
}

.msg__content {
  padding: 11px 15px;
  border-radius: var(--radius);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 0.94rem;
  overflow-wrap: anywhere;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}
.msg--user .msg__content {
  background: linear-gradient(150deg, rgba(25, 230, 140, 0.2), rgba(16, 185, 129, 0.12));
  border-color: rgba(25, 230, 140, 0.3);
  color: #f2f4ff;
  white-space: pre-wrap;
}
.msg--error .msg__content {
  background: var(--danger-soft);
  border-color: rgba(255, 107, 129, 0.36);
  color: #ffd9df;
}

.msg__retry {
  align-self: flex-start;
  margin-top: 2px;
}

/* -------------------------- markdown rendering ------------------------- */

.md > *:first-child {
  margin-top: 0;
}
.md > *:last-child {
  margin-bottom: 0;
}
.md p {
  margin: 0.55em 0;
}
.md h1,
.md h2,
.md h3,
.md h4 {
  margin: 1.1em 0 0.45em;
  line-height: 1.28;
  letter-spacing: -0.015em;
  font-weight: 620;
}
.md h1 {
  font-size: 1.3em;
}
.md h2 {
  font-size: 1.16em;
}
.md h3 {
  font-size: 1.04em;
}
.md h4 {
  font-size: 0.97em;
  color: var(--text-dim);
}
.md ul,
.md ol {
  margin: 0.55em 0;
  padding-left: 1.25em;
}
.md li {
  margin: 0.24em 0;
}
.md li::marker {
  color: var(--accent);
}
.md a {
  color: var(--accent-2);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.md a:hover {
  color: #7ceaff;
}
.md strong {
  color: #fff;
  font-weight: 620;
}
.md em {
  color: #dbe2f5;
}
.md blockquote {
  margin: 0.7em 0;
  padding: 0.15em 0 0.15em 0.9em;
  border-left: 2px solid rgba(25, 230, 140, 0.55);
  color: var(--text-dim);
}
.md hr {
  height: 1px;
  margin: 1.1em 0;
  border: 0;
  background: var(--border);
}
.md :not(pre) > code {
  padding: 0.14em 0.4em;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.855em;
  color: #ffd8a8;
}

.md table {
  width: 100%;
  margin: 0.8em 0;
  border-collapse: collapse;
  font-size: 0.87em;
  display: block;
  overflow-x: auto;
  white-space: nowrap;
}
.md th,
.md td {
  padding: 7px 11px;
  border: 1px solid var(--border);
  text-align: left;
}
.md th {
  background: var(--surface-strong);
  font-weight: 600;
  color: var(--text);
}
.md tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.014);
}

/* code blocks */
.code-block {
  margin: 0.8em 0;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: #05060b;
  overflow: hidden;
}
.code-block__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  background: rgba(255, 255, 255, 0.035);
  border-bottom: 1px solid var(--border);
}
.code-block__lang {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.code-block__copy {
  padding: 3px 9px;
  border-radius: 7px;
  font-size: 0.7rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  transition: background 0.15s ease, color 0.15s ease;
}
.code-block__copy:hover {
  background: var(--surface-strong);
  color: #fff;
}
.code-block__copy.is-done {
  color: var(--ok);
  border-color: rgba(74, 222, 128, 0.4);
}
.code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  scrollbar-width: thin;
}
.code-block code {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  line-height: 1.62;
  color: #e3e8f5;
  white-space: pre;
  tab-size: 2;
}

/* streaming caret + typing dots */
.caret {
  display: inline-block;
  width: 7px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -0.16em;
  border-radius: 1px;
  background: var(--accent-2);
  animation: blink 1s steps(2, start) infinite;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 3px 0;
}
.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.55;
  animation: bounce 1.05s ease-in-out infinite;
}
.typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.typing i:nth-child(3) {
  animation-delay: 0.3s;
}

/* ------------------------------- composer ------------------------------ */

.composer-wrap {
  flex: 0 0 auto;
  width: 100%;
  padding: 6px 12px calc(10px + var(--safe-b));
  background: linear-gradient(180deg, rgba(8, 9, 15, 0) 0%, rgba(8, 9, 15, 0.92) 34%, var(--bg) 100%);
}

.composer-wrap > * {
  max-width: var(--shell-max);
  margin-inline: auto;
}

/* In-chat notice (replaces the old banner that sat above the composer) */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--warn-soft);
  border: 1px solid rgba(255, 196, 107, 0.34);
  animation: rise 0.22s ease both;
}
.notice[data-tone="error"] {
  background: var(--danger-soft);
  border-color: rgba(255, 107, 129, 0.36);
}
.notice__body {
  flex: 1 1 auto;
  min-width: 0;
}
.notice__text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #ffe8c4;
}
.notice[data-tone="error"] .notice__text {
  color: #ffd9df;
}
.notice__hint {
  margin: 4px 0 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: rgba(255, 232, 196, 0.72);
  overflow-wrap: anywhere;
}
.notice[data-tone="error"] .notice__hint {
  color: rgba(255, 217, 223, 0.72);
}
.notice__close {
  flex: 0 0 auto;
  margin-top: -2px;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.composer:focus-within {
  border-color: rgba(25, 230, 140, 0.55);
  box-shadow: 0 0 0 3px rgba(25, 230, 140, 0.12), var(--shadow);
}

.composer textarea {
  flex: 1 1 auto;
  min-height: 26px;
  max-height: 190px;
  padding: 6px 0;
  border: 0;
  background: transparent;
  resize: none;
  font-size: 0.96rem;
  line-height: 1.55;
  color: var(--text);
  scrollbar-width: thin;
}
.composer textarea::placeholder {
  color: var(--text-faint);
}
.composer textarea:focus {
  outline: none;
}

.send {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 14px;
  color: #030806;
  background: var(--gradient);
  transition: opacity 0.16s ease, transform 0.16s ease, filter 0.16s ease;
}
.send:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.send:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  transform: none;
}
.send__stop {
  display: none;
}
.send.is-streaming .send__arrow {
  display: none;
}
.send.is-streaming .send__stop {
  display: block;
}

.composer__hint {
  margin: 8px 2px 0;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.5;
}
.kbd-hint {
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
}

/* ------------------------------- primitives ---------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 550;
  border: 1px solid transparent;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}
.btn--primary {
  color: #030806;
  background: var(--gradient);
  box-shadow: 0 12px 30px -16px rgba(25, 230, 140, 0.9);
}
.btn--primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
.btn--ghost {
  border-color: var(--border-strong);
  color: var(--text-dim);
  background: var(--surface);
}
.btn--ghost:hover {
  color: var(--text);
  background: var(--surface-strong);
}
.btn--block {
  width: 100%;
}

.link-btn {
  padding: 2px;
  font-size: 0.74rem;
  color: var(--text-dim);
  border-radius: 6px;
  transition: color 0.15s ease;
}
.link-btn:hover {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn--danger:hover {
  color: var(--danger);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  color: var(--text-dim);
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover {
  background: var(--surface-strong);
  color: var(--text);
}
.icon-btn--sm {
  width: 26px;
  height: 26px;
  margin-top: -2px;
}

.chip {
  align-self: flex-start;
  max-width: 100%;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-family: var(--font-mono);
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chip.is-error {
  color: #ffd9df;
  background: var(--danger-soft);
  border-color: rgba(255, 107, 129, 0.35);
}

/* --------------------------------- about ------------------------------- */

.about {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 20px;
}
.about[hidden] {
  display: none;
}
.about__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 5, 9, 0.72);
  backdrop-filter: blur(3px);
  animation: fade 0.2s ease;
}
.about__card {
  position: relative;
  width: min(460px, 100%);
  max-height: min(82dvh, 640px);
  overflow-y: auto;
  padding: 26px 24px 22px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, #10131d 0%, #050d0a 100%);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  animation: rise 0.26s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.about__close {
  position: absolute;
  top: 14px;
  right: 14px;
  margin-top: 0;
}
.about__mark {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(25, 230, 140, 0.26), rgba(16, 185, 129, 0.12));
  border: 1px solid var(--border-strong);
  box-shadow: 0 18px 44px -22px rgba(25, 230, 140, 0.85);
}
.about__title {
  margin: 14px 0 0;
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
  background: var(--gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.about__credit {
  margin: 4px 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
}
.about__credit strong {
  color: var(--text);
  font-weight: 600;
}
.about__body {
  margin-top: 16px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-dim);
}
.about__body p {
  margin: 0 0 10px;
}
.about__list {
  margin: 0;
  padding-left: 1.15rem;
}
.about__list li {
  margin: 0.24em 0;
}
.about__list li::marker {
  color: var(--accent);
}
.about__note {
  margin: 16px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 0.74rem;
  line-height: 1.55;
  color: var(--text-faint);
}
.sidebar__about {
  align-self: flex-start;
  font-size: 0.72rem;
}

/* --------------------------------- toast ------------------------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-b));
  z-index: 80;
  transform: translate(-50%, 12px);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #030806;
  background: #e8ecf6;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* --------------------------------- utils ------------------------------- */

.only-mobile {
  display: grid;
}

/* ------------------------------- animation ----------------------------- */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes blink {
  50% {
    opacity: 0;
  }
}
@keyframes bounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  50% {
    transform: translateY(-3px);
    opacity: 1;
  }
}
@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

/* ============================ responsive ============================== */

/* Small tablet and up: roomier message layout */
@media (min-width: 560px) {
  .messages {
    padding: 26px 22px 10px;
  }
  .composer-wrap {
    padding: 8px 20px calc(12px + var(--safe-b));
  }
  .starters {
    grid-template-columns: 1fr 1fr;
  }
  .msg__avatar {
    width: 30px;
    height: 30px;
  }
  .msg {
    gap: 12px;
  }
}

/* Desktop: persistent sidebar, centered conversation */
@media (min-width: 900px) {
  .sidebar {
    position: relative;
    transform: none;
    inset: auto;
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    box-shadow: none;
    z-index: 1;
  }
  .sidebar.is-open {
    box-shadow: none;
  }
  .scrim,
  .only-mobile {
    display: none !important;
  }
  .messages {
    padding: 30px 34px 12px;
  }
  .composer-wrap {
    padding: 10px 34px calc(14px + var(--safe-b));
  }
  .topbar {
    padding: 0 22px;
  }
  .history__del {
    opacity: 0;
  }
}

@media (min-width: 1240px) {
  :root {
    --sidebar-w: 312px;
  }
}

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

/* ============================ markdown, PR-ready ====================== */
/* Print / no-JS fallback niceties */
@media print {
  .sidebar,
  .topbar,
  .composer-wrap {
    display: none;
  }
  body {
    overflow: visible;
    background: #fff;
    color: #111;
  }
}

/* ============================ micro-interactions ======================= */

/* Press feedback */
.icon-btn:active,
.btn:active:not(:disabled),
.send:active:not(:disabled),
.starter:active {
  transform: scale(0.96);
}

/* Brand mark: scale-and-fade in, then a slow purple pulse */
@keyframes markIn {
  from {
    opacity: 0;
    transform: scale(0.86) translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes markGlow {
  0%,
  100% {
    box-shadow: 0 18px 44px -22px rgba(25, 230, 140, 0.85), 0 0 0 0 rgba(25, 230, 140, 0);
  }
  50% {
    box-shadow: 0 18px 44px -22px rgba(25, 230, 140, 0.85), 0 0 26px 2px rgba(25, 230, 140, 0.26);
  }
}

/* ==========================================================================
   Section switch (AI Assistant / Messages)
   ========================================================================== */

.appnav {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--nav-h);
  padding: 0 14px;
  padding-top: env(safe-area-inset-top, 0px);
  background: rgba(10, 12, 19, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.appnav__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.appnav__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(160deg, rgba(25, 230, 140, 0.22), rgba(16, 185, 129, 0.12));
  border: 1px solid var(--border-strong);
}

.appnav__mark--sm {
  width: 28px;
  height: 28px;
  border-radius: 9px;
}

.appnav__name {
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.appnav__switch {
  display: flex;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.appnav__tab {
  appearance: none;
  border: 0;
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 0.84rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transition: background 0.18s ease, color 0.18s ease;
}

.appnav__tab:hover {
  color: var(--text);
}

.appnav__tab[aria-selected="true"] {
  background: var(--gradient);
  color: #0a0c13;
}

/* The shell sits below the fixed nav. */
.app {
  padding-top: var(--nav-h);
}

.scrim {
  inset: var(--nav-h) 0 0 0;
}

/* ==========================================================================
   Messages — WhatsApp-style messenger
   ========================================================================== */

.messenger {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--app-h, 100vh) - var(--nav-h));
  background: var(--bg);
  overflow: hidden;
}

.messenger[hidden] {
  display: none;
}

.msg-shell {
  display: flex;
  height: 100%;
  min-height: 0;
}

/* ------------------------------- list pane ------------------------------- */

.msg-list-pane {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, #0c0e16 0%, #0a0c13 100%);
}

.msg-list__top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.msg-list__title {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 700;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease, border-color 0.16s ease;
}

.msg-icon-btn:hover:not(:disabled) {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--border-strong);
}

.msg-icon-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.msg-icon-btn--sm {
  width: 28px;
  height: 28px;
}

.msg-icon-btn.is-active {
  color: var(--accent-2);
  border-color: rgba(16, 185, 129, 0.4);
}

.msg-newrow {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.msg-newrow[hidden] {
  display: none;
}

.msg-newrow__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.msg-newrow__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.msg-newrow__go {
  flex: 0 0 auto;
  padding: 9px 14px;
  border-radius: 999px;
  border: 0;
  background: var(--gradient);
  color: #0a0c13;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.msg-search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 14px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.msg-search__icon {
  flex: 0 0 auto;
  color: var(--text-faint);
}

.msg-search__input {
  flex: 1 1 auto;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.msg-search__input:focus {
  outline: none;
}

.msg-search__input::-webkit-search-cancel-button {
  display: none;
}

.msg-search__clear {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: var(--surface-strong);
  color: var(--text-dim);
  cursor: pointer;
}

.msg-search__clear[hidden] {
  display: none;
}

.msg-list {
  flex: 1 1 auto;
  min-height: 0;
  margin: 0;
  padding: 0 8px 12px;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.msg-row + .msg-row {
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.msg-row__btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s ease;
}

.msg-row__btn:hover {
  background: var(--surface);
}

.msg-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.msg-avatar--sm {
  width: 36px;
  height: 36px;
  font-size: 0.82rem;
}

.msg-row__main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-row__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.msg-row__name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-row__time {
  flex: 0 0 auto;
  font-size: 0.72rem;
  color: var(--text-faint);
}

.msg-row__preview {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-chip-demo {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.msg-badge {
  display: grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--gradient);
  color: #0a0c13;
  font-size: 0.72rem;
  font-weight: 800;
}

/* ------------------------------- empty state ------------------------------ */

.msg-empty {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px 22px 40px;
  text-align: center;
}

.msg-empty[hidden] {
  display: none;
}

.msg-empty__art {
  color: var(--text-faint);
  opacity: 0.7;
}

.msg-empty__title {
  margin: 0;
  font-size: 1.02rem;
}

.msg-empty__text {
  margin: 0;
  max-width: 34ch;
  color: var(--text-dim);
  font-size: 0.88rem;
  line-height: 1.5;
}

.msg-empty__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 6px;
}

.msg-empty__actions[hidden] {
  display: none;
}

/* ------------------------------- chat screen ----------------------------- */

.msg-thread {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  background:
    radial-gradient(circle at 20% 10%, rgba(25, 230, 140, 0.08), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(16, 185, 129, 0.06), transparent 45%),
    var(--bg);
}

.msg-thread__top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(12, 14, 22, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.msg-thread__meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.msg-thread__name {
  font-weight: 650;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread__sub {
  font-size: 0.75rem;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-thread__input {
  width: 100%;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
}

.msg-thread__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.msg-thread__placeholder {
  margin: auto;
  padding: 24px;
  max-width: 32ch;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.88rem;
}

.msg-thread__placeholder[hidden] {
  display: none;
}

.msg-thread__hint {
  margin: auto;
  color: var(--text-faint);
  font-size: 0.85rem;
}

.msg-thread__body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.msg-daysep {
  align-self: center;
  margin: 8px 0 4px;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 600;
}

.msg-bubble {
  position: relative;
  max-width: min(78%, 520px);
  padding: 8px 11px 6px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.45;
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: msgBubbleIn 0.22s ease both;
}

.msg-bubble--in {
  align-self: flex-start;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
  color: var(--text);
}

.msg-bubble--out {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(25, 230, 140, 0.32), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(25, 230, 140, 0.38);
  border-bottom-right-radius: 5px;
  color: var(--text);
}

.msg-bubble__text {
  display: block;
  white-space: pre-wrap;
}

.msg-bubble__time {
  display: block;
  margin-top: 2px;
  text-align: right;
  font-size: 0.66rem;
  color: var(--text-faint);
}

.msg-attachment {
  display: inline-block;
  margin-bottom: 4px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.8rem;
}

@keyframes msgBubbleIn {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* -------------------------------- composer ------------------------------- */

.msg-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 6px;
  padding: 6px 6px 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-dim);
}

.msg-chip[hidden] {
  display: none;
}

.msg-chip__name {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px 10px calc(10px + var(--safe-b));
  border-top: 1px solid var(--border);
  background: rgba(12, 14, 22, 0.9);
}

.msg-composer__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev-2);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.3;
}

.msg-composer__input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.msg-send {
  background: var(--gradient);
  border-color: transparent;
  color: #0a0c13;
}

.msg-send:hover:not(:disabled) {
  color: #0a0c13;
  filter: brightness(1.08);
}

.msg-emoji-panel {
  position: absolute;
  right: 12px;
  bottom: 74px;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  padding: 8px;
  max-width: min(320px, calc(100vw - 24px));
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
}

.msg-emoji-panel[hidden] {
  display: none;
}

.msg-emoji {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.14s ease;
}

.msg-emoji:hover {
  background: var(--surface-strong);
  transform: scale(1.1);
}

/* ------------------------------- responsive ------------------------------- */

@media (max-width: 900px) {
  .msg-list-pane {
    width: 100%;
  }

  .msg-thread {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: none;
  }

  .messenger[data-view="thread"] .msg-thread {
    display: flex;
  }
}

@media (min-width: 901px) {
  .msg-list-pane {
    width: 380px;
    flex: 0 0 380px;
  }

  .msg-back {
    display: none;
  }
}

@media (max-width: 480px) {
  .appnav {
    padding: 0 10px;
  }

  .appnav__name {
    font-size: 0.9rem;
  }

  .appnav__tab {
    padding: 7px 11px;
    font-size: 0.78rem;
  }

  .msg-bubble {
    max-width: 86%;
  }

  .msg-emoji-panel {
    grid-template-columns: repeat(6, 1fr);
    right: 8px;
    left: 8px;
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .msg-bubble {
    animation: none;
  }
}

@media print {
  .appnav,
  .messenger {
    display: none !important;
  }
}

/* ------------------------- Mini Chat account / people ---------------------- */
/* Additive only: the account panel sits above the chat search inside the
   existing list pane and is hidden until it has something to say. */

.dm-account {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 0;
}

.dm-account__block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dm-account__lead {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--text-dim);
}

.dm-account__fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dm-account__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.dm-btn {
  padding: 8px 14px;
  font-size: 0.82rem;
  border-radius: 999px;
}

.dm-account__who {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dm-account__handle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-account__username {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dm-account__username .msg-newrow__input {
  flex: 1 1 auto;
  min-width: 0;
}

.dm-help {
  margin: 0;
  font-size: 0.74rem;
  line-height: 1.4;
  color: var(--text-faint);
}

.dm-help[data-kind='ok'] {
  color: var(--ok);
}

.dm-help[data-kind='error'] {
  color: var(--danger);
}

.dm-notice {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.dm-notice[data-kind='error'] {
  color: var(--danger);
}

.dm-notice[data-kind='ok'] {
  color: var(--ok);
}

/* Signup extras (display name + username) revealed by "Create account". */
.dm-account__fields--signup {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

/* Confirmation / auth result banner: visible from every section. */
.auth-banner {
  margin: 0;
  padding: 10px 16px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: var(--text-dim);
  background: var(--surface-2, rgba(255, 255, 255, 0.04));
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.auth-banner[data-kind='ok'] {
  color: var(--ok);
}

.auth-banner[data-kind='error'] {
  color: var(--danger);
}

@media (max-width: 640px) {
  .auth-banner {
    padding: 8px 12px;
    font-size: 0.8rem;
  }
}

.dm-find {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px 0;
}

.dm-find__form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.dm-find__form .msg-newrow__input {
  flex: 1 1 auto;
  min-width: 0;
}

.dm-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.dm-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}

.dm-result__main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.dm-result__name {
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-result__handle {
  font-size: 0.75rem;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dm-result__action {
  flex: 0 0 auto;
}

.dm-error {
  color: var(--danger);
}

@media (max-width: 900px) {
  .dm-account__username {
    flex-direction: column;
    align-items: stretch;
  }
}

/* --------------------- App nav account chip + profile --------------------- */
/* The account chip is the always-visible answer to "am I signed in?". It sits
   in the existing nav, so the signed-in state no longer requires opening
   Messages first. */

.appnav__account {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 40vw;
  padding: 4px 11px 4px 5px;
  margin-left: auto;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.appnav__account:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.appnav__account:focus-visible {
  outline: 2px solid #19e68c;
  outline-offset: 2px;
}

.appnav__avatar {
  --avatar-color: #6b7280;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--avatar-color);
  color: #0a0c13;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.appnav__account-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appnav__account[data-state='loading'] {
  opacity: 0.7;
}

.appnav__account[data-state='setup'] {
  border-color: rgba(25, 230, 140, 0.45);
  color: var(--text);
}

.profile__head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.profile__avatar {
  --avatar-color: #6b7280;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--avatar-color);
  color: #0a0c13;
  font-size: 1.05rem;
  font-weight: 800;
}

.profile__id {
  min-width: 0;
}

.profile__title {
  margin: 0 0 4px;
  font-size: 1.05rem;
}

.profile__handle {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.profile__state {
  margin: 0 0 14px;
  padding: 9px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.84rem;
  line-height: 1.5;
}

.profile__state[hidden] {
  display: none;
}

.profile__state[data-kind='error'] {
  border-color: rgba(248, 113, 113, 0.4);
  color: #fca5a5;
}

.profile__state[data-kind='info'] {
  border-color: var(--border-strong);
  color: var(--text);
}

.profile__meta {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 16px;
}

.profile__meta[hidden] {
  display: none;
}

.profile__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 0.86rem;
}

.profile__row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.profile__row dt {
  color: var(--text-dim);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.profile__row dd {
  margin: 0;
  color: var(--text);
  font-weight: 600;
  text-align: right;
  overflow-wrap: anywhere;
}

.profile__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.profile__actions:empty {
  display: none;
}

.dm-account__email {
  margin: 2px 0 0;
  color: var(--text-dim);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.dm-account__email:empty {
  display: none;
}

@media (max-width: 480px) {
  .appnav__account {
    max-width: 34vw;
    padding-right: 9px;
  }
}

/* ==========================================================================
   Emerald Gaming theme — refinements (visual only)
   ========================================================================== */
::selection {
  background: rgba(25, 230, 140, 0.3);
  color: #fff;
}

html {
  color-scheme: dark;
  scrollbar-color: rgba(25, 230, 140, 0.35) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(25, 230, 140, 0.28);
  border-radius: 8px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(25, 230, 140, 0.5);
}

body::after {
  content: "";
  position: fixed;
  inset: auto -10% -25% -10%;
  height: 45vh;
  background: radial-gradient(50% 60% at 50% 100%, rgba(16, 185, 129, 0.1), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

button,
a,
input,
textarea {
  transition: background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease,
    color 0.2s ease, transform 0.2s ease;
}

input:focus,
textarea:focus {
  border-color: rgba(25, 230, 140, 0.55);
  box-shadow: 0 0 0 3px rgba(25, 230, 140, 0.14);
}

img,
svg,
video {
  max-width: 100%;
}
pre {
  max-width: 100%;
  overflow-x: auto;
}

@media (max-width: 480px) {
  html,
  body {
    max-width: 100vw;
    overflow-x: hidden;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   Authentication gate
   --------------------------------------------------------------------------
   The gate is the app's outermost layer. It ships visible in the markup and is
   only taken down once a real session has been verified, so a slow or failed
   session check can never flash the assistant behind it. The assistant and
   Messages are hidden with body.auth-locked rather than unmounted, so their
   state (drafts, scroll, history) survives a lock/unlock round trip.
   ========================================================================== */

body.auth-locked {
  overflow: hidden;
}

body.auth-locked .appnav,
body.auth-locked #appShell,
body.auth-locked #messenger {
  display: none !important;
}

.authgate {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  padding: calc(18px + env(safe-area-inset-top, 0px)) 16px calc(18px + var(--safe-b));
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(25, 230, 140, 0.16), transparent 62%),
    radial-gradient(80% 60% at 50% 108%, rgba(16, 185, 129, 0.12), transparent 60%),
    var(--bg);
  animation: gateFade 0.26s ease both;
}

.authgate[hidden] {
  display: none;
}

/* Ambient emerald bloom behind the card. Purely decorative, never interactive. */
.authgate__aurora {
  position: absolute;
  inset: -10% -20% auto;
  height: 60%;
  pointer-events: none;
  background: radial-gradient(50% 60% at 50% 40%, rgba(25, 230, 140, 0.2), transparent 70%);
  filter: blur(28px);
  opacity: 0.75;
}

.authgate__card {
  position: relative;
  width: 100%;
  max-width: 412px;
  display: grid;
  gap: 14px;
  padding: 24px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(7, 17, 13, 0.94), rgba(3, 8, 6, 0.96));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(52, 211, 153, 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

/* ------------------------------- brand ---------------------------------- */

.authgate__brand {
  display: flex;
  align-items: center;
  gap: 11px;
}

.authgate__mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 13px;
  color: #04140d;
  background: var(--gradient);
  box-shadow: 0 0 22px -6px rgba(25, 230, 140, 0.65);
}

.authgate__brandtext {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.authgate__name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.authgate__name em {
  font-style: normal;
  color: var(--accent);
}

.authgate__credit {
  font-size: 0.72rem;
  color: var(--text-faint);
}

/* ------------------------------- screens -------------------------------- */

.authgate__screen {
  display: grid;
  gap: 9px;
}

.authgate__screen[hidden] {
  display: none;
}

.authgate__title {
  margin: 6px 0 0;
  font-size: 1.32rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--text);
}

.authgate__lead {
  margin: 0 0 2px;
  font-size: 0.86rem;
  line-height: 1.5;
  color: var(--text-dim);
}

.authgate__label {
  margin-top: 4px;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.authgate__input {
  width: 100%;
  padding: 12px 13px;
  font: inherit;
  font-size: 0.95rem; /* 16px-ish keeps Android from zooming on focus */
  color: var(--text);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.authgate__input::placeholder {
  color: var(--text-faint);
}

.authgate__input:hover {
  border-color: var(--border-strong);
}

.authgate__input:focus-visible,
.authgate__input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-strong);
  box-shadow: 0 0 0 3px rgba(25, 230, 140, 0.16);
}

.authgate__submit {
  width: 100%;
  margin-top: 8px;
  justify-content: center;
  padding: 12px 16px;
  font-weight: 650;
}

.authgate__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.authgate__help {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--text-faint);
}

.authgate__help[data-kind='ok'] {
  color: var(--accent-2);
}

.authgate__help[data-kind='error'] {
  color: var(--danger);
}

.authgate__switch {
  margin: 6px 0 0;
  font-size: 0.82rem;
  text-align: center;
  color: var(--text-dim);
}

.authgate__error,
.authgate__notice {
  margin: 0;
  padding: 9px 11px;
  font-size: 0.8rem;
  line-height: 1.45;
  border-radius: var(--radius-sm);
}

.authgate__error {
  color: var(--danger);
  border: 1px solid rgba(255, 107, 129, 0.3);
  background: var(--danger-soft);
}

.authgate__notice {
  color: var(--accent-2);
  border: 1px solid var(--border);
  background: var(--accent-soft);
}

.authgate__error[hidden],
.authgate__notice[hidden] {
  display: none;
}

/* ------------------------- checking indicator --------------------------- */

.authgate__dots {
  display: flex;
  gap: 6px;
  padding: 6px 0 2px;
}

.authgate__dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.35;
  animation: gateDot 1.1s ease-in-out infinite;
}

.authgate__dots span:nth-child(2) {
  animation-delay: 0.14s;
}

.authgate__dots span:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes gateFade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes gateDot {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

/* ------------------------------ responsive ------------------------------ */

@media (max-width: 420px) {
  .authgate {
    padding-inline: 12px;
    place-items: start center;
  }

  .authgate__card {
    margin-top: 8px;
    padding: 20px 16px;
    gap: 12px;
    border-radius: var(--radius);
  }

  .authgate__title {
    font-size: 1.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .authgate,
  .authgate__dots span {
    animation: none;
  }

  .authgate__dots span {
    opacity: 0.6;
  }

  .authgate__input {
    transition: none;
  }
}

/* ======================= friend requests + admin ======================== */
/* Emerald Gaming theme: deep black-green surfaces, mint accents, restrained
   glow. Everything here is additive and only affects the new panels. */

.privacy-note {
  margin: 10px 2px 2px;
  padding: 10px 12px;
  border: 1px solid var(--border, #163a2b);
  border-radius: 12px;
  background: rgba(16, 185, 129, 0.06);
  color: var(--text-dim, #8fb3a4);
  font-size: 11.5px;
  line-height: 1.5;
}

/* --- badges ------------------------------------------------------------- */
.appnav__badge,
.msg-icon-btn__badge {
  min-width: 17px;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent, #19e68c);
  color: #032015;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  letter-spacing: 0;
}

.msg-icon-btn__badge {
  position: absolute;
  top: -5px;
  right: -5px;
  box-shadow: 0 0 10px rgba(25, 230, 140, 0.55);
}

.msg-icon-btn--badged {
  position: relative;
  overflow: visible;
}

/* --- friend rows -------------------------------------------------------- */
.dm-requests {
  margin: 8px 0 12px;
  padding: 12px;
  border: 1px solid var(--border-strong, #1d5340);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(6, 20, 15, 0.96), rgba(3, 8, 6, 0.96));
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(52, 211, 153, 0.08);
  animation: dmPanelIn 180ms ease-out both;
}

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

.dm-requests__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.dm-requests__title {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text, #e6fbf1);
}

.dm-requests__tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dm-requests__group {
  margin: 12px 0 6px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint, #5f8272);
}

.dm-req-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.friend-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid var(--border, #163a2b);
  border-radius: 12px;
  background: rgba(10, 26, 20, 0.7);
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

.friend-row:hover {
  border-color: rgba(25, 230, 140, 0.34);
  background: rgba(14, 38, 29, 0.82);
}

.friend-row__main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.friend-row__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 50%;
  font-size: 12.5px;
  font-weight: 800;
  color: #032015;
  background: linear-gradient(140deg, #34d399, #10b981);
}

.friend-row__text {
  min-width: 0;
}

.friend-row__name {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text, #e6fbf1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-row__meta {
  display: block;
  font-size: 10.5px;
  color: var(--text-faint, #5f8272);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.friend-row__actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
}

.friend-action {
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid rgba(25, 230, 140, 0.35);
  background: rgba(25, 230, 140, 0.12);
  color: var(--accent-2, #10b981);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 130ms ease, transform 130ms ease, border-color 130ms ease;
}

.friend-action:hover:not(:disabled) {
  background: rgba(25, 230, 140, 0.2);
  border-color: rgba(25, 230, 140, 0.55);
}

.friend-action:active:not(:disabled) {
  transform: scale(0.96);
}

.friend-action:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.friend-action--accept {
  background: var(--accent, #19e68c);
  border-color: var(--accent, #19e68c);
  color: #032015;
  box-shadow: 0 0 14px rgba(25, 230, 140, 0.35);
}

.friend-action--accept:hover:not(:disabled) {
  background: var(--accent-3, #34d399);
  border-color: var(--accent-3, #34d399);
}

.friend-action--reject,
.friend-action--cancel {
  border-color: rgba(143, 179, 164, 0.28);
  background: transparent;
  color: var(--text-dim, #8fb3a4);
}

.friend-action--reject:hover:not(:disabled),
.friend-action--cancel:hover:not(:disabled) {
  background: rgba(143, 179, 164, 0.12);
  border-color: rgba(143, 179, 164, 0.45);
}

.friend-status {
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--border, #163a2b);
  background: rgba(143, 179, 164, 0.1);
  color: var(--text-dim, #8fb3a4);
  font-size: 10.5px;
  font-weight: 700;
  white-space: nowrap;
}

.friend-status--accepted {
  border-color: rgba(25, 230, 140, 0.42);
  background: rgba(25, 230, 140, 0.12);
  color: var(--accent-2, #10b981);
}

.friend-status--pending {
  border-color: rgba(52, 211, 153, 0.3);
  color: var(--accent-3, #34d399);
}

.dm-result__actions {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: auto;
  flex: none;
}

/* --- admin dashboard ---------------------------------------------------- */
.admin {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  background: radial-gradient(120% 80% at 50% 0%, #06140f 0%, #030806 62%, #010403 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: dmPanelIn 200ms ease-out both;
}

.admin__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.admin__title {
  margin: 0;
  font-size: 16px;
  font-weight: 750;
  letter-spacing: 0.01em;
  color: var(--text, #e6fbf1);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.admin-stat {
  padding: 10px 12px;
  border: 1px solid var(--border, #163a2b);
  border-radius: 13px;
  background: rgba(10, 26, 20, 0.72);
}

.admin-stat__value {
  display: block;
  font-size: 19px;
  font-weight: 800;
  color: var(--accent, #19e68c);
  line-height: 1.15;
}

.admin-stat__label {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint, #5f8272);
}

.admin-tabs {
  display: flex;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--border, #163a2b);
  border-radius: 12px;
  background: rgba(6, 18, 13, 0.8);
}

.admin-tab {
  flex: 1;
  padding: 8px 6px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-dim, #8fb3a4);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.admin-tab[aria-selected='true'] {
  background: rgba(25, 230, 140, 0.14);
  color: var(--accent, #19e68c);
  box-shadow: inset 0 0 0 1px rgba(25, 230, 140, 0.32);
}

.admin-search__wrap {
  display: flex;
  gap: 7px;
}

.admin-search__wrap .msg-newrow__input {
  flex: 1;
  min-width: 0;
}

.admin-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 20px;
}

.admin-row {
  padding: 10px 12px;
  border: 1px solid var(--border, #163a2b);
  border-radius: 13px;
  background: rgba(10, 26, 20, 0.72);
}

.admin-row__head {
  display: flex;
  align-items: flex-start;
  gap: 9px;
}

.admin-row__main {
  min-width: 0;
  flex: 1;
}

.admin-row__title {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text, #e6fbf1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-row__meta {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--text-faint, #5f8272);
  word-break: break-word;
}

.admin-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.admin-pill {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border, #163a2b);
  background: rgba(143, 179, 164, 0.1);
  color: var(--text-dim, #8fb3a4);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.admin-pill--active {
  border-color: rgba(25, 230, 140, 0.42);
  background: rgba(25, 230, 140, 0.12);
  color: var(--accent-2, #10b981);
}

.admin-pill--suspended,
.admin-pill--deactivated {
  border-color: rgba(248, 113, 113, 0.36);
  background: rgba(248, 113, 113, 0.1);
  color: #f87171;
}

.admin-pill--admin {
  border-color: rgba(52, 211, 153, 0.42);
  color: var(--accent-3, #34d399);
}

.admin-btn {
  padding: 6px 10px;
  border-radius: 9px;
  border: 1px solid rgba(143, 179, 164, 0.28);
  background: transparent;
  color: var(--text-dim, #8fb3a4);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  transition: background 130ms ease, border-color 130ms ease, transform 130ms ease;
}

.admin-btn:hover:not(:disabled) {
  background: rgba(143, 179, 164, 0.12);
  border-color: rgba(143, 179, 164, 0.5);
}

.admin-btn:active:not(:disabled) {
  transform: scale(0.96);
}

.admin-btn--primary {
  border-color: rgba(25, 230, 140, 0.45);
  background: rgba(25, 230, 140, 0.14);
  color: var(--accent, #19e68c);
}

.admin-btn--danger {
  border-color: rgba(248, 113, 113, 0.34);
  color: #f87171;
}

.admin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-mod {
  border: 1px solid var(--border-strong, #1d5340);
  border-radius: 13px;
  background: rgba(6, 18, 13, 0.86);
  padding: 10px 12px;
}

.admin-mod__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.admin-mod__msg {
  padding: 7px 9px;
  border-radius: 10px;
  background: rgba(10, 26, 20, 0.9);
  border: 1px solid var(--border, #163a2b);
  margin-bottom: 6px;
}

.admin-mod__msg-meta {
  display: block;
  font-size: 9.5px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint, #5f8272);
}

.admin-mod__msg-body {
  display: block;
  margin-top: 3px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text, #e6fbf1);
  white-space: pre-wrap;
  word-break: break-word;
}

.admin-empty {
  padding: 18px 12px;
  border: 1px dashed var(--border, #163a2b);
  border-radius: 13px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-faint, #5f8272);
}

/* --- reason prompt ------------------------------------------------------ */
/* Closed by default. Visibility is owned by JS: askReason() in admin-ui.js is
   the only opener and toggles `.is-open`. Keeping the closed state in this base
   rule means the prompt cannot paint on launch even before its handlers are
   bound, and the buttons are always wired before it can ever be shown. */
.admin-reason {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  place-items: center;
  padding: 18px;
  background: rgba(1, 4, 3, 0.72);
  backdrop-filter: blur(4px);
  animation: dmPanelIn 140ms ease-out both;
}

.admin-reason.is-open {
  display: grid;
}

.admin-reason__card {
  width: 100%;
  max-width: 400px;
  padding: 14px;
  border: 1px solid var(--border-strong, #1d5340);
  border-radius: 16px;
  background: linear-gradient(180deg, #071a13, #04100c);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.6);
}

.admin-reason__label {
  margin: 0 0 8px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text, #e6fbf1);
}

.admin-reason__text {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border, #163a2b);
  border-radius: 10px;
  background: rgba(3, 10, 7, 0.9);
  color: var(--text, #e6fbf1);
  font: inherit;
  font-size: 12px;
  resize: vertical;
}

.admin-reason__text:focus {
  outline: none;
  border-color: rgba(25, 230, 140, 0.55);
  box-shadow: 0 0 0 3px rgba(25, 230, 140, 0.14);
}

.admin-reason__error {
  margin: 7px 0 0;
  font-size: 11px;
  color: #f87171;
}

.admin-reason__actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  margin-top: 10px;
}

@media (min-width: 720px) {
  .admin-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .admin {
    padding: 20px 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dm-requests,
  .admin,
  .admin-reason {
    animation: none;
  }

  .friend-row,
  .friend-action,
  .admin-btn,
  .admin-tab {
    transition: none;
  }

  .friend-action:active:not(:disabled),
  .admin-btn:active:not(:disabled) {
    transform: none;
  }
}

/* --- closed state for JS-toggled containers ------------------------------
   These elements are shown/hidden by setting the `hidden` attribute, but each
   one sets its own `display` value, which outranks the browser's built-in
   [hidden] rule. Without these, a panel is painted on launch even though the
   markup and the JS both say it is closed. This is the same convention already
   used above by .app[hidden], .about[hidden] and .messenger[hidden]. */
.admin[hidden],
.admin-reason[hidden],
.dm-find[hidden],
.dm-results[hidden],
.intro[hidden],
.intro__mark[hidden],
.authgate__mark[hidden],
.authgate__dots[hidden],
.appnav__mark[hidden],
.appnav__avatar[hidden],
.brand__mark[hidden],
.msg-avatar[hidden],
.msg__avatar[hidden],
.about__mark[hidden],
.profile__avatar[hidden] {
  display: none;
}

/* ------------------------- super admin dashboard ------------------------- */

.admin-charts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

.admin-chart {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(25, 230, 140, 0.16);
  border-radius: 12px;
  background: rgba(6, 24, 18, 0.66);
}

.admin-chart__label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8fb3a4;
}

.admin-chart svg {
  display: block;
  width: 100%;
  height: 64px;
  margin-top: 8px;
}

.admin-chart__bar {
  fill: #19e68c;
  opacity: 0.85;
}

.admin-sys {
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
  border: 1px solid rgba(25, 230, 140, 0.16);
  border-radius: 12px;
  overflow: hidden;
}

.admin-sys__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  font-size: 13px;
  border-bottom: 1px solid rgba(25, 230, 140, 0.1);
}

.admin-sys__row:last-child {
  border-bottom: 0;
}

.admin-sys__key {
  color: #8fb3a4;
}

.admin-sys__val {
  color: #d6ffe9;
  text-align: right;
  word-break: break-word;
}

.admin-sys__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(25, 230, 140, 0.2);
  border-radius: 12px;
  background: rgba(6, 24, 18, 0.6);
}

.admin-hint {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.5;
  color: #8fb3a4;
}

.admin-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid rgba(25, 230, 140, 0.14);
  border-radius: 10px;
  margin-bottom: 8px;
  background: rgba(6, 24, 18, 0.5);
}

.admin-item__name {
  font-size: 13px;
  color: #d6ffe9;
}

.admin-item__meta {
  font-size: 12px;
  color: #8fb3a4;
}

.admin-denied {
  padding: 32px 20px;
  text-align: center;
}

.admin-denied__title {
  margin: 0 0 8px;
  font-size: 20px;
  color: #ff8f8f;
}

.admin-denied__text {
  margin: 0 auto 18px;
  max-width: 44ch;
  font-size: 14px;
  line-height: 1.6;
  color: #9fb8ac;
}

/* ========================================================================== */
/* LOKY CONNECT — social messaging surface                                    */
/* Reuses the emerald palette from the app shell: --bg, --accent, --surface.  */
/* ========================================================================== */

.connect {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: radial-gradient(120% 90% at 50% 0%, #07231a 0%, #030806 62%);
  color: #e6fff4;
  font-family: inherit;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.connect[hidden] { display: none; }

.connect__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 10px;
  border-bottom: 1px solid rgba(25, 230, 140, 0.14);
  background: linear-gradient(180deg, rgba(6, 32, 24, 0.96), rgba(3, 8, 6, 0.82));
  backdrop-filter: blur(12px);
}

.connect__brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.connect__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #04231a;
  background: linear-gradient(140deg, #34d399, #19e68c 55%, #10b981);
  box-shadow: 0 0 16px rgba(25, 230, 140, 0.42);
  flex: none;
}

.connect__title { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: 0.08em; }
.connect__subtitle { margin: 1px 0 0; font-size: 11px; color: #7fe3b6; letter-spacing: 0.06em; text-transform: uppercase; }

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

.connect-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid rgba(25, 230, 140, 0.22);
  background: rgba(10, 30, 24, 0.72);
  color: #b8ffe0;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.connect-icon:hover { background: rgba(16, 185, 129, 0.18); border-color: rgba(52, 211, 153, 0.45); }
.connect-icon:active { transform: scale(0.93); }
.connect-icon:focus-visible { outline: 2px solid #34d399; outline-offset: 2px; }
.connect-icon--avatar { padding: 0; overflow: hidden; }

.connect-icon__badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #19e68c;
  color: #04231a;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

.connect__tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(25, 230, 140, 0.1);
  background: rgba(4, 14, 11, 0.72);
}

.connect-tab {
  padding: 8px 4px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #82b8a4;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: color 0.16s ease, background 0.16s ease;
}

.connect-tab:hover { color: #c8ffe8; background: rgba(25, 230, 140, 0.08); }
.connect-tab[aria-selected='true'] {
  color: #062a1e;
  background: linear-gradient(140deg, #34d399, #19e68c);
  box-shadow: 0 0 14px rgba(25, 230, 140, 0.34);
}

.connect__notice {
  margin: 8px 12px 0;
  padding: 9px 11px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: rgba(16, 185, 129, 0.1);
  color: #ccffe9;
}

.connect__notice[data-kind='warn'] { border-color: rgba(250, 204, 21, 0.34); background: rgba(250, 204, 21, 0.1); color: #ffeeb0; }
.connect__notice[data-kind='bad'] { border-color: rgba(248, 113, 113, 0.36); background: rgba(248, 113, 113, 0.1); color: #ffd4d4; }
.connect__notice[data-kind='ok'] { border-color: rgba(25, 230, 140, 0.42); }

.connect__panes { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.connect-pane { padding: 12px 12px 24px; }
.connect-pane[hidden] { display: none; }
.connect-pane__title { margin: 2px 4px 10px; font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: #8fd9bd; }
.connect-group { margin: 16px 4px 8px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: #6fb59c; }

.connect-search { display: flex; gap: 8px; margin: 0 0 12px; }

.connect-search__input {
  flex: 1;
  min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid rgba(25, 230, 140, 0.2);
  background: rgba(8, 26, 20, 0.85);
  color: #e6fff4;
  font-size: 14px;
  font-family: inherit;
}

.connect-search__input::placeholder { color: #6f9c8c; }
.connect-search__input:focus { outline: none; border-color: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.16); }

.connect-search__go {
  padding: 0 15px;
  border: 0;
  border-radius: 12px;
  background: linear-gradient(140deg, #34d399, #19e68c);
  color: #062a1e;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.connect-search__go:active { transform: scale(0.96); }
.connect-search__go:hover { filter: brightness(1.06); }

.connect-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.connect-empty { margin: 18px 6px; font-size: 13px; line-height: 1.55; color: #85b3a3; text-align: center; }
.connect-empty[hidden] { display: none; }

.connect-avatar {
  --hue: 152;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  overflow: hidden;
  flex: none;
  font-size: 14px;
  font-weight: 700;
  color: #04231a;
  background: linear-gradient(150deg, hsl(var(--hue) 78% 62%), hsl(calc(var(--hue) + 26) 72% 46%));
  border: 1px solid rgba(25, 230, 140, 0.24);
}

.connect-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.connect-avatar--sm { width: 34px; height: 34px; border-radius: 11px; font-size: 12px; }
.connect-avatar--lg { width: 62px; height: 62px; border-radius: 20px; font-size: 20px; }

.connect-chat__btn,
.connect-friend__btn,
.connect-result,
.connect-req {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(25, 230, 140, 0.13);
  background: linear-gradient(160deg, rgba(11, 34, 27, 0.9), rgba(5, 16, 13, 0.9));
  color: inherit;
  text-align: left;
  font-family: inherit;
  transition: border-color 0.16s ease, transform 0.16s ease, background 0.16s ease;
}

.connect-chat__btn,
.connect-friend__btn { cursor: pointer; }
.connect-chat__btn:hover,
.connect-friend__btn:hover { border-color: rgba(52, 211, 153, 0.42); background: rgba(16, 185, 129, 0.12); }
.connect-chat__btn:active,
.connect-friend__btn:active { transform: scale(0.985); }
.connect-chat__btn:focus-visible,
.connect-friend__btn:focus-visible { outline: 2px solid #34d399; outline-offset: 2px; }

.connect-chat__body, .connect-friend__body, .connect-req__body, .connect-notif__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.connect-req__body { flex-direction: row; align-items: center; gap: 10px; }
.connect-req__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.connect-chat__name, .connect-friend__name { font-size: 14px; color: #eafff6; }
.connect-chat__preview, .connect-friend__meta, .connect-req__note {
  font-size: 12px;
  color: #8fb9aa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.connect-chat__meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex: none; }
.connect-chat__time { font-size: 11px; color: #6fa791; }

.connect-badge {
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 10px;
  background: #19e68c;
  color: #04231a;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
}

.connect-friend__cta {
  flex: none;
  padding: 6px 11px;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: #062a1e;
  background: rgba(52, 211, 153, 0.86);
}

.connect-req { align-items: flex-start; flex-wrap: wrap; }
.connect-req__actions { display: flex; gap: 7px; flex-wrap: wrap; }

.connect-btn {
  padding: 7px 13px;
  border-radius: 10px;
  border: 1px solid rgba(25, 230, 140, 0.28);
  background: rgba(9, 30, 23, 0.9);
  color: #ccffe9;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.connect-btn:hover { background: rgba(16, 185, 129, 0.16); border-color: rgba(52, 211, 153, 0.5); }
.connect-btn:active { transform: scale(0.95); }
.connect-btn:disabled { opacity: 0.5; cursor: default; transform: none; }
.connect-btn--primary { background: linear-gradient(140deg, #34d399, #19e68c); color: #062a1e; border-color: transparent; }
.connect-btn--danger { border-color: rgba(248, 113, 113, 0.42); color: #ffc9c9; }

/* -------------------------------- thread --------------------------------- */

.connect-thread {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(130% 80% at 50% 0%, #06211a 0%, #030806 58%);
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: connectSlide 0.2s ease-out;
}

.connect-thread[hidden] { display: none; }

@keyframes connectSlide {
  from { opacity: 0; transform: translateX(12px); }
  to { opacity: 1; transform: translateX(0); }
}

.connect-thread__top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(25, 230, 140, 0.14);
  background: linear-gradient(180deg, rgba(6, 32, 24, 0.97), rgba(4, 14, 11, 0.9));
  backdrop-filter: blur(10px);
  flex: none;
}

.connect-thread__who { display: flex; flex-direction: column; min-width: 0; }
.connect-thread__name { font-size: 14px; color: #eafff6; }
.connect-thread__presence { font-size: 11px; color: #6fd3a9; }

.connect-thread__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #85b3a3;
}

.connect-thread__scroll--error { color: #ffb4b4; }

.connect-daysep {
  align-self: center;
  margin: 6px 0;
  padding: 3px 10px;
  border-radius: 9px;
  background: rgba(16, 185, 129, 0.12);
  color: #8fd9bd;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.connect-bubble {
  position: relative;
  max-width: 78%;
  padding: 8px 11px 7px;
  border-radius: 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: connectPop 0.18s ease-out;
}

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

.connect-bubble--in {
  align-self: flex-start;
  background: linear-gradient(160deg, rgba(13, 40, 32, 0.96), rgba(7, 22, 17, 0.96));
  border: 1px solid rgba(25, 230, 140, 0.16);
  color: #e2fff4;
  border-bottom-left-radius: 5px;
}

.connect-bubble--out {
  align-self: flex-end;
  background: linear-gradient(150deg, #10b981, #19e68c);
  color: #04231a;
  border-bottom-right-radius: 5px;
  box-shadow: 0 3px 14px rgba(25, 230, 140, 0.2);
}

.connect-bubble__text { white-space: pre-wrap; word-break: break-word; line-height: 1.45; }
.connect-bubble__deleted { opacity: 0.72; font-size: 12px; }

.connect-bubble__meta { display: flex; align-items: center; gap: 5px; justify-content: flex-end; }
.connect-bubble__time { font-size: 10px; opacity: 0.72; }
.connect-bubble__tick { font-size: 10px; opacity: 0.8; }

.connect-bubble__reply {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 5px 7px;
  border-left: 2px solid currentColor;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.16);
  font-size: 11px;
  opacity: 0.9;
}

.connect-bubble__reply-who { font-weight: 700; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; }
.connect-bubble__reply-body { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.connect-bubble__media img,
.connect-bubble__media video {
  display: block;
  width: 100%;
  max-width: 240px;
  border-radius: 11px;
}

.connect-bubble__media { font-size: 12px; }

.connect-bubble__reacts { display: flex; gap: 4px; flex-wrap: wrap; }

.connect-react,
.connect-react-pick {
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.24);
  border-radius: 9px;
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.5;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.14s ease, background 0.14s ease;
}

.connect-react--mine { background: rgba(255, 255, 255, 0.46); font-weight: 700; }
.connect-react:active, .connect-react-pick:active { transform: scale(0.9); }

.connect-bubble__menu {
  position: absolute;
  top: -13px;
  right: 4px;
  display: none;
  gap: 2px;
  padding: 3px;
  border-radius: 11px;
  background: rgba(4, 16, 12, 0.97);
  border: 1px solid rgba(25, 230, 140, 0.3);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
  z-index: 2;
}

.connect-bubble:hover .connect-bubble__menu,
.connect-bubble:focus-within .connect-bubble__menu { display: flex; }

.connect-react-pick { background: transparent; border-color: transparent; font-size: 13px; padding: 2px 4px; }
.connect-react-pick:hover { background: rgba(25, 230, 140, 0.2); }
.connect-react-pick--danger { color: #ff9b9b; }

.connect-typing { margin: 0; padding: 0 16px 4px; font-size: 11px; color: #6fd3a9; font-style: italic; }
.connect-typing[hidden] { display: none; }

.connect-attach { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 6px; }
.connect-attach[hidden] { display: none; }

.connect-attach__chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 10px;
  border: 1px solid rgba(25, 230, 140, 0.28);
  background: rgba(10, 34, 26, 0.92);
  color: #ccffe9;
  font-size: 11px;
  max-width: 100%;
}

.connect-attach__x { border: 0; background: transparent; color: #9fe8c9; font-size: 15px; line-height: 1; cursor: pointer; }

.connect-composer {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(25, 230, 140, 0.16);
  background: linear-gradient(0deg, rgba(4, 16, 12, 0.98), rgba(6, 26, 20, 0.9));
  flex: none;
}

.connect-composer__input {
  flex: 1;
  min-width: 0;
  max-height: 118px;
  padding: 10px 13px;
  border-radius: 14px;
  border: 1px solid rgba(25, 230, 140, 0.2);
  background: rgba(8, 26, 20, 0.9);
  color: #e6fff4;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  line-height: 1.4;
}

.connect-composer__input::placeholder { color: #6f9c8c; }
.connect-composer__input:focus { outline: none; border-color: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14); }

.connect-send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 14px;
  background: linear-gradient(140deg, #34d399, #19e68c);
  color: #04231a;
  font-size: 16px;
  cursor: pointer;
  flex: none;
  box-shadow: 0 0 14px rgba(25, 230, 140, 0.3);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.connect-send:hover { filter: brightness(1.07); }
.connect-send:active { transform: scale(0.92); }
.connect-send:disabled { opacity: 0.55; cursor: default; }

/* --------------------------------- sheet --------------------------------- */

.connect-sheet {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(2, 8, 6, 0.72);
  backdrop-filter: blur(3px);
  z-index: 5;
}

.connect-sheet[hidden] { display: none; }

.connect-sheet__panel {
  width: 100%;
  max-width: 460px;
  max-height: 88%;
  overflow-y: auto;
  padding: 14px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  border-radius: 20px 20px 0 0;
  border: 1px solid rgba(25, 230, 140, 0.22);
  border-bottom: 0;
  background: linear-gradient(180deg, #07231a, #040d0a);
  animation: connectSheet 0.22s ease-out;
}

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

.connect-sheet__top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.connect-sheet__title { margin: 0; font-size: 15px; }

.connect-profile__head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.connect-profile__head strong { display: block; font-size: 15px; }
.connect-profile__username { font-size: 12px; color: #7fe3b6; }

.connect-form { display: flex; flex-direction: column; gap: 11px; }
.connect-field { display: flex; flex-direction: column; gap: 5px; }
.connect-field__label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: #7fb9a4; }

.connect-input {
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(25, 230, 140, 0.2);
  background: rgba(8, 26, 20, 0.9);
  color: #e6fff4;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}

.connect-input:focus { outline: none; border-color: #34d399; box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14); }

.connect-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #cdeee0; }
.connect-check input { width: 16px; height: 16px; accent-color: #19e68c; }

.connect-file { display: none; }
.connect-file__label {
  display: inline-block;
  padding: 9px 13px;
  border-radius: 11px;
  border: 1px dashed rgba(25, 230, 140, 0.4);
  color: #a8f2d0;
  font-size: 12px;
  cursor: pointer;
  text-align: center;
}

.connect-notif { display: flex; align-items: flex-start; gap: 10px; padding: 9px 10px; border-radius: 12px; border: 1px solid rgba(25, 230, 140, 0.12); background: rgba(9, 30, 23, 0.7); }
.connect-notif--unread { border-color: rgba(25, 230, 140, 0.42); background: rgba(16, 185, 129, 0.12); }
.connect-notif__body { font-size: 12.5px; line-height: 1.45; color: #dcfff1; }
.connect-notif__time { font-size: 10px; color: #74ab95; }

@media (max-width: 420px) {
  .connect__title { font-size: 14px; }
  .connect-tab { font-size: 11px; }
  .connect-bubble { max-width: 86%; }
  .connect-bubble__menu { display: flex; position: static; order: 3; background: transparent; border: 0; box-shadow: none; padding: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .connect-thread, .connect-bubble, .connect-sheet__panel { animation: none; }
  .connect-icon, .connect-btn, .connect-send, .connect-chat__btn, .connect-friend__btn { transition: none; }
}

/* ------------------------------------------------------------------------- */
/* AI Assistant image attachments                                            */
/* ------------------------------------------------------------------------- */

.composer__file { display: none; }

.composer__attach {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.24);
  background: rgba(16, 185, 129, 0.08);
  color: #34d399;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
}

.composer__attach:hover {
  background: rgba(25, 230, 140, 0.16);
  border-color: rgba(52, 211, 153, 0.48);
}

.composer__attach:active { transform: scale(0.94); }

.composer__attach:focus-visible {
  outline: 2px solid #19e68c;
  outline-offset: 2px;
}

.composer__attach:disabled,
.composer__attach.is-full {
  opacity: 0.45;
  cursor: not-allowed;
}

.composer__previews {
  display: flex;
  gap: 8px;
  padding: 8px 10px 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.preview {
  position: relative;
  flex: 0 0 auto;
  width: 74px;
  height: 74px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(52, 211, 153, 0.28);
  background: rgba(3, 8, 6, 0.85);
}

.preview__img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.preview[data-state='loading'] .preview__img { opacity: 0.5; }

.preview__state {
  position: absolute;
  inset: auto 0 0 0;
  padding: 2px 0;
  font-size: 10px;
  text-align: center;
  background: rgba(3, 8, 6, 0.8);
  color: #34d399;
}

.preview[data-state='error'] .preview__state { color: #fca5a5; }

.preview__remove {
  position: absolute;
  top: 3px;
  right: 3px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(3, 8, 6, 0.82);
  color: #eafaf1;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, transform 120ms ease;
}

.preview__remove:hover { background: rgba(239, 68, 68, 0.85); }
.preview__remove:active { transform: scale(0.9); }

.composer-wrap.is-dropping .composer {
  border-color: #19e68c;
  box-shadow: 0 0 0 1px rgba(25, 230, 140, 0.55), 0 0 22px rgba(25, 230, 140, 0.22);
}

.msg__images {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 8px;
}

.msg__image { margin: 0; max-width: min(240px, 60vw); }

.msg__image img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid rgba(52, 211, 153, 0.3);
  background: #030806;
}

.msg__image figcaption {
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7d9b8c;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .composer__attach { width: 34px; height: 34px; border-radius: 10px; }
  .preview { width: 62px; height: 62px; }
  .msg__image { max-width: min(200px, 68vw); }
}

@media (prefers-reduced-motion: reduce) {
  .composer__attach,
  .preview__remove { transition: none; }
}
