/* ===============================
   ROOT TOKENS
================================ */
#directory-cell-root {
  --bg-start: #f8fafc;
  --bg-end: #eef4ff;
  --surface: rgba(255, 255, 255, 0.9);
  --surface-strong: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(148, 163, 184, 0.28);
  --brand: #0ea5e9;
  --brand-strong: #0284c7;
  --danger: #dc2626;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.06);
  --shadow-float: 0 18px 45px rgba(15, 23, 42, 0.12);

  position: fixed;
  inset: 0;
  overflow: auto;
  z-index: 9999;
  background: linear-gradient(180deg, var(--bg-start), var(--bg-end));
}

.directory-cell {
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  font-family: "Manrope", "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
}

.directory-cell::before,
.directory-cell::after {
  content: "";
  position: fixed;
  pointer-events: none;
  z-index: -1;
  border-radius: 999px;
  filter: blur(24px);
}

.directory-cell::before {
  top: -80px;
  left: -90px;
  width: 320px;
  height: 320px;
  background: rgba(14, 165, 233, 0.14);
}

.directory-cell::after {
  right: -120px;
  top: 28%;
  width: 360px;
  height: 360px;
  background: rgba(59, 130, 246, 0.08);
}

/* ===============================
   HEADER
================================ */
.directory-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(248, 250, 252, 0.78);
  border-bottom: 1px solid var(--border);
}

.directory-header-row {
  width: min(1080px, 100% - 32px);
  margin: 0 auto;
  padding: 14px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

/* ===============================
   BRAND
================================ */
.directory-brand {
  display: flex;
  align-items: center;
  gap: 0px;
  min-width: 0;
}

.directory-logo,
.directory-logo-fallback {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  box-shadow: var(--shadow-soft);
  border: 1px solid rgba(255, 255, 255, 0.95);
  opacity: 1;
}

.directory-logo-fallback {
  background: linear-gradient(145deg, #0f172a, #1e293b);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
}

.directory-brand-text {
  min-width: 0;
}

.directory-title {
  margin: 0;
  font-size: clamp(1rem, 0.93rem + 0.2vw, 1.14rem);
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.directory-description {
  margin: 4px 0 0;
  font-size: 0.84rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===============================
   ACTIONS
================================ */
.directory-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.directory-login-btn {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 10px 24px rgba(2, 132, 199, 0.24);
}

.directory-login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(2, 132, 199, 0.3);
}

.directory-login-btn:active {
  transform: translateY(0);
}

.directory-mobile-account-btn {
  display: none;
  width: 42px;
  height: 42px;
  padding: 0;
  overflow: hidden;
  line-height: 0;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.4);
  background: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  color: var(--text);
}

.directory-mobile-account-icon {
  font-size: 16px;
  letter-spacing: 0.1em;
  line-height: 1;
}

.directory-mobile-account-avatar,
.directory-mobile-account-fallback {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  opacity: 1;
}

.directory-mobile-account-fallback {
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: #ffffff;
  background: linear-gradient(145deg, #334155, #1e293b);
}

/* ===============================
   PROFILE
================================ */
.directory-profile-wrapper {
  position: relative;
}

.directory-profile-chip {
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  padding: 3px 10px 3px 3px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.directory-profile-chip:hover {
  border-color: rgba(59, 130, 246, 0.45);
  box-shadow: var(--shadow-soft);
  transform: translateY(-1px);
}

.directory-profile-avatar,
.directory-profile-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.95);
  opacity: 1;
}

.directory-profile-fallback {
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #334155, #1e293b);
  color: #fff;
  font-weight: 700;
  font-size: 0.78rem;
}

.directory-profile-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.directory-profile-name {
  max-width: 170px;
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.directory-profile-meta {
  max-width: 170px;
  font-size: 0.74rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.directory-profile-menu {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 248px;
  border-radius: var(--radius-md);
  background: var(--surface-strong);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  overflow: hidden;
  z-index: 10000;
  transform-origin: top right;
  animation: menuReveal 0.2s ease-out;
}

@keyframes menuReveal {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.directory-profile-menu-header {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.directory-profile-menu-name {
  font-size: 0.88rem;
  font-weight: 800;
}

.directory-profile-menu-floor {
  margin-top: 2px;
  font-size: 0.75rem;
  color: var(--muted);
}

.directory-profile-menu-item {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  padding: 12px 16px;
  font-size: 0.84rem;
  cursor: pointer;
  transition: background 0.16s ease;
}

.directory-profile-menu-item:hover {
  background: #f8fafc;
}

.directory-profile-menu-item.logout {
  color: var(--danger);
  font-weight: 700;
}

/* ===============================
   BODY
================================ */
.directory-body {
  flex: 1;
  width: min(1080px, 100% - 32px);
  margin: 0 auto;
  padding: 28px 0 64px;
}

.directory-card {
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.directory-content-shell {
  animation: contentRise 0.2s ease-out;
}

.directory-empty {
  text-align: center;
  padding: 56px 22px;
  color: #475569;
}

.directory-empty-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text);
}

.directory-empty-text {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.directory-empty-actions {
  margin-top: 16px;
}

.directory-retry-btn {
  border: 1px solid rgba(14, 165, 233, 0.35);
  background: #ffffff;
  color: #0369a1;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.directory-retry-btn:hover {
  background: #eff6ff;
  border-color: rgba(2, 132, 199, 0.45);
}

/* ===============================
   LOADING
================================ */
.directory-loading {
  padding: 34px 26px 44px;
}

.directory-skeleton {
  position: relative;
  overflow: hidden;
  border-radius: 10px;
  background: #e9eef6;
}

.directory-skeleton::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.7), transparent);
  animation: skeletonSweep 1.2s ease-in-out infinite;
}

.directory-skeleton-title {
  height: 20px;
  width: 220px;
  margin-bottom: 14px;
}

.directory-skeleton-line {
  height: 14px;
  width: 100%;
  margin-bottom: 10px;
}

.directory-skeleton-line.short {
  width: 72%;
  margin-bottom: 22px;
}

.directory-skeleton-block {
  height: 240px;
  width: 100%;
}

@keyframes skeletonSweep {
  to {
    transform: translateX(100%);
  }
}

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

.directory-mobile-sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10020;
  background: rgba(15, 23, 42, 0.38);
}

.directory-mobile-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10021;
  background: #ffffff;
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  box-shadow: 0 -12px 34px rgba(15, 23, 42, 0.2);
  padding: 10px 16px 18px;
  animation: sheetUp 0.2s ease-out;
}

.directory-mobile-sheet-handle {
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: #cbd5e1;
  margin: 0 auto 10px;
}

.directory-mobile-sheet-title {
  font-size: 0.95rem;
  font-weight: 800;
  text-align: center;
}

.directory-mobile-sheet-meta {
  margin-top: 4px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
}

.directory-mobile-sheet-action {
  width: 100%;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 10px;
  cursor: pointer;
  color: black;
}

.directory-mobile-sheet-action.logout {
  color: var(--danger);
}

@keyframes sheetUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.directory-login-btn:focus-visible,
.directory-profile-chip:focus-visible,
.directory-retry-btn:focus-visible,
.directory-mobile-account-btn:focus-visible,
.directory-mobile-sheet-action:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

/* Title Row (Title + Change Icon) */
.directory-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Change (Pen) Icon Button */
.directory-change-floor-btn {
  border: none;
  background: transparent;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.directory-change-floor-btn:hover {
  color: var(--brand-strong);
  background: rgba(14, 165, 233, 0.08);
  transform: scale(1.05);
}

/* ===============================
   MOBILE
================================ */
@media (max-width: 768px) {

  .directory-mobile-account-avatar,
.directory-mobile-account-fallback {

  margin: 0;

}
  .directory-header-row,
  .directory-body {
    width: calc(100% - 24px);
  }

  .directory-header-row {
    padding: 12px 0;
  }

  .directory-brand {
    gap: 0px;
  }

  .directory-logo,
  .directory-logo-fallback {
    width: 42px;
    height: 42px;
  }

  .directory-profile-text {
    display: none;
  }

  .directory-profile-wrapper {
    display: none;
  }

  .directory-mobile-account-btn {
    display: grid;
    place-items: center;
  }

  .directory-profile-chip {
    padding-right: 3px;
    gap: 0;
  }

  .directory-card {
    border-radius: 18px;
  }

  .directory-loading {
    padding: 24px 18px 28px;
  }

  .directory-skeleton-title {
    width: 160px;
  }

  /* Mobile adjustment for change icon */
.directory-title-row {
  gap: 6px;
}

.directory-change-floor-btn {
  padding: 2px;
}

.directory-change-floor-btn svg {
  width: 15px;
  height: 15px;
}
}

@media (prefers-reduced-motion: reduce) {
  .directory-login-btn,
  .directory-profile-chip,
  .directory-profile-menu,
  .directory-skeleton::after,
  .directory-content-shell,
  .directory-mobile-sheet {
    transition: none;
    animation: none;
  }
}
