:root {
  --night: #151b28;
  --deep: #0e121c;
  --dusk: #20293a;
  --dusk-hi: #2a3448;
  --line: #364156;
  --mist: #a9b4c8;
  --text: #eceaf3;
  --lamp: #f5b94a;
  --lamp-ink: #22190a;
  --lamp-glow: rgba(245, 185, 74, 0.32);
  --danger: #e4574e;
  --danger-soft: rgba(228, 87, 78, 0.16);
  --online: #5bd18b;
  --away: #f5b94a;
  --offline: #6c768c;

  --font: "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius-lg: 18px;
  --radius: 12px;

  color-scheme: dark;
  box-sizing: border-box;
  padding-top: var(--safe-area-inset-top, env(safe-area-inset-top, 0px));
  padding-bottom: var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
}

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

html, body { height: 100%; margin: 0; }

body {
  background: var(--night);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--lamp); outline-offset: 2px; }

.icon {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round;
  flex: none;
}

/* ================= Join ================= */

.join {
  height: 100%;
  overflow-y: auto;
  display: grid;
  place-items: center;
  padding: 24px 20px 40px;
}

.join-inner { width: min(400px, 100%); }

/* Sign-in: the Rainlit drop, landing softly, in its own pool of warm light. */
.drop-hero { position: relative; width: 96px; height: 96px; margin: 0 0 14px -18px; }
.drop-hero img { display: block; width: 100%; height: 100%; animation: drop-in 0.9s cubic-bezier(0.3, 0, 0.2, 1) 0.15s both; }
.drop-hero::after {
  /* the pool of light */
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 760px; height: 760px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(245, 185, 74, 0.13) 0%, rgba(245, 185, 74, 0.04) 35%, transparent 62%);
  pointer-events: none;
  z-index: -1;
}
.drop-small { display: block; width: 44px; height: 44px; margin: 0 auto 14px; }
.drop-small.dim { filter: grayscale(1) brightness(0.75); opacity: 0.55; }

@keyframes drop-in {
  0%   { opacity: 0; transform: translateY(-26px); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

/* The logo, lowercase: "rain" strong and "lit" lighter and softer, no space between. */
.wordmark, .brand-name { letter-spacing: -0.008em; }
.wm-rain { font-weight: 720; color: var(--text); }
.wm-lit { font-weight: 420; color: var(--mist); }

.wordmark {
  margin: 0;
  font-size: clamp(48px, 13vw, 76px);
  font-variation-settings: "opsz" 96;
  line-height: 0.95;
}

.get-apps { margin: 32px 0 0; font-size: 14px; }
.get-apps a { color: var(--lamp); font-weight: 600; }

.tagline { margin: 14px 0 36px; color: var(--mist); font-size: 17px; max-width: 32ch; }

.join-form { display: grid; gap: 20px; }

.field { display: grid; gap: 7px; }
.field > span:first-child { font-size: 14px; font-weight: 600; }
.field input:not([type="range"]), .field select {
  width: 100%;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 16px;
}
.field input::placeholder { color: #6c768c; }
.field input:focus-visible, .field select:focus-visible { outline-offset: 0; border-color: var(--lamp); }
.field-row { display: flex; gap: 10px; align-items: center; }
.field-row input { flex: 1; min-width: 0; }
.hint { color: var(--mist); font-size: 13px; }

.text-btn {
  background: none; border: 0; padding: 8px 4px;
  color: var(--mist); font-size: 14px; font-weight: 600; white-space: nowrap;
}
.text-btn:hover { color: var(--text); }

.primary-btn {
  background: var(--lamp);
  color: var(--lamp-ink);
  border: 0;
  border-radius: var(--radius);
  padding: 13px 18px;
  font-weight: 700;
  font-size: 16px;
}
.primary-btn:hover { filter: brightness(1.06); }
.primary-btn:disabled { opacity: 0.6; cursor: progress; }
.primary-btn.small { padding: 9px 14px; font-size: 14px; }

.form-error {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: #ffb4ae;
  font-size: 14px;
}

.auth-tabs { display: flex; gap: 6px; margin: -12px 0 22px; padding: 4px; background: var(--dusk); border-radius: 999px; width: max-content; }
.auth-tab {
  background: none; border: 0; border-radius: 999px;
  padding: 7px 16px;
  color: var(--mist); font-size: 14px; font-weight: 600;
}
.auth-tab[aria-selected="true"] { background: var(--dusk-hi); color: var(--text); }
.auth-error { margin-top: 16px; }

.text-btn.danger { color: #ffb4ae; }
.text-btn.danger:hover { color: var(--danger); }

/* ================= App shell ================= */

.app {
  height: 100%;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
}

.sidebar {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--deep);
  border-right: 1px solid var(--line);
}
.side-head { padding: 14px 18px 8px; }

.add-friend { display: flex; gap: 8px; padding: 6px 14px 10px; }
.add-friend input {
  flex: 1; min-width: 0;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 14px;
}
.add-friend .icon-btn { width: 38px; height: 38px; }
.add-friend .icon { width: 18px; height: 18px; }

.side-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 12px; }
.side-section + .side-section { margin-top: 14px; }
.side-title {
  margin: 8px 10px 6px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--mist);
}
.side-empty { margin: 4px 10px; color: var(--mist); font-size: 14px; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.person {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius);
  text-align: left;
  min-width: 0;
}
button.person { background: none; border: 0; }
button.person:hover, .person:focus-within { background: var(--dusk); }
.person.offline .person-name { color: var(--mist); }
.person-text { flex: 1; min-width: 0; display: grid; }
.person-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-sub { color: var(--mist); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-actions { display: flex; gap: 4px; }
.person-actions .icon-btn { width: 32px; height: 32px; }
.person-actions .icon { width: 16px; height: 16px; }
.person-actions .accept { background: var(--lamp); color: var(--lamp-ink); border: 0; }

/* A round picture (or initial) with an online / away / offline dot. */
.face {
  position: relative;
  width: 36px; height: 36px;
  flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--face-bg, var(--dusk-hi));
  font-weight: 700; font-size: 15px;
  color: #fff;
  user-select: none;
}
.face img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.face[data-presence]::after {
  content: "";
  position: absolute; right: -2px; bottom: -2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 3px solid var(--deep);
  background: var(--offline);
}
.face[data-presence="online"]::after { background: var(--online); }
.face[data-presence="away"]::after { background: var(--away); }
.face.big { width: 48px; height: 48px; font-size: 20px; }
.face.xl { width: 84px; height: 84px; font-size: 34px; }
.face.xl[data-presence]::after { width: 20px; height: 20px; border-width: 4px; right: 0; bottom: 0; border-color: var(--dusk); }

.me-card {
  display: flex; align-items: center; gap: 4px;
  padding: 8px 8px 10px;
  border-top: 1px solid var(--line);
  background: rgba(32, 41, 58, 0.5);
}
.me-btn {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; border-radius: var(--radius);
  padding: 6px 8px;
  text-align: left;
}
.me-btn:hover { background: var(--dusk); }
.me-btn .face[data-presence]::after { border-color: #171d2b; }
.me-text { min-width: 0; display: grid; }
.me-name { font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-status { color: var(--mist); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.content { position: relative; min-width: 0; min-height: 0; }

.home { height: 100%; overflow-y: auto; display: grid; place-items: center; padding: 24px; }
.home-inner { width: min(460px, 100%); text-align: center; }
.home-inner h2 { margin: 0 0 6px; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.home-inner > p { color: var(--mist); margin: 0 0 20px; }
.home .history { text-align: left; }
.rejoin { display: flex; align-items: center; gap: 12px; text-align: left; margin-bottom: 18px; }
.rejoin span { flex: 1; }

.call-with { display: flex; align-items: center; gap: 9px; font-weight: 700; min-width: 0; }
.call-with span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar-photo { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }

/* ----- A friend is calling ----- */

.ring {
  position: fixed; top: 16px; left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  width: min(420px, calc(100vw - 24px));
  display: flex; align-items: center; gap: 12px;
  padding: 12px 12px 12px 14px;
  background: var(--dusk-hi);
  border: 1px solid rgba(245, 185, 74, 0.5);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(245, 185, 74, 0.08);
  animation: ring-in 0.25s ease-out;
}
.ring-text { flex: 1; min-width: 0; display: grid; }
.ring-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ring-text span { color: var(--mist); font-size: 14px; }
.ring .icon-btn { width: 46px; height: 46px; border: 0; }
.ring .ring-decline { background: var(--danger); color: #fff; }
.ring .ring-join { background: var(--online); color: #08301b; animation: ring-pulse 1.2s ease-in-out infinite; }
@keyframes ring-in { from { opacity: 0; transform: translate(-50%, -12px); } }
@keyframes ring-pulse { 50% { box-shadow: 0 0 0 7px rgba(91, 209, 139, 0.25); } }

/* ----- Profiles ----- */

.settings.mini-profile { width: min(340px, calc(100vw - 32px)); }
.mp-top { display: flex; justify-content: space-between; align-items: flex-start; margin-right: -8px; }
.mp-name { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: -0.015em; overflow-wrap: anywhere; }
.mp-username { margin: 0; color: var(--mist); }
.mp-presence { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.mp-presence::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--offline); }
.mp-presence[data-presence="online"]::before { background: var(--online); }
.mp-presence[data-presence="away"]::before { background: var(--away); }
.mp-status {
  margin: 0;
  padding: 10px 12px;
  background: var(--deep);
  border-radius: var(--radius);
  overflow-wrap: anywhere;
}
.mp-status:empty { display: none; }
.mp-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mp-buttons { display: flex; gap: 8px; }
.primary-btn.ghost-btn { background: var(--dusk-hi); color: var(--text); }

.avatar-row { display: flex; align-items: center; gap: 16px; }
.avatar-actions { display: grid; gap: 6px; }
.avatar-buttons { display: flex; align-items: center; gap: 6px; }
.pw-details summary { cursor: pointer; font-size: 14px; font-weight: 600; color: var(--mist); }
.pw-fields { display: grid; gap: 12px; margin-top: 12px; }
.pw-fields .primary-btn { justify-self: start; }
.signout { justify-self: start; padding-left: 0; }

.settings.admin { width: min(560px, calc(100vw - 32px)); }
.admin-section { display: grid; gap: 8px; }
.admin-section h3 { margin: 0; font-size: 16px; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.admin-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  min-width: 0;
}
.admin-list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-list .muted { color: var(--mist); }
.admin-list code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 15px; letter-spacing: 0.04em; }
.admin-list .icon-btn { width: 32px; height: 32px; flex: none; }
.admin-list .icon { width: 16px; height: 16px; }
.reset-link { display: grid; gap: 6px; padding: 10px 12px; margin: 4px 0 8px; background: var(--deep); border-radius: var(--radius); font-size: 13px; overflow-wrap: anywhere; }

/* ================= Call layout ================= */

.call {
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  min-width: 0;
}

.brand { display: flex; align-items: center; gap: 4px; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark { width: 30px; height: 30px; margin: -6px 0 -6px -8px; flex: none; }
.call-dot {
  width: 11px; height: 11px; border-radius: 50%;
  background: #3c4558;
  transition: background 0.3s, box-shadow 0.3s;
}
.call-dot.on { background: var(--lamp); box-shadow: 0 0 10px 3px var(--lamp-glow); }

.room-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 12px 5px 10px;
  font-size: 14px;
  color: var(--mist);
  min-width: 0;
}
.room-chip .icon { width: 16px; height: 16px; }
.room-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-chip:hover { color: var(--text); }

.status {
  margin-left: auto;
  display: flex; align-items: baseline; gap: 10px;
  font-size: 14px; font-weight: 600;
  white-space: nowrap; min-width: 0;
}
.status-detail { color: var(--mist); font-weight: 400; overflow: hidden; text-overflow: ellipsis; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--dusk);
}
.icon-btn.ghost { background: transparent; border-color: transparent; color: var(--mist); }
.icon-btn.ghost:hover { color: var(--text); background: var(--dusk); }

.main {
  display: flex;
  gap: 12px;
  padding: 0 12px;
  min-height: 0;
}

/* ================= Stage ================= */

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  border-radius: var(--radius-lg);
  background: var(--deep);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  place-items: center;
}

.remote-video {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  background: #000;
}

.waiting { text-align: center; width: 100%; max-width: 460px; padding: 24px; }
.waiting h2 { margin: 0 0 6px; font-size: 24px; font-weight: 600; letter-spacing: -0.015em; }
.waiting p { margin: 0 0 20px; color: var(--mist); }
.invite {
  display: flex; gap: 8px; align-items: center;
  background: var(--dusk);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 6px 14px;
}
.invite code {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 14px; color: var(--mist);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left;
}

.peer-card { display: grid; justify-items: center; gap: 16px; }
.avatar {
  position: relative;
  width: 136px; height: 136px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, var(--dusk-hi), var(--dusk));
  border: 1px solid var(--line);
  font-size: 56px; font-weight: 600;
  transition: box-shadow 0.12s ease-out, border-color 0.12s;
}
.avatar.speaking {
  border-color: var(--lamp);
  box-shadow: 0 0 0 5px var(--lamp), 0 0 70px 18px var(--lamp-glow);
}
.peer-name { display: flex; align-items: center; gap: 8px; font-size: 20px; font-weight: 600; }
.mute-badge {
  position: absolute; right: 2px; bottom: 2px;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--danger);
  color: #fff;
  border: 3px solid var(--deep); /* cuts it out of the avatar's edge */
}
.mute-badge .icon { width: 19px; height: 19px; stroke-width: 2.2; }
.label-muted { display: grid; color: var(--danger); }
.label-muted .icon { width: 16px; height: 16px; stroke-width: 2.2; }

.video-label {
  position: absolute; left: 14px; bottom: 14px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(14, 18, 28, 0.72);
  backdrop-filter: blur(6px);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 14px; font-weight: 600;
  transition: box-shadow 0.12s;
}
.video-label.speaking { box-shadow: 0 0 0 2px var(--lamp); }

.stage-btn { position: absolute; top: 12px; right: 12px; z-index: 4; background: rgba(14, 18, 28, 0.6); color: var(--text); }

.self-view {
  position: absolute; right: 14px; bottom: 14px;
  width: clamp(120px, 22%, 240px);
  aspect-ratio: 16 / 9;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: #000;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.self-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.self-view.mirror video { transform: scaleX(-1); }
.self-view { cursor: pointer; }

/* Your own camera or screen, big: it fills the stage and your friend moves to the corner. */
.stage.self-big .self-view {
  inset: 0;
  width: 100%; height: 100%;
  aspect-ratio: auto;
  border: 0; border-radius: 0; box-shadow: none;
  background: #000;
}
.stage.self-big .self-view video { object-fit: contain; }
.stage.self-big .remote-video {
  inset: auto 14px 14px auto;
  width: clamp(140px, 24%, 260px); height: auto;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 2; cursor: pointer;
}
.stage.self-big .peer-card {
  position: absolute; right: 14px; bottom: 14px; z-index: 2;
  gap: 6px; padding: 10px 16px;
  background: rgba(14, 18, 28, 0.85);
  border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer;
}
.stage.self-big .peer-card .avatar { width: 56px; height: 56px; font-size: 22px; }
.stage.self-big .peer-card .mute-badge { width: 24px; height: 24px; border-width: 2px; right: -2px; bottom: -2px; }
.stage.self-big .peer-card .mute-badge .icon { width: 13px; height: 13px; }
.stage.self-big .peer-name { font-size: 14px; }
.stage.self-big .peer-away, .stage.self-big .video-label { display: none; }
.self-label {
  position: absolute; left: 8px; bottom: 6px;
  font-size: 12px; font-weight: 600;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

/* ================= Conversation ================= */

.dm { position: relative; height: 100%; display: flex; flex-direction: column; min-height: 0; }
.dm-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.dm-back { display: none; }
.dm-who {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 10px;
  background: none; border: 0; border-radius: var(--radius);
  padding: 5px 8px;
  text-align: left;
}
.dm-who:hover { background: var(--dusk); }
.dm-who .face[data-presence]::after { border-color: var(--night); }
.dm-save {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--dusk); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 12px;
  color: var(--mist); font-size: 13px; font-weight: 600; white-space: nowrap;
}
.dm-save::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--offline); }
.dm-save.on::before { background: var(--lamp); box-shadow: 0 0 6px var(--lamp-glow); }
.dm-save:hover { color: var(--text); }
.dm-save.confirm { color: #ffb4ae; border-color: rgba(228, 87, 78, 0.45); }
.dm-head .dm-call { background: var(--lamp); color: var(--lamp-ink); border: 0; flex: none; }
.dm-head .dm-call:disabled { opacity: 0.4; cursor: not-allowed; }

.call-elsewhere {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 6px 12px;
  background: rgba(245, 185, 74, 0.1);
  border-bottom: 1px solid rgba(245, 185, 74, 0.3);
  font-size: 14px;
}
.call-elsewhere .text-btn { color: var(--lamp); padding: 2px 4px; }

/* During a call, the call sits on top and the conversation carries on below it. */
.dm .call { flex: none; height: 58%; min-height: 340px; border-bottom: 1px solid var(--line); }
.dm .main { padding-top: 2px; }
.dm .avatar { width: clamp(72px, 15vh, 136px); height: clamp(72px, 15vh, 136px); font-size: clamp(30px, 6vh, 56px); }
.dm-body { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Messages from the same person a few minutes apart share one name and time, like Discord. */
.chat-log li.cont { margin-top: -8px; }
.chat-log li.cont > .msg-name { display: none; }

/* ----- GIFs ----- */

.gif-btn {
  flex: none;
  align-self: center;
  height: 32px; padding: 0 9px;
  background: var(--dusk); border: 1px solid var(--line); border-radius: 8px;
  color: var(--mist); font-size: 12px; font-weight: 800; letter-spacing: 0.05em;
}
.gif-btn:hover, .gif-btn[aria-expanded="true"] { color: var(--text); border-color: var(--mist); }
.gif-panel {
  position: absolute; right: 12px; bottom: 58px; z-index: 20;
  width: min(440px, calc(100% - 24px)); height: min(460px, 65vh);
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px;
  background: var(--dusk-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}
.gif-search {
  width: 100%;
  background: var(--deep); border: 1px solid var(--line); border-radius: 999px;
  padding: 8px 14px; font-size: 14px;
}
/* The columns live inside the scrolling box; columns in a fixed-height box would spill sideways. */
.gif-grid { flex: 1; min-height: 0; overflow-y: auto; }
.gif-cols { columns: 2; column-gap: 6px; }
.gif-item {
  display: block; width: 100%;
  margin: 0 0 6px; padding: 0;
  background: var(--deep); border: 0; border-radius: 8px;
  overflow: hidden; break-inside: avoid;
}
.gif-item img { display: block; width: 100%; height: auto; }
.gif-item:hover, .gif-item:focus-visible { outline: 2px solid var(--lamp); outline-offset: -2px; }
.gif-status { margin: 0; color: var(--mist); font-size: 13px; text-align: center; }
.gif-status:empty { display: none; }
.gif-credit { margin: 0; color: var(--mist); font-size: 11px; font-weight: 700; letter-spacing: 0.03em; text-align: right; }
.gif-msg { margin-top: 4px; width: min(300px, 100%); }
.gif-msg video, .gif-msg img { display: block; width: 100%; height: auto; border-radius: 8px; background: var(--deep); }
.dm-notice { margin: 0; padding: 6px 18px; color: var(--mist); font-size: 12.5px; }
.chat-log .load-more { align-self: center; }
.chat-log .day {
  display: flex; align-items: center; gap: 10px;
  color: var(--mist); font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.chat-log .day::before, .chat-log .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.chat-log .pending { opacity: 0.55; }
.chat-log .failed .msg-text { color: #ffb4ae; }
.send-failed { display: block; font-size: 12.5px; color: #ffb4ae; }
.send-failed button { background: none; border: 0; padding: 0; color: var(--lamp); font-size: inherit; font-weight: 600; }
.chat-log .call-note { display: flex; align-items: center; gap: 8px; }
.chat-log .call-note .icon { width: 16px; height: 16px; color: var(--mist); }
.chat-log .call-note.missed .icon { color: var(--danger); }
.dm-empty { margin: auto; text-align: center; color: var(--mist); max-width: 32ch; }

.chat-log {
  list-style: none; margin: 0; padding: 8px 18px;
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.chat-log li { overflow-wrap: anywhere; }
.msg-name { display: block; font-size: 13px; font-weight: 600; color: var(--mist); }
.msg-name time { font-weight: 400; margin-left: 6px; }
.msg-text { white-space: pre-wrap; }
.msg-text a { color: var(--lamp); }
.chat-log .sys { color: var(--mist); font-size: 14px; }
.chat-log .new-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--lamp);
  font-size: 12px; font-weight: 700;
  white-space: nowrap;
}
.new-divider::before, .new-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--lamp);
  box-shadow: 0 0 6px var(--lamp-glow);
}
.chat-empty { color: var(--mist); font-size: 14px; }

.chat-form { display: flex; gap: 8px; padding: 10px 12px 4px; }
.chat-form input {
  flex: 1; min-width: 0;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 16px;
}
.chat-form input:disabled { opacity: 0.55; }
.send-btn { background: var(--lamp); color: var(--lamp-ink); border: 0; }
.send-btn .icon { width: 18px; height: 18px; }

/* ================= Rain ================= */

/* Light rain over everything (Settings can turn it off). It never catches clicks, and
   "screen" only ever lightens, so the text underneath stays as readable as it was. */
.rain {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 30;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 0.8s ease;
}
.rain.on { opacity: 1; }
.toggle-note { color: var(--mist); font-size: 13px; }

/* ================= Files ================= */

/* Files waiting to be sent: a row of previews above the message box. */
.attach-tray {
  display: flex; gap: 10px;
  margin: 8px 12px 0;
  padding: 10px;
  overflow-x: auto;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tray-tile { flex: none; width: 116px; display: grid; gap: 2px; min-width: 0; }
.tray-thumb {
  position: relative;
  height: 88px; margin-bottom: 4px;
  display: grid; place-items: center;
  overflow: hidden;
  background: var(--dusk);
  border-radius: 8px;
}
.tray-thumb img, .tray-thumb video { display: block; width: 100%; height: 100%; object-fit: cover; }
.tray-thumb img { cursor: zoom-in; }
.tray-glyph { display: grid; justify-items: center; gap: 2px; color: var(--lamp); }
.tray-glyph .icon { width: 30px; height: 30px; }
.tray-glyph span { color: var(--mist); font-size: 11px; font-weight: 700; letter-spacing: 0.05em; }
.tray-name { font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray-size { color: var(--mist); font-size: 11px; font-variant-numeric: tabular-nums; }
.tray-remove {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; padding: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 999px;
  background: rgba(14, 18, 28, 0.85);
  color: var(--text);
}
.tray-remove:hover, .tray-remove:focus-visible { background: var(--danger); color: #fff; }
.tray-remove .icon { width: 14px; height: 14px; }

.attach-btn { flex: none; }
.attach-btn:disabled { opacity: 0.45; cursor: not-allowed; background: transparent; }

.file-card {
  max-width: 460px;
  display: grid; gap: 8px;
  margin-top: 4px;
  padding: 8px 8px 8px 12px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.file-preview {
  display: block;
  max-width: 100%; max-height: 220px;
  border-radius: 8px;
  justify-self: start;
}
img.file-preview { cursor: zoom-in; }
.file-video { display: block; width: 100%; max-height: 260px; border-radius: 8px; background: #000; }
.file-audio { display: block; width: 100%; height: 40px; }
.file-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.file-icon { color: var(--lamp); }
.file-info { flex: 1; min-width: 0; display: grid; }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--mist); font-size: 13px; font-variant-numeric: tabular-nums; }
.file-row .icon-btn { width: 36px; height: 36px; flex: none; }
.file-row .icon-btn .icon { width: 18px; height: 18px; }
.file-save { background: var(--lamp); color: var(--lamp-ink); border: 0; }
.file-save:hover { filter: brightness(1.06); }
.file-bar { height: 4px; border-radius: 999px; background: var(--line); overflow: hidden; }
.file-bar span { display: block; height: 100%; width: 0; background: var(--lamp); transition: width 0.2s linear; }
.file-msg.ended .file-card { opacity: 0.6; }

/* Deleting your own messages and files: appears on hover, asks once to be sure. */
.chat-log li { position: relative; }
.msg-delete {
  position: absolute; top: -4px; right: -8px;
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; min-width: 28px; padding: 0 6px;
  justify-content: center;
  border: 0; border-radius: 999px;
  background: var(--dusk-hi);
  color: var(--mist);
  font-size: 12px; font-weight: 700;
  opacity: 0;
  transition: opacity 0.12s;
}
.msg-delete .icon { width: 15px; height: 15px; }
.chat-log li:hover .msg-delete, .msg-delete:focus-visible, .msg-delete.confirm { opacity: 1; }
.msg-delete:hover, .msg-delete.confirm { color: #ffb4ae; background: var(--danger-soft); }
@media (hover: none) { .msg-delete { opacity: 0.7; } }
.chat-log .removed { color: var(--mist); font-size: 14px; font-style: italic; }

/* ================= Picture, full size ================= */

.lightbox {
  width: 100vw; height: 100vh;
  max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: rgba(5, 8, 13, 0.94);
  color: var(--text);
}
.lightbox[open] { display: grid; grid-template-rows: minmax(0, 1fr) auto; place-items: center; }
.lightbox::backdrop { background: transparent; }
.lightbox img {
  max-width: calc(100vw - 32px); max-height: 100%;
  object-fit: contain;
  padding-top: 16px;
}
.lightbox-bar {
  display: flex; align-items: center; gap: 10px;
  width: min(640px, 100%);
  padding: 12px 16px calc(14px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
}
.lightbox-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.drop-overlay {
  position: fixed; inset: 0;
  z-index: 50;
  display: grid; place-items: center;
  padding: 24px;
  background: rgba(8, 11, 18, 0.7);
  pointer-events: none;
}
.drop-overlay p {
  margin: 0;
  padding: 28px 36px;
  border: 2px dashed var(--lamp);
  border-radius: var(--radius-lg);
  background: var(--dusk);
  font-size: 18px; font-weight: 600;
  text-align: center;
}

/* ================= Controls ================= */

.controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 12px 12px 14px;
}

.ctl {
  background: none; border: 0; padding: 0;
  width: 76px;
  display: grid; justify-items: center; gap: 6px;
}
.ctl-icon {
  position: relative;
  width: 54px; height: 54px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--dusk);
  border: 1px solid var(--line);
  transition: background 0.15s, box-shadow 0.12s, color 0.15s;
}
.ctl:hover .ctl-icon { background: var(--dusk-hi); }
.ctl:focus-visible { outline: none; }
.ctl:focus-visible .ctl-icon { outline: 2px solid var(--lamp); outline-offset: 2px; }
.ctl-label { font-size: 12px; color: var(--mist); white-space: nowrap; }

.ctl.lit .ctl-icon { background: var(--text); color: var(--night); border-color: var(--text); }
.ctl.off .ctl-icon { background: var(--danger-soft); color: var(--danger); border-color: rgba(228, 87, 78, 0.45); }
.ctl.speaking .ctl-icon { box-shadow: 0 0 0 3px var(--lamp); }
.ctl.leave .ctl-icon { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl.leave:hover .ctl-icon { filter: brightness(1.08); }
.ctl:disabled { opacity: 0.45; cursor: not-allowed; }

/* How many messages you haven't read, on a friend in the list. */
.badge {
  flex: none;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px;
  background: var(--lamp); color: var(--lamp-ink);
  font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}
button.person.open { background: var(--dusk-hi); }

/* Each friend in the list: the row opens your conversation; the "..." (or a right-click) opens a menu. */
.person-row { position: relative; -webkit-touch-callout: none; user-select: none; }
.person-more {
  position: absolute; right: 6px; top: 50%;
  transform: translateY(-50%);
  width: 30px; height: 30px;
  opacity: 0;
}
.person-more .icon { width: 18px; height: 18px; }
.person-row:hover .person-more, .person-more:focus-visible, .person-more.open { opacity: 1; }
.person-row:hover .badge, .person-row:focus-within .badge { visibility: hidden; }
@media (hover: none) { .person-more { opacity: 0.6; } .person-row .badge { margin-right: 30px; } }

.menu {
  position: fixed; z-index: 70;
  min-width: 190px;
  display: grid; gap: 2px;
  padding: 6px;
  background: var(--dusk-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}
.menu button {
  background: none; border: 0; border-radius: 8px;
  padding: 8px 10px;
  text-align: left; font-size: 14px; font-weight: 600;
}
.menu button:hover, .menu button:focus-visible { background: var(--dusk); outline: none; }
.menu button:disabled { opacity: 0.45; cursor: not-allowed; background: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 2px; }
.menu .danger { color: #ffb4ae; }

.toast {
  position: fixed;
  left: 50%; bottom: calc(110px + var(--safe-area-inset-bottom, env(safe-area-inset-bottom, 0px)));
  transform: translateX(-50%);
  max-width: min(520px, calc(100vw - 32px));
  background: var(--dusk-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  z-index: 40;
}

/* ================= Settings ================= */

.settings {
  width: min(420px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--dusk);
  color: var(--text);
}
.settings::backdrop { background: rgba(8, 11, 18, 0.6); }
.settings-inner { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; padding: 16px 20px 22px; }
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-right: -8px; }
.settings-head h2 { margin: 0; font-size: 20px; font-weight: 600; }
.settings .field select { background: var(--deep); }
.settings input[type="range"] { width: 100%; accent-color: var(--lamp); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; cursor: pointer; }
.toggle input { width: 18px; height: 18px; margin: 0; accent-color: var(--lamp); cursor: pointer; }
.toggle-group { display: grid; gap: 10px; margin-top: -6px; }
.ptt-field { display: grid; gap: 10px; }
.ptt-details { display: grid; gap: 6px; padding-left: 28px; }
.ptt-key-row { display: flex; align-items: center; gap: 12px; font-size: 14px; }
.key-btn {
  min-width: 44px;
  padding: 5px 12px;
  background: var(--deep);
  border: 1px solid var(--line);
  border-bottom-width: 3px;
  border-radius: 8px;
  font-size: 14px; font-weight: 600;
}
.key-btn:hover { border-color: var(--mist); }
.key-btn.listening { border-color: var(--lamp); color: var(--lamp); }

/* Push to talk: the mic button is held, not clicked. */
.ctl.ptt { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.conn-info { margin: 0; color: var(--mist); font-size: 13px; }
.conn-info a { color: var(--lamp); font-weight: 600; }

/* ================= Call timer, away & offline ================= */

.call-timer {
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--lamp);
  white-space: nowrap;
}

.peer-card.away .avatar { opacity: 0.4; filter: grayscale(1); border-style: dashed; }
.peer-card.away .peer-name { color: var(--mist); }
.peer-away { text-align: center; max-width: 34ch; }
.peer-away p { margin: 0; color: var(--mist); font-size: 14px; }
.peer-away .peer-away-title { color: var(--text); font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.peer-away-title span { font-variant-numeric: tabular-nums; color: var(--mist); font-weight: 400; }

.offline-banner {
  position: absolute; top: 14px; left: 50%;
  transform: translateX(-50%);
  width: max-content; max-width: calc(100% - 28px);
  display: grid; gap: 2px; text-align: center;
  background: var(--dusk-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 14px;
  z-index: 5;
}
.offline-banner span { color: var(--mist); }

/* ================= Rejoin note, history, summary ================= */

.rejoin-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(245, 185, 74, 0.35);
  background: rgba(245, 185, 74, 0.08);
  font-size: 14px;
}

.history { margin-top: 40px; }
.history-head { display: flex; align-items: baseline; justify-content: space-between; }
.history-head h2 { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
.history-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.history-list > li { border-bottom: 1px solid var(--line); }
.history-list summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: baseline;
  padding: 10px 2px;
  cursor: pointer;
  list-style: none;
  font-size: 15px;
}
.history-list summary::-webkit-details-marker { display: none; }
.h-with { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.h-when { color: var(--mist); font-size: 13px; }
.h-len { font-variant-numeric: tabular-nums; }
.h-note { margin: 0 0 6px; color: var(--mist); font-size: 13px; }
.history-list details[open] { padding-bottom: 10px; }

.log-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.log-list time, .chat-log .sys time {
  display: inline-block; min-width: 5.2em;
  color: var(--mist); font-style: normal; font-variant-numeric: tabular-nums;
}

.summary-length { display: grid; gap: 2px; }
.summary-duration {
  font-size: 56px; font-weight: 700; line-height: 1;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  font-variation-settings: "opsz" 96;
  color: var(--lamp);
}
.summary-duration-label { color: var(--mist); font-size: 14px; }
.summary-detail { margin: 0; }
.summary-log summary { cursor: pointer; font-weight: 600; font-size: 14px; margin-bottom: 8px; }
.summary .settings-inner > h2 { margin: 4px 0 0; font-size: 20px; font-weight: 600; }

/* ================= Small screens ================= */

@media (max-width: 760px) {
  /* Phones: the friends list is the whole screen, and a call takes over while it's on. */
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar { border-right: 0; }
  .app .content { display: none; }
  .app.in-dm .sidebar { display: none; }
  .app.in-dm .content { display: block; }
  .dm-back { display: inline-grid; }
  .dm-close { display: none; }
  .dm-head { padding: 6px 8px; gap: 4px; }
  .dm .call { height: 52%; min-height: 300px; }
  .topbar { gap: 10px; padding: 8px 10px; }
  .status-detail { display: none; }
  .main { padding: 0 8px; }
  .controls { gap: 2px; padding: 10px 4px 12px; }
  .ctl { width: 64px; }
  .ctl-icon { width: 50px; height: 50px; }
  .ctl-label { font-size: 11px; }
  .avatar { width: 112px; height: 112px; font-size: 46px; }
  .self-view { width: 30%; aspect-ratio: 3 / 4; }
}

@media (prefers-reduced-motion: reduce) {
  .drop-hero img { animation: none; }
  * { transition-duration: 0s !important; }
}
