/* ==========================================================================
   Components - Reusable UI Components
   ========================================================================== */

.component-playground-page {
  min-height: 100vh;
  background: var(--color-app-shell-bg);
}

/* Panel - Generic container */
.panel {
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
}

.panel--shadow {
  border: none;
  box-shadow: var(--shadow-lg);
}

/* Card - Content container */
.card {
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card__header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.card__body {
  padding: var(--space-6);
}

.card__body:has(> table) {
  overflow-x: auto;
}

.card__footer {
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  background: var(--color-tinted-surface);
}

/* Alert - Flash messages */
.alert {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.alert--success {
  color: var(--color-success-700);
  background-color: var(--color-success-bg);
  border: 1px solid var(--color-success-border);
}

.alert--error {
  color: var(--color-danger-700);
  background-color: var(--color-danger-bg);
  border: 1px solid var(--color-danger-border);
}

.alert--warning {
  color: var(--color-warning-600);
  background-color: var(--color-warning-bg);
  border: 1px solid var(--color-warning-border);
}

.alert--info {
  color: var(--color-primary-700);
  background-color: var(--color-primary-50);
  border: 1px solid var(--color-primary-200);
}

/* Auth Layout - Centered login/signup pages */
.auth-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-6);
  padding: var(--space-8) var(--space-4);
  background: var(--color-tinted-surface);
}

.auth-panel {
  width: 100%;
  max-width: 24rem;
  background: var(--color-component-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
}

.auth-panel__header {
  text-align: center;
  margin-bottom: var(--space-6);
}

.auth-panel__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin-bottom: var(--space-2);
}

.auth-panel__subtitle {
  color: var(--color-ink-light);
  font-size: var(--text-sm);
}

/* Dev quick-login picker (development only) */
.auth-dev-picker {
  width: 100%;
  max-width: 48rem;
  background: var(--color-component-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-6);
  border: 2px dashed var(--color-warning-400);
}

.auth-dev-picker__label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-warning-600);
  margin-bottom: var(--space-4);
}

.auth-dev-picker__group {
  margin-bottom: var(--space-4);
}

.auth-dev-picker__group:last-child {
  margin-bottom: 0;
}

.auth-dev-picker__school {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-1);
  border-bottom: 1px solid var(--color-border);
}

.auth-dev-picker__btn {
  display: inline-block;
  margin: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-family: inherit;
  background: var(--color-tinted-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-ink);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

.auth-dev-picker__btn:hover {
  background: var(--color-primary-50, #eff6ff);
  border-color: var(--color-primary-600);
  color: var(--color-primary-600);
}

/* Badge */
.badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--font-normal);
  border-radius: var(--radius-full);
  background: var(--color-gray-100);
  color: var(--color-ink-light);
  border: 1px solid transparent;
}

.badge--primary {
  background: var(--color-primary-100);
  color: var(--color-primary-700);
}

.badge--secondary {
  background: var(--color-secondary-100);
  color: var(--color-secondary-700);
}

.badge--warning {
  background: var(--color-warning-bg);
  color: var(--color-warning-700, #a16207);
  border-color: var(--color-warning-border);
}

.badge--success {
  background: var(--color-success-bg);
  color: var(--color-success-700);
}

.badge--danger {
  background: var(--color-danger-bg);
  color: var(--color-danger-700);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) .badge {
    background: transparent;
    border-color: var(--color-gray-600);
    color: var(--color-gray-300);
  }
  :root:not([data-color-scheme="light"]) .badge--primary {
    background: transparent;
    border-color: var(--color-primary-400);
    color: var(--color-primary-300);
  }
  :root:not([data-color-scheme="light"]) .badge--secondary {
    background: transparent;
    border-color: var(--color-secondary-600);
    color: color-mix(in srgb, var(--theme-secondary) 60%, white);
  }
  :root:not([data-color-scheme="light"]) .badge--success {
    background: transparent;
    border-color: var(--color-success-600);
    color: var(--color-success-500);
  }
  :root:not([data-color-scheme="light"]) .badge--danger {
    background: transparent;
    border-color: color-mix(in srgb, var(--color-danger-600) 60%, transparent);
    color: color-mix(in srgb, var(--color-danger-600) 80%, white);
  }
  :root:not([data-color-scheme="light"]) .badge--warning {
    background: transparent;
    border-color: color-mix(in srgb, var(--color-warning-500) 60%, transparent);
    color: color-mix(in srgb, var(--color-warning-500) 80%, white);
  }
  :root:not([data-color-scheme="light"]) .feed-filter__count {
    background: var(--color-gray-700);
    color: var(--color-gray-200);
  }
}

:root[data-color-scheme="dark"] .badge {
  background: transparent;
  border-color: var(--color-gray-600);
  color: var(--color-gray-300);
}
:root[data-color-scheme="dark"] .badge--primary {
  background: transparent;
  border-color: var(--color-primary-400);
  color: var(--color-primary-300);
}
:root[data-color-scheme="dark"] .badge--secondary {
  background: transparent;
  border-color: var(--color-secondary-600);
  color: color-mix(in srgb, var(--theme-secondary) 60%, white);
}
:root[data-color-scheme="dark"] .badge--success {
  background: transparent;
  border-color: var(--color-success-600);
  color: var(--color-success-500);
}
:root[data-color-scheme="dark"] .badge--danger {
  background: transparent;
  border-color: color-mix(in srgb, var(--color-danger-600) 60%, transparent);
  color: color-mix(in srgb, var(--color-danger-600) 80%, white);
}
:root[data-color-scheme="dark"] .badge--warning {
  background: transparent;
  border-color: color-mix(in srgb, var(--color-warning-500) 60%, transparent);
  color: color-mix(in srgb, var(--color-warning-500) 80%, white);
}
:root[data-color-scheme="dark"] .feed-filter__count {
  background: var(--color-gray-700);
  color: var(--color-gray-200);
}

/* Avatar */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-full);
  background: var(--color-primary-100);
  color: var(--color-primary-700);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

/* Avatar group (iMessage-style stacked avatars) */
.avatar-group {
  position: relative;
  flex-shrink: 0;
  width: 3.5rem;
  height: 3.5rem;
}

.avatar-group__item {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--color-primary-600);
  color: white;
  font-weight: var(--font-semibold);
  box-shadow: 0 0 0 2px var(--color-surface);
  overflow: hidden;
}

.avatar-group__item--img {
  object-fit: cover;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--color-surface);
}

.avatar-group__item--more {
  background: var(--color-gray-400);
  color: white;
  font-size: 0.75rem;
}

/* 1 avatar: centered, full size */
.avatar-group--1 .avatar-group__item,
.avatar-group--1 .avatar-group__item--img {
  width: 3.5rem;
  height: 3.5rem;
  font-size: var(--text-base);
  top: 0;
  left: 0;
}

/* 2 avatars: diagonal overlap */
.avatar-group--2 .avatar-group__item,
.avatar-group--2 .avatar-group__item--img {
  width: 2.25rem;
  height: 2.25rem;
  font-size: 0.75rem;
}
.avatar-group--2 .avatar-group__item:nth-child(1),
.avatar-group--2 .avatar-group__item--img:nth-child(1) { top: 0; left: 0; }
.avatar-group--2 .avatar-group__item:nth-child(2),
.avatar-group--2 .avatar-group__item--img:nth-child(2) { bottom: 0; right: 0; }

/* 3 avatars: 2 on top, 1 bottom center */
.avatar-group--3 .avatar-group__item,
.avatar-group--3 .avatar-group__item--img {
  width: 2rem;
  height: 2rem;
  font-size: 0.7rem;
}
.avatar-group--3 .avatar-group__item:nth-child(1),
.avatar-group--3 .avatar-group__item--img:nth-child(1) { top: 0; left: 0.125rem; }
.avatar-group--3 .avatar-group__item:nth-child(2),
.avatar-group--3 .avatar-group__item--img:nth-child(2) { top: 0; right: 0.125rem; }
.avatar-group--3 .avatar-group__item:nth-child(3),
.avatar-group--3 .avatar-group__item--img:nth-child(3) { bottom: 0; left: 50%; transform: translateX(-50%); }

/* 4+ avatars: 2x2 grid */
.avatar-group--4 .avatar-group__item,
.avatar-group--4 .avatar-group__item--img {
  width: 1.625rem;
  height: 1.625rem;
  font-size: 0.625rem;
}
.avatar-group--4 .avatar-group__item:nth-child(1),
.avatar-group--4 .avatar-group__item--img:nth-child(1) { top: 0; left: 0; }
.avatar-group--4 .avatar-group__item:nth-child(2),
.avatar-group--4 .avatar-group__item--img:nth-child(2) { top: 0; right: 0; }
.avatar-group--4 .avatar-group__item:nth-child(3),
.avatar-group--4 .avatar-group__item--img:nth-child(3) { bottom: 0; left: 0; }
.avatar-group--4 .avatar-group__item:nth-child(4),
.avatar-group--4 .avatar-group__item--img:nth-child(4) { bottom: 0; right: 0; }

/* Sidebar */
.app-shell {
  height: calc(100vh - var(--masquerade-banner-height, 0px));
  display: flex;
  background: var(--color-app-shell-bg);
  overflow: hidden;
}

.app-shell__content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  z-index: 1;
}

.app-shell--demo {
  min-height: 26rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 2;
  width: 18rem;
  background: var(--color-component-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  transition: width var(--transition-normal), transform var(--transition-normal);
}

.sidebar__scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.sidebar::after {
  display: none;
}

.sidebar.is-collapsed {
  width: 5rem;
  overflow: hidden;
}

.sidebar.is-collapsed:hover,
.sidebar.is-collapsed:focus-within {
  overflow: visible;
}

.sidebar.is-collapsed .sidebar-label,
.sidebar.is-collapsed .sidebar-item__chevron,
.sidebar.is-collapsed .sidebar-subnav {
  display: none;
}

.sidebar__header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--font-semibold);
}

.sidebar__brand-mark {
  width: 5rem;
  height: 5rem;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-primary, var(--theme-primary)), var(--brand-secondary, var(--theme-secondary)));
  color: var(--color-white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex: 0 0 auto;
}

.sidebar__brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar__brand-name {
  text-align: left;
  font-size: 1.1rem;
  line-height: 1.5;
  font-family: var(--font-sans);
  font-weight: 500;
  color: var(--color-ink);
  padding-left: 5px;
}

.sidebar__brand-name--fallback {
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.sidebar.is-collapsed .sidebar__brand-mark {
  width: 2.5rem;
  height: 2.5rem;
}

.sidebar__collapse {
  position: absolute;
  top: 2rem;
  right: -0.875rem;
  z-index: 1;
  border: 1px solid var(--color-sidebar-handle-border);
  background: var(--color-sidebar-handle-bg);
  color: var(--color-white);
  width: 1.75rem;
  height: 3rem;
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  border-left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--sidebar-handle-shadow);
  cursor: pointer;
  transition: right var(--transition-normal), opacity var(--transition-fast), color var(--transition-fast), background-color var(--transition-fast);
}

.sidebar__collapse::before {
  content: "";
  display: block;
  width: 0.625rem;
  height: 1.75rem;
  border-radius: var(--radius-sm);
  background-image:
    repeating-linear-gradient(
      to bottom,
      color-mix(in srgb, var(--color-white) 55%, transparent) 0 2px,
      transparent 2px 5px
    );
  opacity: 1;
}

.sidebar__collapse::after {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 0;
  bottom: 0;
  width: 0.75rem;
}

.sidebar__collapse:hover {
  color: var(--color-white);
  background: var(--color-sidebar-handle-hover);
}

.sidebar__collapse svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0.9rem;
  height: 0.9rem;
  transition: transform var(--transition-fast);
}

.sidebar.is-collapsed .sidebar__collapse {
  right: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar.is-collapsed .sidebar__collapse svg {
  transform: translate(-50%, -50%) rotate(180deg);
}

.sidebar.is-collapsed:hover .sidebar__collapse,
.sidebar.is-collapsed:focus-within .sidebar__collapse {
  opacity: 1;
  pointer-events: auto;
  right: -1.45rem;
}

.sidebar__collapse svg,
.sidebar-mobile-trigger svg,
.sidebar-item svg {
  width: 1rem;
  height: 1rem;
}

.sidebar__nav {
  display: grid;
  gap: var(--space-2);
}

.sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.sidebar-admin {
  border: 1px solid color-mix(in srgb, var(--theme-primary) 30%, var(--color-component-surface));
  background: color-mix(in srgb, var(--theme-primary) 8%, var(--color-component-surface));
  border-radius: var(--radius-md);
  padding: var(--space-2);
}

.sidebar-admin__label {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-theme {
  margin-bottom: var(--space-2);
}

.sidebar-theme__label {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-ink-light);
}

.sidebar-theme__select {
  width: 100%;
  min-height: 2rem;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.sidebar-admin__link {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--color-primary-700);
  text-decoration: none;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}

.sidebar-admin__link:hover {
  background: color-mix(in srgb, var(--theme-primary) 14%, var(--color-component-surface));
  text-decoration: none;
}

.sidebar__group {
  display: grid;
  gap: var(--space-1);
}

.sidebar-item {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--color-ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
}

.sidebar-item:focus {
  outline: none;
  box-shadow: none;
  -webkit-appearance: none;
}

.sidebar-item:hover {
  background: color-mix(in srgb, var(--theme-primary) 10%, var(--color-component-surface));
}

.sidebar-item__left {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-item__chevron {
  transition: transform var(--transition-fast);
  color: var(--color-ink-light);
}

.sidebar-item[aria-expanded="true"] .sidebar-item__chevron {
  transform: rotate(90deg);
}

.sidebar-item--parent {
  font-weight: var(--font-medium);
}

.sidebar-unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  color: var(--color-white);
  background: var(--color-danger-600);
  border-radius: var(--radius-full);
}

.sidebar.is-collapsed .sidebar-unread-badge {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  min-width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  font-size: 0;
}

.sidebar-item--child {
  color: var(--color-ink-light);
}

.sidebar-item--grandchild {
  padding-left: calc(var(--space-6) + var(--space-2));
  color: var(--color-ink-light);
}

.sidebar-subnav {
  display: grid;
  gap: var(--space-1);
  padding-left: var(--space-2);
  border-left: 1px solid var(--color-border);
  margin-left: var(--space-2);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) .sidebar-item {
    color: var(--color-gray-200);
  }

  :root:not([data-color-scheme="light"]) .sidebar-item--child,
  :root:not([data-color-scheme="light"]) .sidebar-item--grandchild {
    color: var(--color-gray-300);
  }

  :root:not([data-color-scheme="light"]) .sidebar-item__chevron {
    color: var(--color-gray-400);
  }

  :root:not([data-color-scheme="light"]) .sidebar-admin__label,
  :root:not([data-color-scheme="light"]) .sidebar-theme__label {
    color: var(--color-gray-400);
  }

  :root:not([data-color-scheme="light"]) .sidebar-admin__link {
    color: var(--color-gray-300);
  }

  :root:not([data-color-scheme="light"]) .sidebar__brand-name {
    color: var(--color-gray-100);
  }

  :root:not([data-color-scheme="light"]) .sidebar-subnav {
    border-left-color: var(--color-gray-600);
  }
}

:root[data-color-scheme="dark"] .sidebar-item {
  color: var(--color-gray-200);
}

:root[data-color-scheme="dark"] .sidebar-item--child,
:root[data-color-scheme="dark"] .sidebar-item--grandchild {
  color: var(--color-gray-300);
}

:root[data-color-scheme="dark"] .sidebar-item__chevron {
  color: var(--color-gray-400);
}

:root[data-color-scheme="dark"] .sidebar-admin__label,
:root[data-color-scheme="dark"] .sidebar-theme__label {
  color: var(--color-gray-400);
}

:root[data-color-scheme="dark"] .sidebar-admin__link {
  color: var(--color-gray-300);
}

:root[data-color-scheme="dark"] .sidebar__brand-name {
  color: var(--color-gray-100);
}

:root[data-color-scheme="dark"] .sidebar-subnav {
  border-left-color: var(--color-gray-600);
}

.sidebar-subnav[hidden] {
  display: none;
}

.sidebar-mobile-trigger {
  display: none;
}

.sidebar-overlay {
  display: none;
}

body.has-mobile-sidebar {
  overflow: hidden;
}

.toast-stack {
  position: fixed;
  bottom: var(--space-4);
  right: var(--space-4);
  width: min(24rem, calc(100vw - var(--space-8)));
  z-index: 1000;
  display: grid;
  gap: var(--space-2);
}

.toast {
  margin-bottom: 0;
  box-shadow: var(--shadow-lg);
  animation: toast-fade-in 240ms ease-out;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.is-dismissing {
  opacity: 0;
  transform: translateY(8px);
}

@keyframes toast-fade-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 640px) {
  .toast-stack {
    bottom: var(--space-3);
    left: var(--space-3);
    right: var(--space-3);
    width: auto;
  }
}

@media (max-width: 768px) {
  .app-shell--demo .sidebar-mobile-trigger,
  .app-shell--demo .sidebar-overlay {
    display: none;
  }

  .app-shell--demo .sidebar {
    position: relative;
    inset: auto;
    width: 18rem;
    transform: none;
    border-right: 1px solid var(--color-border);
    box-shadow: none;
  }

  .app-shell--demo.is-mobile-open .sidebar {
    transform: none;
  }

  .sidebar-mobile-trigger {
    position: fixed;
    top: var(--space-4);
    left: var(--space-4);
    z-index: 1300;
    display: inline-flex;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-component-surface);
    color: var(--color-ink);
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgb(0 0 0 / 0.35);
    border: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
    z-index: 1200;
  }

  .app-shell.is-mobile-open .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  .sidebar {
    position: fixed;
    inset: 0;
    z-index: 1250;
    width: 100vw;
    transform: translateX(-100%);
    border-right: 0;
    box-shadow: var(--shadow-lg);
  }

  .app-shell.is-mobile-open .sidebar {
    transform: translateX(0);
  }

  .sidebar__collapse {
    display: none;
  }
}

.theme-preview {
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.theme-preview__swatches {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  min-height: 4rem;
}

.theme-preview__swatch--primary { background: var(--theme-primary); }
.theme-preview__swatch--secondary { background: var(--theme-secondary); }
.theme-preview__swatch--surface { background: var(--theme-surface-tint); }

.theme-preview__body {
  padding: var(--space-3);
  background: var(--theme-surface-tint);
}

.theme-preview__chip {
  display: inline-block;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  color: var(--color-white);
  background: var(--theme-primary);
}

.avatar--sm {
  width: 2rem;
  height: 2rem;
  font-size: var(--text-xs);
}

.avatar--lg {
  width: 3rem;
  height: 3rem;
  font-size: var(--text-base);
}

/* Toggle Switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  width: fit-content;
}

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

.switch__track {
  width: 2.75rem;
  height: 1.5rem;
  border-radius: var(--radius-full);
  background: var(--color-switch-track-off);
  border: 1px solid var(--color-border-dark);
  display: inline-flex;
  align-items: center;
  padding: 0.125rem;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.switch__thumb {
  width: 1.125rem;
  height: 1.125rem;
  border-radius: var(--radius-full);
  background: var(--color-switch-thumb);
  box-shadow: var(--shadow-sm);
  transform: translateX(0);
  transition: transform var(--transition-fast);
}

.switch__label {
  font-size: var(--text-sm);
  color: var(--color-ink);
}

.switch__input:checked + .switch__track {
  background: var(--color-primary-600);
  border-color: var(--color-primary-700);
}

.switch__input:checked + .switch__track .switch__thumb {
  transform: translateX(1.25rem);
}

.switch__input:focus-visible + .switch__track {
  box-shadow: 0 0 0 3px var(--color-primary-100);
}

.switch__input:disabled + .switch__track {
  opacity: 0.6;
}

.switch__input:disabled ~ .switch__label {
  color: var(--color-ink-light);
}

.switch:has(.switch__input:disabled) {
  cursor: not-allowed;
}

/* Masquerade Banner */
.masquerade-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  background: var(--color-warning-600);
  color: var(--color-white);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
}

.masquerade-banner__stop {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-xs);
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: var(--color-white);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.masquerade-banner__stop:hover {
  background: rgba(255, 255, 255, 0.35);
}

body:has(.masquerade-banner) {
  padding-top: 2.5rem;
  --masquerade-banner-height: 2.5rem;
}

/* Masquerade Picker */
.masquerade-picker__wrapper {
  position: relative;
}

.masquerade-picker__input {
  width: 100%;
  min-height: 2rem;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
}

.masquerade-picker__dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 15rem;
  overflow-y: auto;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  margin-bottom: var(--space-1);
  z-index: 100;
}

.masquerade-picker__result {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  padding: var(--space-2);
  border: 0;
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  text-align: left;
  font-size: var(--text-xs);
  border-radius: 0;
}

.masquerade-picker__result:hover {
  background: var(--color-primary-50);
}

.masquerade-picker__result + .masquerade-picker__result {
  border-top: 1px solid var(--color-border);
}

.masquerade-picker__result-name {
  font-weight: var(--font-medium);
  color: var(--color-ink);
}

.masquerade-picker__result-email {
  color: var(--color-ink-light);
  font-size: var(--text-xs);
}

.masquerade-picker__empty {
  padding: var(--space-3);
  text-align: center;
  color: var(--color-ink-light);
  font-size: var(--text-xs);
}

.masquerade-picker__active {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: color-mix(in srgb, var(--color-warning-600) 15%, var(--color-component-surface));
  border: 1px solid color-mix(in srgb, var(--color-warning-600) 30%, var(--color-border));
  border-radius: var(--radius-md);
  min-height: 2rem;
}

.masquerade-picker__active-name {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--color-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.masquerade-picker__stop-btn {
  padding: 0.125rem var(--space-2);
  font-size: 0.625rem;
  background: var(--color-danger-600);
  color: var(--color-white);
  border: 0;
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
}

.masquerade-picker__stop-btn:hover {
  background: var(--color-danger-700);
}

/* Activity Feed */
.feed-page {
  max-width: 64rem;
  margin: 0 auto;
  padding: var(--space-6);
}

@media (min-width: 1600px) {
  .feed-page {
    max-width: 80rem;
  }
}

@media (min-width: 2000px) {
  .feed-page {
    max-width: 96rem;
  }
}

.feed-header {
  margin-bottom: var(--space-4);
}

.feed-header__title {
  font-family: var(--font-heading);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin: 0;
}

.feed-header__subtitle {
  font-size: var(--text-sm);
  color: var(--color-ink-light);
  margin: var(--space-1) 0 0;
}

.feed-filters {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-3);
  overflow-x: auto;
  flex-wrap: nowrap;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.feed-search {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-4);
}

.feed-search__input {
  flex: 1;
  min-width: 0;
}

.feed-search__clear {
  font-size: var(--text-sm);
  color: var(--color-ink-light);
}

.feed-filter {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  background: var(--color-component-surface);
  color: var(--color-ink-light);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.feed-filter:hover {
  border-color: var(--color-primary-300);
  color: var(--color-ink);
  background: color-mix(in srgb, var(--theme-primary) 10%, var(--color-component-surface));
}

.feed-filter--active {
  background: var(--theme-primary);
  border-color: var(--theme-primary);
  color: var(--color-white);
  font-weight: var(--font-medium);
  cursor: default;
}

.feed-filter__count {
  font-size: var(--text-xs);
  background: var(--color-gray-100);
  padding: 0 var(--space-1);
  border-radius: var(--radius-full);
  min-width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.feed-filter--active .feed-filter__count {
  background: rgba(255, 255, 255, 0.25);
  color: var(--color-white);
}

/* Store cart button + dropdown panel */
.store-cart {
  position: relative;
  display: inline-block;
}
.store-cart__trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  color: var(--color-ink);
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.store-cart__trigger:hover {
  border-color: var(--color-primary-400);
  background: color-mix(in srgb, var(--theme-primary) 8%, var(--color-component-surface));
}
.store-cart__trigger svg {
  width: 2rem;
  height: 2rem;
  stroke-width: 2;
}
.store-cart__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 1.4rem;
  height: 1.4rem;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: var(--font-semibold);
  color: var(--color-white);
  background: var(--theme-primary);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 2px var(--color-component-surface);
  transform-origin: center;
}
@keyframes storeCartBadgeBump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.5); }
  60%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.store-cart__badge--bump {
  animation: storeCartBadgeBump 0.4s ease-out;
}
@media (prefers-reduced-motion: reduce) {
  .store-cart__badge--bump { animation: none; }
}

.store-cart__panel {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  width: 360px;
  max-width: calc(100vw - 2rem);
  max-height: 70vh;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.store-cart__panel[hidden] { display: none; }
.store-cart__panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}
.store-cart__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--color-ink-light);
}
.store-cart__panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-3) var(--space-4);
}
.store-cart__panel-footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border);
}
.store-cart__item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}
.store-cart__item:last-child { border-bottom: none; }
.store-cart__item-img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.store-cart__item-img--placeholder {
  background: var(--color-surface-subtle);
}
.store-cart__item-info { min-width: 0; }
.store-cart__item-price { white-space: nowrap; }

.store-thumb {
  border: 2px solid transparent;
  transition: border-color 0.15s;
}
.store-thumb:not(.store-thumb--active):hover {
  border-color: var(--color-border);
}
.store-thumb--active {
  border-color: var(--theme-primary);
}

@keyframes feedFiltersSlideDown {
  from {
    opacity: 0;
    transform: translateY(-12px);
    max-height: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
  }
  to {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom-color: var(--color-border);
  }
}

.feed-filters--sub-animate {
  overflow: hidden;
  animation: feedFiltersSlideDown 0.25s ease-out;
  transform-origin: top;
}

@keyframes feedFiltersSlideUp {
  from {
    opacity: 1;
    transform: translateY(0);
    max-height: 200px;
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-3);
    border-bottom-color: var(--color-border);
  }
  to {
    opacity: 0;
    transform: translateY(-12px);
    max-height: 0;
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
  }
}

.feed-filters--sub-closing {
  overflow: hidden;
  animation: feedFiltersSlideUp 0.25s ease-in forwards;
  transform-origin: top;
}

@media (prefers-reduced-motion: reduce) {
  .feed-filters--sub-animate,
  .feed-filters--sub-closing {
    animation: none;
  }
}

.feed-list {
  display: grid;
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.feed-item {
  display: grid;
  grid-template-columns: 1.5rem 2.5rem 1fr;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4);
  background: var(--color-component-surface);
  align-items: start;
}

.feed-item--unread {
  background: color-mix(in srgb, var(--theme-surface-tint) var(--feed-unread-tint, 50%), var(--color-component-surface));
}

.feed-item--urgent.feed-item--unread {
  background: color-mix(in srgb, var(--color-danger-600) var(--feed-urgent-tint, 8%), var(--color-component-surface));
}

.feed-item__indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: var(--space-2);
}

.feed-item__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-primary-600);
}

.feed-item__dot--urgent {
  background: var(--color-danger-600);
}

.feed-item__dot--low {
  background: var(--color-gray-400);
}

.feed-item__avatar {
  padding-top: 0.125rem;
}

.feed-item__content {
  min-width: 0;
}

.feed-item__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.feed-item__title {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--color-ink);
}

.feed-item--unread .feed-item__title {
  font-weight: var(--font-bold);
}

.feed-item__meta {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.feed-item__sender {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-ink);
  margin-bottom: var(--space-2);
}

.feed-item__time {
  color: var(--color-ink-lighter);
}

.feed-item__time::before {
  content: "\00b7";
  margin-right: var(--space-1);
}

.feed-item__time:first-child::before {
  content: none;
}

.feed-item__body {
  font-size: var(--text-sm);
  color: var(--color-ink);
  line-height: 1.5;
}

.feed-item__body p {
  margin: 0;
}

.feed-item__actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.feed-item__expires {
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-warning-600);
  font-weight: var(--font-medium);
}

.feed-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--color-ink-light);
  background: var(--color-component-surface);
}

.feed-empty svg {
  color: var(--color-gray-300);
  margin-bottom: var(--space-3);
}

.feed-empty p {
  margin: 0;
  font-size: var(--text-sm);
}

/* ==========================================================================
   Calendar
   ========================================================================== */

.cal-page {
  max-width: 56rem;
  margin: 0 auto;
  padding: var(--space-6);
}

/* Header */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-3);
}

.cal-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  margin: 0;
}

.cal-header__controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.cal-header__month {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  min-width: 10rem;
  text-align: center;
  color: var(--color-ink);
}

.cal-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-component-surface);
  color: var(--color-ink);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cal-nav-btn:hover {
  background: color-mix(in srgb, var(--theme-primary) 10%, var(--color-component-surface));
  border-color: var(--color-primary-300);
}

.cal-nav-btn svg {
  width: 1rem;
  height: 1rem;
  overflow: visible;
  flex-shrink: 0;
}

.cal-today-btn {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-component-surface);
  color: var(--color-ink);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cal-today-btn:hover {
  background: color-mix(in srgb, var(--theme-primary) 10%, var(--color-component-surface));
  border-color: var(--color-primary-300);
}

/* Pending event invitations */
.cal-pending {
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-primary-200);
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--color-primary-600) 4%, var(--color-component-surface));
}

.cal-pending__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary-700);
  cursor: pointer;
  list-style: none;
}

.cal-pending__toggle::-webkit-details-marker { display: none; }

.cal-pending__toggle svg {
  flex-shrink: 0;
  color: var(--color-primary-600);
}

.cal-pending__count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-white);
  background: var(--color-primary-600);
  border-radius: var(--radius-full);
}

.cal-pending__list {
  padding: 0 var(--space-4) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  animation: cal-pending-open 0.25s ease-out;
  transform-origin: top;
}

@keyframes cal-pending-open {
  from {
    opacity: 0;
    max-height: 0;
    padding-bottom: 0;
    overflow: hidden;
  }
  to {
    opacity: 1;
    max-height: 50rem;
    padding-bottom: var(--space-4);
  }
}

.cal-pending__toggle::before {
  content: "";
  display: inline-block;
  width: 0.375rem;
  height: 0.375rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.cal-pending[open] > .cal-pending__toggle::before {
  transform: rotate(45deg);
}

.cal-pending__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.cal-pending__content {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  min-width: 0;
}

.cal-pending__title {
  font-weight: 600;
  font-size: var(--text-sm);
}

.cal-pending__meta {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
}

.cal-pending__actions {
  display: flex;
  gap: var(--space-2);
  flex-shrink: 0;
}

/* Grid */
.cal-grid {
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: var(--space-6);
}

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--color-border);
}

.cal-weekday {
  padding: var(--space-2) var(--space-1);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.cal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-day {
  position: relative;
  min-height: 5rem;
  padding: var(--space-1);
  border: 0;
  border-right: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  cursor: pointer;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--transition-fast);
}

.cal-day:nth-child(7n) {
  border-right: 0;
}

.cal-days > .cal-day:nth-last-child(-n+7) {
  border-bottom: 0;
}

.cal-day:hover {
  background: color-mix(in srgb, var(--theme-primary) 6%, transparent);
}

.cal-day--selected {
  background: color-mix(in srgb, var(--theme-primary) 12%, transparent);
}

.cal-day--selected:hover {
  background: color-mix(in srgb, var(--theme-primary) 16%, transparent);
}

.cal-day__number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-ink);
  line-height: 1;
}

.cal-day--other-month .cal-day__number {
  color: var(--color-ink-lighter);
}

.cal-day--today .cal-day__number {
  background: var(--theme-primary);
  color: var(--color-white);
  font-weight: var(--font-bold);
}

.cal-day__dots {
  display: flex;
  gap: 3px;
  padding: 0 2px;
  flex-wrap: wrap;
}

.cal-day__dot {
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--theme-primary);
}

.cal-day__dot.cal-event--primary {
  background: var(--theme-primary);
}

.cal-day__dot.cal-event--secondary {
  background: var(--theme-secondary);
}

.cal-day__dot.cal-event--accent {
  background: var(--color-warning-500);
}

.cal-day__more {
  font-size: 0.5rem;
  color: var(--color-ink-lighter);
  line-height: 6px;
}

/* Events list */
.cal-events {
  margin-top: var(--space-2);
}

.cal-events__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.cal-events__heading {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  margin: 0;
  color: var(--color-ink);
}

.cal-events__list {
  display: grid;
  gap: var(--space-3);
}

.cal-events__empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--color-ink-light);
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.cal-events__empty svg {
  color: var(--color-gray-300);
  margin-bottom: var(--space-3);
}

.cal-events__empty p {
  margin: 0;
  font-size: var(--text-sm);
}

/* Event card */
.cal-event-card {
  display: flex;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 0;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}

.cal-event-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--color-primary-300);
}

.cal-event-card__accent {
  width: 4px;
  flex-shrink: 0;
  background: var(--theme-primary);
}

.cal-event--primary .cal-event-card__accent {
  background: var(--theme-primary);
}

.cal-event--secondary .cal-event-card__accent {
  background: var(--theme-secondary);
}

.cal-event--accent .cal-event-card__accent {
  background: var(--color-warning-500);
}

.cal-event-card__body {
  flex: 1;
  padding: var(--space-3) var(--space-4);
  min-width: 0;
}

.cal-event-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.cal-event-card__time {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--theme-primary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.cal-event--secondary .cal-event-card__time {
  color: var(--theme-secondary);
}

.cal-event--accent .cal-event-card__time {
  color: var(--color-warning-600);
}

.cal-event-card__title {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  text-transform: none;
  margin: 0 0 var(--space-2);
  color: var(--color-ink);
}

.cal-event-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  margin-bottom: var(--space-2);
}

.cal-event-card__date,
.cal-event-card__duration {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.cal-event-card__desc {
  font-size: var(--text-sm);
  color: var(--color-ink-light);
  line-height: var(--leading-relaxed);
}

.cal-event-card__links {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.cal-event-card__link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--theme-primary);
  text-decoration: none;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--color-primary-200);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
}

.cal-event-card__link:hover {
  background: color-mix(in srgb, var(--theme-primary) 8%, var(--color-component-surface));
  border-color: var(--color-primary-300);
  text-decoration: none;
}

/* ==========================================================================
   Popover - Apple-style popover / Bootstrap modal hybrid
   ========================================================================== */

/* Backdrop */
.popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / 0.35);
  z-index: 1400;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.popover-backdrop--visible {
  opacity: 1;
  pointer-events: auto;
}

/* Popover container */
.popover {
  position: fixed;
  z-index: 1500;
  width: min(28rem, calc(100vw - 2rem));
  max-height: calc(100vh - var(--space-8));
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgb(0 0 0 / 0.03);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  opacity: 0;
  transform: scale(0.95) translateY(4px);
  pointer-events: none;
  transition: opacity var(--transition-normal), transform var(--transition-normal);
}

.popover--visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

/* Arrow (points toward the trigger) */
.popover__arrow {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  transform: rotate(45deg);
  z-index: -1;
}

.popover__arrow--top {
  top: -7px;
  border-right: none;
  border-bottom: none;
}

.popover__arrow--bottom {
  bottom: -7px;
  border-left: none;
  border-top: none;
}

.popover__arrow--right {
  right: -7px;
  border-left: none;
  border-bottom: none;
}

.popover__arrow--left {
  left: -7px;
  border-right: none;
  border-top: none;
}

/* Header */
.popover__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.popover__title {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  text-transform: none;
  color: var(--color-ink);
  margin: 0;
  line-height: var(--leading-tight);
}

.popover__close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-ink-light);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
}

.popover__close:hover {
  background: var(--color-hover-surface);
  color: var(--color-ink);
}

.popover__close svg {
  width: 1rem;
  height: 1rem;
}

/* Body */
.popover__body {
  padding: var(--space-5);
  overflow-y: auto;
  flex: 1;
}

/* Footer */
.popover__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
  background: var(--color-tinted-surface);
  flex-shrink: 0;
}

/* Popover event detail layout */
.popover-event-meta {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.popover-event-links {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 768px) {
  .cal-page {
    padding: var(--space-4);
  }

  .cal-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .cal-day {
    min-height: 3.5rem;
    padding: 2px;
  }

  .cal-day__number {
    width: 1.5rem;
    height: 1.5rem;
    font-size: var(--text-xs);
  }

  .cal-event-card__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
  }
}

/* ==========================================================================
   Date/Time Picker
   ========================================================================== */

.dtpicker {
  position: relative;
}

/* Trigger — single input-like button showing "Mar 18, 2026 at 9:00 AM" */
.dtpicker__trigger {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  font-weight: var(--font-medium);
  color: var(--color-ink);
  background: var(--color-component-surface);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  text-align: left;
}

.dtpicker__trigger:hover {
  border-color: var(--color-primary-300);
}

.dtpicker__trigger:focus {
  outline: none;
  border-color: var(--color-primary-400);
  box-shadow: 0 0 0 3px var(--color-primary-100);
}

.dtpicker__trigger svg {
  width: 1rem;
  height: 1rem;
  color: var(--color-ink-light);
  flex-shrink: 0;
}

/* Dropdown */
.dtpicker__dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  z-index: 100;
  width: 18rem;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3);
  display: none;
}

.dtpicker__dropdown--open {
  display: block;
}

/* Calendar header */
.dtpicker__cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.dtpicker__month-label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-ink);
}

.dtpicker__nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: var(--text-lg);
  line-height: 1;
}

.dtpicker__nav:hover {
  background: color-mix(in srgb, var(--theme-primary) 10%, var(--color-component-surface));
  border-color: var(--color-primary-300);
}

/* Weekday labels */
.dtpicker__weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: var(--space-1);
}

.dtpicker__weekdays span {
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  padding: var(--space-1) 0;
}

/* Day grid */
.dtpicker__days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.dtpicker__day {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0 auto;
  border: none;
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.dtpicker__day:hover {
  background: color-mix(in srgb, var(--theme-primary) 12%, var(--color-component-surface));
}

.dtpicker__day--other {
  color: var(--color-ink-lighter);
}

.dtpicker__day--today {
  font-weight: var(--font-bold);
  background: color-mix(in srgb, var(--theme-primary) 10%, var(--color-component-surface));
  color: var(--theme-primary);
}

.dtpicker__day--selected {
  background: var(--theme-primary);
  color: var(--color-white);
  font-weight: var(--font-semibold);
}

.dtpicker__day--selected:hover {
  background: color-mix(in srgb, var(--theme-primary) 85%, black);
}

.dtpicker__day--today.dtpicker__day--selected {
  background: var(--theme-primary);
  color: var(--color-white);
}

/* Time bar — sits below calendar inside dropdown */
.dtpicker__time-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.dtpicker__time-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dtpicker__time-bar select {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  min-height: auto;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  background: var(--color-component-surface);
  color: var(--color-ink);
}

.dtpicker__time-sep {
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  line-height: 1;
}

/* =========================================================
   Chat Room
   ========================================================= */

.chat-room {
  position: relative;
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--masquerade-banner-height, 0px));
  max-height: calc(100vh - var(--masquerade-banner-height, 0px));
  overflow: hidden;
}

.chat-room__header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-component-surface);
}

.chat-room__header-left,
.chat-room__header-right {
  flex: 1;
}

.chat-room__header-right {
  display: flex;
  justify-content: flex-end;
}

.chat-room__header-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.chat-room__member-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
}

.chat-room__member-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.chat-room__member-item:last-child {
  border-bottom: none;
}

.chat-room__member-avatar {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  background: var(--color-primary-600);
  color: white;
  font-size: 0.65rem;
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-room__member-avatar--img {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  object-fit: cover;
}

.chat-room__messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  opacity: 0;
  transition: opacity 180ms ease;
}
.chat-room__messages--ready {
  opacity: 1;
}

.chat-room__empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--color-ink-light);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-8);
}

.chat-room__empty:not(:only-child) {
  display: none;
}

button.chat-room__new-messages {
  display: none;
  position: absolute;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-primary-600);
  color: var(--color-white);
  border: none;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}

button.chat-room__new-messages.chat-room__new-messages--visible {
  display: inline-flex;
}

.chat-room-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  transition: background-color var(--transition-fast);
}

.chat-room-row:hover {
  background: var(--color-surface-hover, rgba(0, 0, 0, 0.03));
}

.chat-room-row--unread {
  border-left: 3px solid var(--color-primary-600);
  background: color-mix(in srgb, var(--color-primary-600) 4%, transparent);
}

.chat-room-row__unread-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-primary-600);
  flex-shrink: 0;
}

.chat-room__input {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
  background: var(--color-component-surface);
}

.chat-room__input-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.chat-room__input-field {
  flex: 1;
  min-height: auto;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
}

/* Chat Message */

.chat-message {
  display: flex;
  gap: var(--space-2);
  align-items: flex-end;
  padding: var(--space-1) var(--space-4);
}

.chat-message__avatar {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-primary-600);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-1);
}

.chat-message__content {
  max-width: 68%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-message__meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
}

.chat-message__author {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink);
}

.chat-message__time {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
}

.chat-message__body {
  background: var(--color-border);
  padding: var(--space-2) var(--space-3);
  border-radius: 1.1rem;
  border-bottom-left-radius: 0.25rem;
  font-size: var(--text-sm);
  color: var(--color-ink);
  word-break: break-word;
  white-space: pre-wrap;
  line-height: 1.45;
}

/* Meta variants — theirs visible by default, mine hidden */
.chat-message__meta--mine {
  display: none;
}

/* Mine — right-aligned bubble */
.chat-message--mine {
  flex-direction: row-reverse;
}

.chat-message--mine .chat-message__avatar-slot {
  display: none;
}

.chat-message--mine .chat-message__meta--theirs {
  display: none;
}

.chat-message--mine .chat-message__meta--mine {
  display: flex;
}

.chat-message--mine .chat-message__content {
  align-items: flex-end;
}

.chat-message--mine .chat-message__meta {
  flex-direction: row-reverse;
  margin-bottom: 0;
  margin-top: var(--space-1);
}

.chat-message--mine .chat-message__body {
  background: var(--color-primary-600);
  color: white;
  border-radius: 1.1rem;
  border-bottom-right-radius: 0.25rem;
}

.chat-message--mine .chat-message__body a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: underline;
}

/* Avatar image (when user has uploaded a photo) */
.chat-message__avatar--img {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  margin-bottom: var(--space-1);
}

/* Link preview card */
.link-preview {
  display: flex;
  flex-direction: column;
  margin-top: var(--space-2);
  max-width: 280px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  background: var(--color-component-surface);
  transition: box-shadow var(--transition-fast);
}

.link-preview:hover {
  box-shadow: var(--shadow-sm);
}

.link-preview__image {
  width: 100%;
  max-height: 140px;
  overflow: hidden;
  background: var(--color-border);
}

.link-preview__image img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}

.link-preview__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
}

.link-preview__domain {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.link-preview__title {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-ink);
  line-height: 1.3;
}

.link-preview__desc {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Mine messages: link preview card uses muted colors */
.chat-message--mine .link-preview {
  border-color: color-mix(in srgb, white 20%, var(--color-primary-600));
  background: color-mix(in srgb, white 15%, var(--color-primary-600));
}

.chat-message--mine .link-preview__domain,
.chat-message--mine .link-preview__title,
.chat-message--mine .link-preview__desc {
  color: rgba(255, 255, 255, 0.9);
}

.chat-message--mine .link-preview__domain {
  color: rgba(255, 255, 255, 0.7);
}

/* Settings avatar row */
.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.settings-avatar-preview {
  flex-shrink: 0;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-primary-100);
}

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

.settings-avatar-preview__initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--color-primary-700);
}

.settings-avatar-actions {
  flex: 1;
  min-width: 0;
}

/* Sidebar settings link pinned to bottom */
.sidebar__group--bottom {
  margin-top: auto;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}

/* Admin Tools wrapper — let its children participate in the parent grid */
.admin-tools {
  display: contents;
}

/* Admin Tools modal */
.admin-tools-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-tools-dialog[hidden] {
  display: none;
}

.admin-tools-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.admin-tools-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(420px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.admin-tools-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.admin-tools-dialog__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.admin-tools-dialog__field:last-child {
  margin-bottom: 0;
}

.admin-tools-dialog__label {
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  color: var(--color-ink);
}

/* Sidebar account menu (email + log out popover) — pinned to extreme bottom */
.account-menu {
  position: relative;
  margin-top: auto;
  padding-top: var(--space-2);
  border-top: 1px solid var(--color-border);
}
.account-menu__trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  text-align: left;
  font: inherit;
  color: var(--color-ink-light);
  cursor: pointer;
}
.account-menu__trigger:hover,
.account-menu--open .account-menu__trigger {
  background: color-mix(in srgb, var(--theme-primary) 6%, transparent);
  color: var(--color-ink);
}
.account-menu__mohawk {
  transition: fill var(--transition-fast), stroke var(--transition-fast);
}
.account-menu__trigger:hover .account-menu__mohawk,
.account-menu--open .account-menu__mohawk {
  fill: #f97316;
  stroke: #f97316;
}
.account-menu__icon {
  display: inline-flex;
  flex-shrink: 0;
}
.account-menu__icon svg {
  width: 1.1rem;
  height: 1.1rem;
}
.account-menu__logo {
  display: block;
  height: 1.1rem;
  width: auto;
  object-fit: contain;
}
.account-menu__email {
  font-size: 0.95em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.account-menu__menu {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: var(--space-1);
  z-index: 20;
}
.account-menu__menu form {
  margin: 0;
}
.account-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.account-menu__item:hover {
  background: color-mix(in srgb, var(--theme-primary) 8%, transparent);
}
.account-menu__item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.sidebar.is-collapsed .account-menu__email {
  display: none;
}
.sidebar.is-collapsed .account-menu__trigger {
  justify-content: center;
}

/* ── Chat: submit progress bar ───────────────────────────────── */
.chat-room__progress-bar {
  height: 3px;
  background: transparent;
  flex-shrink: 0;
}
.chat-room__progress-bar--active {
  background: linear-gradient(
    90deg,
    var(--color-border) 0%,
    var(--brand-primary, var(--color-accent)) 40%,
    var(--color-border) 100%
  );
  background-size: 200% 100%;
  animation: chat-progress-shimmer 1.3s ease-in-out infinite;
}
@keyframes chat-progress-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Chat: file preview strip ─────────────────────────────────── */
.chat-room__file-previews {
  display: none;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}
.chat-room__file-previews--visible { display: flex; }

.file-preview-thumb {
  position: relative;
  flex-shrink: 0;
  width: 64px;
  height: 64px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-tinted-surface);
}
.file-preview-thumb img,
.file-preview-thumb video { width: 100%; height: 100%; object-fit: cover; }

.file-preview-thumb__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.35);
  color: white;
}
.file-preview-thumb__play svg { width: 1.25rem; height: 1.25rem; }

/* ── Chat: attach button ──────────────────────────────────────── */
.chat-room__attach-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  color: var(--color-ink-light);
  cursor: pointer;
  transition: color var(--transition-fast), background var(--transition-fast);
}
.chat-room__attach-btn:hover { background: var(--color-hover-surface); color: var(--color-ink); }
.chat-room__attach-btn svg { width: 1.25rem; height: 1.25rem; }

/* ── Chat: inline attachment thumbnails ──────────────────────── */
.message-attachments {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-1);
  overflow: hidden;
  border-radius: 1rem;
  max-width: 280px;
}
.message-attachments--grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.message-attachment {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--color-tinted-surface);
  aspect-ratio: 4 / 3;
}
.message-attachment__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity var(--transition-fast);
}
.message-attachment:hover .message-attachment__img { opacity: 0.9; }

.message-attachment__video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}
.message-attachment__play-btn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 0.25);
  color: white;
  transition: background var(--transition-fast);
}
.message-attachment--video:hover .message-attachment__play-btn { background: rgb(0 0 0 / 0.4); }
.message-attachment__play-btn svg { filter: drop-shadow(0 1px 3px rgb(0 0 0 / 0.5)); }

/* ── Media viewer lightbox ────────────────────────────────────── */
.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.media-viewer--open { opacity: 1; pointer-events: auto; }

.media-viewer__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(0 0 0 / 0.85);
}
.media-viewer__shell {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: min(90vw, 1200px);
  max-height: 90vh;
}
.media-viewer__toolbar {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}
.media-viewer__download { text-decoration: none; }
.media-viewer__stage {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.media-viewer__content {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  will-change: transform, opacity;
}
.media-viewer__img {
  max-width: 100%;
  max-height: calc(90vh - 5rem);
  border-radius: var(--radius-lg);
  object-fit: contain;
  display: block;
}
.media-viewer__img--placeholder {
  filter: blur(10px);
  position: absolute;
}
.media-viewer__img--loading {
  opacity: 0;
}
.media-viewer__video {
  max-width: 100%;
  max-height: calc(90vh - 5rem);
  border-radius: var(--radius-lg);
}
.media-viewer__prev,
.media-viewer__next {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.media-viewer__prev:hover,
.media-viewer__next:hover {
  background: rgba(255,255,255,0.3);
}
.media-viewer__counter {
  color: rgba(255,255,255,0.8);
  margin-right: auto;
}

/* ── Chat: react button ───────────────────────────────────────── */
.chat-message__actions {
  position: relative;
  flex-shrink: 0;
  align-self: center;
  display: flex;
  align-items: center;
}
.chat-message__react-btn {
  display: flex;
  flex-shrink: 0;
  align-self: center;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  min-width: 1.5rem;
  height: 1.5rem;
  min-height: 1.5rem;
  border-radius: 50%;
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-ink-light);
  cursor: pointer;
  opacity: 0.5;
  padding: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast), border-color var(--transition-fast);
}
.chat-message__react-btn:hover {
  opacity: 1;
  background: var(--color-hover-surface);
  border-color: var(--color-ink-light);
}

/* ── Emoji picker ─────────────────────────────────────────────── */
.emoji-picker {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 200;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 20px rgb(0 0 0 / 0.12);
  padding: var(--space-2);
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  max-width: min(320px, 90vw);
  scrollbar-width: none;
}
.emoji-picker::-webkit-scrollbar { display: none; }
.emoji-picker--open { display: flex; gap: 2px; }
/* "mine" messages are row-reversed — flip the picker so it opens left */
.chat-message--mine .emoji-picker {
  right: auto;
  left: 0;
}
/* "theirs" messages — picker opens to the right of the button */
.chat-message:not(.chat-message--mine) .emoji-picker {
  left: 0;
  right: auto;
}
.emoji-picker__emoji {
  flex-shrink: 0;
  font-size: 1.375rem;
  line-height: 1;
  width: 2.25rem;
  height: 2.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  cursor: pointer;
  background: transparent;
  border: none;
  padding: 0;
  transition: background var(--transition-fast), transform var(--transition-fast);
}
.emoji-picker__emoji:hover {
  background: var(--color-hover-surface);
  transform: scale(1.2);
}

/* ── Reaction badges on messages ─────────────────────────────── */
.message-reactions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  margin-top: var(--space-1);
  min-height: 0;
}
.reaction-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px 2px 6px;
  border-radius: 9999px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
  user-select: none;
}
/* not-mine hover → green tint (will ADD) */
.reaction-badge:not(.reaction-badge--mine):hover {
  background: color-mix(in srgb, #22c55e 15%, transparent);
  border-color: #22c55e;
}
.reaction-badge--mine {
  background: color-mix(in srgb, var(--brand-primary, var(--color-accent)) 12%, transparent);
  border-color: var(--brand-primary, var(--color-accent));
}
/* mine hover → red tint (will REMOVE) */
.reaction-badge--mine:hover {
  background: color-mix(in srgb, #ef4444 15%, transparent);
  border-color: #ef4444;
}
.reaction-badge__emoji { font-size: 0.9375rem; line-height: 1; }
.reaction-badge__count { color: var(--color-ink-light); font-size: 0.75rem; }

/* ==========================================================================
   Classroom Page
   ========================================================================== */

.classroom-page {
  max-width: 680px;
  margin: 0 auto;
  padding: var(--space-6);
}

@media (min-width: 1024px) {
  .classroom-page { max-width: 800px; }
}

@media (min-width: 1440px) {
  .classroom-page { max-width: 920px; }
}

.classroom-page__header {
  margin-bottom: var(--space-6);
}

.classroom-teacher-card {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
}

.classroom-teacher-card__avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--color-primary-600);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.classroom-teacher-card__avatar--img {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  object-fit: cover;
}

.classroom-teacher-card__name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-ink);
}

/* Composer */
.classroom-composer {
  margin-bottom: var(--space-6);
}

.classroom-composer__field {
  width: 100%;
  border: none;
  resize: none;
  overflow: hidden;
  min-height: 3rem;
  font-size: var(--text-sm);
  background: var(--color-white);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  outline: none;
}

.classroom-composer__editor {
  width: 100%;
  font-size: var(--text-sm);
}

.classroom-composer__actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
  margin-top: var(--space-2);
}

.classroom-composer__attach-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
  color: var(--color-ink-light);
  padding: var(--space-1);
  border-radius: var(--radius-md);
  transition: color 0.15s, background 0.15s;
}

.classroom-composer__attach-btn:hover {
  color: var(--color-ink);
  background: var(--color-surface-subtle);
}

.classroom-composer__previews {
  display: none;
}

.classroom-composer__previews--visible {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding-bottom: var(--space-3);
}

/* Post Card */
.classroom-post {
  margin-bottom: var(--space-4);
}

.classroom-post__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.classroom-post__meta {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.classroom-post__actions {
  margin-left: auto;
}

.classroom-post__body {
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: var(--space-3);
}

.classroom-post .card__body:not(:has(.message-attachments)):not(:has(.link-preview)) .classroom-post__body {
  margin-bottom: 0;
}

.classroom-post .card__body:not(:has(.message-attachments)):not(:has(.link-preview)) {
  padding-block: var(--space-4);
}

.classroom-post__body a {
  color: var(--color-primary-600);
  text-decoration: underline;
}

.classroom-post .message-attachments {
  margin-top: var(--space-2);
  max-width: 100%;
  display: flex;
  flex-wrap: wrap;
  flex-direction: row;
  gap: var(--space-2);
  border-radius: 0;
}

.classroom-post .message-attachments .message-attachment {
  width: 120px;
  height: 90px;
  border-radius: var(--radius-md);
  aspect-ratio: 4 / 3;
}

/* Edit attachments grid */
.edit-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.edit-attachment {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  width: 120px;
  transition: opacity 0.2s;
}

.edit-attachment--removed {
  opacity: 0.35;
}

.edit-attachment__preview {
  position: relative;
}

.edit-attachment__thumb {
  width: 120px;
  height: 90px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  background: var(--color-tinted-surface);
  display: flex;
  align-items: center;
  justify-content: center;
}

.edit-attachment__thumb--video {
  position: relative;
}

.edit-attachment__thumb--file {
  cursor: default;
  color: var(--color-ink-light);
}

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

.edit-attachment__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(0,0,0,0.3);
  pointer-events: none;
}

.edit-attachment__name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-ink-light);
  text-align: center;
}

.edit-attachment__remove {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--text-xs);
  color: var(--color-danger-600);
  cursor: pointer;
  padding: 2px var(--space-1);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.edit-attachment__remove:hover {
  background: var(--color-danger-50);
}

.edit-attachment__drag-handle {
  cursor: grab;
  color: var(--color-ink-lighter);
  padding: 2px;
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.edit-attachment__drag-handle:hover {
  color: var(--color-ink);
}
.edit-attachment__drag-handle:active {
  cursor: grabbing;
}

/* Drag-sort shared styles */
.drag-sort--dragging {
  opacity: 0.4;
}

/* Sortable form rows (phone numbers, addresses, etc.) */
.sortable-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sortable-row--block {
  align-items: stretch;
}

.sortable-row__handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--color-ink-light);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.sortable-row__handle:hover {
  color: var(--color-ink);
  background: var(--color-surface-subtle);
}

.sortable-row__handle:active {
  cursor: grabbing;
}

.sortable-row--block .sortable-row__handle {
  align-self: center;
  margin-left: var(--space-2);
}

.sortable-row__primary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  margin-bottom: 0;
  cursor: pointer;
  white-space: nowrap;
}

/* Bulk-actions toolbar */
.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.bulk-toolbar--hidden {
  visibility: hidden;
}

.bulk-toolbar__count {
  color: var(--color-ink);
  font-weight: 500;
}

.bulk-toolbar__menu-wrap {
  position: relative;
  margin-left: auto;
}

.bulk-toolbar__menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  z-index: 20;
  min-width: 180px;
  background: var(--color-canvas);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md, 0 4px 12px rgba(0, 0, 0, 0.12));
  padding: var(--space-1) 0;
}

.bulk-toolbar__menu[hidden] {
  display: none;
}

.bulk-toolbar__menu-item {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 0;
  text-align: left;
  font-size: var(--text-sm);
  color: var(--color-ink);
  cursor: pointer;
}

.bulk-toolbar__menu-item:hover {
  background: var(--color-surface-subtle);
}

.bulk-toolbar__menu-empty {
  display: block;
  padding: var(--space-3);
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-ink-light);
}

/* Class-assign dialog */
.class-assign-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.class-assign-dialog[hidden] {
  display: none;
}

.class-assign-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.class-assign-dialog__panel {
  position: relative;
  z-index: 1;
  min-width: 340px;
  max-width: 480px;
}

/* Bulk-selectable table rows */
.bulk-checkbox-cell {
  cursor: pointer;
  user-select: none;
}

.bulk-checkbox {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--color-accent, var(--color-ink));
  pointer-events: none;
}

tr:has(.bulk-checkbox:checked) {
  background: color-mix(in srgb, var(--color-accent, var(--color-primary-600)) 6%, transparent);
}

/* Filter input (paired with filterable-list controller) */
.filter-input {
  position: relative;
  display: flex;
  align-items: center;
}

.filter-input__icon {
  position: absolute;
  left: var(--space-3);
  display: inline-flex;
  color: var(--color-ink-light);
  pointer-events: none;
}

input[type="search"].filter-input__field {
  padding: var(--space-2) var(--space-8) var(--space-2) calc(var(--space-3) + 18px);
  font-size: var(--text-sm);
}

.filter-input__field::placeholder {
  color: var(--color-ink-light);
}

.filter-input__field:focus {
  outline: 2px solid var(--color-accent, var(--color-ink));
  outline-offset: -1px;
  border-color: transparent;
}

/* Hide the native search clear button so we can show our own */
.filter-input__field::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
}

.filter-input__clear {
  position: absolute;
  right: var(--space-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--color-ink-light);
}

.filter-input__clear:hover {
  background: var(--color-surface-subtle);
  color: var(--color-ink);
}

.filter-input__clear[hidden] {
  display: none;
}

/* Sortable table header (paired with sortable-table controller) */
.sort-header {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-weight: inherit;
  cursor: pointer;
  text-align: left;
  width: 100%;
}

.sort-header--right {
  justify-content: flex-end;
}

.sort-header--center {
  justify-content: center;
}

.sort-header:hover {
  color: var(--color-ink);
  background: transparent;
}

.sort-header__icon {
  display: inline-flex;
  color: var(--color-ink-lighter);
  transition: transform 0.15s, color 0.15s;
}

.sort-header[data-sort-direction] .sort-header__icon {
  color: var(--color-ink);
}

.sort-header[data-sort-direction="asc"] .sort-header__icon {
  transform: rotate(180deg);
}

/* Breadcrumbs */
.breadcrumbs {
  margin-bottom: var(--space-4);
}

.breadcrumbs__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  font-size: var(--text-sm);
}

.breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--color-ink-light);
}

.breadcrumbs__link {
  color: var(--color-ink-light);
  text-decoration: none;
}

.breadcrumbs__link:hover {
  color: var(--color-ink);
  text-decoration: underline;
}

.breadcrumbs__current {
  color: var(--color-ink);
  font-weight: 500;
}

.breadcrumbs__sep {
  display: inline-flex;
  color: var(--color-ink-lighter);
}

.file-preview-thumb {
  cursor: grab;
}
.file-preview-thumb:active {
  cursor: grabbing;
}

/* File attachment link (PDF etc) */
.message-attachment--file {
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  display: inline-block;
}

.message-attachment__file-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-ink);
  text-decoration: none;
  font-size: var(--text-sm);
}

.message-attachment__file-link:hover {
  color: var(--color-primary-600);
}

/* Download all */
.classroom-post__download-all {
  margin-top: var(--space-3);
}

.classroom-post__download-all .btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* Feed empty state */
.classroom-feed-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
}

/* Classroom show — 2-column layout (gallery + feed) */
.classroom-page--with-gallery {
  max-width: 1100px;
}

@media (min-width: 1280px) {
  .classroom-page--with-gallery { max-width: 1240px; }
}

.classroom-page__layout {
  display: grid;
  gap: var(--space-6);
  grid-template-columns: 1fr;
}

@media (min-width: 1024px) {
  .classroom-page__layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: start;
  }
}

.classroom-page__main {
  min-width: 0;
}

/* Classroom show sidebar (reminders + gallery) */
.classroom-page__sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  position: sticky;
  top: var(--space-4);
}

/* Pinned Reminders panel */
.pinned-reminders-panel__list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

.pinned-reminders-panel__item {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.pinned-reminders-panel__icon {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--color-primary-600);
}

.pinned-reminders-panel__text {
  font-size: var(--text-sm);
  line-height: 1.5;
  color: var(--color-ink);
  margin: 0;
}

/* Pinned Reminders dialog */
.pinned-reminders-dialog {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pinned-reminders-dialog[hidden] {
  display: none;
}

.pinned-reminders-dialog__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
}

.pinned-reminders-dialog__panel {
  position: relative;
  z-index: 1;
  width: min(480px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
}

.pinned-reminders-dialog__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.pinned-reminders-dialog__items {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.pinned-reminders-dialog__item {
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}

.pinned-reminders-dialog__item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.pinned-reminders-dialog__edit-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
  min-width: 0;
}

.pinned-reminders-dialog__item-top {
  display: flex;
  gap: var(--space-2);
  align-items: flex-start;
}

.pinned-reminders-dialog__item-bottom {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
  padding-left: calc(16px + var(--space-2));
  padding-top: 5px;
}

.pinned-reminders-dialog__drag-handle {
  flex-shrink: 0;
  cursor: grab;
  color: var(--color-ink-lighter);
  padding: var(--space-2) 0;
}

.pinned-reminders-dialog__drag-handle:active {
  cursor: grabbing;
}

.pinned-reminders-dialog__item.drag-sort--dragging {
  opacity: 0.5;
}

.pinned-reminders-dialog__input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-canvas);
  color: var(--color-ink);
  resize: none;
  overflow: hidden;
}

.pinned-reminders-dialog__item-actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  justify-content: flex-end;
}

.pinned-reminders-dialog__item-bottom .btn {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
}

.pinned-reminders-dialog__item-bottom form {
  display: inline;
}

.pinned-reminders-dialog__new {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.pinned-reminders-dialog__new-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.btn--danger-text {
  color: var(--color-danger-600, #dc2626);
}

.btn--danger-text:hover {
  color: var(--color-danger-700, #b91c1c);
}

/* Gallery preview panel (classroom show sidebar) */
.gallery-panel {
}

.gallery-panel__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.gallery-panel__title {
  font-size: var(--text-base);
  font-weight: 600;
  margin: 0;
}

.gallery-panel__view-all {
  color: var(--color-accent, var(--color-ink));
  text-decoration: none;
}

.gallery-panel__view-all:hover {
  text-decoration: underline;
}

.gallery-panel__grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2);
}

.gallery-panel__item {
  cursor: pointer;
}

/* Gallery thumb (presentational) */
.gallery-thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface-subtle, #f3f3f3);
}

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

.gallery-thumb__play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  background: rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

/* Full gallery index page */
.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-bg, white);
  z-index: 10;
}

.gallery-toolbar__select-all {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
  font-size: var(--text-sm);
}

.gallery-toolbar__count {
  flex: 1;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space-3);
}

.gallery-cell {
  position: relative;
  display: block;
  cursor: pointer;
  border-radius: var(--radius-md);
  overflow: hidden;
  outline: 2px solid transparent;
  outline-offset: 2px;
  transition: outline-color 0.15s;
}

.gallery-cell:has(.gallery-cell__checkbox:checked) {
  outline-color: var(--color-accent, var(--color-ink));
}

.gallery-cell__checkbox {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  width: 20px;
  height: 20px;
  z-index: 2;
  cursor: pointer;
  accent-color: var(--color-accent, var(--color-ink));
}

.gallery-cell:has(.gallery-cell__checkbox:checked) .gallery-thumb__img {
  opacity: 0.85;
}

.gallery-pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-6);
}

/* Download status (background zip prep) */
.download-status-card {
  max-width: 480px;
  margin: var(--space-6) auto 0;
}

.download-status {
  text-align: center;
  padding: var(--space-6) var(--space-4);
}

.download-status__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: var(--space-4);
}

.download-status__icon--spinner {
  background: var(--color-surface-subtle, #f3f3f3);
  color: var(--color-ink-light);
  animation: download-status-spin 1.2s linear infinite;
}

.download-status__icon--ready {
  background: rgba(34, 197, 94, 0.12);
  color: rgb(22, 163, 74);
}

.download-status__icon--failed {
  background: rgba(239, 68, 68, 0.12);
  color: rgb(220, 38, 38);
}

.download-status__title {
  font-size: var(--text-lg);
  font-weight: 600;
  margin: 0 0 var(--space-2);
}

.download-status__msg {
  margin: 0;
}

@keyframes download-status-spin {
  to { transform: rotate(360deg); }
}

/* ==========================================================================
   Lunch Calendar (Admin)
   ========================================================================== */

.lunch-calendar__header {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  margin: 0 auto 1px;
  max-width: 720px;
}

.lunch-calendar__day-name {
  text-align: center;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  padding: var(--space-2);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lunch-calendar__grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.lunch-calendar__cell {
  background: var(--color-canvas);
  padding: var(--space-3);
  min-height: 140px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.lunch-calendar__cell--empty {
  background: var(--color-surface-subtle);
}

.lunch-calendar__cell--off {
  background: color-mix(in srgb, var(--color-warning-500) 8%, var(--color-canvas));
}

.lunch-calendar__cell--has-menu {
  background: color-mix(in srgb, var(--color-success-500) 6%, var(--color-canvas));
}

.lunch-calendar__date {
  display: flex;
  align-items: baseline;
  gap: var(--space-1);
}

.lunch-calendar__date-num {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

.lunch-calendar__date-day {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
}

.lunch-calendar__label {
  font-size: var(--text-xs);
  color: var(--color-warning-700, #a16207);
  font-style: italic;
  margin: 0;
}

.lunch-calendar__meals {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.lunch-calendar__meal {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-2);
}

.lunch-calendar__actions {
  display: flex;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-top: auto;
}

.lunch-calendar__actions .btn {
  font-size: 0.65rem;
  padding: 2px 6px;
}

/* Lunch Meal Row (nested fields in menu form) */

.lunch-meal-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  margin-bottom: var(--space-2);
}

.lunch-meal-row .form-group {
  margin-bottom: 0;
}

/* ==========================================================================
   Lunch Order Form (Parent-facing)
   ========================================================================== */

.lunch-order-table {
  width: 100%;
  border-collapse: collapse;
}

.lunch-order-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink-light);
  text-transform: uppercase;
  border-bottom: 2px solid var(--color-border);
}

.lunch-order-table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.lunch-order-table tr.lunch-order-table__off-day td {
  color: var(--color-ink-lighter);
  font-style: italic;
}

.lunch-order-table tr.lunch-order-table__row--selected {
  background: color-mix(in srgb, var(--color-primary-600) 10%, transparent);
}

.lunch-order-table tr.lunch-order-table__row--selected td:first-child {
  border-left: 3px solid var(--color-primary-600);
}

.lunch-order-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}

@media (min-width: 1024px) {
  .lunch-order-layout {
    flex-direction: row;
    align-items: flex-start;
  }

  .lunch-order-layout__calendar {
    flex: 0 0 auto;
    position: sticky;
    top: var(--space-4);
  }

  .lunch-order-layout__table {
    flex: 1;
    min-width: 0;
  }

  .lunch-order-layout .lunch-menu-calendar,
  .lunch-order-layout .lunch-selection-calendar,
  .lunch-order-layout .lunch-selection-calendar .lunch-calendar__header {
    margin: 0;
  }
}

/* Lunch Order Selection Calendar */

.lunch-selection-calendar__cell {
  transition: background var(--transition-fast);
}

.lunch-selection-calendar__cell--selected {
  background: color-mix(in srgb, var(--color-primary-600) 12%, var(--color-canvas)) !important;
  border: 1px solid color-mix(in srgb, var(--color-primary-600) 40%, transparent);
}

.lunch-selection-calendar__cell--skipped {
  background: color-mix(in srgb, var(--color-ink-light) 12%, var(--color-component-surface)) !important;
  border: 1px solid var(--color-ink-light);
}

.lunch-selection-calendar__selection {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: var(--space-1);
}

.lunch-selection-calendar__meal {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  color: var(--color-ink);
}

.lunch-selection-calendar__price {
  font-size: 0.65rem;
  color: var(--color-ink-light);
}

.lunch-selection-calendar__skip {
  font-size: var(--text-xs);
  font-style: italic;
  color: var(--color-ink-lighter);
}

.lunch-selection-calendar__empty {
  font-size: var(--text-xs);
  color: var(--color-ink-lighter);
}

.lunch-order-choices {
  display: grid;
  grid-auto-columns: 1fr;
  grid-auto-flow: column;
  gap: var(--space-2);
}

.lunch-order-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: var(--space-2) var(--space-3);
  min-height: 3.25rem;
  text-align: center;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  margin: 0;
}

.lunch-order-choice:hover {
  background: color-mix(in srgb, var(--color-primary-600) 6%, var(--color-component-surface));
  border-color: color-mix(in srgb, var(--color-primary-600) 30%, var(--color-border));
}

.lunch-order-choice input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.lunch-order-choice__title {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-ink);
}

.lunch-order-choice__price {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
}

.lunch-order-choice--active {
  background: color-mix(in srgb, var(--color-primary-600) 15%, var(--color-component-surface));
  border-color: var(--color-primary-600);
}

.lunch-order-choice--active .lunch-order-choice__title {
  color: var(--color-primary-600);
  font-weight: var(--font-semibold);
}

.lunch-order-choice--active .lunch-order-choice__price {
  color: var(--color-primary-600);
}

.lunch-order-choice--skip.lunch-order-choice--active {
  background: color-mix(in srgb, var(--color-ink-light) 12%, var(--color-component-surface));
  border-color: var(--color-ink-light);
}

.lunch-order-choice--skip.lunch-order-choice--active .lunch-order-choice__title {
  color: var(--color-ink);
}

.lunch-order-choice--unavailable {
  opacity: 0.4;
  cursor: not-allowed;
  text-decoration: line-through;
}
.lunch-order-choice--unavailable:hover {
  background: var(--color-component-surface);
  border-color: var(--color-border);
}

@media (max-width: 640px) {
  .lunch-order-choices {
    grid-auto-flow: row;
    grid-auto-columns: auto;
  }
}

.lunch-order-total {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

/* Lunch month show (parent-facing calendar) */

.lunch-menu-calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
}

.lunch-month-nav {
  min-width: 28px;
  padding-left: var(--space-2);
  padding-right: var(--space-2);
  font-weight: var(--font-semibold);
  line-height: 1;
}

.lunch-month-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.lunch-month-deadline-slot {
  display: inline-flex;
  align-items: center;
  min-width: 13rem;
  min-height: 1.75rem;
}

/* Bulk order layout (menu on left, per-student panels on right) */
.lunch-bulk__layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 1100px) {
  .lunch-bulk__layout {
    grid-template-columns: 1fr;
  }
}

.lunch-bulk__menu {
  position: sticky;
  top: var(--space-4);
}

.lunch-bulk__students {
  min-width: 0;
}

.lunch-bulk__student .lunch-order-table {
  width: 100%;
}

.lunch-bulk__row--missing > td {
  background: color-mix(in srgb, var(--color-warning-500) 18%, transparent);
  border-left: 3px solid var(--color-warning-500);
}

.lunch-bulk__row--missing > td:first-child {
  position: relative;
}

/* Lunch order dropdown (Submit Orders ▾) */
.lunch-order-dropdown {
  position: relative;
  display: inline-flex;
}

.lunch-order-dropdown__trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.lunch-order-dropdown__caret {
  font-size: 0.65rem;
}

.lunch-order-dropdown__menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  padding: var(--space-1);
  z-index: 30;
}

.lunch-order-dropdown__item {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-ink);
  text-decoration: none;
  font-size: var(--text-sm);
}

.lunch-order-dropdown__item:hover {
  background: color-mix(in srgb, var(--theme-primary) 8%, transparent);
}

.lunch-order-dropdown__item--strong {
  font-weight: var(--font-semibold);
}

.lunch-order-dropdown__divider {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--color-border);
}

/* Public fundraiser shell */
.public-body {
  background: var(--color-canvas);
  color: var(--color-ink);
  min-height: 100vh;
}

.public-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
}

.public-shell__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border);
}

.public-shell__header-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
}

.public-shell__header-link:hover .public-shell__school-name {
  text-decoration: underline;
}

.public-shell__logo {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  object-fit: contain;
}

.public-shell__school-name {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--color-ink);
}

.public-shell__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.fundraiser-hero-image {
  border-radius: var(--radius-lg);
  overflow: hidden;
  aspect-ratio: 16 / 7;
  background: var(--color-component-surface);
}

.fundraiser-hero-image__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.fundraiser-hero {
  text-align: center;
  padding: var(--space-6) var(--space-4);
  background: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 6%, transparent);
  border-radius: var(--radius-lg);
}

.fundraiser-hero--with-image {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  margin-top: calc(-1 * var(--space-6));
}

.fundraiser-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
}

.fundraiser-gallery__item {
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.fundraiser-gallery__item:hover {
  transform: scale(1.02);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.fundraiser-gallery__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-md);
  display: block;
}

.gallery-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: var(--space-2);
}

.gallery-tile {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
}

.gallery-tile__order {
  position: absolute;
  top: var(--space-1);
  left: var(--space-1);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 2;
}

.gallery-tile__order-btn {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border: 0;
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
}

.gallery-tile__order-btn:hover {
  background: rgba(0, 0, 0, 0.85);
}

.gallery-tile.dragging {
  opacity: 0.5;
}

.gallery-tile.dragover {
  outline: 2px dashed var(--brand-primary, var(--color-primary-500));
  outline-offset: -2px;
}

.gallery-tile__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.gallery-tile__remove {
  position: absolute;
  top: var(--space-1);
  right: var(--space-1);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  padding: 4px 8px;
  cursor: pointer;
  user-select: none;
}

.gallery-tile__remove:hover {
  background: var(--color-danger-500, #dc2626);
}

.gallery-tile:has(input:checked) .gallery-tile__img {
  opacity: 0.3;
  filter: grayscale(0.6);
}

.gallery-tile:has(input:checked) .gallery-tile__remove {
  background: var(--color-danger-500, #dc2626);
}

.gallery-tile:has(input:checked)::after {
  content: "Will be removed";
  position: absolute;
  inset: auto 0 var(--space-1) 0;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-danger-500, #dc2626);
  font-weight: var(--font-semibold);
  pointer-events: none;
}

.qr-share {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.qr-share__code {
  background: white;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  width: 200px;
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-share__code svg {
  width: 100%;
  height: 100%;
  display: block;
}

.qr-share__body {
  flex: 1;
  min-width: 220px;
}

.qr-share__url {
  display: inline-block;
  word-break: break-all;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  padding: var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--color-ink);
}

.fundraiser-rank {
  margin: var(--space-3) 0 0;
  font-size: var(--text-sm);
  color: var(--color-ink-light);
}

.fundraiser-rank strong {
  color: var(--brand-primary, var(--color-primary-600));
  font-weight: var(--font-semibold);
}

.qr-dialog {
  max-width: 360px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  background: var(--color-component-surface);
  color: var(--color-ink);
}

.qr-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.qr-dialog__close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  background: transparent;
  border: 0;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--color-ink-light);
  cursor: pointer;
  padding: 4px 8px;
}

.qr-dialog__close:hover {
  color: var(--color-ink);
}

.qr-dialog__img {
  display: block;
  width: 280px;
  height: 280px;
  margin: 0 auto var(--space-3);
  background: white;
  padding: var(--space-2);
  border-radius: var(--radius-md);
}

.qr-dialog__url {
  display: block;
  word-break: break-all;
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  text-align: center;
}

.fundraiser-hero__eyebrow {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-ink-light);
  margin-bottom: var(--space-2);
}

.fundraiser-hero__title {
  font-size: 2rem;
  font-weight: var(--font-bold);
  margin: 0 0 var(--space-2);
}

.fundraiser-hero__countdown,
.fundraiser-hero__meta {
  color: var(--color-ink-light);
  margin: 0 0 var(--space-4);
}

.fundraiser-hero__cta {
  margin-top: var(--space-4);
}

.fundraiser-progress {
  max-width: 480px;
  margin: var(--space-4) auto;
}

.fundraiser-progress__amounts {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.fundraiser-progress__raised {
  font-size: 1.75rem;
  font-weight: var(--font-bold);
  color: var(--brand-primary, var(--color-primary-600));
}

.fundraiser-progress__goal {
  color: var(--color-ink-light);
  font-size: var(--text-sm);
}

.fundraiser-progress__bar {
  height: 12px;
  background: var(--color-component-surface);
  border-radius: var(--radius-full);
  overflow: hidden;
  border: 1px solid var(--color-border);
}

.fundraiser-progress__fill {
  height: 100%;
  background: var(--brand-primary, var(--color-primary-500));
  transition: width var(--transition-normal);
}

.fundraiser-progress__percent {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  margin-top: var(--space-2);
}

.fundraiser-section {
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
}

.fundraiser-section__title {
  font-size: 1.25rem;
  font-weight: var(--font-semibold);
  margin: 0 0 var(--space-3);
}

.fundraiser-section__body {
  color: var(--color-ink);
  line-height: 1.6;
}

.fundraiser-leaderboards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
}

@media (max-width: 720px) {
  .fundraiser-leaderboards {
    grid-template-columns: 1fr;
  }
}

.currency-input {
  position: relative;
  display: block;
}

.currency-input__prefix {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-ink-light);
  font-weight: var(--font-medium);
  pointer-events: none;
  font-size: var(--text-base);
  line-height: 1;
}

.currency-input input,
.currency-input input[type="text"],
.currency-input input[type="number"] {
  padding-left: 1.75rem;
}

.fundraiser-leaderboard__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.fundraiser-leaderboard__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border);
}

.fundraiser-leaderboard__row:last-child {
  border-bottom: 0;
}

.fundraiser-leaderboard__rank {
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 12%, transparent);
  color: var(--brand-primary, var(--color-primary-600));
  border-radius: var(--radius-full);
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

.fundraiser-leaderboard__name {
  color: var(--color-ink);
  text-decoration: none;
}

.fundraiser-leaderboard__amount {
  font-weight: var(--font-semibold);
  color: var(--color-ink);
}

.fundraiser-messages {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.fundraiser-message {
  border-left: 3px solid var(--brand-primary, var(--color-primary-500));
  padding: var(--space-2) var(--space-3);
  background: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 4%, transparent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.fundraiser-message__body {
  font-style: italic;
  margin: 0 0 var(--space-1);
}

.fundraiser-message__meta {
  font-size: var(--text-xs);
  color: var(--color-ink-light);
  margin: 0;
}

.donation-amount__chips {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.donation-amount__chip {
  flex: 1 1 80px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-component-surface);
  color: var(--color-ink);
  font-weight: var(--font-semibold);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.donation-amount__chip:hover {
  background: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 8%, var(--color-component-surface));
  border-color: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 30%, var(--color-border));
}

.donation-amount__chip--active {
  background: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 18%, var(--color-component-surface));
  border-color: var(--brand-primary, var(--color-primary-500));
  color: var(--brand-primary, var(--color-primary-600));
}

.donation-amount__custom {
  margin-top: var(--space-2);
}

.countdown {
  margin: var(--space-3) auto var(--space-4);
  text-align: center;
}

.countdown__date {
  color: var(--color-ink-light);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-3);
}

.countdown__cells {
  display: inline-flex;
  gap: var(--space-3);
  justify-content: center;
  flex-wrap: wrap;
}

.countdown__cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4rem;
  padding: var(--space-2) var(--space-3);
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.countdown__value {
  font-size: 1.75rem;
  font-weight: var(--font-bold);
  font-variant-numeric: tabular-nums;
  color: var(--brand-primary, var(--color-primary-600));
  line-height: 1;
}

.countdown__unit {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-ink-light);
  margin-top: var(--space-1);
}

.countdown--ended .countdown__cells {
  display: none;
}

.countdown__ended-message {
  margin: var(--space-3) 0 0;
  color: var(--color-ink-light);
  font-size: var(--text-sm);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-color-scheme="light"]) .countdown__value,
  :root:not([data-color-scheme="light"]) .fundraiser-progress__raised {
    color: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 45%, white);
  }
}

:root[data-color-scheme="dark"] .countdown__value,
:root[data-color-scheme="dark"] .fundraiser-progress__raised {
  color: color-mix(in srgb, var(--brand-primary, var(--color-primary-500)) 45%, white);
}

/* Billing */
.billing-tabs {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: var(--space-2);
}

.billing-tab {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--color-ink-light);
  text-decoration: none;
  border: 1px solid transparent;
}

.billing-tab:hover {
  background: color-mix(in srgb, var(--theme-primary) 6%, transparent);
  color: var(--color-ink);
}

.billing-tab--active {
  background: color-mix(in srgb, var(--theme-primary) 10%, transparent);
  color: var(--color-ink);
  border-color: color-mix(in srgb, var(--theme-primary) 25%, transparent);
}

.billing-table tbody tr:hover {
  background: color-mix(in srgb, var(--theme-primary) 4%, transparent);
}

/* Personalized lunch calendar (per-student colored chips) */
.lunch-personal-calendar {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-width: 720px;
  margin: 0 auto;
}

.lunch-personal-calendar__cell {
  background: var(--color-canvas);
  padding: var(--space-2);
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.lunch-personal-calendar__cell--empty {
  background: var(--color-surface-subtle);
}

.lunch-personal-calendar__cell--off {
  background: color-mix(in srgb, var(--color-warning-500) 8%, var(--color-canvas));
}

.lunch-personal-calendar__date {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
}

.lunch-personal-calendar__off-label {
  font-size: var(--text-xs);
  color: var(--color-warning-700, #a16207);
  font-style: italic;
}

.lunch-personal-calendar__chip {
  display: flex;
  flex-direction: column;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--student-color, var(--color-primary-500));
  background: color-mix(in srgb, var(--student-color, var(--color-primary-500)) 12%, var(--color-canvas));
  font-size: var(--text-xs);
  line-height: 1.3;
  min-width: 0;
}

.lunch-personal-calendar__chip-name {
  font-weight: var(--font-semibold);
  color: var(--student-color, var(--color-primary-600));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lunch-personal-calendar__chip-meal {
  color: var(--color-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lunch-personal-calendar__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
}

.lunch-personal-calendar__legend-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-ink);
}

.lunch-personal-calendar__swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: var(--radius-sm);
  background: var(--student-color, var(--color-primary-500));
}

.lunch-selection-calendar {
  max-width: 720px;
  margin: 0 auto;
}

.lunch-selection-calendar .lunch-calendar__header {
  max-width: 720px;
  margin: 0 auto;
}

.lunch-menu-calendar__cell {
  background: var(--color-canvas);
  padding: var(--space-3);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.lunch-menu-calendar__cell--off {
  background: color-mix(in srgb, var(--color-warning-500) 8%, var(--color-canvas));
}

.lunch-menu-calendar__date {
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
}

.lunch-menu-calendar__meal {
  font-size: var(--text-xs);
  color: var(--color-ink);
  display: flex;
  justify-content: space-between;
}

.lunch-menu-calendar__label {
  font-size: var(--text-xs);
  color: var(--color-warning-700, #a16207);
  font-style: italic;
}

/* Admin calendar cells */

.lunch-admin-cell__meals {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  margin-bottom: var(--space-1);
}

.lunch-admin-cell__actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: auto;
}

.lunch-admin-cell__actions .btn,
.lunch-admin-cell__actions button,
.lunch-admin-cell__actions a.btn,
.lunch-admin-cell__actions form button,
.lunch-admin-cell__actions form .btn {
  font-size: 0.65rem !important;
  padding: 2px 6px !important;
  line-height: 1.2 !important;
  min-height: 0 !important;
  height: auto !important;
}

.lunch-admin-cell__actions form {
  display: inline;
  margin: 0;
}

.lunch-admin-cell__actions--empty {
  justify-content: center;
  align-items: center;
  flex: 1;
}

/* Row action dropdown (gear menu) */
.row-actions {
  position: relative;
  display: inline-block;
}

.row-actions__trigger {
  padding: var(--space-1) var(--space-2);
  min-width: 0;
}

.row-actions__menu.popover {
  width: min(13rem, calc(100vw - 2rem));
}

.row-actions__menu .popover__body {
  padding: var(--space-1);
}

.row-actions__menu .row-actions-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-ink);
  font-size: var(--text-sm);
  font-weight: var(--font-normal);
  line-height: 1.4;
  cursor: pointer;
  text-decoration: none;
  box-shadow: none;
  font-family: inherit;
}

.row-actions__menu .row-actions-menu__item:hover {
  background: color-mix(in srgb, var(--color-ink) 8%, transparent);
  color: var(--color-ink);
  text-decoration: none;
}

.row-actions__menu .row-actions-menu__item--danger {
  color: var(--color-danger-600, #dc2626);
}

.row-actions__menu .row-actions-menu__item--danger:hover {
  background: color-mix(in srgb, var(--color-danger-500, #dc2626) 12%, transparent);
  color: var(--color-danger-700, #b91c1c);
}

/* Collapsible action menu (used for responsive button rows) */
.action-menu {
  display: none;
  position: relative;
}

.action-menu__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}

.action-menu__summary::-webkit-details-marker { display: none; }
.action-menu__summary::marker { content: ""; }

.action-menu__list {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 30;
  min-width: 220px;
  background: var(--color-component-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-menu__item {
  display: block;
  padding: 8px 12px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--color-ink);
  font-size: 0.875rem;
}

.action-menu__item:hover {
  background: color-mix(in srgb, var(--color-ink) 8%, transparent);
  color: var(--color-ink);
  text-decoration: none;
}

@media (max-width: 1199px) {
  .fundraiser-actions-row { display: none !important; }
  .action-menu { display: inline-block; }
}
