@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&display=swap');

/* --------------------------------------------------------------------------
   1. DESIGN TOKENS & SYSTEM VARIABLES
   -------------------------------------------------------------------------- */
:root {
  /* Surface & Background */
  --bg: #07111f;
  --surface: #0d1b2d;
  --surface-raised: #11243a;
  --surface-muted: #0a1728;
  --surface-hover: #162c45;
  --input-background: #091728;
  --border: #1b3148;
  --surface-border: rgba(40, 68, 95, .52);

  /* Typography Colors */
  --text-primary: #f4f8fc;
  --text-secondary: #9db0c4;
  --text-muted: #8295a9;

  /* Brand Accents */
  --primary: #53c7e8;
  --primary-hover: #78d7ef;
  --primary-ink: #06202b;
  --primary-soft: rgba(83, 199, 232, .1);
  --primary-border: rgba(83, 199, 232, .55);
  --primary-glow: rgba(83, 199, 232, .12);

  /* Feedback Colors */
  --danger: #ff7180;
  --danger-soft: rgba(255, 113, 128, .1);
  --danger-border: rgba(255, 113, 128, .55);
  --danger-text: #ffc7cd;
  --success: #5ed6a1;
  --success-soft: rgba(94, 214, 161, .1);
  --success-border: rgba(94, 214, 161, .45);
  --success-text: #a7f3d0;
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, .12);
  --warning-border: rgba(251, 191, 36, .45);
  --warning-text: #fef08a;
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, .12);
  --info-border: rgba(56, 189, 248, .45);
  --info-text: #bae6fd;

  /* Realtime & Chat Tokens */
  --chat-incoming-bg: #182738;
  --chat-outgoing-bg: #164656;
  --chat-incoming-text: #f4f8fc;
  --chat-outgoing-text: #f3fbfd;
  --chat-meta: #9bb3be;
  --chat-reply-bg: rgba(4, 18, 28, .38);
  --chat-composer-bg: #0b1b2b;

  /* Spacing Scale */
  --space-1: .8rem;
  --space-2: 1.2rem;
  --space-3: 1.6rem;
  --space-4: 2.4rem;
  --space-5: 3.2rem;
  --space-6: 4.8rem;

  /* Radii & Elevation */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-pill: 9999px;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, .12);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, .14);
  --shadow: 0 16px 40px rgba(0, 0, 0, .24);

  /* Layout Boundaries */
  --content-max: 1380px;
  --nav-height: 7.2rem;
}

/* --------------------------------------------------------------------------
   2. GLOBAL RESETS & FLUID ROOT SCALING
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 62.5%; /* 10px baseline */
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 0;
  min-height: 100vh;
  color: var(--text-secondary);
  background: var(--bg);
  font: 400 1.5rem/1.6 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}

html:has(.messages-page),
html:has(.room-page),
body:has(.messages-page),
body:has(.room-page) {
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body:has(.messages-page),
body:has(.room-page) {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

body.drawer-open {
  overflow: hidden;
  touch-action: none;
}

body.modal-open {
  overflow: hidden;
  touch-action: none;
}

.studybud-toast {
  position: fixed;
  left: 50%;
  bottom: 2.4rem;
  z-index: 9999;
  max-width: min(36rem, calc(100vw - 3.2rem));
  padding: .8rem 1.6rem;
  transform: translateX(-50%);
  color: var(--text-primary);
  background: rgba(15, 23, 42, .94);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  font-size: 1.25rem;
}

.studybud-toast[hidden] {
  display: none;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color .15s ease;
}

a:hover {
  color: var(--primary-hover);
}

img, svg, video {
  max-width: 100%;
  display: block;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button, a, input, textarea, select {
  outline-offset: 3px;
}

button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 3px;
}

h1, h2, h3, h4, h5, h6, p {
  margin-top: 0;
}

h1, h2, h3 {
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -.02em;
}

/* --------------------------------------------------------------------------
   3. RESPONSIVE CONTAINER & UTILITY SYSTEM
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 2.4rem;
  padding-right: 2.4rem;
}

.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;
}

.muted {
  color: var(--text-muted);
}

.eyebrow {
  margin: 0 0 .5rem;
  color: var(--primary);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.empty-state {
  padding: 3.2rem 1.6rem;
  color: var(--text-muted);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: .4rem;
  color: var(--text-primary);
  font-size: 1.5rem;
}

.empty-state span {
  font-size: 1.25rem;
}

.empty-state--card {
  padding: 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.task-grid .empty-state--card,
.user-grid .empty-state--card {
  grid-column: 1 / -1;
  width: 100%;
}

.empty-state--hero {
  padding: 3.2rem 2.4rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-top: 2rem;
  width: 100%;
}

.empty-state--hero .empty-state__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 5.6rem;
  height: 5.6rem;
  margin-bottom: 1.6rem;
  border-radius: var(--radius-pill);
  background: var(--primary-soft);
  color: var(--primary);
}

.empty-state--hero .empty-state__icon svg {
  width: 2.8rem;
  height: 2.8rem;
}

.empty-state--hero h2 {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.8rem;
}

.empty-state--hero p {
  font-size: 1.4rem;
  color: var(--text-muted);
  max-width: 44rem;
  margin: 0 auto 2rem;
  line-height: 1.5;
}

.flash-stack {
  position: fixed;
  top: calc(var(--nav-height) + 1.2rem);
  left: 50%;
  z-index: 80;
  width: min(56rem, calc(100% - 3.2rem));
  padding: 0;
  transform: translateX(-50%);
  display: grid;
  gap: .8rem;
  pointer-events: none;
}

.flash {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  width: 100%;
  padding: 1.2rem 1.6rem;
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .24);
  pointer-events: auto;
  transition: opacity .2s ease, transform .2s ease;
}

.flash__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
}

.flash__icon svg {
  width: 100%;
  height: 100%;
}

.flash__message {
  min-width: 0;
  flex: 1 1 auto;
  line-height: 1.45;
  font-weight: 500;
}

.flash__close {
  display: inline-grid;
  flex: 0 0 auto;
  place-items: center;
  width: 2.8rem;
  height: 2.8rem;
  margin: -.25rem -.55rem -.25rem 0;
  padding: 0;
  color: currentColor;
  background: transparent;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  font-size: 2rem;
  line-height: 1;
  opacity: .75;
  transition: opacity .15s ease, background .15s ease;
}

.flash__close:hover,
.flash__close:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, .08);
  outline: 0;
}

.flash.is-dismissing {
  opacity: 0;
  transform: translateY(-.8rem) scale(.98);
  pointer-events: none;
}

.flash--error {
  border-color: var(--danger-border);
  border-left: 3px solid var(--danger);
  background: var(--surface-raised);
  color: var(--text-primary);
}
.flash--error .flash__icon {
  color: var(--danger);
}

.flash--warning {
  border-color: var(--warning-border);
  border-left: 3px solid var(--warning);
  background: var(--surface-raised);
  color: var(--text-primary);
}
.flash--warning .flash__icon {
  color: var(--warning);
}

.flash--success {
  border-color: var(--success-border);
  border-left: 3px solid var(--success);
  background: var(--surface-raised);
  color: var(--text-primary);
}
.flash--success .flash__icon {
  color: var(--success);
}

.flash--info {
  border-color: var(--info-border);
  border-left: 3px solid var(--info);
  background: var(--surface-raised);
  color: var(--text-primary);
}
.flash--info .flash__icon {
  color: var(--info);
}

@media (max-width: 520px) {
  .flash-stack {
    top: calc(var(--nav-height) + .8rem);
    width: min(100% - 2rem, 56rem);
  }

  .flash {
    padding: 1rem 1.2rem;
    font-size: 1.3rem;
  }
}

/* Global / Form-wide errors (e.g. login failed, non-field errors) */
.form-errors--global {
  display: flex;
  align-items: flex-start;
  gap: 1.2rem;
  padding: 1.1rem 1.4rem;
  margin-bottom: 2rem;
  background: var(--surface-raised);
  border: 1px solid var(--danger-border);
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.35rem;
  line-height: 1.45;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .15);
}

.form-errors--global::before {
  content: '';
  display: inline-block;
  flex-shrink: 0;
  width: 1.8rem;
  height: 1.8rem;
  margin-top: 0.15rem;
  background-color: var(--danger);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z'/%3E%3Cline x1='12' y1='9' x2='12' y2='13'/%3E%3Cline x1='12' y1='17' x2='12.01' y2='17'/%3E%3C/svg%3E") no-repeat center / contain;
}

.form-errors--global .errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  background: transparent;
  border: none;
  color: inherit;
}

.form-errors--global .errorlist li {
  font-size: 1.35rem;
  color: var(--text-primary);
}

.form-errors--global .errorlist li::before {
  display: none;
}

.form-errors__text {
  flex: 1 1 auto;
}

/* Field-level errors (compact, subtle, no clunky box) */
.field-errors {
  color: var(--danger-text);
  font-size: 1.35rem;
  margin-top: .4rem;
}

.field-errors:not(.form-errors--global) {
  display: flex;
  flex-direction: column;
  gap: .4rem;
}

.field-errors:not(.form-errors--global) > span,
.field-errors:not(.form-errors--global) > p {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  line-height: 1.4;
  color: var(--danger-text);
}

.field-errors:not(.form-errors--global) .errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  background: transparent;
  border: none;
}

.field-errors:not(.form-errors--global) .errorlist li {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  font-size: 1.35rem;
  line-height: 1.4;
  color: var(--danger-text);
  font-weight: 500;
}

.field-errors:not(.form-errors--global) .errorlist li::before {
  content: '';
  display: inline-block;
  flex-shrink: 0;
  width: 1.4rem;
  height: 1.4rem;
  background-color: var(--danger);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") no-repeat center / contain;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' y1='8' x2='12' y2='12'/%3E%3Cline x1='12' y1='16' x2='12.01' y2='16'/%3E%3C/svg%3E") no-repeat center / contain;
}

.errorlist {
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--danger-text);
  font-size: 1.35rem;
}

.helptext {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  margin-bottom: 2rem;
  color: var(--text-muted);
  font-size: 1.3rem;
  font-weight: 600;
}

.back-link:hover {
  color: var(--primary);
}

.error-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem;
  background: var(--bg);
}

.error-card {
  width: min(100%, 52rem);
  padding: 4.8rem 3.2rem;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  text-align: center;
}

.error-card img {
  width: 5.6rem;
  height: 5.6rem;
  margin: 0 auto 1.8rem;
}

.error-card h1 {
  margin: .6rem 0 1rem;
  font-size: clamp(2.6rem, 5vw, 4rem);
}

/* --------------------------------------------------------------------------
   4. BUTTONS, AVATARS, ICONS & BADGES
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  min-height: 4.2rem;
  padding: 0 1.8rem;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn--primary {
  color: var(--primary-ink);
  background: var(--primary);
}

.btn--primary:hover {
  background: var(--primary-hover);
  color: var(--primary-ink);
}

.btn--secondary, .btn--dark {
  color: var(--text-primary);
  background: var(--surface-raised);
  border-color: var(--border);
}

.btn--secondary:hover, .btn--dark:hover {
  background: var(--surface-hover);
  border-color: var(--primary-border);
  color: var(--text-primary);
}

.btn--danger {
  color: #ffdce0;
  background: transparent;
  border-color: var(--danger-border);
}

.btn--danger:hover {
  background: var(--danger-soft);
  color: #fff;
}

.btn--link {
  min-height: auto;
  padding: 0;
  color: var(--primary);
  background: transparent;
  border: 0;
}

.btn--compact {
  min-height: 3.8rem;
  padding: 0 1.4rem;
  font-size: 1.3rem;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 4.2rem;
  height: 4.2rem;
  min-width: 4.2rem;
  min-height: 4.2rem;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 1.8rem;
  cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}

.icon-button:hover {
  color: var(--primary);
  border-color: var(--primary);
  background: var(--surface-hover);
}

.ui-icon {
  width: 1.8rem;
  height: 1.8rem;
  vertical-align: middle;
  flex-shrink: 0;
}

.avatar {
  display: inline-flex;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid var(--primary-border);
  border-radius: 50%;
  background: var(--surface-raised);
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar--small {
  width: 3.2rem;
  height: 3.2rem;
}

.avatar--medium, .avatar--nav {
  width: 4rem;
  height: 4rem;
}

.avatar--large {
  width: 10.8rem;
  height: 10.8rem;
  border-width: 3px;
}

.notification-badge, .nav-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.8rem;
  height: 1.8rem;
  padding: 0 .4rem;
  color: var(--primary-ink);
  background: var(--primary);
  border-radius: var(--radius-pill);
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1;
}

.topic-badge {
  display: inline-flex;
  align-items: center;
  max-width: 18rem;
  padding: .4rem .9rem;
  overflow: hidden;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-pill);
  font-size: 1.15rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.priority-badge, .status-badge {
  display: inline-flex;
  padding: .35rem .75rem;
  border-radius: var(--radius-pill);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.priority-badge--high { color: var(--danger); background: var(--danger-soft); }
.priority-badge--medium { color: var(--primary); background: var(--primary-soft); }
.priority-badge--low { color: var(--success); background: var(--success-soft); }
.status-badge { color: var(--text-secondary); background: var(--surface-raised); }
.status-badge--completed { color: var(--success); }

/* --------------------------------------------------------------------------
   5. GLOBAL NAVBAR & HEADER
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--surface-border);
  background: rgba(7, 17, 31, .94);
  backdrop-filter: blur(16px);
}

.nav-shell {
  min-width: 0;
  min-height: var(--nav-height);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 2rem;
}

.nav-shell > * {
  min-width: 0;
}

.menu-button {
  display: none;
  align-items: center;
  justify-content: center;
  width: 4.2rem;
  height: 4.2rem;
  min-width: 4.2rem;
  min-height: 4.2rem;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.menu-button:hover {
  color: var(--text-primary);
  border-color: var(--primary);
  background: var(--surface-hover);
}

.brand, .header__logo {
  display: inline-flex;
  align-items: center;
  gap: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  white-space: nowrap;
}

.brand img {
  width: 3.6rem;
  height: 3.6rem;
  object-fit: contain;
}

.brand strong {
  display: block;
  font-size: 1.9rem;
  line-height: 1.1;
  letter-spacing: -.03em;
}

.brand small {
  display: block;
  margin-top: .2rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  letter-spacing: .02em;
}

.global-search {
  position: relative;
  max-width: 38rem;
  width: 100%;
  justify-self: center;
}

.global-search label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.global-search input {
  width: 100%;
  height: 4.2rem;
  padding: 0 1.6rem 0 4.2rem;
  color: var(--text-primary);
  background: var(--input-background);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-pill);
  font-size: 1.35rem;
}

.global-search input::placeholder {
  color: var(--text-muted);
}

.global-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: 0;
}

.search-icon-svg {
  position: absolute;
  top: 50%;
  left: 1.4rem;
  transform: translateY(-50%);
  color: var(--primary);
  pointer-events: none;
}

.global-search > .search-icon {
  display: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: .8rem;
}

.nav-link {
  color: var(--text-secondary);
  font-weight: 600;
  padding: .8rem .6rem;
  font-size: 1.35rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
}

.nav-link.is-active {
  color: var(--primary);
}

.nav-link:hover {
  color: var(--text-primary);
}

.notification-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.notification-link.is-active {
  color: var(--primary);
  border-color: var(--primary);
}

.notification-link .notification-badge {
  position: absolute;
  top: -.35rem;
  right: -.35rem;
}

.nav-notifications-link {
  display: flex;
  align-items: center;
  gap: .9rem;
}

.nav-notifications-link .nav-unread-badge {
  margin-left: auto;
}

/* User Menu Dropdown */
.user-menu {
  position: relative;
}

.user-menu__toggle {
  display: flex;
  align-items: center;
  gap: .8rem;
  min-height: 4.2rem;
  padding: .2rem .4rem .2rem .4rem;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.user-menu__toggle:hover {
  color: var(--text-primary);
}

.user-menu__name {
  max-width: 12rem;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chevron {
  display: none;
}

.chevron-svg {
  color: var(--text-muted);
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 1rem);
  right: 0;
  min-width: 19rem;
  max-width: calc(100vw - 3.2rem);
  padding: .6rem;
  overflow: hidden;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  z-index: 60;
}

.dropdown-menu[hidden] {
  display: none;
}

.dropdown-menu a {
  display: block;
  padding: 1rem 1.2rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
}

.dropdown-menu a:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.dropdown-menu form {
  margin: 0;
}

.dropdown-menu__button {
  display: block;
  width: 100%;
  padding: 1rem 1.2rem;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: 1.35rem;
}

.dropdown-menu__button:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

/* Language Menu Dropdown */
.language-menu {
  position: relative;
}

.language-menu__toggle {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 4.2rem;
  padding: .2rem .6rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
}

.language-menu__toggle:hover,
.language-menu__toggle:focus-visible {
  color: var(--text-primary);
  background: var(--surface-hover);
  border-color: var(--border);
}

.language-menu__current {
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 600;
  white-space: nowrap;
}

.language-flag {
  display: inline-block;
  width: 22px;
  height: 15px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .15);
}

.language-dropdown {
  min-width: 17rem;
}

.language-option {
  display: flex;
  align-items: center;
  gap: .8rem;
  width: 100%;
  font-family: inherit;
  font-weight: 500;
  transition: background .15s ease;
}

.language-option.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 600;
}

.language-option.is-active::after {
  content: "✓";
  margin-left: auto;
  color: var(--primary);
  font-size: 1.2rem;
}

.mobile-language-section {
  padding: 1.6rem 2rem;
  border-top: 1px solid var(--border);
}

.mobile-language-section .sidebar-heading {
  margin-bottom: 1rem;
}

.mobile-language-buttons {
  display: flex;
  gap: .8rem;
  flex-wrap: wrap;
}

.mobile-language-buttons .btn {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
}

.auth-language-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  margin-top: 1.6rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--surface-border);
}

.auth-language-switcher__label {
  font-size: 1.2rem;
  color: var(--text-muted);
}

.auth-language-buttons {
  display: inline-flex;
  gap: .4rem;
}

.auth-language-btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .8rem;
  font-size: 1.25rem;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  transition: all .15s ease;
}

.auth-language-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
  border-color: var(--primary-border);
}

.auth-language-btn.is-active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary-border);
  font-weight: 600;
}

/* Off-canvas Navigation Drawer */
.mobile-nav-backdrop[hidden], .mobile-nav-drawer[hidden] {
  display: none;
}

.mobile-nav-backdrop {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(2, 8, 16, .72);
  backdrop-filter: blur(4px);
}

.mobile-nav-drawer {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 60;
  width: min(32rem, 86vw);
  padding: 1.8rem;
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.mobile-nav-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .2rem .2rem 1.6rem 1rem;
  color: var(--text-primary);
  font-size: 1.7rem;
  border-bottom: 1px solid var(--surface-border);
  margin-bottom: 1.4rem;
}

.mobile-nav-drawer__links {
  margin-bottom: 2.2rem;
}

.mobile-topic-list {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   6. SIDEBAR & NAV COMPONENTS
   -------------------------------------------------------------------------- */
.sidebar-card, .activity-panel, .progress-card, .today-plan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.sidebar-card {
  padding: 1.4rem;
  position: sticky;
  top: 8.8rem;
  max-height: calc(100vh - 11rem);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.sidebar-heading {
  padding: .8rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.side-nav {
  margin-bottom: 2.2rem;
}

.side-nav a, .topic-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: 1rem;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  font-size: 1.35rem;
}

.side-nav a {
  justify-content: flex-start;
}

.side-nav a .ui-icon {
  flex: 0 0 1.8rem;
}

.side-nav a:hover, .side-nav a.is-active, .topic-list a:hover, .topic-list a.is-active {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.side-nav a.is-active {
  color: var(--primary);
  font-weight: 600;
}

.topic-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.topic-page-list {
  margin-top: 2rem;
}

.topic-list li {
  margin: .25rem 0;
}

.topic-list span, .count {
  color: var(--text-muted);
  font-size: 1.25rem;
}

.browse-all {
  display: block;
  padding: 1rem;
  font-weight: 600;
  font-size: 1.3rem;
}

/* --------------------------------------------------------------------------
   7. DASHBOARD / DISCOVER ROOMS
   -------------------------------------------------------------------------- */
.dashboard {
  padding: 3.2rem 0 6rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 22rem minmax(0, 1fr) 30rem;
  gap: 2.4rem;
  align-items: start;
}

.dashboard-grid > *, .profile-grid > *, .room-layout > *, .task-grid > * {
  min-width: 0;
}

.feed-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.2rem;
}

.feed-header h1 {
  margin-bottom: .6rem;
  font-size: clamp(2.6rem, 3vw, 3.4rem);
  letter-spacing: -.03em;
}

.feed-header p {
  margin-bottom: 0;
  color: var(--text-secondary);
}

.feed-tools {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.tabs {
  display: flex;
  gap: .4rem;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tab {
  padding: .7rem 1.2rem;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 1.3rem;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  color: var(--text-primary);
  background: var(--surface-raised);
}

.tab:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.room-list {
  display: grid;
  gap: 1.4rem;
}

.room-card {
  display: block;
  padding: 2rem;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  transition: border-color .2s, background .2s, transform .2s;
}

.room-card:hover {
  background: var(--surface-hover);
  border-color: var(--primary-border);
  transform: translateY(-2px);
}

.room-card__top, .room-card__meta, .room-card__host {
  display: flex;
  align-items: center;
}

.room-card__top {
  justify-content: space-between;
  gap: 1rem;
}

.room-card__host {
  gap: .8rem;
  min-width: 0;
}

.room-card__host strong {
  display: block;
  overflow: hidden;
  color: var(--text-primary);
  font-size: 1.35rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-card__host span, .room-card__time {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.room-card h2 {
  margin: 1.4rem 0 .7rem;
  font-size: 2rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.room-card__description {
  display: -webkit-box;
  margin-bottom: 1.6rem;
  overflow: hidden;
  color: var(--text-secondary);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.5;
}

.room-card__meta {
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--surface-border);
}

.room-card__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.room-card__cta {
  color: var(--primary);
  font-size: 1.3rem;
  font-weight: 700;
  white-space: nowrap;
}

.dashboard-right {
  display: grid;
  gap: 1.8rem;
  align-content: start;
}

.activity-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: sticky;
  top: 8.8rem;
  max-height: clamp(44rem, 62vh, 58rem);
}

.panel-heading {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 1.8rem;
  border-bottom: 1px solid var(--border);
}

.panel-heading h2 {
  margin: 0;
  font-size: 1.65rem;
}

.activity-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: .4rem 1.8rem 1rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.standalone__card .activity-list {
  overflow-y: visible;
  max-height: none;
  padding: .6rem 0;
}

.activity-item {
  padding: 1rem 0;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: 0;
}

.activity-item__user {
  display: flex;
  align-items: center;
  gap: .8rem;
  color: var(--text-primary);
  font-size: 1.25rem;
  font-weight: 600;
  min-width: 0;
}

.activity-item__user a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item__user time {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 1.1rem;
  font-weight: 400;
  white-space: nowrap;
  flex-shrink: 0;
}

.activity-item__text {
  margin: .4rem 0 0 3.6rem;
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 1.4;
}

.activity-item__text a {
  color: var(--primary);
  font-weight: 500;
}

.activity-item__body {
  margin-top: .4rem;
  padding: .5rem .8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 1.2rem;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 4.6rem;
}

/* Progress card */
.progress-card {
  overflow: hidden;
  border-color: var(--surface-border);
}

.progress-card__body {
  padding: 1.8rem;
}

.progress-card__value {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.progress-card__value span {
  color: var(--text-secondary);
}

.progress-card__value strong {
  color: var(--text-primary);
  font-size: 1.8rem;
}

.progress-card__value small {
  color: var(--text-muted);
  font-size: 1.3rem;
  font-weight: 400;
}

.progress-track {
  height: .8rem;
  overflow: hidden;
  background: var(--bg);
  border-radius: 99px;
}

.progress-track span {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  background: var(--primary);
  border-radius: inherit;
  transition: width .3s ease;
}

.progress-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  margin-top: 1rem;
  color: var(--text-muted);
  font-size: 1.15rem;
}

.streak-badge {
  color: var(--primary);
  white-space: nowrap;
  font-weight: 600;
}

.progress-card__cta {
  width: 100%;
  margin-top: 1.6rem;
}

.progress-card__body--empty p {
  margin-bottom: 0;
  color: var(--text-secondary);
}

/* Today's plan widget */
.today-plan {
  overflow: hidden;
}

.today-plan--wide {
  margin-bottom: 2.4rem;
}

.today-plan__body {
  padding: .5rem 1.8rem 1rem;
}

.today-plan__item {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  padding: 1.2rem 0;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.today-plan__item:last-child {
  border-bottom: 0;
}

.today-plan__item:hover strong {
  color: var(--primary);
}

.today-plan__dot {
  flex: 0 0 .8rem;
  width: .8rem;
  height: .8rem;
  background: var(--text-muted);
  border-radius: 50%;
}

.today-plan__dot--high { background: var(--danger); }
.today-plan__dot--medium { background: var(--primary); }
.today-plan__dot--low { background: var(--success); }

.today-plan__content {
  display: grid;
  min-width: 0;
  flex: 1;
}

.today-plan__content strong {
  overflow: hidden;
  color: var(--text-primary);
  font-size: 1.3rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.today-plan__content small {
  color: var(--text-muted);
  font-size: 1.15rem;
}

.today-plan__empty {
  padding: 1.8rem 0;
  color: var(--text-muted);
}

.today-plan__empty p {
  margin: 0 0 .5rem;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .8rem;
  margin-top: 2.4rem;
  color: var(--text-muted);
}

.pagination a, .pagination span {
  min-width: 4.2rem;
  min-height: 4.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: .6rem 1.2rem;
  color: var(--text-secondary);
  text-align: center;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1.3rem;
  text-decoration: none;
}

.pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.pagination .is-current {
  color: var(--primary-ink) !important;
  background: var(--primary) !important;
  border-color: var(--primary) !important;
  font-weight: 700;
}

/* --------------------------------------------------------------------------
   8. ROOM CHAT & COLLABORATION
   -------------------------------------------------------------------------- */
.room-page {
  flex: 1 1 0%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  padding: 1.6rem 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.room-layout {
  display: flex;
  flex-direction: column;
  flex: 1 1 0%;
  height: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.room-page .room {
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #081827;
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.room-header {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 6.6rem;
  padding: .8rem 1.6rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--surface-border);
  gap: 1.2rem;
}

.room-header__identity {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.room-header__mark {
  display: grid;
  place-items: center;
  flex: 0 0 3.8rem;
  width: 3.8rem;
  height: 3.8rem;
  color: var(--primary-ink);
  background: var(--primary);
  border-radius: 1.1rem;
  font-size: 1.7rem;
  font-weight: 800;
}

.room-header__copy {
  min-width: 0;
}

.room-header__copy h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.2vw, 2.3rem);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.room-header__copy p {
  margin: .15rem 0 0;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 1.15rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-header__tools {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex: 0 0 auto;
  margin-left: auto;
}

.room-header__tools .icon-button {
  width: 3.6rem;
  height: 3.6rem;
  min-width: 3.6rem;
  min-height: 3.6rem;
}

.room-search-popover {
  position: static;
}

.room-search {
  position: absolute;
  z-index: 15;
  top: calc(100% + .6rem);
  right: 5rem;
  display: flex;
  align-items: center;
  width: min(32rem, calc(100vw - 3.6rem));
  padding: .35rem .45rem .35rem .8rem;
  background: var(--surface-raised);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.room-search[hidden], .room-search__results[hidden] {
  display: none !important;
}

.room-search input {
  flex: 1 1 auto;
  width: auto;
  min-width: 0;
  padding: .5rem .6rem;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 1.3rem;
}

.room-search .icon-button {
  width: 3.2rem;
  height: 3.2rem;
  min-width: 3.2rem;
  min-height: 3.2rem;
  border: 0;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.room-search__icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  opacity: .7;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: .2rem;
  flex: 0 0 auto;
}

.room-search__close {
  color: var(--text-muted);
}

.room-search__results {
  position: absolute;
  z-index: 14;
  top: calc(100% + 5.6rem);
  right: 5rem;
  width: min(32rem, calc(100vw - 3.6rem));
  max-height: min(24rem, 45vh);
  overflow-y: auto;
  padding: .5rem;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.room-search__results button {
  display: block;
  width: 100%;
  padding: .75rem;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: .45rem;
  text-align: left;
  cursor: pointer;
  font-size: 1.25rem;
}

.room-search__results button:hover, .room-search__results button:focus-visible {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.room-info {
  position: relative;
}

.room-info summary {
  list-style: none;
  cursor: pointer;
}

.room-info summary::-webkit-details-marker {
  display: none;
}

.room-info__panel {
  position: absolute;
  z-index: 20;
  top: calc(100% + .8rem);
  right: 0;
  width: min(30rem, calc(100vw - 3rem));
  padding: 1.4rem;
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
}

.room-info__panel p {
  margin: .65rem 0;
  overflow-wrap: anywhere;
  font-size: 1.25rem;
}

.room-header__host {
  display: inline-flex;
  align-items: center;
  gap: .8rem;
  margin-top: .6rem;
  color: var(--text-secondary);
  font-size: 1.25rem;
}

.room-header__host strong {
  color: var(--text-primary);
}

.room-info__actions {
  display: flex;
  gap: .6rem;
  margin-top: 1rem;
}

.room-info__actions .btn {
  min-height: 3.4rem;
  padding: 0 1rem;
  font-size: 1.2rem;
}

/* Participants Drawer */
.participants-drawer__backdrop {
  position: fixed;
  inset: 0;
  z-index: 48;
  background: rgba(2, 8, 16, .65);
  backdrop-filter: blur(3px);
  border: 0;
  cursor: default;
}

.participants-drawer__backdrop[hidden] {
  display: none !important;
}

.room-page .participants-drawer {
  position: fixed;
  z-index: 50;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(28rem, 85vw);
  background: var(--surface);
  border-left: 1px solid var(--surface-border);
  box-shadow: -8px 0 28px rgba(0, 0, 0, .35);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s cubic-bezier(.16, 1, .3, 1), opacity .2s ease;
}

.room-page .participants-drawer.is-open {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
}

.participants__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--surface-border);
}

.participants__top h2 {
  margin: 0;
  font-size: 1.45rem;
}

.participants__total {
  color: var(--text-muted);
  font-weight: 500;
}

.participants__top-actions {
  display: inline-flex;
  align-items: center;
  gap: .75rem;
}

.participants__online {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  color: var(--success);
  font-size: 1.15rem;
}

.participants__close {
  width: 3.2rem;
  height: 3.2rem;
  min-width: 3.2rem;
  min-height: 3.2rem;
  border: 0;
  font-size: 2rem;
}

.participants__list {
  flex: 1 1 auto;
  padding: .8rem 1.4rem 1.2rem;
  overflow-y: auto;
}

.participant {
  display: flex;
  align-items: center;
  gap: .9rem;
  padding: .75rem 0;
  color: var(--text-secondary);
  text-decoration: none;
  position: relative;
}

.participant:hover {
  color: var(--text-primary);
}

.participant p {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-size: 1.3rem;
  font-weight: 600;
}

.participant span {
  display: block;
  color: var(--text-muted);
  font-size: 1.15rem;
  font-weight: 400;
}

.participant__presence {
  display: block;
  flex: 0 0 .8rem;
  width: .8rem;
  height: .8rem;
  margin-left: auto;
  background: var(--text-muted);
  border: 2px solid var(--surface);
  border-radius: 50%;
  opacity: .55;
}

.participant.is-online .participant__presence {
  background: var(--success);
  box-shadow: 0 0 0 .3rem var(--success-soft);
  opacity: 1;
}

/* Conversation message thread */
.room-page .conversation {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 1rem 2rem 1.4rem;
  background: #091a2a;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #34485e transparent;
}

.room-page .conversation::-webkit-scrollbar {
  width: 6px;
}

.room-page .conversation::-webkit-scrollbar-thumb {
  background: #34485e;
  border-radius: 99px;
}

.room-page .conversation__messages {
  display: flex;
  flex: 0 0 auto;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  margin-top: auto;
}

.room-page .conversation__messages > .thread,
.room-page .conversation__messages > .date-separator,
.room-page .conversation__messages > .conversation__older {
  flex: 0 0 auto;
}

.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  margin: 1.4rem 0 1rem;
  color: var(--chat-meta);
  font-size: 1.05rem;
  font-weight: 600;
}

.date-separator::before, .date-separator::after {
  width: 2.8rem;
  height: 1px;
  background: var(--surface-border);
  content: '';
}

.conversation__older {
  display: flex;
  justify-content: center;
  margin-bottom: .8rem;
}

.conversation__older button {
  padding: .5rem 1.2rem;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 1.2rem;
}

.conversation__older button:hover, .conversation__older button:focus-visible {
  color: var(--text-primary);
  border-color: var(--primary-border);
}

.thread {
  position: relative;
  display: flex;
  align-items: flex-end;
  width: 100%;
  gap: .75rem;
  padding: 0;
}

.thread + .thread {
  margin-top: .3rem;
}

.thread + .thread.thread--group-start {
  margin-top: 1rem;
}

.thread--group-continuation {
  margin-top: .25rem !important;
}

.thread--group-continuation .thread__avatar,
.thread--group-continuation .thread__meta {
  display: none;
}

.thread--group-continuation.thread--other {
  padding-left: 3.55rem;
}

.thread--own {
  justify-content: flex-end;
}

.thread--other {
  justify-content: flex-start;
}

.thread__avatar {
  flex: 0 0 2.8rem;
  width: 2.8rem;
  height: 2.8rem;
  align-self: flex-end;
}

.thread__stack {
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: min(72%, 60rem);
  position: relative;
}

.thread--own .thread__stack {
  align-items: flex-end;
}

.thread--other .thread__stack {
  align-items: flex-start;
}

.thread__meta {
  display: flex;
  align-items: baseline;
  max-width: 100%;
  margin: 0 .6rem .2rem;
}

.thread__author {
  color: var(--text-primary);
  font-size: 1.15rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.thread__bubble {
  position: relative;
  width: fit-content;
  min-width: 12.5rem;
  max-width: 100%;
  padding: .55rem 2.6rem .4rem .85rem;
  color: var(--chat-incoming-text);
  background: var(--chat-incoming-bg);
  border: 1px solid rgba(145, 173, 193, .16);
  border-radius: 1rem 1rem 1rem .28rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
}

.thread--own .thread__bubble {
  color: var(--chat-outgoing-text);
  background: var(--chat-outgoing-bg);
  border-color: rgba(83, 199, 232, .24);
  border-radius: 1rem 1rem .28rem 1rem;
}

.thread--deleted .thread__bubble {
  background: var(--surface-muted);
  border-style: dashed;
}

.thread__deleted-text {
  margin: 0;
  color: var(--text-muted);
  font-style: italic;
  font-size: 1.15rem;
}

.thread__details {
  margin: 0;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.45;
  font-size: 1.35rem;
}

.thread__reply {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0 0 .5rem;
  padding: .45rem .7rem;
  color: var(--text-secondary);
  background: var(--chat-reply-bg);
  border: 0;
  border-left: 3px solid var(--primary);
  border-radius: .45rem;
  text-align: left;
  cursor: pointer;
}

.thread__reply strong {
  color: var(--text-primary);
  font-size: 1.05rem;
}

.thread__reply span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.1rem;
}

.thread__attachment {
  display: flex;
  align-items: center;
  max-width: 100%;
  margin-top: .5rem;
  overflow: hidden;
}

.thread__attachment--image img {
  display: block;
  width: min(30rem, 100%);
  max-height: 22rem;
  object-fit: cover;
  border-radius: .8rem;
}

.thread__attachment--file {
  gap: .65rem;
  padding: .65rem .85rem;
  background: rgba(0, 0, 0, .14);
  border: 1px solid var(--surface-border);
  border-radius: .65rem;
  color: var(--text-primary);
  font-size: 1.25rem;
}

.thread__attachment--file small {
  margin-left: auto;
  color: var(--text-muted);
  white-space: nowrap;
}

.thread__reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  min-height: 0;
  margin-top: .35rem;
}

.thread__reaction-bar:empty {
  display: none;
}

.thread__reaction {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .5rem;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, .14);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 1.1rem;
}

.thread__reaction.is-mine {
  color: var(--primary-ink);
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.thread__bubble-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: .4rem;
  align-self: flex-end;
  margin-top: .2rem;
  margin-left: auto;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
  line-height: 1.2;
}

.thread__date, .thread__edited, .thread__seen, .thread__receipt {
  display: inline-block;
  color: var(--chat-meta);
  font-size: .95rem;
  line-height: 1.2;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
}

.thread__menu-button {
  width: 2.2rem;
  height: 2.2rem;
  min-width: 2.2rem;
  min-height: 2.2rem;
  padding: 0;
  color: var(--text-muted);
  border: 0;
  font-size: 1.5rem;
  line-height: 1;
  opacity: 0;
  transition: opacity .15s ease;
}

.thread:hover .thread__menu-button, .thread__menu-button:focus-visible {
  opacity: 1;
}

.new-messages-button {
  position: absolute;
  right: 1.6rem;
  bottom: 1.2rem;
  z-index: 8;
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 3.6rem;
  padding: 0 1.2rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1px solid var(--primary-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-size: 1.2rem;
  font-weight: 700;
}

.new-messages-button[hidden] {
  display: none !important;
}

/* Lightbox */
.message-lightbox {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 2rem;
  background: rgba(3, 12, 24, .92);
}

.message-lightbox img {
  max-width: min(92vw, 100rem);
  max-height: 88vh;
  object-fit: contain;
  border-radius: .8rem;
}

.message-lightbox__close {
  position: absolute;
  top: 1.6rem;
  right: 1.6rem;
  width: 4.4rem;
  height: 4.4rem;
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: 50%;
  font-size: 2.4rem;
  cursor: pointer;
}

/* Room Composer */
.room__message {
  flex: 0 0 auto;
  padding: .8rem 1.6rem 1rem;
  background: var(--surface-raised);
  border-top: 1px solid var(--surface-border);
  position: relative;
}

.room-connection-status, .typing-indicator {
  min-height: 1.4rem;
  margin: 0 0 .3rem;
  font-size: 1.05rem;
}

.room-connection-status[hidden] {
  display: none;
}

.room-connection-status[data-state="connected"] { color: var(--success); }
.room-connection-status[data-state="reconnecting"], .room-connection-status[data-state="offline"] { color: var(--danger-text); }
.room-connection-status[data-state="notice"] { color: var(--text-muted); }

.typing-indicator {
  color: var(--primary);
  font-style: italic;
}

.typing-indicator.is-active::after {
  content: ' • • •';
  letter-spacing: .15em;
}

.composer-context, .composer-attachments {
  display: flex;
  align-items: center;
  gap: .7rem;
  min-height: 2.8rem;
  margin-bottom: .6rem;
  padding: .55rem .85rem;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border-left: 3px solid var(--primary);
  border-radius: .5rem;
  font-size: 1.2rem;
}

.composer-context[hidden], .composer-attachments[hidden] {
  display: none !important;
}

.composer-context button, .composer-attachments button {
  margin-left: auto;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.room-composer {
  display: flex;
  align-items: flex-end;
  gap: .6rem;
  padding: .35rem .45rem .35rem .65rem;
  background: var(--chat-composer-bg);
  border: 1px solid var(--surface-border);
  border-radius: 1.4rem;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.room-composer:focus-within {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.room-page .composer__leading {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: .25rem;
}

.composer__attach, .composer__emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.2rem;
  height: 3.2rem;
  min-width: 3.2rem;
  min-height: 3.2rem;
  padding: 0;
  color: var(--text-secondary);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.8rem;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}

.composer__attach:hover, .composer__emoji:hover,
.composer__attach:focus-visible, .composer__emoji:focus-visible {
  color: var(--primary);
  background: var(--surface-hover);
}

.room__message textarea {
  flex: 1 1 auto;
  width: 100%;
  min-height: 2.8rem;
  max-height: 13rem;
  height: 2.8rem;
  padding: .35rem 0;
  overflow-y: hidden;
  resize: none;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  box-shadow: none;
  line-height: 1.5;
  font-size: 1.35rem;
}

.room__message textarea:focus {
  border: 0;
  box-shadow: none;
  outline: 0;
}

.composer__send,
.composer__mic {
  display: inline-flex;
  flex: 0 0 4rem;
  align-items: center;
  justify-content: center;
  width: 4rem;
  height: 4rem;
  padding: 0;
  color: var(--primary-ink);
  background: var(--primary);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}

.composer__send:hover,
.composer__mic:hover {
  background: var(--primary-hover);
  transform: scale(1.04);
}

.composer__send:focus-visible,
.composer__mic:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 2px;
}

.composer__send[hidden],
.composer__mic[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   9. UNIFIED EMOJI PICKER (ROOM + DIRECT MESSAGES)
   -------------------------------------------------------------------------- */
.composer__emoji-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  width: min(340px, calc(100vw - 24px));
  height: 380px;
  max-height: min(400px, calc(100dvh - 120px));
  padding: 0;
  overflow: hidden;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  box-shadow: 0 14px 36px rgba(0, 0, 0, .4), 0 2px 6px rgba(0, 0, 0, .2);
}

.composer__emoji-picker[hidden] {
  display: none !important;
}

.composer__emoji-picker.is-flipped-below {
  bottom: auto;
  top: calc(100% + 8px);
}

.emoji-picker__header {
  flex: 0 0 auto;
  padding: 8px 10px 6px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-raised);
}

.emoji-picker__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.emoji-picker__top strong {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.emoji-picker__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
  transition: color .15s ease, background-color .15s ease;
}

.emoji-picker__close:hover, .emoji-picker__close:focus-visible {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.emoji-picker__search {
  width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 0 10px;
  color: var(--text-primary);
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: 7px;
  font-size: 1.25rem;
  outline: 0;
}

.emoji-picker__search::placeholder {
  color: var(--text-muted);
}

.emoji-picker__search:focus {
  border-color: var(--primary-border);
  box-shadow: 0 0 0 2px var(--primary-soft);
}

.emoji-picker__categories {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 4px 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-raised);
  scrollbar-width: thin;
  scrollbar-color: #34485e transparent;
}

.emoji-picker__category {
  display: inline-flex;
  flex: 0 0 32px;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 30px;
  min-width: 32px;
  padding: 0;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease;
}

.emoji-picker__category:hover, .emoji-picker__category:focus-visible {
  color: var(--text-primary);
  background: var(--surface-hover);
}

.emoji-picker__category[aria-pressed="true"] {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

.emoji-picker__grid {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(auto-fill, minmax(36px, 1fr));
  align-content: start;
  gap: 2px;
  min-height: 0;
  padding: 6px 8px 8px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #34485e transparent;
}

.emoji-picker__grid::-webkit-scrollbar {
  width: 5px;
}

.emoji-picker__grid::-webkit-scrollbar-thumb {
  background: #34485e;
  border-radius: 99px;
}

.emoji-picker__emoji {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 1.95rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color .1s ease, transform .08s ease;
}

.emoji-picker__emoji:hover, .emoji-picker__emoji:focus-visible {
  background: var(--surface-hover);
  border-color: var(--primary-border);
  outline: 0;
  transform: scale(1.12);
}

.emoji-picker__empty {
  grid-column: 1 / -1;
  margin: 24px 8px;
  color: var(--text-muted);
  font-size: 1.15rem;
  text-align: center;
}

/* --------------------------------------------------------------------------
   10. DIRECT MESSAGES / INBOX
   -------------------------------------------------------------------------- */
.messages-page {
  flex: 1 1 0%;
  height: 100%;
  min-height: 0;
  max-height: 100%;
  padding: 1.6rem 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.messages-shell {
  width: min(1360px, calc(100% - 3.2rem));
  height: 100%;
  min-height: 0;
  max-height: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 16px;
  background: #0d1726;
  box-shadow: 0 20px 45px rgba(0, 0, 0, .45);
}

/* Left Inbox Pane */
.messages-inbox {
  width: 320px;
  min-width: 320px;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid rgba(148, 163, 184, .14);
  background: #0d1828;
  overflow: hidden;
}

.messages-inbox__header {
  height: 64px;
  min-height: 64px;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, .12);
  background: rgba(13, 24, 40, .95);
}

.messages-inbox__header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  color: #f1f5f9;
}

.messages-inbox__header p {
  margin: 2px 0 0;
  color: #8da3ba;
  font-size: 1.15rem;
}

.messages-search {
  margin: 10px 14px 8px;
}

.messages-search label, .new-message-panel label {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.messages-search input, .new-message-panel input {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(148, 163, 184, .16);
  border-radius: 8px;
  padding: 8px 12px;
  color: #f1f5f9;
  background: #142438;
  font-size: 1.25rem;
  transition: border-color .15s ease, background .15s ease;
}

.messages-search input:focus, .new-message-panel input:focus {
  outline: 0;
  border-color: #2dd4bf;
  background: #182b40;
}

.new-message-panel {
  margin: 0 14px 10px;
  padding: 12px;
  border-radius: 10px;
  background: #16273c;
  border: 1px solid rgba(148, 163, 184, .15);
}

.new-message-results {
  display: grid;
  margin-top: 8px;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
}

.new-message-result {
  padding: 8px 10px;
  color: #d8e7f4;
  text-decoration: none;
  border-radius: 7px;
  font-size: 1.25rem;
  background: transparent;
  border: 0;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background .12s ease;
}

.new-message-result:hover {
  background: rgba(45, 212, 191, .14);
}

.conversation-list {
  flex: 1 1 auto;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .2) transparent;
}

.conversation-list__item {
  min-height: 68px;
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
  border-bottom: 1px solid rgba(148, 163, 184, .07);
  transition: background-color .15s ease;
}

.conversation-list__item:hover {
  background: rgba(45, 212, 191, .06);
}

.conversation-list__item.is-active {
  background: rgba(45, 212, 191, .12);
  border-left: 3px solid #2dd4bf;
}

.conversation-list__copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.conversation-list__copy strong, .conversation-list__copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-list__copy strong {
  font-size: 1.35rem;
  color: #f1f5f9;
}

.conversation-list__copy span {
  color: #8fa5bc;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.conversation-list__tick {
  color: #2dd4bf;
  font-size: 1.15rem;
  font-weight: 700;
}

.conversation-list__meta {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  color: #7b92a9;
  font-size: 1.05rem;
  padding: 2px 0;
}

.conversation-list__meta b {
  min-width: 20px;
  padding: 2px 6px;
  border-radius: 10px;
  text-align: center;
  color: #07151e;
  background: #2dd4bf;
  font-size: 1rem;
  font-weight: 700;
}

.messages-empty-list {
  padding: 35px 20px;
  display: grid;
  gap: 8px;
  color: #8da2b8;
  text-align: center;
}

.messages-empty-list strong {
  color: #dbe8f5;
  font-size: 1.35rem;
}

.messages-empty-list .btn {
  justify-self: center;
  margin-top: 10px;
}

/* Right Chat Pane */
.messages-thread {
  min-width: 0;
  min-height: 0;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: #0a1320;
  background-image: radial-gradient(rgba(56, 189, 248, 0.035) 1px, transparent 0);
  background-size: 24px 24px;
  overflow: hidden;
}

.messages-thread > #direct-realtime {
  min-height: 0;
  min-width: 0;
  display: flex;
  flex: 1 1 0%;
  flex-direction: column;
  position: relative;
  height: 100%;
  overflow: hidden;
}

/* Chat Header */
.direct-header {
  flex: 0 0 64px;
  height: 64px;
  min-height: 64px;
  max-height: 64px;
  box-sizing: border-box;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  background: #0f1c2e;
  position: relative;
  z-index: 20;
}

.direct-header__info {
  min-width: 0;
  flex: 1;
}

.direct-header h2 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 600;
  color: #f8fafc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.direct-header p {
  margin: 2px 0 0;
  color: #8ba2b9;
  font-size: 1.15rem;
}

.direct-header p.is-online {
  color: #2dd4bf;
  font-weight: 500;
}

.direct-header__back {
  display: none;
  align-items: center;
  justify-content: center;
  width: 3.4rem;
  height: 3.4rem;
  font-size: 2.4rem;
  color: #cfe1ee;
  text-decoration: none;
  border-radius: 8px;
  line-height: 1;
}

.direct-header__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}

.direct-header__tools .icon-button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  border-radius: 8px;
  font-size: 1.3rem;
}

.direct-header-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 6px;
  z-index: 50;
  min-width: 190px;
  padding: 6px;
  border-radius: 12px;
  background: #132235;
  border: 1px solid rgba(148, 163, 184, .25);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.direct-header-menu[hidden] {
  display: none !important;
}

.direct-call-popover {
  position: fixed;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100vw - 16px);
  padding: 7px 12px;
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.35;
  color: #e2e8f0;
  background: #132235;
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  pointer-events: auto;
  white-space: nowrap;
  animation: directCallPopoverFadeIn .15s ease-out;
}

.direct-call-popover::before {
  content: '';
  position: absolute;
  top: -5px;
  left: var(--caret-left, 50%);
  transform: translateX(-50%) rotate(45deg);
  width: 8px;
  height: 8px;
  background: inherit;
  border-left: 1px solid rgba(148, 163, 184, .25);
  border-top: 1px solid rgba(148, 163, 184, .25);
}

@keyframes directCallPopoverFadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* One-to-one WebRTC call surface. Signaling remains in the DM socket; media
   elements are local browser endpoints and never uploaded to the server. */
.direct-call-overlay {
  position: absolute;
  inset: 64px 0 0;
  z-index: 35;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 12, 23, .88);
}

.direct-call-overlay[hidden] {
  display: none !important;
}

.direct-call-panel {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: min(680px, calc(100% - 24px));
  overflow: auto;
  padding: 24px;
  color: #f1f5f9;
  background: #102137;
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .45);
}

.direct-call-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.direct-call-panel__header h2 {
  margin: 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.7rem;
}

.direct-call-panel__type {
  flex: 0 0 auto;
  color: #8da4bb;
  font-size: 1.2rem;
}

.direct-call-media {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background: #071321;
  border-radius: 14px;
}

.direct-call-overlay[data-call-type="video"] .direct-call-panel {
  width: min(760px, 100%);
}

.direct-call-overlay[data-call-type="video"] .direct-call-media {
  min-height: min(52vh, 460px);
  aspect-ratio: 16 / 9;
}

.direct-call-overlay[data-call-type="voice"] .direct-call-media {
  overflow: visible;
  background: transparent;
}

.direct-call-placeholder {
  display: grid;
  place-items: center;
  min-height: 148px;
  padding: 12px 0;
}

.direct-call-overlay[data-call-type="voice"] .direct-call-placeholder {
  min-height: 128px;
}

.direct-call-remote {
  display: block;
  width: 100%;
  max-height: min(55vh, 460px);
  object-fit: contain;
  background: #02070d;
}

.direct-call-local {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 2;
  width: clamp(110px, 22vw, 180px);
  max-height: 30%;
  object-fit: cover;
  background: #02070d;
  border: 2px solid rgba(255, 255, 255, .75);
  border-radius: 10px;
  box-shadow: 0 5px 18px rgba(0, 0, 0, .45);
}

.direct-call-remote[hidden],
.direct-call-local[hidden],
.direct-call-placeholder[hidden] {
  display: none !important;
}

.direct-call-audio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.direct-call-status {
  min-height: 24px;
  margin: 18px 0 0;
  color: #cbd5e1;
  text-align: center;
  font-size: 1.35rem;
}

.direct-call-duration {
  margin: -10px 0 10px;
  color: #2dd4bf;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: 1.2rem;
}

.direct-call-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.direct-call-actions[hidden] {
  display: none !important;
}

.direct-call-action {
  min-width: 112px;
  min-height: 42px;
  padding: 8px 16px;
  color: #dbeafe;
  background: #1b3550;
  border: 1px solid rgba(148, 163, 184, .28);
  border-radius: 10px;
  cursor: pointer;
  font-size: 1.25rem;
}

.direct-call-action:hover,
.direct-call-action:focus-visible {
  background: #284a69;
}

.icon-button:focus,
.direct-header__tools .icon-button:focus,
.direct-call-button:focus,
.direct-call-action:focus {
  outline: none;
  box-shadow: none;
}

.icon-button:focus:not(:focus-visible),
.direct-header__tools .icon-button:focus:not(:focus-visible),
.direct-call-button:focus:not(:focus-visible),
.direct-call-action:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
}

.icon-button:focus-visible,
.direct-header__tools .icon-button:focus-visible,
.direct-call-button:focus-visible,
.direct-call-action:focus-visible {
  outline: 2px solid #5eead4;
  outline-offset: 2px;
  box-shadow: none;
}

.direct-call-action--accept {
  color: #042127;
  background: #2dd4bf;
  border-color: #2dd4bf;
}

.direct-call-action--accept:hover,
.direct-call-action--accept:focus-visible {
  background: #5eead4;
}

.direct-call-action--decline {
  color: #ffe4e6;
  background: #652d3a;
  border-color: rgba(248, 113, 113, .45);
}

.direct-call-action--decline:hover,
.direct-call-action--decline:focus-visible {
  background: #873947;
}

.direct-header-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  color: #dbe8f5;
  text-decoration: none;
  border-radius: 7px;
  font-size: 1.25rem;
  transition: background .12s ease;
}

.direct-header-menu__item:hover {
  background: rgba(45, 212, 191, .14);
  color: #ffffff;
}

/* In-Chat Search Bar */
.direct-search {
  flex: 0 0 44px;
  height: 44px;
  min-height: 44px;
  max-height: 44px;
  box-sizing: border-box;
  position: relative;
  padding: 5px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  background: #112032;
  z-index: 15;
}

.direct-search[hidden] {
  display: none !important;
}

.direct-search__icon {
  color: #64748b;
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
}

.direct-search input {
  min-width: 0;
  flex: 1;
  height: 34px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 6px;
  padding: 6px 10px;
  color: #f1f5f9;
  background: #0c1726;
  font-size: 1.25rem;
}

.direct-search input:focus {
  outline: 0;
  border-color: #2dd4bf;
}

.direct-search__count {
  color: #8ea4bb;
  font-size: 1.15rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.direct-search__nav {
  display: flex;
  gap: 2px;
}

.direct-search__nav-btn, .direct-search__close {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .12s ease, color .12s ease;
}

.direct-search__nav-btn:hover:not(:disabled), .direct-search__close:hover {
  background: rgba(255, 255, 255, .08);
  color: #f1f5f9;
}

.direct-search__nav-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

/* Message Timeline & Stack */
.direct-conversation {
  flex: 1 1 0%;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .25) transparent;
  position: relative;
}

.direct-message-stack {
  min-height: 100%;
  padding: 16px 20px 12px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0;
}

.date-separator {
  display: flex;
  justify-content: center;
  margin: 18px 0;
  position: sticky;
  top: 8px;
  z-index: 6;
  pointer-events: none;
}

.date-separator span {
  pointer-events: auto;
  padding: 4px 14px;
  background: rgba(18, 32, 51, .88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 14px;
  color: #94a3b8;
  font-size: 1.1rem;
  font-weight: 500;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
}

/* Message Bubbles */
.direct-thread {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  margin-top: 3px;
  margin-bottom: 0;
}

.direct-thread:first-child {
  margin-top: 0;
}

.direct-thread.thread--group-start {
  margin-top: 11px;
}

.direct-thread.thread--own {
  align-self: flex-end;
  align-items: flex-end;
}

.direct-thread.thread--other {
  align-self: flex-start;
  align-items: flex-start;
}

/* Direct messages do not use the room avatar column. The generic continuation
   rule reserves that column for room rows, which otherwise shifts every
   continuation bubble to the right in a DM thread. */
.direct-thread.thread--other,
.direct-thread.thread--group-continuation.thread--other {
  padding-left: 0;
}

.direct-thread .thread__stack {
  max-width: min(560px, 68%);
  position: relative;
  display: flex;
  flex-direction: column;
}

.direct-thread.thread--own .thread__stack {
  align-items: flex-end;
}

.direct-thread.thread--other .thread__stack {
  align-items: flex-start;
}

.direct-thread .thread__bubble {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 12.5rem;
  max-width: 100%;
  width: fit-content;
  padding: 6px 26px 5px 11px;
  font-size: 1.35rem;
  line-height: 1.42;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .2);
}

.direct-thread.thread--own .thread__bubble {
  background: linear-gradient(135deg, #0e5661, #0c757a);
  color: #f1fbfb;
  border-radius: 14px 14px 4px 14px;
  border: 1px solid rgba(45, 212, 191, .2);
  align-self: flex-end;
}

.direct-thread.thread--other .thread__bubble {
  background: #18283d;
  color: #f1f5f9;
  border-radius: 14px 14px 14px 4px;
  border: 1px solid rgba(148, 163, 184, .14);
  align-self: flex-start;
}

/* Subdued deleted message presentation across both DM and Room */
.thread.thread--deleted .thread__bubble,
.direct-thread.thread--deleted .thread__bubble {
  background: rgba(15, 23, 42, 0.45) !important;
  color: #94a3b8 !important;
  border: 1px dashed rgba(148, 163, 184, 0.22) !important;
  box-shadow: none !important;
}

.thread.thread--deleted .thread__deleted-text,
.direct-thread.thread--deleted .thread__deleted-text {
  color: #8da4be !important;
  font-style: italic;
  font-size: 1.25rem;
  margin: 0;
}

.direct-thread .thread__avatar, .direct-thread .thread__meta {
  display: none;
}

.thread__reply {
  display: block;
  width: 100%;
  text-align: left;
  padding: 5px 8px;
  margin-bottom: 5px;
  border-left: 3px solid #2dd4bf;
  border-radius: 6px;
  background: rgba(0, 0, 0, .25);
  cursor: pointer;
  border-top: 0;
  border-right: 0;
  border-bottom: 0;
  color: inherit;
  font-size: 1.15rem;
  transition: background .12s ease;
}

.thread__reply:hover {
  background: rgba(0, 0, 0, .38);
}

.thread__reply strong {
  display: block;
  color: #2dd4bf;
  font-size: 1.1rem;
  margin-bottom: 2px;
}

.thread__reply span {
  display: block;
  color: #cbd5e1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread__details {
  margin: 0;
  overflow-wrap: break-word;
  word-break: normal;
  line-height: 1.42;
  font-size: 1.35rem;
}

.thread__deleted-text {
  font-style: italic;
  color: rgba(255, 255, 255, .55);
}

/* Attachments */
.thread__attachment--image {
  display: block;
  border-radius: 10px;
  overflow: hidden;
  margin-top: 6px;
  max-width: 320px;
  max-height: 280px;
  cursor: pointer;
}

.thread__attachment--image img {
  width: 100%;
  height: auto;
  object-fit: cover;
  display: block;
  border-radius: 10px;
  transition: transform .15s ease;
}

.thread__attachment--image:hover img {
  transform: scale(1.02);
}

.thread__attachment--file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-top: 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, .25);
  border: 1px solid rgba(148, 163, 184, .15);
  text-decoration: none;
  color: #f8fafc;
  transition: background .12s ease;
}

.thread__attachment--file:hover {
  background: rgba(0, 0, 0, .38);
}

.thread__attachment-icon {
  font-size: 1.8rem;
}

.thread__attachment-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.thread__attachment-info strong {
  font-size: 1.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.thread__attachment-info small {
  color: #8fa5bc;
  font-size: 1.05rem;
}

.thread__attachment-action {
  font-size: 1.3rem;
  color: #2dd4bf;
}

/* Reactions */
.thread__reaction-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.thread__reaction-bar:empty {
  display: none;
}

.thread__reaction {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 12px;
  font-size: 1.15rem;
  background: rgba(15, 23, 42, .6);
  border: 1px solid rgba(148, 163, 184, .25);
  color: #e2e8f0;
  cursor: pointer;
  transition: transform .1s ease, background .1s ease;
}

.thread__reaction:hover {
  transform: scale(1.08);
  background: rgba(45, 212, 191, .2);
  border-color: #2dd4bf;
}

/* Quick Reaction Strip */
.thread__reaction-strip {
  position: absolute;
  z-index: 110;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 6px;
  border-radius: 20px;
  background: #101d2e;
  border: 1px solid rgba(45, 212, 191, .25);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
  top: -36px;
  right: 0;
  animation: dmMenuFadeIn .1s cubic-bezier(0.16, 1, 0.3, 1);
}

.thread--other .thread__reaction-strip {
  left: 0;
  right: auto;
}

.thread__reaction-strip[hidden] {
  display: none !important;
}

.thread__reaction-strip button {
  background: transparent;
  border: 0;
  padding: 3px 5px;
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 10px;
  transition: transform .1s ease, background .1s ease;
  line-height: 1;
}

.thread__reaction-strip button:hover,
.thread__reaction-strip button:focus-visible {
  transform: scale(1.25);
  background: rgba(45, 212, 191, .15);
  outline: none;
}

/* Bubble Meta */
.thread__bubble-meta {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  align-self: flex-end;
  margin-top: 2px;
  margin-left: auto;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
  line-height: 1.1;
}

.thread__edited {
  display: inline-block;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
  font-size: 1rem;
  color: rgba(255, 255, 255, .6);
  font-style: italic;
  line-height: 1;
}

.thread__date {
  display: inline-block;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, .7);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.direct-receipt {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
  font-size: 0;
  line-height: 1;
}

.direct-receipt::after {
  content: '✓';
  font-size: 1.1rem;
  color: rgba(255, 255, 255, .65);
  line-height: 1;
  white-space: nowrap;
}

.direct-receipt[data-state='delivered']::after {
  content: '✓✓';
  color: rgba(255, 255, 255, .65);
}

.direct-receipt[data-state='read']::after {
  content: '✓✓';
  color: #38efdb !important;
}

.thread__seen {
  font-size: 0;
  white-space: nowrap;
  word-break: normal;
  overflow-wrap: normal;
  flex-shrink: 0;
  line-height: 1;
}

.thread__seen::after {
  content: '✓✓';
  font-size: 1.1rem;
  color: #38efdb;
}

.thread__menu-button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  min-width: 22px;
  min-height: 22px;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255, 255, 255, .7);
  opacity: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
  transition: opacity .12s ease, background .12s ease, color .12s ease;
  z-index: 2;
}

.thread__menu-button .menu-chevron-icon {
  width: 14px;
  height: 14px;
  display: block;
  flex-shrink: 0;
}

.thread__menu-button:hover,
.thread__menu-button:focus-visible {
  background: rgba(255, 255, 255, .15);
  color: #ffffff;
  outline: none;
}

.thread:hover .thread__menu-button,
.thread__bubble:hover .thread__menu-button,
.thread:focus-within .thread__menu-button,
.thread__bubble:focus-within .thread__menu-button,
.thread__menu-button[aria-expanded="true"] {
  opacity: 1;
}

@media (hover: none), (max-width: 899px) {
  .thread__menu-button {
    opacity: .65;
  }
}

/* Context Menu */
.thread__menu {
  position: fixed;
  z-index: 120;
  width: 180px;
  min-width: 176px;
  max-width: 184px;
  padding: 8px;
  border-radius: 12px;
  background: #112032;
  border: 1px solid rgba(148, 163, 184, .2);
  box-shadow: 0 10px 28px rgba(0, 0, 0, .55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: dmMenuFadeIn .1s cubic-bezier(0.16, 1, 0.3, 1);
}

.thread__menu[hidden] {
  display: none !important;
}

@keyframes dmMenuFadeIn {
  from { opacity: 0; transform: translateY(2px); }
  to { opacity: 1; transform: translateY(0); }
}

.thread__menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thread__menu-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 38px;
  min-height: 38px;
  padding: 0 10px;
  box-sizing: border-box;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  font-size: 1.25rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background .1s ease, color .1s ease;
}

.thread__menu-list button .menu-icon,
.thread__menu-list button svg {
  width: 17px;
  height: 17px;
  min-width: 17px;
  min-height: 17px;
  flex: 0 0 17px;
  color: currentColor;
  opacity: .85;
}

.thread__menu-list button:hover,
.thread__menu-list button:focus-visible {
  background: rgba(83, 199, 232, .12);
  color: #ffffff;
  outline: none;
}

.thread__menu-list button.menu-item--danger {
  color: #ff9da8;
  border-top: 1px solid rgba(148, 163, 184, .14);
  border-radius: 0 0 8px 8px;
  margin-top: 3px;
  padding-top: 2px;
}

.thread__menu-list button.menu-item--danger:hover,
.thread__menu-list button.menu-item--danger:focus-visible {
  background: rgba(255, 113, 128, .15);
  color: #ffc7cd;
  outline: none;
}

/* Dropzone Overlay */
.direct-dropzone {
  position: absolute;
  inset: 0;
  z-index: 40;
  background: rgba(13, 24, 40, .92);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #2dd4bf;
  margin: 12px;
  border-radius: 14px;
}

.direct-dropzone[hidden] {
  display: none !important;
}

.direct-dropzone__content {
  text-align: center;
  color: #e2e8f0;
}

.direct-dropzone__icon {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 8px;
}

.direct-dropzone__content strong {
  font-size: 1.6rem;
  display: block;
  color: #2dd4bf;
  margin-bottom: 4px;
}

.direct-dropzone__content p {
  color: #94a3b8;
  font-size: 1.25rem;
  margin: 0;
}

/* Older messages button */
.direct-load-older {
  align-self: center;
  margin: 0 auto 12px;
  padding: 6px 14px;
  border: 1px solid rgba(148, 163, 184, .18);
  border-radius: 14px;
  color: #a9c0d3;
  background: rgba(22, 42, 63, .7);
  cursor: pointer;
  font-size: 1.2rem;
  transition: background .12s ease;
}

.direct-load-older:hover {
  background: rgba(22, 42, 63, .95);
  color: #ffffff;
}

.direct-load-older[hidden] {
  display: none !important;
}

/* Floating Scroll to Bottom */
.direct-scroll-bottom {
  position: absolute;
  right: 20px;
  bottom: 80px;
  z-index: 25;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #162a42;
  border: 1px solid rgba(148, 163, 184, .3);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  color: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.6rem;
  transition: transform .15s ease, background .15s ease;
}

.direct-scroll-bottom:hover {
  transform: translateY(-2px);
  background: #203957;
}

.direct-scroll-bottom[hidden] {
  display: none !important;
}

.direct-scroll-bottom__badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #2dd4bf;
  color: #07151e;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.direct-scroll-bottom__badge[hidden] {
  display: none !important;
}

/* Composer Area */
.direct-composer-wrap {
  flex: 0 0 auto;
  padding: 8px 16px 10px;
  background: #0f1c2e;
  border-top: 1px solid rgba(148, 163, 184, .14);
  position: relative;
  z-index: 15;
}

.direct-reply-bar, .direct-edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 6px 12px;
  margin-bottom: 6px;
  border-radius: 8px;
  background: #142438;
  border-left: 3px solid #2dd4bf;
}

.direct-reply-bar[hidden], .direct-edit-bar[hidden] {
  display: none !important;
}

.direct-reply-bar__content, .direct-edit-bar__content {
  min-width: 0;
  flex: 1;
}

.direct-reply-bar__label, .direct-edit-bar__label {
  font-size: 1.15rem;
  color: #2dd4bf;
  display: block;
}

.direct-reply-bar__text, .direct-edit-bar__text {
  margin: 2px 0 0;
  color: #cbd5e1;
  font-size: 1.25rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.direct-attachment-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 0;
  margin-bottom: 6px;
}

.direct-attachment-bar[hidden] {
  display: none !important;
}

.direct-attachment-bar__list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.direct-attachment-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  background: #182a40;
  border: 1px solid rgba(148, 163, 184, .2);
  color: #e2e8f0;
  font-size: 1.15rem;
}

.direct-attachment-chip__thumb {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 4px;
}

.direct-attachment-chip__icon {
  font-size: 1.4rem;
}

.direct-attachment-chip__info {
  display: flex;
  flex-direction: column;
  max-width: 140px;
}

.direct-attachment-chip__info strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.15rem;
}

.direct-attachment-chip__info small {
  color: #8ea4bb;
  font-size: 1rem;
}

.direct-attachment-chip__remove {
  font-size: 1.3rem;
  color: #94a3b8;
  cursor: pointer;
  background: transparent;
  border: 0;
  padding: 0 4px;
}

.direct-attachment-chip__remove:hover {
  color: #f87171;
}

.direct-status {
  min-height: 0;
  margin: 0 0 2px;
  color: #8da4bb;
  font-size: 1.1rem;
}

.typing-indicator {
  min-height: 0;
  margin: 0 0 4px;
  color: #2dd4bf;
  font-size: 1.15rem;
  font-style: italic;
}

.direct-composer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 6px;
  border: 1px solid rgba(148, 163, 184, .2);
  border-radius: 14px;
  background: #16263b;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.direct-composer:focus-within {
  border-color: #2dd4bf;
  box-shadow: 0 0 0 2px rgba(45, 212, 191, .15);
}

.direct-composer textarea {
  min-width: 0;
  flex: 1;
  align-self: center;
  width: 100%;
  min-height: 36px;
  height: 36px;
  resize: none;
  max-height: 130px;
  padding: 7px 4px;
  overflow-y: hidden;
  box-sizing: border-box;
  border: 0;
  outline: 0;
  color: #f8fafc;
  background: transparent;
  font-size: 1.35rem;
  line-height: 1.42;
}

.direct-composer .composer__leading {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.direct-composer .composer__attach,
.direct-composer .composer__emoji {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
}

.composer__attach-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  z-index: 50;
  min-width: 180px;
  padding: 6px;
  border-radius: 12px;
  background: #132235;
  border: 1px solid rgba(148, 163, 184, .25);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .55);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.composer__attach-menu[hidden] {
  display: none !important;
}

.attach-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  font-size: 1.25rem;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}

.attach-menu__item:hover {
  background: rgba(45, 212, 191, .15);
  color: #ffffff;
}

.direct-composer .composer__send,
.direct-composer .composer__mic {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  color: #042127;
  background: #2dd4bf;
  cursor: pointer;
  font-size: 1.35rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s ease, background .15s ease;
}

.direct-composer .composer__send:hover,
.direct-composer .composer__mic:hover {
  background: #38efdb;
  transform: scale(1.05);
}

.direct-composer .composer__send:focus-visible,
.direct-composer .composer__mic:focus-visible {
  outline: 2px solid #38efdb;
  outline-offset: 2px;
}

.direct-composer .composer__send[hidden],
.direct-composer .composer__mic[hidden] {
  display: none !important;
}

@media (max-width: 768px), (pointer: coarse) {
  .direct-composer .composer__attach,
  .direct-composer .composer__emoji {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }

  .direct-composer .composer__send,
  .direct-composer .composer__mic {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
  }

  .direct-call-overlay {
    inset: 64px 0 0;
    padding: 12px;
  }

  .direct-call-panel {
    padding: 16px;
  }

  .direct-call-media {
    min-height: 0;
  }

  .direct-call-overlay[data-call-type="video"] .direct-call-media {
    min-height: min(52vh, 360px);
  }
}

@media (max-width: 400px) {
  .direct-call-panel__header {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .direct-call-action {
    flex: 1 1 110px;
  }
}

.direct-composer .composer__emoji-picker {
  left: 0;
  right: auto;
  bottom: calc(100% + 8px);
}

/* Modals & Popovers */
.direct-info-modal, .direct-lightbox, .direct-delete-modal, .new-message-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.direct-info-modal[hidden], .direct-lightbox[hidden], .direct-delete-modal[hidden], .new-message-modal[hidden] {
  display: none !important;
}

.direct-info-modal__backdrop, .direct-lightbox__backdrop, .direct-delete-modal__backdrop, .new-message-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 11, 20, .78);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.direct-delete-modal__dialog {
  position: relative;
  z-index: 10;
  width: min(420px, calc(100vw - 32px));
  border-radius: var(--radius-md);
  background: #111f30;
  border: 1px solid rgba(148, 163, 184, .22);
  box-shadow: 0 20px 48px rgba(0, 0, 0, .65);
  padding: 2.2rem 2.4rem;
  animation: modalScaleIn .15s cubic-bezier(0.16, 1, 0.3, 1);
}

.new-message-modal__dialog {
  position: relative;
  z-index: 10;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 60px);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  background: #111f30;
  border: 1px solid rgba(148, 163, 184, .25);
  box-shadow: 0 24px 50px rgba(0, 0, 0, .7);
  padding: 20px;
  animation: modalScaleIn .15s cubic-bezier(0.16, 1, 0.3, 1);
}

.new-message-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.new-message-modal__header h3 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
}

.new-message-modal__search {
  position: relative;
  margin-bottom: 12px;
}

.new-message-modal__search input {
  width: 100%;
  height: 44px;
  padding: 10px 14px 10px 40px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, .2);
  background: #142438;
  color: #f1f5f9;
  font-size: 1.3rem;
  transition: border-color .15s ease, background-color .15s ease;
}

.new-message-modal__search input:focus {
  outline: none;
  border-color: #2dd4bf;
  background: #182b40;
}

.new-message-modal__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: #8da3ba;
  pointer-events: none;
}

.new-message-modal__dialog .new-message-results {
  max-height: 280px;
  overflow-y: auto;
  margin-top: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .2) transparent;
}

.new-message-result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: #d8e7f4;
  text-decoration: none;
  border-radius: 8px;
  font-size: 1.25rem;
  background: transparent;
  border: 1px solid transparent;
  text-align: left;
  cursor: pointer;
  width: 100%;
  transition: background .12s ease, border-color .12s ease;
}

.new-message-result:hover,
.new-message-result:focus-visible,
.new-message-result.is-focused {
  background: rgba(45, 212, 191, .14);
  border-color: rgba(45, 212, 191, .3);
  outline: none;
}

.new-message-result.is-loading {
  opacity: .6;
  pointer-events: none;
}

.new-message-result__copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.new-message-result__copy strong {
  font-size: 1.3rem;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.new-message-result__copy span {
  font-size: 1.15rem;
  color: #8da3ba;
}

.new-message-results__status {
  padding: 24px 12px;
  text-align: center;
  color: #8da3ba;
  font-size: 1.3rem;
}

.new-message-results__status strong,
.new-message-results__status span {
  display: block;
}

.new-message-results__status strong {
  color: var(--text-primary);
  margin-bottom: 6px;
}

.direct-composer-disabled {
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-size: .9rem;
}

.direct-composer--disabled {
  opacity: .68;
}

@keyframes modalScaleIn {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.direct-delete-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.2rem;
}

.direct-delete-modal__header h3 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  color: var(--text-primary);
}

.direct-delete-modal__body p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1.5;
}

.direct-delete-modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 2.4rem;
}

.direct-delete-modal__footer .btn {
  min-height: 4rem;
  padding: 0 1.8rem;
  font-size: 1.35rem;
}

.direct-delete-modal__footer .btn--danger {
  background: rgba(255, 113, 128, .18);
  border: 1px solid var(--danger-border);
  color: #ff9da8;
}

.direct-delete-modal__footer .btn--danger:hover,
.direct-delete-modal__footer .btn--danger:focus-visible {
  background: var(--danger);
  color: #0d1b2d;
  border-color: var(--danger);
}

.direct-info-modal__dialog {
  position: relative;
  z-index: 10;
  width: min(440px, calc(100% - 32px));
  border-radius: 16px;
  background: #111f30;
  border: 1px solid rgba(148, 163, 184, .25);
  box-shadow: 0 20px 45px rgba(0, 0, 0, .6);
  padding: 20px;
}

.direct-info-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(148, 163, 184, .14);
  padding-bottom: 10px;
}

.direct-info-modal__header h3 {
  margin: 0;
  font-size: 1.5rem;
  color: #f1f5f9;
}

.direct-info-modal__preview {
  padding: 10px 12px;
  border-radius: 8px;
  background: #182b40;
  color: #e2e8f0;
  font-size: 1.25rem;
  margin-bottom: 16px;
}

.direct-info-modal__list {
  display: grid;
  gap: 10px;
}

.direct-info-modal__row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(148, 163, 184, .08);
  font-size: 1.25rem;
}

.direct-info-modal__row strong {
  color: #2dd4bf;
}

.direct-info-modal__row span {
  color: #94a3b8;
}

.direct-lightbox__dialog {
  position: relative;
  z-index: 10;
  max-width: min(90vw, 900px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.direct-lightbox__dialog img {
  max-width: 100%;
  max-height: calc(90vh - 70px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 15px 40px rgba(0,0,0,.6);
}

.direct-lightbox__close {
  position: absolute;
  top: -40px;
  right: 0;
  color: #ffffff;
  font-size: 2.2rem;
  background: transparent;
  border: 0;
  cursor: pointer;
}

.direct-lightbox__footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  color: #cbd5e1;
  font-size: 1.25rem;
}

.direct-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  background: rgba(15, 23, 42, .92);
  color: #f8fafc;
  border: 1px solid #2dd4bf;
  padding: 8px 20px;
  border-radius: 24px;
  font-size: 1.25rem;
  box-shadow: 0 8px 25px rgba(0, 0, 0, .45);
  backdrop-filter: blur(8px);
}

.direct-toast[hidden] {
  display: none !important;
}

/* Highlights */
@keyframes dmHighlightPulse {
  0% { outline: 2px solid #2dd4bf; background-color: rgba(45, 212, 191, .2); }
  100% { outline: 2px solid transparent; background-color: transparent; }
}

.direct-thread.is-search-hit .thread__bubble,
.direct-thread.is-reply-hit .thread__bubble {
  animation: dmHighlightPulse 1.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Empty Placeholder */
.messages-placeholder {
  max-width: 430px;
  margin: auto;
  padding: 30px;
  text-align: center;
  color: #8ea4bc;
}

.messages-placeholder__mark {
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #042127;
  background: #2dd4bf;
  font-size: 2rem;
}

.messages-placeholder h2 {
  margin: 0 0 8px;
  color: #f1f5f9;
  font-size: 1.8rem;
}

.messages-placeholder p {
  margin: 0 0 20px;
  font-size: 1.35rem;
}

/* Responsive Overrides */
@media (min-width: 900px) and (max-width: 1024px) {
  .messages-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }
}

@media (max-width: 899px) {
  .messages-page {
    flex: 1 1 0%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    min-height: 0;
  }

  .messages-shell {
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    border-radius: 0;
    border: none;
    margin: 0;
    display: flex;
    flex-direction: column;
  }

  .messages-shell:not(.messages-shell--active) .messages-thread {
    display: none !important;
  }

  .messages-shell:not(.messages-shell--active) .messages-inbox {
    display: flex !important;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    height: 100%;
    flex: 1 1 0%;
    min-height: 0;
  }

  .messages-shell.messages-shell--active .messages-inbox {
    display: none !important;
  }

  .messages-shell.messages-shell--active .messages-thread {
    display: flex !important;
    width: 100%;
    height: 100%;
    flex: 1 1 0%;
    min-height: 0;
  }

  .direct-header__back {
    display: inline-flex;
  }

  .direct-thread .thread__stack {
    max-width: 86%;
  }

  .direct-thread .thread__bubble {
    max-width: 100%;
  }

  .thread__menu-button {
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   11. FOCUS / POMODORO PAGE
   -------------------------------------------------------------------------- */
.focus-page {
  padding: 3.6rem 0 6rem;
}

.focus-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34rem;
  gap: 2.4rem;
  align-items: start;
}

.focus-card {
  padding: 3.2rem;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.focus-card__header {
  max-width: 62rem;
  margin: 0 auto 2.8rem;
}

.focus-card__header h1 {
  margin-bottom: .8rem;
  font-size: clamp(2.6rem, 3.5vw, 3.8rem);
  letter-spacing: -.03em;
}

.focus-card__header p:last-child {
  margin-bottom: 0;
  color: var(--text-secondary);
}

.focus-task-field {
  max-width: 48rem;
  margin: 0 auto 2.4rem;
  text-align: left;
}

.focus-task-field select {
  width: 100%;
}

.timer {
  display: grid;
  place-items: center;
  gap: .8rem;
  padding: 3.5rem 1rem;
  margin-bottom: 2.4rem;
  background: radial-gradient(circle at center, var(--primary-glow), transparent 55%), var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.timer > span:first-child {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.timer strong {
  color: var(--text-primary);
  font-size: clamp(5.2rem, 10vw, 9.6rem);
  font-weight: 600;
  letter-spacing: -.06em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.timer-status {
  min-height: 2.4rem;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.mode-switcher {
  display: flex;
  justify-content: center;
  gap: .6rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}

.mode-button {
  min-height: 4.4rem;
  padding: 0 1.4rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 600;
  transition: all .15s ease;
}

.mode-button span {
  display: block;
  color: inherit;
  font-size: 1.1rem;
  font-weight: 400;
}

.mode-button:hover, .mode-button.is-active {
  color: var(--text-primary);
  background: var(--surface-raised);
  border-color: var(--border);
}

.mode-button.is-active {
  color: var(--primary);
  border-color: var(--primary-border);
}

.timer-controls {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.is-hidden {
  display: none !important;
}

.focus-feedback {
  min-height: 2.4rem;
  margin: 1.5rem 0 0;
  color: var(--text-muted);
  font-size: 1.25rem;
}

.focus-feedback.is-success { color: var(--success); }
.focus-feedback.is-error { color: var(--danger); }

.focus-side {
  display: grid;
  gap: 1.8rem;
}

.focus-stat {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.4rem;
}

.focus-stat strong {
  color: var(--text-primary);
  font-size: 2rem;
}

.focus-stat small {
  color: var(--text-muted);
  font-size: 1.3rem;
  font-weight: 400;
}

.weekly-card {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
}

.weekly-bars {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .8rem;
  align-items: end;
  padding: 2rem 1.6rem 1.6rem;
}

.week-day {
  display: grid;
  justify-items: center;
  gap: .5rem;
  min-width: 0;
}

.week-day strong {
  overflow: hidden;
  max-width: 100%;
  color: var(--text-secondary);
  font-size: 1.05rem;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.week-day small {
  color: var(--text-muted);
  font-size: 1.1rem;
}

.week-bar {
  display: flex;
  align-items: flex-end;
  width: 100%;
  height: 10rem;
  padding: .3rem;
  background: var(--bg);
  border-radius: 99px 99px .5rem .5rem;
}

.week-bar i {
  display: block;
  width: 100%;
  min-height: .4rem;
  height: var(--bar-height, 0%);
  background: linear-gradient(var(--primary-hover), var(--primary));
  border-radius: 99px 99px .4rem .4rem;
}

/* --------------------------------------------------------------------------
   12. STUDY TASKS & STUDY PLANNING
   -------------------------------------------------------------------------- */
.tasks-page {
  padding: 3.6rem 0 6rem;
}

.task-page__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 2.8rem;
}

.task-page__header h1 {
  margin: .4rem 0 .6rem;
  font-size: clamp(2.6rem, 3.5vw, 3.8rem);
  letter-spacing: -.03em;
}

.task-page__header p:last-child {
  margin: 0;
}

.task-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 2.4rem;
}

.summary-card {
  padding: 1.6rem 1.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.summary-card span {
  display: block;
  margin-bottom: .4rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.summary-card strong {
  color: var(--text-primary);
  font-size: 2.4rem;
  font-weight: 600;
}

.task-filters {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 1.8rem;
}

.task-filters a {
  padding: .8rem 1.4rem;
  min-height: 3.8rem;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  font-size: 1.25rem;
  font-weight: 600;
  text-decoration: none;
}

.task-filters a:hover, .task-filters a.is-active {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.6rem;
}

.task-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 2rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.task-card--overdue {
  border-color: var(--danger-border);
  background: var(--surface-raised);
}

.task-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.task-card h2 {
  margin: 1.4rem 0 .6rem;
  font-size: 1.9rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-card h2 a {
  color: var(--text-primary);
  text-decoration: none;
}

.task-card h2 a:hover {
  color: var(--primary);
}

.task-card__description {
  display: -webkit-box;
  min-height: 4.4rem;
  margin-bottom: 1.4rem;
  overflow: hidden;
  color: var(--text-secondary);
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-height: 1.5;
}

.task-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .8rem 1.4rem;
  min-height: 2.2rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.is-overdue {
  color: var(--danger);
  font-weight: 600;
}

.task-card__progress {
  margin-top: 1.5rem;
}

.task-card__progress-label {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .7rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.task-card__progress-label strong {
  color: var(--primary);
}

.task-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  min-width: 0;
  padding-top: 1.5rem;
  margin-top: auto;
  border-top: 1px solid var(--surface-border);
}

.task-card__cta {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 700;
}

.task-complete-label {
  color: var(--success);
  font-size: 1.25rem;
  font-weight: 700;
}

/* Task Detail */
.task-detail {
  width: min(100%, 94rem);
}

.task-detail__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2rem;
}

.task-detail__header h1 {
  margin: 1.2rem 0 0;
  font-size: clamp(2.4rem, 3.5vw, 3.6rem);
  letter-spacing: -.03em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task-detail__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  flex: 0 1 auto;
  gap: .8rem;
}

.task-detail__actions .btn {
  flex: 0 0 auto;
}

.task-detail__description {
  max-width: 72rem;
  margin: 2rem 0;
  color: var(--text-secondary);
  white-space: pre-line;
  line-height: 1.6;
}

.task-detail__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 2rem;
  padding: 1.5rem 0;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  font-size: 1.25rem;
}

.task-detail__meta strong {
  margin-left: .3rem;
  color: var(--text-secondary);
}

.task-detail__stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.2rem;
  margin: 2.2rem 0;
}

.task-detail__stats div {
  padding: 1.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.task-detail__stats span {
  display: block;
  margin-bottom: .4rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.task-detail__stats strong {
  color: var(--text-primary);
  font-size: 1.8rem;
}

.task-detail__progress {
  margin-bottom: 2.2rem;
}

.task-detail__status-actions {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding-bottom: 2.4rem;
}

.task-sessions {
  padding-top: 2.4rem;
  border-top: 1px solid var(--border);
}

.task-sessions .section-heading {
  margin: 0 0 1rem;
}

/* --------------------------------------------------------------------------
   13. PROFILE & SOCIAL DISCOVERY
   -------------------------------------------------------------------------- */
.profile-page {
  padding: 3.2rem 0 6rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 22rem minmax(0, 1fr) 30rem;
  gap: 2.4rem;
  align-items: start;
}

.profile-content {
  min-width: 0;
}

.profile-card {
  padding: 2.4rem 2rem;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  text-align: center;
}

.profile-card h1 {
  margin: 1.4rem 0 .4rem;
  font-size: 2.4rem;
}

.profile-card__username {
  margin-bottom: 1.4rem;
  color: var(--primary);
  font-size: 1.35rem;
}

.profile-card__bio {
  padding-top: 1.4rem;
  border-top: 1px solid var(--surface-border);
  color: var(--text-secondary);
  text-align: left;
  line-height: 1.5;
}

.profile-actions {
  display: flex;
  justify-content: center;
  gap: .8rem;
  margin-bottom: 1.6rem;
  flex-wrap: wrap;
}

.profile-follow-counts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .8rem;
  margin: 1.4rem 0;
}

.profile-follow-counts a {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: .6rem;
  min-height: 4.6rem;
  padding: .9rem 1rem;
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  text-align: center;
  text-decoration: none;
}

.profile-follow-counts a:hover {
  border-color: var(--primary-border);
}

.profile-follow-counts strong {
  color: var(--text-primary);
  font-size: 1.6rem;
}

.profile-follow-counts span {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.study-stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.6rem;
}

.study-stats div {
  padding: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.study-stats span {
  display: block;
  margin-bottom: .5rem;
  color: var(--text-muted);
  font-size: 1.15rem;
}

.study-stats strong {
  color: var(--text-primary);
  font-size: 1.5rem;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.section-heading h1, .section-heading h2 {
  margin: 0;
  font-size: 2.2rem;
}

.profile-section-heading {
  justify-content: flex-start;
  align-items: baseline;
  margin-top: 2.4rem;
  margin-bottom: 1.2rem;
}

.profile-section-heading .count {
  margin-left: .4rem;
}

.profile-section-heading--joined {
  margin-top: 2.8rem;
}

.profile-empty-state {
  padding: 2.2rem 1.6rem;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  text-align: left;
}

/* Discover Social */
.discover-page, .social-list-page, .notifications-page {
  padding-top: 3.6rem;
}

.discover-page .standalone__card, .social-list-page .standalone__card {
  width: min(100%, 104rem);
}

.notifications-page .standalone__card {
  width: min(100%, 88rem);
  padding: 2.4rem 2.8rem;
}

.discover-search {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  margin: 2.4rem 0 0;
}

.discover-search__field {
  min-width: 0;
}

.discover-search__field label {
  display: block;
  margin-bottom: .7rem;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 1.35rem;
}

.discover-search__control {
  position: relative;
}

.discover-search__control input {
  width: 100%;
  height: 4.4rem;
  min-width: 0;
  padding: 0 1.4rem 0 4.2rem;
  color: var(--text-primary);
  background: var(--input-background);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  font-size: 1.35rem;
}

.discover-search__control input::placeholder {
  color: var(--text-muted);
}

.discover-search__control input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: 0;
}

.discover-search__icon {
  position: absolute;
  top: 50%;
  left: 1.3rem;
  z-index: 1;
  width: 1.8rem;
  height: 1.8rem;
  color: var(--primary);
  pointer-events: none;
  transform: translateY(-50%);
}

.discover-search > .btn {
  align-self: end;
  min-height: 4.4rem;
  height: 4.4rem;
  padding: 0 1.8rem;
  font-size: 1.35rem;
}

.discover-tabs, .activity-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .6rem;
  margin-bottom: 2.8rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--border);
}

.discover-tabs {
  margin-top: 2rem;
}

.discover-tabs a, .activity-tabs a {
  padding: .8rem 1.4rem;
  min-height: 4rem;
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-weight: 700;
  text-decoration: none;
  font-size: 1.35rem;
}

.discover-tabs a:hover, .discover-tabs a.is-active, .activity-tabs a:hover, .activity-tabs a.is-active {
  color: var(--primary);
  background: var(--primary-soft);
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.4rem;
}

.user-card {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 1.8rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.user-card__identity {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
}

.user-card__identity:hover strong {
  color: var(--primary);
}

.user-card__copy {
  display: grid;
  min-width: 0;
}

.user-card__copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 1.4rem;
}

.user-card__copy span, .user-card__count {
  color: var(--text-muted);
  font-size: 1.2rem;
}

.user-card__bio {
  min-height: 3.8rem;
  margin: 1.3rem 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  color: var(--text-secondary);
  font-size: 1.3rem;
  line-height: 1.5;
}

.user-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 1.2rem;
  margin-top: auto;
  border-top: 1px solid var(--surface-border);
}

.follow-button, .follow-profile-button {
  min-height: 4.2rem;
  font-size: 1.25rem;
}

.notifications-page .standalone__header {
  margin-bottom: 2.2rem;
  text-align: center;
}

.notification-page__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.4rem;
  margin-bottom: 2.2rem;
}

.notification-page__intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
}

.notifications-page .standalone__header .eyebrow {
  margin: 0 0 .6rem;
  text-align: center;
}

.notifications-page .standalone__header h1 {
  margin-bottom: .6rem;
  text-align: center;
}

.notifications-page .notification-page__desc,
.notifications-page .standalone__header p:not(.eyebrow) {
  max-width: 60rem;
  margin: 0 auto;
  color: var(--text-secondary);
  font-size: 1.4rem;
  line-height: 1.5;
  text-align: center;
}

.notification-page__action {
  display: flex;
  justify-content: center;
}

.notification-list {
  display: grid;
  gap: .8rem;
}

.notification-item {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 1.4rem;
  padding: 1.2rem 1.6rem;
  min-height: 6.8rem;
  color: var(--text-secondary);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: background .15s ease, border-color .15s ease, transform .12s ease;
}

.notification-item:hover {
  background: var(--surface-hover);
  border-color: var(--border);
  transform: translateY(-1px);
}

.notification-item--unread {
  background: rgba(45, 212, 191, .06);
  border-color: rgba(45, 212, 191, .3);
}

.notification-item--unread:hover {
  background: rgba(45, 212, 191, .1);
  border-color: rgba(45, 212, 191, .45);
}

.notification-item__indicator {
  flex: 0 0 1rem;
  color: var(--text-muted);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notification-item--unread .notification-item__indicator {
  color: var(--primary);
}

.notification-item__content {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  text-align: left;
}

.notification-item__content p {
  margin: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  font-size: 1.35rem;
  color: var(--text-primary);
  line-height: 1.4;
  text-align: left;
}

.notification-item__content time {
  color: var(--text-muted);
  font-size: 1.15rem;
  text-align: left;
}

.notifications-page .empty-state {
  padding: 2.4rem 1.6rem 1.6rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 1.35rem;
  max-width: 54rem;
  margin-inline: auto;
}

.notifications-page .empty-state__icon {
  font-size: 2.8rem;
  line-height: 1;
  margin-bottom: 1.2rem;
}

.notifications-page .empty-state p {
  margin: 0 0 .5rem;
}

.notifications-page .empty-state p strong {
  color: var(--text-primary);
  font-size: 1.5rem;
}

.notifications-page .empty-state p:last-child {
  margin-bottom: 0;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1.5;
}

/* --------------------------------------------------------------------------
   14. FORMS, AUTH & STANDALONE PAGES
   -------------------------------------------------------------------------- */
.standalone {
  padding: 4.8rem 0 7rem;
}

.standalone__card {
  width: min(100%, 68rem);
  margin: 0 auto;
  padding: 3.2rem;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.standalone__card--narrow {
  width: min(100%, 52rem);
}

.auth-layout .standalone__card--narrow {
  width: min(100%, 54rem);
}

.profile-form-card {
  width: min(100%, 72rem);
}

.history-card {
  width: min(100%, 104rem);
  max-width: none;
}

.standalone__header {
  margin-bottom: 2.8rem;
  text-align: center;
}

.profile-form-page .standalone__header,
.history-card > .standalone__header {
  text-align: left;
}

.profile-form-page .standalone__header {
  margin-bottom: 2rem;
}

.standalone__header h1 {
  margin-bottom: .8rem;
  font-size: clamp(2.4rem, 3.5vw, 3.2rem);
}

.standalone__header p {
  margin-bottom: 0;
  color: var(--text-secondary);
}

.form {
  display: grid;
  gap: 1.8rem;
}

.form__group {
  display: grid;
  gap: .7rem;
}

.form__group label {
  color: var(--text-primary);
  font-size: 1.35rem;
  font-weight: 600;
}

.form__group input, .form__group textarea, .form__group select {
  width: 100%;
  padding: 1.15rem 1.3rem;
  color: var(--text-primary);
  background: var(--input-background);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  resize: vertical;
  font-size: 1.35rem;
}

.form__group textarea {
  min-height: 12rem;
  line-height: 1.5;
}

.room-form-page .form__group textarea {
  min-height: 14rem;
}

.task-form-page .form__group textarea {
  min-height: 9rem;
}

.profile-form-page .form__group textarea {
  min-height: 9rem;
}

.form__group input:focus, .form__group textarea:focus, .form__group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
  outline: 0;
}

.form__group input[aria-invalid="true"],
.form__group textarea[aria-invalid="true"],
.form__group select[aria-invalid="true"] {
  border-color: var(--danger-border);
  background: rgba(255, 113, 128, .04);
}

.form__group input[aria-invalid="true"]:focus,
.form__group textarea[aria-invalid="true"]:focus,
.form__group select[aria-invalid="true"]:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
  outline: 0;
}

.form__group select option {
  color: var(--text-primary);
  background: var(--surface);
}

.form__action {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1rem;
}

.auth-layout {
  min-height: calc(100vh - var(--nav-height));
  display: grid;
  place-items: center;
  padding: 4rem 0;
}

.auth-brand {
  margin-bottom: 2rem;
  text-align: center;
}

.auth-brand h1 {
  margin-bottom: .6rem;
  font-size: 3.2rem;
}

.auth-brand p {
  margin-bottom: 0;
  color: var(--primary);
  font-size: 1.35rem;
}

.auth-switch {
  margin: 2rem 0 0;
  color: var(--text-muted);
  text-align: center;
  font-size: 1.35rem;
}

.auth-switch a {
  margin-left: .4rem;
  font-weight: 700;
}

.form-submit {
  width: 100%;
  min-height: 4.4rem;
}

.form-section-heading {
  margin-bottom: 1.2rem;
}

.form-section-heading h2 {
  margin-bottom: .35rem;
  font-size: 1.75rem;
}

.form-section-heading p {
  margin: 0;
  color: var(--text-muted);
  font-size: 1.3rem;
}

.profile-form-section {
  padding-top: .4rem;
}

.profile-form-section + .profile-form-section {
  padding-top: 2rem;
  border-top: 1px solid var(--surface-border);
}

.form-grid {
  display: grid;
  gap: 1.5rem;
}

.form-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form__group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .6rem;
}

.form__group-header label {
  margin-bottom: 0;
}

.char-counter {
  font-size: 1.2rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.form__group--goal {
  max-width: 24rem;
}

/* Centered Social Profile Photo Editor */
.profile-form-section--photo .form-section-heading {
  text-align: center;
}

.profile-avatar-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 1.2rem;
  padding: .6rem 0;
  margin: 0 auto;
}

.profile-avatar-interactive {
  position: relative;
  display: inline-flex;
  flex-shrink: 0;
}

.profile-avatar-target {
  position: relative;
  display: inline-block;
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease;
}

.profile-avatar-target:hover {
  transform: scale(1.02);
}

.profile-avatar-target:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 4px;
}

.avatar--profile-edit {
  width: 12rem;
  height: 12rem;
  border-radius: 50%;
  border: 3px solid var(--surface-border);
  background: var(--surface-raised);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color .15s ease;
}

.profile-avatar-target:hover .avatar--profile-edit {
  border-color: var(--primary);
}

.avatar--profile-edit img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-camera-badge {
  position: absolute;
  bottom: .4rem;
  right: .4rem;
  width: 3.4rem;
  height: 3.4rem;
  background: var(--primary);
  color: var(--primary-ink);
  border: 3px solid var(--surface);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
  padding: 0;
  cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}

.profile-avatar-interactive:hover .avatar-camera-badge,
.avatar-camera-badge:focus-visible {
  background: var(--primary-hover);
  transform: scale(1.08);
}

.avatar-camera-badge:focus-visible {
  outline: 3px solid var(--primary-border);
  outline-offset: 3px;
}

.camera-icon-svg {
  display: block;
}

.profile-avatar-interactive input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.profile-avatar-interactive input[type="file"]:focus-visible ~ .profile-avatar-target,
.profile-avatar-interactive input[type="file"]:focus-visible + .profile-avatar-target {
  outline: 3px solid var(--primary-border);
  outline-offset: 4px;
}

.profile-avatar-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 1.2rem;
}

.profile-avatar-action {
  background: transparent;
  border: 0;
  padding: 4px 8px;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  border-radius: 6px;
  transition: color .12s ease, background .12s ease;
}

.profile-avatar-action:hover,
.profile-avatar-action:focus-visible {
  color: var(--primary-hover);
  background: rgba(83, 199, 232, .12);
  outline: none;
}

.profile-avatar-action--danger {
  color: #ff9da8;
}

.profile-avatar-action--danger:hover,
.profile-avatar-action--danger:focus-visible {
  color: #ff7180;
  background: rgba(255, 113, 128, .14);
}

.profile-avatar-action-sep {
  color: var(--text-muted);
  font-size: 1.2rem;
  user-select: none;
}

/* History */
.history-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.2rem;
  margin-bottom: 2.6rem;
}

.history-summary__item {
  padding: 1.4rem 1.6rem;
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.history-summary__item span {
  display: block;
  margin-bottom: .4rem;
  color: var(--text-muted);
  font-size: 1.2rem;
}

.history-summary__item strong {
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 600;
}

.history-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin-bottom: 1.6rem;
}

.history-table {
  width: 100%;
  min-width: 48rem;
  border-collapse: collapse;
  text-align: left;
}

.history-table th {
  padding: 1rem 1.2rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  font-size: 1.15rem;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.history-table td {
  padding: 1.4rem 1.2rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--surface-border);
  font-size: 1.35rem;
}

.history-table tr:last-child td {
  border-bottom: 0;
}

.history-table tbody tr:hover {
  background: var(--surface-muted);
}

.session-type {
  display: inline-flex;
  padding: .35rem .8rem;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: var(--radius-pill);
  font-size: 1.15rem;
  font-weight: 600;
}

.manual-session {
  padding: 2.2rem;
  margin-top: 2.4rem;
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-md);
}

.manual-session h2 {
  margin-bottom: .5rem;
  font-size: 1.8rem;
}

.manual-session > p {
  color: var(--text-muted);
  font-size: 1.25rem;
  margin-bottom: 1.6rem;
}

.history-table input, .history-table select, .manual-session input,
.form__group input[type="date"], .form__group input[type="datetime-local"] {
  color-scheme: dark;
}

.noscript-message {
  width: min(calc(100% - 4.8rem), 48rem);
  margin: 1.6rem auto;
  padding: 1.2rem 1.6rem;
  color: var(--text-primary);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  text-align: center;
}

/* --------------------------------------------------------------------------
   15. SYSTEMATIC RESPONSIVE BREAKPOINT ARCHITECTURE
   -------------------------------------------------------------------------- */

/* Ultra-Wide & Large Desktop (1728px+) */
@media (min-width: 1728px) {
  :root {
    --content-max: 1640px;
  }

  .container {
    padding-left: 3.6rem;
    padding-right: 3.6rem;
  }

  .dashboard-grid {
    grid-template-columns: 28rem minmax(0, 1fr) 36rem;
    gap: 3.2rem;
  }

  .task-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.4rem;
  }

  .messages-shell {
    width: min(1640px, calc(100% - 6.4rem));
    height: 100%;
    min-height: 0;
    max-height: none;
    grid-template-columns: 360px minmax(0, 1fr);
  }
}

/* Large Desktop (1440px–1727px) */
@media (min-width: 1440px) and (max-width: 1727px) {
  :root {
    --content-max: 1520px;
  }

  .container {
    padding-left: 3.2rem;
    padding-right: 3.2rem;
  }

  .dashboard-grid {
    grid-template-columns: 26rem minmax(0, 1fr) 34rem;
    gap: 2.8rem;
  }

  .task-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 2.2rem;
  }

  .messages-shell {
    width: min(1520px, calc(100% - 4.8rem));
    height: 100%;
    min-height: 0;
    max-height: none;
    grid-template-columns: 350px minmax(0, 1fr);
  }
}

/* Standard Desktop (1280px–1439px) */
@media (min-width: 1280px) and (max-width: 1439px) {
  .dashboard-grid {
    grid-template-columns: 23rem minmax(0, 1fr) 31rem;
    gap: 2.4rem;
  }

  .task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
  }
}

/* Small Desktop / Large Tablet (1024px–1279px) */
@media (min-width: 1024px) and (max-width: 1279px) {
  .dashboard-grid, .profile-grid {
    grid-template-columns: 21rem minmax(0, 1fr) 28rem;
    gap: 2rem;
  }

  .room-page .room {
    height: 100%;
    min-height: 0;
    max-height: none;
  }

  .messages-shell {
    height: 100%;
    min-height: 0;
    max-height: none;
    grid-template-columns: 310px minmax(0, 1fr);
  }
}

/* Tablet (768px–1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .menu-button {
    display: inline-flex;
  }

  .desktop-sidebar {
    display: none;
  }

  .nav-shell {
    grid-template-columns: auto 1fr auto;
    gap: 1.4rem;
    min-height: 6.6rem;
    padding-top: 1rem;
    padding-bottom: 1rem;
  }

  .brand small {
    display: none;
  }

  .nav-link--tasks {
    display: none;
  }

  .global-search {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: 100%;
  }

  .dashboard-grid, .profile-grid {
    grid-template-columns: 1fr;
    gap: 2.4rem;
  }

  .dashboard-right {
    grid-column: auto;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
  }

  .dashboard-right .activity-panel, .profile-grid .activity-panel {
    grid-column: 1 / -1;
    position: static;
    max-height: none;
  }

  .dashboard-right .activity-panel .activity-list, .profile-grid .activity-panel .activity-list {
    max-height: none;
    overflow-y: visible;
  }

  .focus-layout {
    grid-template-columns: 1fr;
    gap: 2.4rem;
  }

  .focus-side {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2rem;
  }

  .task-summary {
    grid-template-columns: repeat(2, 1fr);
  }

  .task-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .study-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* All Mobile & Phablet (< 768px) */
@media (max-width: 767px) {
  .menu-button {
    display: inline-flex;
  }

  .desktop-sidebar {
    display: none;
  }

  .site-header {
    position: sticky;
  }

  .nav-shell {
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    min-height: 6rem;
    padding-top: .6rem;
    padding-bottom: .6rem;
  }

  body:has(.messages-page) .global-search,
  body:has(.room-page) .global-search {
    display: none !important;
  }

  body:has(.messages-page) .nav-shell,
  body:has(.room-page) .nav-shell {
    min-height: 5.4rem;
    padding-top: .4rem;
    padding-bottom: .4rem;
  }

  .brand strong {
    font-size: 1.8rem;
  }

  .brand small {
    display: none;
  }

  .user-menu__name, .chevron-svg, .language-menu__current {
    display: none;
  }

  .create-room-label {
    display: none;
  }

  .nav-actions .nav-link, .nav-actions .notification-link {
    display: none;
  }

  .global-search {
    grid-column: 1 / -1;
    grid-row: 2;
    max-width: 100%;
    margin-top: .2rem;
  }

  .dashboard, .profile-page, .tasks-page, .focus-page, .standalone {
    padding-top: 2.4rem;
    padding-bottom: 4.8rem;
  }

  .dashboard-grid, .profile-grid, .focus-layout {
    grid-template-columns: 1fr;
    gap: 1.8rem;
  }

  .dashboard-right, .focus-side {
    grid-template-columns: 1fr;
    gap: 1.6rem;
  }

  .dashboard-right .activity-panel, .profile-grid .activity-panel {
    position: static;
    max-height: none;
  }

  .dashboard-right .activity-panel .activity-list, .profile-grid .activity-panel .activity-list {
    max-height: none;
    overflow-y: visible;
  }

  .notifications-page .standalone__card {
    padding: 2rem 1.6rem;
  }

  .feed-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1.4rem;
  }

  .feed-tools {
    justify-content: space-between;
    flex-wrap: wrap;
    width: 100%;
  }

  .empty-state--hero {
    padding: 2.4rem 1.6rem;
  }

  .task-page__header {
    flex-direction: column;
    align-items: stretch;
    gap: 1.4rem;
  }

  .task-page__header .btn {
    width: 100%;
    min-height: 4.4rem;
  }

  .task-summary {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
  }

  .task-grid {
    grid-template-columns: 1fr;
  }

  .task-detail__header {
    flex-direction: column;
    gap: 1.2rem;
  }

  .task-detail__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .task-detail__actions .btn {
    flex: 1 1 100%;
    min-height: 4.4rem;
  }

  .task-detail__stats {
    grid-template-columns: 1fr;
  }

  .task-detail__status-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .task-detail__status-actions form, .task-detail__status-actions .btn {
    width: 100%;
    min-height: 4.4rem;
  }

  .discover-search {
    grid-template-columns: 1fr;
  }

  .discover-search > .btn {
    width: 100%;
  }

  .user-grid {
    grid-template-columns: 1fr;
  }

  .form-grid--two {
    grid-template-columns: 1fr;
  }

  .form__action {
    flex-direction: column-reverse;
  }

  .form__action .btn {
    width: 100%;
    min-height: 4.4rem;
  }

  .history-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
  }

  .study-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .study-stats div:nth-child(5) {
    grid-column: 1 / -1;
  }

  .standalone__card {
    padding: 2.2rem 1.6rem;
  }

  /* Room Chat on Mobile */
  .room-page {
    flex: 1 1 0%;
    height: 100%;
    max-height: 100%;
    padding: 0;
    min-height: 0;
  }

  .room-page > .container {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    min-height: 0;
    padding: 0;
  }

  .room-page .room {
    height: 100%;
    max-height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
  }

  .room-page .room-header {
    min-height: 5.8rem;
    padding: .6rem 1.2rem;
  }

  .room-search {
    top: calc(100% + .4rem);
    right: 1rem;
    left: 1rem;
    width: auto;
  }

  .room-search__results {
    top: calc(100% + 5.2rem);
    right: 1rem;
    left: 1rem;
    width: auto;
  }

  .room-page .conversation {
    min-height: 0;
    padding: .8rem 1rem 1rem;
  }

  .thread__stack {
    max-width: 86%;
  }

  .thread__menu-button {
    opacity: 1;
  }

  .room-page .room__message {
    padding: .6rem 1rem .8rem;
  }

  /* Mobile Message Action Sheet */
  .thread__menu {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    border-radius: 18px 18px 0 0 !important;
    background: #0d1b2d !important;
    border: 1px solid var(--surface-border) !important;
    border-bottom: 0 !important;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, .65) !important;
    padding: 1.4rem 1.6rem calc(1.6rem + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 1000 !important;
    animation: sheetSlideUp .18s cubic-bezier(0.16, 1, 0.3, 1) !important;
  }

  .thread__menu::before {
    content: '';
    display: block;
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: rgba(148, 163, 184, .3);
    margin: 0 auto 1.2rem;
  }

  .thread__menu-list {
    display: grid;
    gap: .4rem;
  }

  .thread__menu-list button {
    min-height: 4.8rem;
    padding: 1.2rem 1.6rem;
    font-size: 1.45rem;
    font-weight: 500;
    border-radius: 10px;
  }

  .thread__menu-list button span {
    font-size: 1.7rem;
  }

  /* Mobile Delete Confirmation Bottom Sheet */
  .direct-delete-modal {
    align-items: flex-end;
  }

  .direct-delete-modal__dialog {
    width: 100%;
    max-width: 100%;
    border-radius: 18px 18px 0 0;
    border-bottom: 0;
    padding: 2rem 1.8rem calc(1.8rem + env(safe-area-inset-bottom, 0px));
    animation: sheetSlideUp .18s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .direct-delete-modal__footer {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: .8rem;
    margin-top: 2rem;
  }

  .direct-delete-modal__footer .btn {
    width: 100%;
    min-height: 4.8rem;
    font-size: 1.45rem;
  }

  @keyframes sheetSlideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* Standard Mobile (375px–479px) */
@media (max-width: 479px) {
  .container {
    padding-left: 1.4rem;
    padding-right: 1.4rem;
  }

  .room-card {
    padding: 1.6rem 1.4rem;
  }

  .room-card__top {
    flex-wrap: wrap;
    gap: .8rem;
  }

  .room-card__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .room-card__cta {
    align-self: flex-end;
  }

  .focus-card {
    padding: 2.2rem 1.4rem;
  }

  .timer {
    padding: 2.6rem .8rem;
  }

  .timer strong {
    font-size: clamp(4.8rem, 14vw, 7.5rem);
  }

  .mode-switcher {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: .4rem;
  }

  .mode-button {
    padding: 0 .4rem;
    font-size: 1.2rem;
    min-height: 4.4rem;
  }

  .timer-controls .btn {
    flex: 1 1 0;
    min-height: 4.4rem;
  }

  .profile-avatar-center {
    width: 100%;
  }

  .avatar-camera-badge {
    width: 4.4rem;
    height: 4.4rem;
    right: 0;
    bottom: 0;
  }

  .composer__emoji-picker {
    width: min(340px, calc(100vw - 20px)) !important;
    max-width: calc(100vw - 20px);
    height: min(340px, calc(100dvh - 90px));
    max-height: min(340px, calc(100dvh - 90px));
  }
}

/* Small Mobile (320px–374px) */
@media (max-width: 374px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .nav-shell {
    gap: .8rem;
  }

  .standalone__card {
    padding: 1.8rem 1.2rem;
  }

  .auth-brand h1 {
    font-size: 2.4rem;
  }

  .standalone__header h1,
  .standalone__header h2 {
    font-size: 2rem;
    overflow-wrap: break-word;
  }

  .brand strong {
    font-size: 1.5rem;
  }

  .brand img {
    width: 3.2rem;
    height: 3.2rem;
  }

  .nav-actions {
    gap: .4rem;
  }

  .btn--compact {
    padding: 0 .8rem;
    font-size: 1.25rem;
  }

  .timer strong {
    font-size: clamp(4.4rem, 16vw, 6.5rem);
  }

  .mode-button {
    font-size: 1.15rem;
    padding: 0 .2rem;
  }

  .history-summary, .task-summary, .study-stats {
    grid-template-columns: 1fr;
  }

  .study-stats div:nth-child(5) {
    grid-column: auto;
  }

  .thread__stack {
    max-width: 88%;
  }

  .composer__emoji-picker {
    width: min(310px, calc(100vw - 16px)) !important;
    max-width: calc(100vw - 16px);
  }
}

/* ==========================================================================
   Account Settings Area
   ========================================================================== */
.settings-page {
  padding: 3rem 0 5rem;
}

.settings-container {
  max-width: 1080px;
  margin: 0 auto;
}

.settings-page__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--surface-border);
}

.settings-page__header-content h1 {
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.settings-page__header-content p {
  color: var(--text-secondary);
  font-size: 1.4rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 2.5rem;
  align-items: start;
}

.settings-nav {
  position: sticky;
  top: 80px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  padding: 1rem;
}

.settings-nav__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.settings-nav__heading {
  padding: .8rem 1.2rem .35rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.settings-nav__icon {
  display: inline-grid;
  width: 1.8rem;
  place-items: center;
  color: currentColor;
  font-size: 1.45rem;
  line-height: 1;
}

.settings-nav__link {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.2rem;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 1.35rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-nav__link:hover {
  background: rgba(56, 189, 248, 0.08);
  color: var(--primary);
}

.settings-nav__link.is-active {
  background: rgba(56, 189, 248, 0.12);
  color: var(--primary);
  font-weight: 600;
}

.settings-nav__link--danger {
  color: var(--danger);
}

.settings-nav__link--danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.settings-panels {
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.settings-card {
  background: var(--surface);
  border: 1px solid var(--surface-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  scroll-margin-top: 80px;
}

.settings-card--danger {
  border-color: rgba(239, 68, 68, 0.35);
}

.settings-card__header {
  padding: 2rem 2.5rem 1.5rem;
  border-bottom: 1px solid var(--surface-border);
}

.settings-card__header h2 {
  font-size: 2rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

.settings-card__header p {
  color: var(--text-secondary);
  font-size: 1.3rem;
  margin: 0;
}

.settings-card__body {
  padding: 2rem 2.5rem;
}

.settings-card__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.settings-card__actions--split {
  justify-content: space-between;
}

.settings-link-muted {
  color: var(--text-muted);
  font-size: 1.3rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.settings-link-muted:hover {
  color: #38bdf8;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--surface-border);
  margin: 0;
}

.settings-subform {
  margin-top: 1.5rem;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
}

.settings-item__info {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.settings-item__label {
  font-size: 1.2rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
}

.settings-item__value {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 1.5rem;
  color: var(--text-primary);
}

.settings-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  font-size: 1.15rem;
  font-weight: 600;
}

.settings-badge--success {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.settings-badge--warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--danger);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.settings-alert {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  margin: 1.25rem 0;
  font-size: 1.35rem;
  line-height: 1.5;
}

.settings-alert--warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: var(--text-primary);
}

.settings-alert--danger {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: var(--danger-text);
}

.settings-profile-preview {
  display: flex;
  align-items: center;
  gap: 1.75rem;
}

.settings-profile-preview__meta {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.settings-profile-preview__meta strong {
  font-size: 1.7rem;
  color: var(--text-primary);
}

.settings-profile-preview__handle {
  font-size: 1.3rem;
  color: var(--primary);
}

.settings-profile-preview__bio {
  font-size: 1.35rem;
  color: var(--text-secondary);
  margin: 0.3rem 0;
}

.settings-profile-preview__goal {
  font-size: 1.25rem;
  color: var(--text-secondary);
}

.settings-language-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
}

.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.8rem;
}

.settings-choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.settings-choice-card {
  display: grid;
  gap: .45rem;
  min-height: 9rem;
  padding: 1.3rem;
  color: var(--text-secondary);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.settings-choice-card:hover,
.settings-choice-card.is-selected {
  color: var(--text-primary);
  border-color: var(--primary);
  background: var(--primary-soft);
}

.settings-choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.settings-choice-card__title {
  color: inherit;
  font-size: 1.45rem;
  font-weight: 700;
}

.settings-choice-card small {
  color: var(--text-muted);
  font-size: 1.2rem;
  line-height: 1.4;
}

.settings-lang-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1.2rem 1.4rem;
  background: var(--surface-raised);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 1.4rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.settings-lang-button:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--primary);
}

.settings-lang-button.is-active {
  background: rgba(56, 189, 248, 0.12);
  border-color: var(--primary);
}

.settings-lang-button .language-flag {
  width: 22px;
  height: 16px;
  border-radius: 2px;
  object-fit: cover;
}

.settings-checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  cursor: pointer;
}

.settings-checkbox-label input[type="checkbox"] {
  width: 1.8rem;
  height: 1.8rem;
  accent-color: #06b6d4;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.settings-checkbox-label span {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.settings-checkbox-label strong {
  font-size: 1.4rem;
  color: var(--text-primary);
}

.settings-checkbox-label small {
  font-size: 1.25rem;
  color: var(--text-secondary);
}

.settings-privacy-summary {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.5rem;
  padding: 1.25rem;
  background: var(--surface-muted);
  border: 1px solid var(--surface-border);
  border-radius: 8px;
}

.settings-privacy-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  color: var(--text-secondary);
  font-size: 1.3rem;
}

.settings-privacy-item .ui-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--primary);
}

.settings-alert--info {
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  color: var(--text-secondary);
}

@media (max-width: 860px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    position: static;
    overflow-x: auto;
  }

  .settings-nav__list {
    flex-direction: row;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .settings-card__header,
  .settings-card__body {
    padding: 1.5rem;
  }

  .settings-form-grid,
  .settings-choice-grid {
    grid-template-columns: 1fr;
  }

  .settings-page__header {
    flex-direction: column;
  }

  .settings-page__header-content h1 {
    font-size: 2.3rem;
  }
}

/* ==========================================================================
   Theme variants
   ========================================================================== */
html[data-theme="light"] {
  /* A cool blue-gray canvas keeps white content surfaces visually anchored. */
  --bg: #eaf1f6;
  --surface: #ffffff;
  --surface-raised: #f7fbfd;
  --surface-muted: #eef5f9;
  --surface-hover: #e1f0f5;
  --input-background: #fbfdff;
  --border: #c4d6e1;
  --surface-border: rgba(62, 99, 122, .26);
  --text-primary: #102a43;
  --text-secondary: #456176;
  --text-muted: #657e8f;
  --primary: #087f9f;
  --primary-hover: #056982;
  --primary-ink: #ffffff;
  --primary-soft: rgba(8, 127, 159, .11);
  --primary-border: rgba(8, 127, 159, .4);
  --primary-glow: rgba(8, 127, 159, .12);
  --danger: #c83f53;
  --danger-soft: rgba(200, 63, 83, .1);
  --danger-border: rgba(200, 63, 83, .42);
  --danger-text: #9d2e40;
  --success: #147b56;
  --success-soft: rgba(20, 123, 86, .11);
  --success-border: rgba(20, 123, 86, .35);
  --success-text: #147b56;
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, .1);
  --warning-border: rgba(180, 83, 9, .35);
  --warning-text: #92400e;
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, .1);
  --info-border: rgba(2, 132, 199, .35);
  --info-text: #0369a1;
  --shadow-sm: 0 2px 8px rgba(24, 57, 78, .07);
  --shadow-soft: 0 8px 24px rgba(24, 57, 78, .09);
  --shadow: 0 16px 40px rgba(24, 57, 78, .12);
  --chat-incoming-bg: #f7fbfd;
  --chat-outgoing-bg: #d9f0f2;
  --chat-incoming-text: #102a43;
  --chat-outgoing-text: #102a43;
  --chat-meta: #5d7788;
  --chat-reply-bg: rgba(214, 231, 237, .82);
  --chat-composer-bg: #f7fbfd;
}

html[data-theme="light"] .site-header {
  background: rgba(247, 251, 253, .96);
  border-bottom-color: rgba(62, 99, 122, .3);
  box-shadow: 0 2px 12px rgba(24, 57, 78, .07);
}

html[data-theme="light"] .mobile-nav-backdrop {
  background: rgba(16, 42, 67, .34);
}

html[data-theme="light"] .btn--danger {
  color: var(--danger-text);
}

html[data-theme="light"] .btn--danger:hover {
  color: var(--danger-text);
}

/* Keep legacy chat controls on the same surface hierarchy as the rest of the
   application. These components predate the shared token layer and retain
   literal dark values in their base rules. */
html[data-theme="light"] .room-page .room,
html[data-theme="light"] .messages-shell {
  background: var(--surface);
  border-color: var(--surface-border);
  box-shadow: var(--shadow);
}

html[data-theme="light"] .room-page .conversation {
  background: var(--surface-muted);
  scrollbar-color: var(--border) transparent;
}

html[data-theme="light"] .room-page .conversation::-webkit-scrollbar-thumb {
  background: var(--border);
}

html[data-theme="light"] .messages-shell,
html[data-theme="light"] .messages-inbox,
html[data-theme="light"] .messages-thread,
html[data-theme="light"] .room-page,
html[data-theme="light"] .room-layout,
html[data-theme="light"] .modal,
html[data-theme="light"] .modal__content {
  color: var(--text-secondary);
  background: var(--surface);
  border-color: var(--surface-border);
}

html[data-theme="light"] .messages-inbox {
  background: var(--surface-raised);
}

html[data-theme="light"] .messages-inbox__header,
html[data-theme="light"] .direct-header,
html[data-theme="light"] .direct-composer-wrap {
  background: var(--surface);
  border-color: var(--surface-border);
}

html[data-theme="light"] .messages-inbox__header h1,
html[data-theme="light"] .direct-header h2,
html[data-theme="light"] .conversation-list__copy strong,
html[data-theme="light"] .new-message-result__copy strong {
  color: var(--text-primary);
}

html[data-theme="light"] .messages-inbox__header p,
html[data-theme="light"] .conversation-list__copy span,
html[data-theme="light"] .conversation-list__meta,
html[data-theme="light"] .messages-empty-list,
html[data-theme="light"] .direct-header p,
html[data-theme="light"] .direct-search__count,
html[data-theme="light"] .new-message-result__copy span,
html[data-theme="light"] .new-message-results__status,
html[data-theme="light"] .messages-placeholder {
  color: var(--text-muted);
}

html[data-theme="light"] .messages-search input,
html[data-theme="light"] .new-message-panel,
html[data-theme="light"] .new-message-modal__search input,
html[data-theme="light"] .direct-search,
html[data-theme="light"] .direct-search input,
html[data-theme="light"] .direct-reply-bar,
html[data-theme="light"] .direct-edit-bar,
html[data-theme="light"] .direct-attachment-chip,
html[data-theme="light"] .direct-composer {
  color: var(--text-primary);
  background: var(--input-background);
  border-color: var(--surface-border);
}

html[data-theme="light"] .messages-search input:focus,
html[data-theme="light"] .new-message-modal__search input:focus,
html[data-theme="light"] .direct-search input:focus,
html[data-theme="light"] .direct-composer:focus-within {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

html[data-theme="light"] .conversation-list__item {
  border-color: rgba(62, 99, 122, .12);
}

html[data-theme="light"] .conversation-list__item:hover,
html[data-theme="light"] .new-message-result:hover,
html[data-theme="light"] .new-message-result:focus-visible,
html[data-theme="light"] .new-message-result.is-focused {
  background: var(--primary-soft);
  border-color: var(--primary-border);
}

html[data-theme="light"] .conversation-list__item.is-active {
  background: var(--primary-soft);
  border-left-color: var(--primary);
}

html[data-theme="light"] .messages-thread {
  background-color: var(--surface-muted);
  background-image: radial-gradient(rgba(8, 127, 159, .07) 1px, transparent 0);
}

html[data-theme="light"] .direct-header p.is-online,
html[data-theme="light"] .conversation-list__tick,
html[data-theme="light"] .direct-reply-bar__label,
html[data-theme="light"] .direct-edit-bar__label,
html[data-theme="light"] .typing-indicator {
  color: var(--primary);
}

html[data-theme="light"] .direct-header__back,
html[data-theme="light"] .direct-search__nav-btn,
html[data-theme="light"] .direct-search__close {
  color: var(--text-secondary);
}

html[data-theme="light"] .direct-header-menu,
html[data-theme="light"] .composer__attach-menu,
html[data-theme="light"] .direct-info-modal__dialog,
html[data-theme="light"] .direct-delete-modal__dialog,
html[data-theme="light"] .new-message-modal__dialog {
  background: var(--surface);
  border-color: var(--surface-border);
  box-shadow: var(--shadow);
}

html[data-theme="light"] .direct-header-menu__item,
html[data-theme="light"] .attach-menu__item,
html[data-theme="light"] .new-message-result {
  color: var(--text-secondary);
}

html[data-theme="light"] .direct-header-menu__item:hover,
html[data-theme="light"] .attach-menu__item:hover {
  color: var(--text-primary);
  background: var(--primary-soft);
}

html[data-theme="light"] .thread__bubble,
html[data-theme="light"] .direct-thread .thread__bubble {
  color: var(--text-primary);
  background: var(--surface-raised);
  border-color: var(--surface-border);
  box-shadow: var(--shadow-sm);
}

html[data-theme="light"] .thread--own .thread__bubble,
html[data-theme="light"] .direct-thread .thread--own .thread__bubble {
  color: var(--chat-outgoing-text);
  background: var(--chat-outgoing-bg);
  border-color: rgba(8, 127, 159, .2);
}

html[data-theme="light"] .direct-thread.thread--other .thread__bubble {
  background: var(--chat-incoming-bg);
  color: var(--chat-incoming-text);
}

html[data-theme="light"] .thread__reply {
  background: var(--chat-reply-bg);
  border-left-color: var(--primary);
}

html[data-theme="light"] .thread__reply:hover,
html[data-theme="light"] .thread__attachment--file:hover {
  background: var(--surface-hover);
}

html[data-theme="light"] .thread__reply strong,
html[data-theme="light"] .thread__attachment-action {
  color: var(--primary);
}

html[data-theme="light"] .thread__reply span,
html[data-theme="light"] .thread__attachment--file,
html[data-theme="light"] .thread__attachment-info small,
html[data-theme="light"] .thread__reaction {
  color: var(--text-secondary);
}

html[data-theme="light"] .thread__attachment--file,
html[data-theme="light"] .thread__reaction,
html[data-theme="light"] .date-separator span {
  background: var(--surface-raised);
  border-color: var(--surface-border);
}

html[data-theme="light"] .thread__reaction {
  color: var(--text-secondary);
}

html[data-theme="light"] .thread__reaction:hover {
  background: var(--primary-soft);
}

html[data-theme="light"] .date-separator span {
  color: var(--text-muted);
  box-shadow: var(--shadow-sm);
}

html[data-theme="light"] .direct-scroll-bottom {
  color: var(--primary-ink);
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

html[data-theme="light"] .direct-scroll-bottom:hover {
  background: var(--primary-hover);
}

html[data-theme="light"] .direct-scroll-bottom__badge,
html[data-theme="light"] .direct-composer .composer__send,
html[data-theme="light"] .direct-composer .composer__mic {
  color: var(--primary-ink);
  background: var(--primary);
}

html[data-theme="light"] .direct-composer textarea {
  color: var(--text-primary);
}

html[data-theme="light"] .direct-call-overlay {
  background: rgba(226, 232, 240, .82);
}

html[data-theme="light"] .direct-call-panel {
  color: var(--text-primary);
  background: var(--surface);
  border-color: var(--surface-border);
  box-shadow: var(--shadow);
}

html[data-theme="light"] .direct-call-media {
  background: var(--surface-muted);
}

html[data-theme="light"] .direct-call-status {
  color: var(--text-secondary);
}

html[data-theme="light"] .direct-call-action {
  color: var(--text-primary);
  background: var(--surface-raised);
  border-color: var(--surface-border);
}

html[data-theme="light"] .direct-call-popover {
  color: var(--text-primary);
  background: var(--surface);
  border-color: var(--surface-border);
  box-shadow: var(--shadow);
}

html[data-theme="light"] .direct-call-popover::before {
  border-color: var(--surface-border);
}

html[data-theme="light"] .direct-composer .composer__send:hover,
html[data-theme="light"] .direct-composer .composer__mic:hover {
  background: var(--primary-hover);
}

html[data-theme="light"] .direct-info-modal__header,
html[data-theme="light"] .direct-info-modal__row {
  border-color: var(--surface-border);
}

html[data-theme="light"] .direct-info-modal__header h3,
html[data-theme="light"] .direct-info-modal__preview {
  color: var(--text-primary);
}

html[data-theme="light"] .direct-info-modal__preview,
html[data-theme="light"] .direct-load-older {
  background: var(--surface-muted);
  border-color: var(--surface-border);
}

html[data-theme="light"] .direct-info-modal__row strong {
  color: var(--primary);
}

html[data-theme="light"] .direct-info-modal__row span,
html[data-theme="light"] .direct-lightbox__footer {
  color: var(--text-secondary);
}

html[data-theme="light"] .direct-lightbox__close {
  color: var(--text-primary);
}

html[data-theme="light"] .direct-toast {
  color: var(--text-primary);
  background: rgba(247, 251, 253, .96);
  border-color: var(--primary);
  box-shadow: var(--shadow-soft);
}

/* Settings-specific controls use the same tokens as the application shell. */
html[data-theme="light"] .settings-nav__link:hover,
html[data-theme="light"] .settings-lang-button:hover {
  background: var(--primary-soft);
}

html[data-theme="light"] .settings-nav__link.is-active,
html[data-theme="light"] .settings-lang-button.is-active {
  background: var(--primary-soft);
}

html[data-theme="light"] .settings-card--danger {
  border-color: var(--danger-border);
}

html[data-theme="light"] .settings-alert--warning {
  background: rgba(245, 158, 11, .12);
  border-color: rgba(180, 112, 8, .32);
}

html[data-theme="light"] .settings-alert--danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger-text);
}

html[data-theme="light"] input[type="checkbox"],
html[data-theme="light"] input[type="radio"] {
  accent-color: var(--primary);
}

html[data-theme="light"] .form__group input[aria-invalid="true"],
html[data-theme="light"] .form__group textarea[aria-invalid="true"],
html[data-theme="light"] .form__group select[aria-invalid="true"] {
  background: rgba(200, 63, 83, .04);
}

html[data-theme="light"] .flash__close:hover,
html[data-theme="light"] .flash__close:focus-visible {
  background: rgba(0, 0, 0, .06);
}

/* Accessibility: Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
.notification-item__actions,
.profile-request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.profile-message-help {
  flex-basis: 100%;
  max-width: 28rem;
  margin: .25rem 0 0;
  color: var(--text-muted, #8ea3b8);
  font-size: .85rem;
}

.user-card__shared-room {
  color: var(--text-muted, #8ea3b8);
  font-size: .78rem;
}

.new-message-modal__discovery {
  margin: .75rem 0 0;
  text-align: center;
  font-size: .85rem;
}
