/* Visual layer on top of style.css: themes, the brand fonts, floating panels,
   the frosted header, depth, and motion. Theme and accent come from
   appearance.js (data-theme on <html>, --accent inline). */

/* ---------- fonts: Geist (interface), Geist Mono (labels and numbers), Unbounded (display) ---------- */

@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/geist-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/geist-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/geist-mono-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Geist Mono';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/geist-mono-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/unbounded-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('fonts/unbounded-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ---------- themes ---------- */

:root,
:root[data-theme='night'] {
  --app-bg: #08080c;
  --bg-0: #0c0c12;
  --bg-1: #111118;
  --bg-2: #15151d;
  --bg-3: #2b2b38;
  --text: #f2f1f7;
  --muted: #9a98ab;
  --glow-a: rgba(200, 255, 61, 0.06);
  --glow-b: rgba(184, 164, 255, 0.08);
}
:root[data-theme='midnight'] {
  --app-bg: #0a0b0e;
  --bg-0: #0f1014;
  --bg-1: #16171c;
  --bg-2: #1c1d23;
  --bg-3: #2a2c34;
  --text: #e9eaef;
  --muted: #9095a3;
  --glow-a: rgba(108, 123, 255, 0.16);
  --glow-b: rgba(162, 89, 255, 0.1);
}
:root[data-theme='ash'] {
  --app-bg: #111214;
  --bg-0: #18191c;
  --bg-1: #232428;
  --bg-2: #2c2d32;
  --bg-3: #383a40;
  --text: #e3e5e8;
  --muted: #9a9ea6;
  --glow-a: rgba(255, 255, 255, 0.04);
  --glow-b: rgba(255, 255, 255, 0.02);
}
:root[data-theme='ocean'] {
  --app-bg: #060c17;
  --bg-0: #0a1322;
  --bg-1: #0f1a2c;
  --bg-2: #132036;
  --bg-3: #1d2e4a;
  --text: #e6eefb;
  --muted: #8ea3c2;
  --glow-a: rgba(6, 182, 212, 0.14);
  --glow-b: rgba(59, 130, 246, 0.12);
}
:root[data-theme='plum'] {
  --app-bg: #0c0910;
  --bg-0: #120e18;
  --bg-1: #1a1422;
  --bg-2: #211a2b;
  --bg-3: #31283f;
  --text: #f0e9f7;
  --muted: #a397b3;
  --glow-a: rgba(236, 72, 153, 0.13);
  --glow-b: rgba(162, 89, 255, 0.13);
}
:root {
  --accent: #c8ff3d;
  --on-accent: #0c0c12;
  --on-red: #fff;
  --mention: var(--accent);
  --font-ui: 'Geist', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Unbounded', 'Geist', system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, 'Cascadia Code', Consolas, monospace;
  --hover: color-mix(in srgb, var(--text) 5%, transparent);
  --active: color-mix(in srgb, var(--text) 9%, transparent);
  --panel-border: color-mix(in srgb, var(--text) 6%, transparent);
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --accent-soft: color-mix(in srgb, var(--accent) 18%, transparent);
  --spring: cubic-bezier(0.2, 0.9, 0.3, 1.15);
  --radius-panel: 14px;
}

/* ---------- base ---------- */

:root[data-theme='night'] {
  --green: #c8ff3d;
  --red: #ff5c47;
  --on-red: #0c0c12;
  --mention: #b8a4ff;
}

body {
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  /* A faint grain and two soft glows behind the panels. */
  background:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>"),
    radial-gradient(ellipse 60% 50% at 0% 0%, var(--glow-a), transparent 70%),
    radial-gradient(ellipse 50% 45% at 100% 100%, var(--glow-b), transparent 70%),
    var(--app-bg);
  background-attachment: fixed;
}

/* Display type: names and headlines. Never below 20 px (brand rule). */
.server-header,
.channel-intro h1,
.auth-form h1,
.error-card h1,
.error-code,
.dialog h2,
.settings-inner > h2,
.empty-state h3 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.035em;
}
.server-header {
  text-transform: lowercase;
}

/* Labels and anything that counts: Geist Mono. */
.msg-time,
.msg-time-hover,
.tile-label,
.mention-badge,
.reaction-count,
.unread-pill,
.badge-live,
.voice-quality-tooltip,
.typing-indicator,
.category,
.settings-group,
.settings-subtitle,
.mention-popup-title,
.md-code,
.md-pre {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.category,
.settings-group,
.settings-subtitle,
.mention-popup-title {
  font-weight: 500;
  letter-spacing: 0.12em;
}

/* Links follow the mention colour (Lilac on Night). */
.link-btn,
.msg-text a,
.embed-title {
  color: color-mix(in srgb, var(--mention) 85%, #fff);
}
.auth-form h1 {
  text-transform: lowercase;
}

/* Brand: mentions and their badges are Lilac on Night. */
.mention-badge {
  background: var(--mention);
  color: #0c0c12;
}
.mention {
  background: color-mix(in srgb, var(--mention) 22%, transparent);
  color: color-mix(in srgb, var(--mention) 60%, #fff);
}
.mention:hover {
  background: var(--mention);
  color: #0c0c12;
}

* {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--text) 16%, transparent) transparent;
}
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 16%, transparent) padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: color-mix(in srgb, var(--text) 28%, transparent);
}
::-webkit-scrollbar-track {
  background: transparent;
}

::selection {
  background: color-mix(in srgb, var(--accent) 40%, transparent);
}

/* ---------- floating panels ---------- */

.main {
  background: var(--bg-2);
}
.sidebar,
.members {
  background: linear-gradient(180deg, color-mix(in srgb, var(--bg-1) 100%, #fff 1.5%), var(--bg-1) 40%);
}
.user-panel {
  background: color-mix(in srgb, var(--bg-0) 80%, transparent);
  border-top: 1px solid var(--panel-border);
}
.voice-status {
  background: color-mix(in srgb, var(--green) 5%, var(--bg-1));
  border-top: 1px solid var(--panel-border);
}
.server-header {
  font-weight: 800;
  font-size: 17px;
  border-bottom: 1px solid var(--panel-border);
}
.category {
  font-size: 11px;
  letter-spacing: 0.07em;
}

@media (min-width: 761px) {
  #app {
    gap: 8px;
    padding: 8px;
  }
  #channels-sidebar,
  .main,
  #members {
    border-radius: var(--radius-panel);
    overflow: hidden;
    border: 1px solid var(--panel-border);
    box-shadow: var(--panel-shadow);
  }
}
@media (min-width: 761px) and (max-width: 1000px) {
  /* The member list is a drawer here. */
  body #members {
    inset: 8px 8px 8px auto;
  }
}

/* ---------- frosted header over the content ---------- */

.main-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 7;
  background: color-mix(in srgb, var(--bg-2) 72%, transparent);
  -webkit-backdrop-filter: blur(16px) saturate(1.5);
  backdrop-filter: blur(16px) saturate(1.5);
  border-bottom: 1px solid var(--panel-border);
}
.banners {
  position: absolute;
  inset: 52px 0 auto 0;
  z-index: 6;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}
.messages {
  padding-top: 64px;
  scroll-padding-top: 64px;
}
.voice-view {
  position: relative;
  padding-top: 52px;
}

/* ---------- channel list ---------- */

.channel-scroll {
  position: relative;
}
.channel-scroll .channel {
  z-index: 1;
  transition: background-color 120ms, color 120ms;
}
.channel-scroll .channel.active {
  background: transparent;
}
/* One highlight that slides to whichever channel is open. */
.channel-indicator {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  border-radius: 6px;
  background: var(--active);
  box-shadow: inset 3px 0 0 var(--accent);
  opacity: 0;
  pointer-events: none;
}
.channel-indicator.shown {
  opacity: 1;
}
.channel-indicator.ready {
  transition: transform 280ms var(--spring), width 280ms var(--spring), height 280ms var(--spring), opacity 150ms;
}
.channel.unread::before {
  transition: height 150ms var(--spring);
}
.channel.unread:hover::before {
  height: 16px;
}

/* Streaming: a ring turns around the avatar. */
.live-ring {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  padding: 3px;
  margin: -3px;
  border-radius: 50%;
}
.live-ring::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(#ff3b5c, #ff9f43, #ff3b5c 45%, #a855f7 70%, #ff3b5c);
  animation: spin 2.4s linear infinite;
}
.live-ring .avatar {
  position: relative;
  box-shadow: 0 0 0 1.5px var(--bg-1);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

.message {
  transition: background-color 120ms;
}
.message:hover {
  background: color-mix(in srgb, var(--text) 3%, transparent);
}
.message.enter {
  animation: message-in 260ms var(--spring) both;
}
@keyframes message-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.msg-actions {
  background: color-mix(in srgb, var(--bg-1) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
}
.message:hover .msg-actions {
  animation: actions-in 140ms var(--motion-ease, ease-out);
}
@keyframes actions-in {
  from { opacity: 0; transform: translateY(3px) scale(0.98); }
}

.reaction {
  transition: background-color 120ms, border-color 120ms, transform 160ms var(--spring);
}
.reaction:hover {
  transform: translateY(-1px);
}
.reaction-count {
  display: inline-block;
}
.reaction.bump {
  animation: reaction-pop 420ms cubic-bezier(0.3, 1.8, 0.5, 1);
}
.reaction.bump .reaction-count {
  animation: count-tick 280ms ease-out;
}
@keyframes reaction-pop {
  0% { transform: scale(0.75); }
  55% { transform: scale(1.14); }
  100% { transform: scale(1); }
}
@keyframes count-tick {
  from { opacity: 0; transform: translateY(70%); }
}

.composer-box {
  background: color-mix(in srgb, var(--bg-3) 85%, var(--bg-2));
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}
.composer-box:focus-within {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent), 0 6px 20px rgba(0, 0, 0, 0.18);
}

.channel-intro h1 {
  background: linear-gradient(90deg, var(--text), color-mix(in srgb, var(--accent) 60%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.jump-bar {
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #a259ff));
  animation: bar-in 260ms var(--spring);
}
@keyframes bar-in {
  from { opacity: 0; transform: translateY(8px); }
}

.embed {
  background: color-mix(in srgb, var(--bg-1) 80%, transparent);
  border-radius: 8px;
  transition: transform 160ms var(--spring);
}
.embed-video img {
  transition: transform 300ms var(--motion-ease, ease-out);
}
.embed-video:hover img {
  transform: scale(1.03);
}

/* ---------- buttons ---------- */

.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 82%, #fff), var(--accent));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 32%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: filter 120ms, transform 160ms var(--spring), box-shadow 160ms;
}
.primary:hover:not(:disabled) {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.icon-pop svg {
  animation: icon-pop 320ms cubic-bezier(0.3, 1.7, 0.5, 1);
}
@keyframes icon-pop {
  0% { transform: scale(0.55) rotate(-14deg); }
  100% { transform: none; }
}

.ctrl-btn {
  background: color-mix(in srgb, var(--bg-3) 92%, var(--text));
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: transform 180ms var(--spring), background-color 150ms, box-shadow 150ms;
}
.ctrl-btn:hover:not(:disabled) {
  filter: none;
  transform: translateY(-2px);
  background: color-mix(in srgb, var(--bg-3) 80%, var(--text));
}
.ctrl-btn.on {
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, #fff 25%, transparent), 0 6px 16px rgba(0, 0, 0, 0.35);
}
.ctrl-btn.off {
  background: color-mix(in srgb, var(--red) 20%, var(--bg-2));
}
.ctrl-btn.danger {
  background: linear-gradient(180deg, color-mix(in srgb, var(--red) 88%, #fff), var(--red));
  box-shadow: 0 6px 18px color-mix(in srgb, var(--red) 35%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.ctrl-btn.danger:hover:not(:disabled) {
  background: linear-gradient(180deg, color-mix(in srgb, var(--red) 75%, #fff), var(--red));
}
.ctrl-btn svg {
  transition: transform 220ms var(--spring);
}
.ctrl-btn.danger:hover svg {
  transform: rotate(-18deg);
}

.voice-controls {
  padding-top: 14px;
}

/* ---------- call tiles ---------- */

.tile {
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.35);
  background: var(--bg-1);
}
.tile-backdrop {
  position: absolute;
  inset: -25%;
  filter: blur(42px) saturate(1.6) brightness(0.55);
  opacity: 0.85;
  pointer-events: none;
}
.tile.has-video .tile-backdrop {
  display: none;
}
.tile-avatar {
  position: relative;
}
.tile-avatar .avatar {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}
.tile.speaking .tile-avatar .avatar {
  box-shadow: 0 0 0 3px var(--bg-1), 0 0 0 6px var(--green);
}
.tile-label {
  background: rgba(0, 0, 0, 0.45);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 8px;
}
.tile-toolbar {
  transition: opacity 150ms;
}

/* ---------- menus, dialogs, toasts ---------- */

.menu,
.emoji-picker,
.mention-popup,
.stream-preview {
  background: color-mix(in srgb, var(--bg-0) 88%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}
.dialog {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}
.dialog[open] {
  animation: dialog-in 260ms var(--spring);
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
}

.toast {
  background: color-mix(in srgb, var(--bg-3) 86%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  animation: toast-in 380ms cubic-bezier(0.2, 1.3, 0.4, 1) both;
}
.toast.leaving {
  animation: toast-out 220ms ease-in forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

/* ---------- switching chats ---------- */

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}
#chat-view,
#voice-view {
  view-transition-name: main-view;
}
#main-title {
  view-transition-name: main-title;
}
::view-transition-old(main-view),
::view-transition-old(main-title) {
  animation: vt-out 110ms ease-in both;
}
::view-transition-new(main-view),
::view-transition-new(main-title) {
  animation: vt-in 240ms var(--motion-ease, ease-out) both;
}
@keyframes vt-out {
  to { opacity: 0; }
}
@keyframes vt-in {
  from { opacity: 0; transform: translateY(6px); }
}

/* ---------- sign-in screen ---------- */

.auth {
  background:
    radial-gradient(circle at 20% 25%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 42%),
    radial-gradient(circle at 80% 20%, color-mix(in srgb, var(--mention) 22%, transparent), transparent 45%),
    radial-gradient(circle at 60% 85%, rgba(255, 92, 71, 0.12), transparent 50%),
    var(--app-bg);
  background-size: 170% 170%;
  animation: auth-drift 22s ease-in-out infinite alternate;
}
@keyframes auth-drift {
  from { background-position: 0% 0%; }
  to { background-position: 100% 100%; }
}
.auth-card {
  background: color-mix(in srgb, var(--bg-2) 70%, transparent);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid color-mix(in srgb, var(--text) 10%, transparent);
  border-radius: 20px;
}
.auth-logo {
  display: block;
  width: 52px;
  height: 52px;
  margin-bottom: 14px;
  border-radius: 14px;
  filter: drop-shadow(0 8px 20px color-mix(in srgb, var(--accent) 45%, transparent));
}

/* ---------- 404 and error pages ---------- */

.error-card {
  text-align: center;
}
.error-card .auth-logo {
  margin: 0 auto 6px;
}
.error-code {
  margin: 0;
  font-size: clamp(72px, 18vw, 112px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
  background: linear-gradient(135deg, var(--text) 10%, var(--accent) 60%, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: error-float 5s ease-in-out infinite;
}
@keyframes error-float {
  50% { transform: translateY(-6px); }
}
.error-card h1 {
  margin: 8px 0 6px;
  font-size: 22px;
}
.error-card p.muted {
  margin: 0 0 22px;
  line-height: 1.5;
}
a.error-home {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* ---------- brand: logo in the sidebar, mascots in empty states ---------- */

.server-header {
  gap: 10px;
}
.server-mark {
  display: grid;
  flex: none;
}
.server-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Six and Seven doing the bit: one up while the other is down. */
.intro-mascots {
  display: flex;
  align-items: flex-end;
  margin-bottom: 10px;
}
.intro-mascots svg + svg {
  margin-left: -16px;
}
.intro-mascots svg,
.empty-art svg {
  animation: the-bit 1.1s ease-in-out infinite alternate;
}
.intro-mascots svg + svg {
  animation-delay: -1.1s;
}
@keyframes the-bit {
  from { transform: translateY(3px); }
  to { transform: translateY(-5px); }
}
.channel-intro h1 {
  font-size: 30px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.empty-state p {
  margin: 0;
}
.empty-art {
  display: grid;
  place-items: center;
}

.stage-alone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 16px 4px;
  color: var(--muted);
  font-size: 15px;
}
.stage-alone p {
  margin: 0;
  max-width: 420px;
}
.stage-alone strong {
  color: var(--text);
}

.error-art {
  display: flex;
  justify-content: center;
  margin-bottom: 4px;
}

/* ---------- Settings → Appearance ---------- */

.settings-subtitle {
  margin: 28px 0 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.theme-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
  border-radius: 12px;
  border: 2px solid transparent;
  background: var(--bg-1);
  text-align: left;
  transition: border-color 150ms, transform 160ms var(--spring);
}
.theme-card:hover {
  transform: translateY(-2px);
}
.theme-card.selected {
  border-color: var(--accent);
}
.theme-preview {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 4px;
  height: 64px;
  padding: 6px;
  border-radius: 8px;
}
.theme-preview i {
  border-radius: 5px;
  position: relative;
}
.theme-preview b {
  position: absolute;
  left: 6px;
  right: 30%;
  bottom: 6px;
  height: 8px;
  border-radius: 4px;
}
.theme-name {
  font-weight: 600;
  font-size: 14px;
  padding: 0 2px 2px;
}
.accent-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.accent-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  transition: transform 160ms var(--spring), box-shadow 150ms;
}
.accent-swatch:hover {
  transform: scale(1.08);
}
.accent-swatch.selected {
  box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 5px var(--swatch);
}

/* ---------- phones ---------- */

@media (max-width: 760px) {
  #channels-sidebar {
    border-radius: 0 var(--radius-panel) var(--radius-panel) 0;
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
  }
  body #members {
    border-radius: var(--radius-panel) 0 0 var(--radius-panel);
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- less motion ---------- */

:root[data-motion='reduced'] *,
:root[data-motion='reduced'] *::before,
:root[data-motion='reduced'] *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}
:root[data-motion='reduced'] :where(button, [role='button'], a.icon-btn):active {
  scale: none !important;
}

/* ---------- fitting phones ---------- */

/* Call tiles: layoutStage picks the shape (taller tiles on an upright phone). */
.stage:not(.has-focus) > .tile {
  aspect-ratio: var(--tile-ar, 16 / 9);
}
/* Camera, switch camera and screen buttons share the row evenly. */
.voice-status-actions {
  grid-template-columns: none;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
}
/* A long channel name shrinks instead of pushing the header buttons off screen. */
#main-title {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-tools,
.members-toggle {
  flex: none;
}

@media (max-width: 760px) {
  /* Landscape iPhones: keep content out of the notch and the home bar. */
  #app {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .main-header {
    gap: 4px;
    padding: 0 8px;
  }
  .header-tools {
    gap: 2px;
  }
  /* Search collapses to its icon until tapped (or while it holds a search). */
  .search-box input {
    height: 36px;
  }
  .search-box input:not(:focus):placeholder-shown {
    width: 40px;
    padding: 0;
    background: transparent;
    cursor: pointer;
  }
  .search-box input:not(:focus):placeholder-shown::placeholder {
    color: transparent;
  }
  .search-box input:not(:focus):placeholder-shown + .search-icon {
    right: 12px;
    pointer-events: none;
  }
  .search-box input:focus,
  .search-box input:not(:placeholder-shown) {
    width: min(180px, 46vw);
    padding: 0 30px 0 10px;
  }
  .composer {
    padding-left: 10px;
    padding-right: 10px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
  .stage {
    padding: 10px;
    gap: 8px;
  }
  .voice-controls {
    gap: 10px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .user-panel {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }
  #members {
    padding-bottom: env(safe-area-inset-bottom);
  }
  /* Settings: tabs stay clear of the close button; the picture button gets its own row. */
  .settings-nav-inner {
    padding-right: 60px;
  }
  .profile-card {
    flex-wrap: wrap;
  }
  .avatar-actions {
    flex-basis: 100%;
    flex-direction: row;
    align-items: center;
  }
}

/* Touch screens: 16px text in fields stops iPhones from zooming in on tap. */
@media (pointer: coarse) {
  /* The press animation is the tap feedback, not the browser's grey flash,
     and it's a little stronger so it shows under a finger. */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  :where(button, [role='button'], a.icon-btn):not(.channels-backdrop):not(.attachment.image):not(:disabled):active {
    scale: 0.94;
  }
  input:not([type='checkbox']):not([type='radio']):not([type='range']):not([type='color']),
  textarea,
  select {
    font-size: 16px;
  }
}

/* ---------- phone drawers: channel list (burger menu) and member list ---------- */

@keyframes drawer-item-in {
  from { opacity: 0; transform: translateX(-14px); }
}
@keyframes drawer-item-in-right {
  from { opacity: 0; transform: translateX(14px); }
}

@media (max-width: 1000px) {
  /* The dimmed background fades out as well as in, with a light blur. */
  #members-backdrop,
  #members-backdrop[hidden] {
    display: block !important;
    position: fixed;
    inset: 0;
    z-index: 15;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: none;
    transition: opacity 240ms ease-out, visibility 0s;
  }
  #members-backdrop[hidden] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease-in, visibility 0s 200ms;
  }
  body #members {
    transition: transform 220ms cubic-bezier(0.4, 0, 0.7, 0.2), visibility 0s 220ms;
  }
  .members-open #members {
    transition: transform 340ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.5);
  }
  .members-open #members li {
    animation: drawer-item-in-right 320ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  }
  .members-open #members li:nth-child(1) { animation-delay: 50ms; }
  .members-open #members li:nth-child(2) { animation-delay: 80ms; }
  .members-open #members li:nth-child(3) { animation-delay: 110ms; }
  .members-open #members li:nth-child(4) { animation-delay: 140ms; }
  .members-open #members li:nth-child(5) { animation-delay: 170ms; }
  .members-open #members li:nth-child(n + 6) { animation-delay: 200ms; }
}

@media (max-width: 760px) {
  #channels-backdrop,
  #channels-backdrop[hidden] {
    display: block !important;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    animation: none;
    transition: opacity 240ms ease-out, visibility 0s;
  }
  #channels-backdrop[hidden] {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 200ms ease-in, visibility 0s 200ms;
  }
  /* Slides out quickly, glides in and settles. */
  #channels-sidebar {
    transition: transform 220ms cubic-bezier(0.4, 0, 0.7, 0.2), visibility 0s 220ms;
  }
  .channels-open #channels-sidebar {
    transition: transform 340ms cubic-bezier(0.16, 1, 0.3, 1), visibility 0s;
    box-shadow: 18px 0 48px rgba(0, 0, 0, 0.5);
  }
  /* The drawer's contents follow it in, one after another. */
  .channels-open #channels-sidebar .server-header,
  .channels-open #channels-sidebar .channel-scroll > *,
  .channels-open #channels-sidebar .voice-status,
  .channels-open #channels-sidebar .user-panel {
    animation: drawer-item-in 340ms cubic-bezier(0.16, 1, 0.3, 1) backwards;
  }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(1) { animation-delay: 40ms; }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(2) { animation-delay: 65ms; }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(3) { animation-delay: 90ms; }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(4) { animation-delay: 115ms; }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(5) { animation-delay: 140ms; }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(6) { animation-delay: 165ms; }
  .channels-open #channels-sidebar .channel-scroll > :nth-child(n + 7) { animation-delay: 190ms; }
  .channels-open #channels-sidebar .voice-status,
  .channels-open #channels-sidebar .user-panel { animation-delay: 200ms; }
  /* The burger icon turns as the drawer opens. */
  #channels-toggle svg {
    transition: rotate 300ms cubic-bezier(0.16, 1, 0.3, 1);
  }
  .channels-open #channels-toggle svg {
    rotate: 90deg;
  }
}
