/* ============================================================
   Cloude Design System
   ============================================================ */

/* 1. Custom Properties */
:root {
  --bg-base:        #0d0d16;
  --bg-card:        #13131f;
  --bg-elevated:    #1a1a2e;
  --bg-input:       #0f0f1c;
  --accent:         #a78bfa;
  --accent-dim:     rgba(167, 139, 250, 0.13);
  --accent-hover:   #c4b5fd;
  --accent-active:  #7c3aed;
  --text-primary:   #ffffff;
  --text-muted:     #ffffff;
  --text-faint:     rgba(255,255,255,0.7);
  --border:         rgba(167, 139, 250, 0.11);
  --border-hover:   rgba(167, 139, 250, 0.3);
  --danger:         #f87171;
  --danger-dim:     rgba(248, 113, 113, 0.12);
  --success:        #6ee7b7;
  --success-dim:    rgba(110, 231, 183, 0.12);
  --warning:        #fbbf24;

  --radius-sm:      6px;
  --radius:         10px;
  --radius-card:    14px;
  --radius-pill:    999px;

  --sidebar-w:      240px;
  --sidebar-w-sm:   64px;
  --nav-h:          58px;

  --shadow:         0 4px 24px rgba(0, 0, 0, 0.45);
  --shadow-sm:      0 2px 8px  rgba(0, 0, 0, 0.3);

  --transition:     0.17s ease;

  --font:           'Inter', system-ui, -apple-system, sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', monospace;
}

/* 2. Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img, svg { display: block; max-width: 100%; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* 3. App Shell Layout */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-content {
  flex: 1;
  width: 100%;
  max-width: 1800px;
  margin: 0 auto;
  padding: calc(var(--nav-h) + 1.75rem) 2.5rem 2.5rem;
  min-width: 0;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.75rem;
  gap: 1rem;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.page-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ============================================================
   Page hero — shared, colorful header used across the app.
   Each page sets --hero-1/--hero-2 (and optionally --hero-3) inline
   on .pg-hero to theme its gradient; everything else is shared here
   so future tweaks apply everywhere at once.
   ============================================================ */
.pg-hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-card);
  padding: 1.75rem 2rem;
  margin-bottom: 1.75rem;
  background: linear-gradient(120deg, var(--hero-1, #7c3aed) 0%, var(--hero-2, #a78bfa) 55%, var(--hero-3, var(--hero-2, #a78bfa)) 100%);
  box-shadow: var(--shadow);
}

.pg-hero-glow {
  position: absolute;
  top: -60%; right: -10%;
  width: 340px; height: 340px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.32) 0%, rgba(255,255,255,0) 70%);
  pointer-events: none;
}

.pg-hero-top {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  flex-wrap: wrap;
}

.pg-hero-icon {
  flex-shrink: 0;
  width: 54px; height: 54px;
  border-radius: var(--radius-card);
  background: rgba(255,255,255,0.22);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.35);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
}
.pg-hero-icon svg { width: 26px; height: 26px; }

.pg-hero-text { flex: 1; min-width: 160px; }

.pg-hero-title {
  font-size: 1.55rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 12px rgba(0,0,0,0.15);
  margin: 0;
}

.pg-hero-sub {
  font-size: 0.9rem;
  font-weight: 600;
  color: rgba(255,255,255,0.88);
  margin-top: 0.2rem;
}

.pg-hero-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.pg-hero-actions .btn-primary {
  background: #fff;
  color: var(--hero-1, #7c3aed);
  border-color: #fff;
  font-weight: 700;
}
.pg-hero-actions .btn-primary:hover { background: rgba(255,255,255,0.9); }

.pg-hero-actions .btn-ghost {
  background: rgba(255,255,255,0.16);
  border-color: rgba(255,255,255,0.35);
  color: #fff;
}
.pg-hero-actions .btn-ghost:hover { background: rgba(255,255,255,0.26); }

.pg-hero-select {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  font-weight: 700;
  font-size: 0.82rem;
  border-radius: var(--radius);
  padding: 0.4rem 0.65rem;
  appearance: none;
  cursor: pointer;
}
.pg-hero-select option { color: #1a1a2e; }

.pg-hero-context-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  flex-shrink: 0;
  overflow: hidden;
}
.pg-hero-context-badge svg { width: 22px; height: 22px; }
.pg-hero-context-badge img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.pg-hero-stats {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--pg-stat-cols, 4), minmax(88px, 1fr));
  gap: 0.6rem;
  margin-top: 1.4rem;
}

.pg-stat {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  background: rgba(255,255,255,0.16);
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: var(--radius);
  padding: 0.55rem 0.95rem;
  min-width: 0;
}

.pg-stat-num {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.pg-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.8);
}

.pg-stat--warn { background: rgba(251,191,36,0.28); border-color: rgba(251,191,36,0.5); }
.pg-stat--warn .pg-stat-num { color: #fef3c7; }

.pg-stat--empty {
  background: rgba(255,255,255,0.06);
  border-style: dashed;
  transition: background 0.15s ease;
}
.pg-stat--empty:hover { background: rgba(255,255,255,0.14); }
.pg-stat--empty .pg-stat-label { text-transform: none; letter-spacing: normal; font-weight: 600; color: rgba(255,255,255,0.85); }

.pg-hero-stats-divider {
  height: 1px;
  background: rgba(255,255,255,0.18);
  margin: 0.7rem 0;
}

.pg-hero-stats-toggle {
  margin-top: 0.55rem;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  text-decoration: underline;
  cursor: pointer;
}
.pg-hero-stats-toggle:hover { color: #fff; }

@media (max-width: 640px) {
  .pg-hero { padding: 1.35rem 1.4rem; }
  .pg-hero-icon { width: 46px; height: 46px; }
  .pg-hero-title { font-size: 1.25rem; }
  .pg-hero-actions { width: 100%; }
  .pg-hero-actions .btn { flex: 1; }
  /* Ignore the admin's per-row count on narrow screens — always fit what fits */
  .pg-hero-stats { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* Search bar — shared across files, gallery */
.search-bar-wrap {
  flex: 1;
  max-width: 360px;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-primary);
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  outline: none;
  transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--accent); }
.search-input::placeholder { color: var(--text-faint); }

/* Sort bar — shared across files, gallery */
.sort-bar {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex-wrap: wrap;
}

.sort-btn {
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-faint);
  text-decoration: none;
  transition: all var(--transition);
  border: 1px solid transparent;
}
.sort-btn:hover { color: var(--text-muted); background: var(--accent-dim); }
.sort-btn.active { color: var(--accent); background: var(--accent-dim); border-color: var(--border-hover); }

/* 4. Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* 5. Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  line-height: 1.4;
}

.btn-primary {
  background: var(--accent);
  color: #0d0d16;
  border-color: var(--accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #0d0d16;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border);
}
.btn-ghost:hover {
  background: var(--accent-dim);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover {
  background: rgba(248, 113, 113, 0.22);
}

.btn-sm {
  padding: 0.3rem 0.65rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  transition: all var(--transition);
}
.btn-icon:hover {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--border);
}

/* 6. Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.form-input,
.form-select,
.form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-faint);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b85b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

.form-textarea { resize: vertical; min-height: 90px; }

.form-hint {
  font-size: 0.78rem;
  color: var(--text-faint);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* Checkbox */
.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}
.form-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
.form-check-label {
  font-size: 0.88rem;
  color: var(--text-primary);
}

/* 7. Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--transition);
}

.modal-overlay.open .modal-box {
  transform: translateY(0) scale(1);
}

.modal-box.modal-lg { max-width: 720px; }
.modal-box.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 1.4rem; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--border);
}

/* 8. Toast */
.toast-stack {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  pointer-events: none;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 1rem;
  font-size: 0.875rem;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 240px;
  max-width: 360px;
  animation: toast-in 0.2s ease forwards;
}

.toast.toast-success { border-color: rgba(110, 231, 183, 0.35); }
.toast.toast-error   { border-color: rgba(248, 113, 113, 0.35); }
.toast.toast-out     { animation: toast-out 0.2s ease forwards; }

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

/* ── Notification bell (sidebar) ──────────────────────── */
.notif-bell-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 500;
  position: relative;
  transition: background var(--transition), color var(--transition);
  text-align: left;
  margin-bottom: 0.25rem;
}
.notif-bell-btn:hover { background: var(--accent-dim); color: var(--text-primary); }

.notif-badge {
  position: absolute;
  top: 4px;
  left: 22px;
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  pointer-events: none;
}

/* Collapsed sidebar: hide label, keep badge */
.sidebar.collapsed .notif-bell-btn .nav-label { display: none; }

/* ── Notification panel (slide-in from left above sidebar) */
.notif-panel {
  position: fixed;
  top: calc(var(--nav-h) + 8px);
  right: 1rem;
  left: auto;
  bottom: auto;
  width: 340px;
  max-width: calc(100vw - 2rem);
  max-height: 520px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-card);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  z-index: 500;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.notif-panel.open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.notif-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 499;
}
.notif-backdrop.open { display: block; }

.notif-panel-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.notif-panel-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.notif-panel-close {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background var(--transition);
}
.notif-panel-close:hover { color: var(--text-primary); background: var(--accent-dim); }

.notif-list {
  overflow-y: auto;
  flex: 1;
  padding: 0.4rem 0;
}

.notif-empty {
  padding: 2rem 1rem;
  text-align: center;
  font-size: 0.83rem;
  color: var(--text-faint);
}

.notif-item {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.7rem 1rem;
  border-left: 3px solid var(--accent);
  transition: background var(--transition);
  position: relative;
}
.notif-item:hover { background: var(--bg-card); }
.notif-item.notif-read {
  border-left-color: transparent;
  opacity: 0.65;
}
.notif-item.notif-read:hover { opacity: 1; }

.notif-actor {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 0.05rem;
}

.notif-body { flex: 1; min-width: 0; }

.notif-title {
  font-size: 0.82rem;
  color: var(--text-primary);
  line-height: 1.35;
  display: flex;
  align-items: flex-start;
  gap: 0.3rem;
}
.notif-type-icon { flex-shrink: 0; font-size: 0.8rem; }

.notif-msg {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notif-time {
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-top: 0.25rem;
}

.notif-dismiss {
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.1rem;
  opacity: 0;
  transition: opacity var(--transition), color var(--transition);
  flex-shrink: 0;
  align-self: center;
}
.notif-item:hover .notif-dismiss { opacity: 1; }
.notif-dismiss:hover { color: var(--danger); }


/* 9. Avatar */
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.avatar-sm  { width: 24px; height: 24px; }
.avatar-lg  { width: 52px; height: 52px; }
.avatar-xl  { width: 80px; height: 80px; }

.avatar-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8em;
  color: #0d0d16;
  flex-shrink: 0;
}

/* 10. Badge */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.badge-accent  { background: var(--accent-dim);  color: var(--accent); }
.badge-success { background: var(--success-dim); color: var(--success); }
.badge-danger  { background: var(--danger-dim);  color: var(--danger); }
.badge-muted   { background: rgba(139,133,184,0.12); color: var(--text-muted); }

/* 11. Divider */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* 12. Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
  text-align: center;
  gap: 0.75rem;
}
.empty-state svg { opacity: 0.35; }
.empty-state p { font-size: 0.9rem; }

/* 13. Utilities */
.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.items-start  { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end  { justify-content: flex-end; }
.gap-1        { gap: 0.4rem; }
.gap-2        { gap: 0.75rem; }
.gap-3        { gap: 1rem; }
.gap-4        { gap: 1.5rem; }
.w-full       { width: 100%; }
.mt-1         { margin-top: 0.4rem; }
.mt-2         { margin-top: 0.75rem; }
.mt-3         { margin-top: 1rem; }
.mt-4         { margin-top: 1.5rem; }
/* ── Team module toggles ─────────────────────────────────── */
.modules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
}

.module-toggle {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.75rem 0.5rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  user-select: none;
}

.module-toggle input { display: none; }

.module-toggle--on {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.module-toggle-icon { font-size: 1.4rem; line-height: 1; }
.module-toggle-label { font-size: 0.75rem; font-weight: 600; color: #fff; }
.module-toggle-state { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); }
.module-toggle--on .module-toggle-state { color: var(--accent); }

.mb-1         { margin-bottom: 0.4rem; }
.mb-2         { margin-bottom: 0.75rem; }
.mb-3         { margin-bottom: 1rem; }
.text-muted   { color: var(--text-muted); }
.text-faint   { color: var(--text-faint); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--danger); }
.text-sm      { font-size: 0.85rem; }
.text-xs      { font-size: 0.75rem; }
.font-semibold { font-weight: 600; }
.font-bold    { font-weight: 700; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only      { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* 14. Color dot (for user/team colors) */
.color-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* 15. Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(167,139,250,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(167,139,250,0.4); }

/* 16. Focus visible */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 17. Loading spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 18. Responsive */
@media (max-width: 768px) {
  .page-content { padding: calc(var(--nav-h) + 1rem) 1rem 1.5rem; }
  .form-row { grid-template-columns: 1fr; }
}

/* ── Upload progress (shared: gallery + files) ─────────── */
.upload-progress {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.5rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.progress-bar-wrap {
  height: 4px;
  background: var(--bg-base);
  border-radius: 2px;
  margin-top: 0.4rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.15s ease;
}

/* ── Countdown alarm bar (global — present on every page) ── */
.alarm-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-elevated);
  border-top: 2px solid var(--accent);
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 900;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.4);
}
.alarm-bar.visible { transform: translateY(0); }
.alarm-bar-icon { font-size: 1.5rem; flex-shrink: 0; }
.alarm-bar-info { flex: 1; min-width: 0; }
.alarm-bar-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.alarm-bar-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.1rem; }
.alarm-bar-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

@media (max-width: 768px) { .alarm-bar { left: 0; } }

/* ── Preset avatar picker ─────────────────────────────────── */
.preset-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 0.5rem;
}

.preset-picker-item {
  padding: 0;
  border: 2px solid transparent;
  border-radius: 10px;
  background: var(--bg-elevated);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 0.12s, transform 0.1s;
}

.preset-picker-item:hover {
  border-color: rgba(167,139,250,0.4);
  transform: scale(1.05);
}

.preset-picker-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(167,139,250,0.25);
}

.preset-picker-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

/* ── Download "preparing" popup ──────────────────────────── */
.cloude-dl-stack {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 4000;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  width: 340px;
  max-width: calc(100vw - 2rem);
  pointer-events: none;
}
.cloude-dl-card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.8rem 0.9rem;
  animation: cloude-dl-in 0.25s ease;
}
@keyframes cloude-dl-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.cloude-dl-card--out {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.cloude-dl-spinner {
  width: 30px; height: 30px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: cloude-dl-spin 0.8s linear infinite;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
}
@keyframes cloude-dl-spin { to { transform: rotate(360deg); } }
.cloude-dl-card--done .cloude-dl-spinner {
  animation: none;
  border-color: var(--success);
  border-top-color: var(--success);
  color: var(--success);
}
.cloude-dl-card--error .cloude-dl-spinner {
  animation: none;
  border-color: var(--danger);
  border-top-color: var(--danger);
  color: var(--danger);
  font-weight: 800;
  font-size: 1.1rem;
}

.cloude-dl-info { flex: 1; min-width: 0; }
.cloude-dl-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cloude-dl-status {
  font-size: 0.76rem;
  color: var(--text-primary);
  opacity: 0.7;
  margin-top: 1px;
}
.cloude-dl-bar {
  margin-top: 0.45rem;
  height: 4px;
  border-radius: 3px;
  background: var(--border);
  overflow: hidden;
}
.cloude-dl-bar-fill {
  height: 100%;
  width: 40%;
  border-radius: 3px;
  background: var(--accent);
  animation: cloude-dl-indeterminate 1.1s ease-in-out infinite;
}
@keyframes cloude-dl-indeterminate {
  0%   { margin-left: -40%; }
  100% { margin-left: 100%; }
}
.cloude-dl-card--done .cloude-dl-bar-fill {
  animation: none;
  width: 100%;
  margin-left: 0;
  background: var(--success);
  transition: width 0.3s ease;
}

.cloude-dl-close {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  opacity: 0.4;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
  transition: opacity var(--transition, 0.15s);
}
.cloude-dl-close:hover { opacity: 1; }

@media (max-width: 600px) {
  .cloude-dl-stack { left: 1rem; right: 1rem; width: auto; }
}

/* ── Upload popup (shares the .cloude-dl-stack area) ──────── */
.cloude-ul-card {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 0.8rem 0.9rem;
  animation: cloude-dl-in 0.25s ease;
}
.cloude-ul-spinner {
  width: 30px; height: 30px;
  flex-shrink: 0;
  margin-top: 2px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: cloude-dl-spin 0.8s linear infinite;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary);
}
.cloude-ul-card--done .cloude-ul-spinner {
  animation: none;
  border-color: var(--success);
  border-top-color: var(--success);
  color: var(--success);
}
.cloude-ul-card--error .cloude-ul-spinner {
  animation: none;
  border-color: var(--danger);
  border-top-color: var(--danger);
  color: var(--danger);
  font-weight: 800;
  font-size: 1.1rem;
}
.cloude-ul-info { flex: 1; min-width: 0; }
.cloude-ul-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.cloude-ul-status {
  font-size: 0.76rem;
  color: var(--text-primary);
  opacity: 0.7;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cloude-ul-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: var(--accent);
  transition: width 0.2s ease;
}
.cloude-ul-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}
.cloude-ul-x {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-primary);
  opacity: 0.4;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.1rem;
  transition: opacity var(--transition, 0.15s);
}
.cloude-ul-x:hover { opacity: 1; }

/* ── Gallery category pane (shared by the image tools) ───────
   Injected by galPickerInit() into whichever modal body holds the thumbnail
   grid, so every tool gets the same picker without eight copies of it. */
.modal-body.galp-body {
  display: flex;
  padding: 0;
  min-height: 380px;
}

.galp-cats {
  width: 210px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  padding: 0.5rem;
  max-height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* Whatever the page already had, now sharing the row with the pane. */
.galp-main {
  flex: 1;
  min-width: 0;
  max-height: 440px;
  overflow-y: auto;
  padding: 0.75rem;
}

.galp-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}
.galp-btn:hover  { background: var(--bg-elevated); color: var(--text-primary); }
.galp-btn.active { background: var(--accent-dim); color: var(--text-primary); font-weight: 600; }

/* Nested paths get long — clip rather than wrap, so rows stay one height and
   the list is scannable. */
.galp-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.galp-count {
  flex: none;
  font-size: 0.68rem;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}

.galp-empty { padding: 0.4rem; font-size: 0.78rem; color: var(--text-faint); }

@media (max-width: 700px) {
  /* Pane above the grid — 210px beside a thumbnail grid leaves no room for
     either on a phone. */
  .modal-body.galp-body { flex-direction: column; }
  .galp-cats {
    width: auto;
    max-height: 30vh;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
