/* ── Boot splash: shown in #app before the app mounts ────────────────────── */
.app-splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--color-bg);
  animation: splash-fade 0.4s ease both;
}
.app-splash__mark {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #cfe0ff;
  background: linear-gradient(160deg, #223860, #16233c);
  border: 1px solid var(--ink-line);
  box-shadow: var(--shadow-md);
  animation: splash-float 2.4s ease-in-out infinite;
}
.app-splash__mark svg { width: 30px; height: 30px; }
.app-splash__name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.app-splash__by {
  margin-top: -10px;
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 0.72rem;
  color: var(--color-faint);
}
.app-splash__bar {
  position: relative;
  width: 180px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  overflow: hidden;
}
.app-splash__fill {
  position: absolute;
  inset: 0;
  width: 40%;
  border-radius: inherit;
  background: var(--color-primary);
  animation: splash-slide 1.15s ease-in-out infinite;
}
.app-splash__hint { font-size: 0.82rem; color: var(--color-muted); }

@keyframes splash-fade { from { opacity: 0; } }
@keyframes splash-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes splash-slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(250%); } }

/* Smooth entrance for whatever mounts once auth resolves. */
.shell, .auth { animation: app-enter 0.34s ease both; }
@keyframes app-enter { from { opacity: 0; transform: translateY(6px); } }

@media (prefers-reduced-motion: reduce) {
  .app-splash, .app-splash__mark, .app-splash__fill, .shell, .auth { animation: none; }
  .app-splash__fill { width: 100%; opacity: 0.5; }
}

/* ── App shell: fixed left sidebar + scrolling content ───────────────────── */
.shell { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--ink);
  color: var(--on-ink);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 8px;
  z-index: 20;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 6px 8px 14px;
}
.sidebar__mark {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: #cfe0ff;
  background: linear-gradient(160deg, #223860, #16233c);
  border: 1px solid var(--ink-line);
}
.sidebar__mark svg { width: 20px; height: 20px; }
.sidebar__name { font-family: var(--font-display); font-weight: 600; font-size: 1.02rem; line-height: 1.2; display: flex; flex-direction: column; }
.sidebar__name small { font-family: var(--font-body); font-weight: 400; font-size: 0.66rem; letter-spacing: 0; color: var(--color-faint); }

.sidebar__nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-section {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--on-ink-dim);
  padding: 12px 10px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 11px;
  border-radius: 9px;
  color: var(--on-ink-dim);
  font-size: 0.92rem;
  font-weight: 500;
  transition: background 0.12s ease, color 0.12s ease;
}
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--on-ink); }
.nav-item.is-active { background: color-mix(in srgb, var(--color-primary) 90%, #fff); color: #fff; box-shadow: 0 6px 18px rgba(37, 99, 235, 0.35); }

/* Content */
.shell__main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.shell__view {
  flex: 1;
  padding: clamp(14px, 1.8vw, 22px) clamp(24px, 3.5vw, 44px) clamp(24px, 3.5vw, 44px);
}

/* ── Top bar: sticky, right-aligned profile menu ─────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 10px clamp(24px, 3.5vw, 44px);
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.profile { position: relative; }
.profile__trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-sm);
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 600;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.profile__trigger:hover { border-color: var(--color-faint); }
.profile__name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile__chev { width: 16px; height: 16px; color: var(--color-faint); flex: none; }

.profile__menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 264px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3);
  z-index: 40;
  animation: menu-pop 0.14s ease;
}
.profile__menu[hidden] { display: none; }
@keyframes menu-pop { from { opacity: 0; transform: translateY(-6px); } }

.profile__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.profile__head-meta { min-width: 0; }
.profile__head-name { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile__head-email { font-size: 0.78rem; color: var(--color-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile__head-role { margin-top: 4px; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-faint); }

.profile__link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  margin-bottom: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.profile__link:hover { background: var(--color-surface-2); border-color: var(--color-faint); }
.profile__link svg { width: 16px; height: 16px; color: var(--color-muted); flex: none; }

.profile__currency { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.profile__currency-label { font-size: 0.78rem; color: var(--color-muted); }
.profile__currency select { width: 100%; }

.profile__signout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.88rem;
  font-weight: 600;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.profile__signout:hover { background: var(--color-surface-2); border-color: var(--color-faint); }
.profile__signout svg { width: 16px; height: 16px; color: var(--color-muted); flex: none; }

/* Mobile: sidebar + profile merge into one fixed, pinned top bar */
@media (max-width: 820px) {
  /* Drop the entrance animation here: its lingering transform would make .shell
     the containing block for the fixed bar, un-pinning it from the viewport. */
  .shell { overflow-x: hidden; animation: none; }
  .sidebar {
    position: fixed;
    inset: 0 0 auto 0;
    width: 100%;
    height: var(--mobile-bar-h, 56px);
    flex-direction: row;
    align-items: center;
    padding: 0 12px;
    padding-right: 72px; /* reserve the right edge for the floating profile */
    gap: 6px;
    z-index: 30;
  }
  .sidebar__brand { padding: 0 8px 0 0; min-width: 0; flex: none; }
  .sidebar__name { font-size: 0.92rem; line-height: 1.2; white-space: nowrap; }
  .sidebar__name small { display: none; }
  .nav-section { display: none; }
  .sidebar__nav { flex-direction: row; margin-top: 0; min-width: 0; overflow-x: auto; }
  .nav-item span { display: none; }
  .nav-item { padding: 9px; flex: none; }
  .shell__main { margin-left: 0; padding-top: var(--mobile-bar-h, 56px); overflow-x: hidden; }
  /* The profile floats into the sidebar row; the bar itself is click-through so
     the nav underneath stays tappable, and only the profile captures pointers. */
  .topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    min-height: 0;
    height: var(--mobile-bar-h, 56px);
    padding: 0 12px;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-bottom: none;
    z-index: 40;
    pointer-events: none;
  }
  .profile { pointer-events: auto; }
  .profile__name { display: none; }
  .shell__view { padding: 12px 20px 20px; }
}

/* Narrow phones: drop the wordmark so brand + nav always fit */
@media (max-width: 520px) {
  .sidebar__name { display: none; }
}

/* Offline / syncing status in the top bar */
.sync-pill {
  margin-right: auto;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: auto;
}
.sync-pill[hidden] { display: none; }
.sync-pill--offline { color: #92400e; background: #fef3c7; border: 1px solid #fde68a; }
.sync-pill--failed { color: #fff; background: var(--status-out); cursor: pointer; }
.sync-pill--syncing { color: var(--color-primary-ink); background: color-mix(in srgb, var(--color-primary) 10%, transparent); }
@media (max-width: 820px) {
  .sync-pill { font-size: 0.72rem; padding: 4px 10px; }
}
