/* === Layout ==========================================================
 * Boot screen. App shell: topbar, sidebar, main, mobile bottom bar.
 * ===================================================================== */

/* ─── Boot screen ─────────────────────────────────────────────────── */
.boot-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--s-8);
  z-index: 9999;
}
.boot-logo {
  text-align: center;
  position: relative;
}
.boot-name {
  font-family: var(--fd);
  font-size: 72px;
  font-weight: var(--w-bold);
  letter-spacing: -0.04em;
  line-height: 0.9;
  animation: fadeUp 700ms var(--ease) backwards;
}
.boot-name__d { color: var(--tx); }
.boot-name__b { color: var(--primary); }

.boot-suffix {
  font-family: var(--fb);
  font-size: 11px;
  font-weight: var(--w-medium);
  color: var(--t3);
  letter-spacing: 0.4em;
  text-transform: uppercase;
  margin-top: 18px;
  animation: fadeUp 700ms var(--ease) 200ms backwards;
}
.boot-suffix::before, .boot-suffix::after {
  content: "—";
  margin: 0 var(--s-3);
  color: var(--t4);
}

.boot-spinner {
  width: 8px; height: 8px;
  background: var(--primary);
  border-radius: 50%;
  position: relative;
  animation: pulse 1.4s ease-in-out infinite;
}
.boot-spinner::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: var(--primary);
  z-index: -1;
  animation: ringExpand 1.6s ease-out infinite;
}

/* ─── App shell grid ──────────────────────────────────────────────── */
.app {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  position: relative;
  z-index: 1;
}

@media (max-width: 1024px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
}

/* ─── Topbar ──────────────────────────────────────────────────────── */
.app__topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 0 var(--s-6);
  background: rgba(246, 248, 251, 0.75);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  border-bottom: 1px solid var(--b1);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.app__brand {
  display: none;
  align-items: center;
  gap: var(--s-3);
}
.app__brand-mark {
  display: flex;
  align-items: baseline;
  font-family: var(--fd);
  font-weight: var(--w-bold);
  font-size: 22px;
  letter-spacing: -0.04em;
  line-height: 1;
}
.app__brand-d { color: var(--tx); }
.app__brand-b { color: var(--primary); }

@media (max-width: 1024px) {
  .app__brand { display: flex; }
}

.app__page-title {
  display: none;
  font-family: var(--fd);
  font-size: 22px;
  font-weight: var(--w-semibold);
  letter-spacing: -0.02em;
  color: var(--tx);
  line-height: 1;
}
@media (min-width: 1025px) {
  .app__page-title { display: block; }
}

.app__topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.app__sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--b1);
  padding: var(--s-5) var(--s-3) var(--s-3);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  position: sticky;
  top: 0;
  height: 100dvh;
}

.app__sidebar-brand {
  padding: 0 var(--s-3) var(--s-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.app__sidebar-brand-mark {
  display: flex;
  align-items: baseline;
  font-family: var(--fd);
  font-weight: var(--w-bold);
  font-size: 32px;
  letter-spacing: -0.04em;
  line-height: 1;
}
.app__sidebar-brand-d { color: var(--tx); }
.app__sidebar-brand-b { color: var(--primary); }

.app__sidebar-brand-sub {
  font-family: var(--fb);
  font-size: 9px;
  font-weight: var(--w-semibold);
  color: var(--t3);
  letter-spacing: 0.3em;
  text-transform: uppercase;
}

@media (max-width: 1024px) {
  .app__sidebar {
    position: fixed;
    top: 0; left: 0;
    height: 100dvh;
    width: 280px;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    z-index: var(--z-sidebar);
    box-shadow: var(--sh-4);
  }
  .app__sidebar.is-open { transform: translateX(0); }
  .iconbtn--menu { display: inline-flex; }
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-section__label {
  font-size: var(--text-2xs);
  font-weight: var(--w-bold);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--t3);
  padding: 0 var(--s-3);
  margin-bottom: 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 9px 12px;
  border-radius: var(--rs);
  font-size: var(--text-sm);
  font-weight: var(--w-medium);
  color: var(--t2);
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
  overflow: hidden;
}

.nav-link::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 0; height: 0;
  background: var(--primary);
  border-radius: 0 2px 2px 0;
  transform: translateY(-50%);
  transition: width var(--t-base), height var(--t-base);
}

.nav-link:hover {
  background: var(--surface-2);
  color: var(--tx);
}

.nav-link.is-active {
  background: var(--primary-tint);
  color: var(--primary-deep);
  font-weight: var(--w-semibold);
}
.nav-link.is-active::before {
  width: 3px;
  height: 60%;
}

.nav-link__icon {
  width: 18px;
  display: grid;
  place-items: center;
  font-size: 13px;
  color: var(--t3);
  transition: color var(--t-fast);
}
.nav-link:hover .nav-link__icon { color: var(--t2); }
.nav-link.is-active .nav-link__icon { color: var(--primary-deep); }

.nav-link__text { flex: 1; }

.nav-foot {
  margin-top: auto;
  padding: var(--s-3);
  border-top: 1px solid var(--b1);
}
.nav-foot__version {
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: var(--t3);
  letter-spacing: 0.06em;
}

/* Backdrop for mobile sidebar */
.app__backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 26, 46, 0.4);
  z-index: calc(var(--z-sidebar) - 1);
  opacity: 0;
  transition: opacity var(--t-base);
  backdrop-filter: blur(2px);
}
.app__backdrop.is-visible {
  display: block;
  opacity: 1;
}
@media (min-width: 1025px) {
  .app__backdrop { display: none !important; }
}

/* ─── Main content area ──────────────────────────────────────────── */
.app__main {
  grid-area: main;
  overflow-x: hidden;
  padding-bottom: var(--s-8);
}
@media (max-width: 1024px) {
  .app__main {
    padding-bottom: calc(var(--bottom-h) + var(--s-8));
  }
}

.module {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-6) var(--s-8);
  animation: viewIn 480ms var(--ease);
}
@media (max-width: 768px) {
  .module { padding: var(--s-5) var(--s-4); }
}
.module__loading {
  padding: var(--s-12) 0;
  text-align: center;
  color: var(--t3);
  font-size: var(--text-sm);
}

/* Module page header */
.module-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-6);
  flex-wrap: wrap;
}
.module-head__title {
  font-family: var(--fd);
  font-size: var(--text-2xl);
  font-weight: var(--w-semibold);
  letter-spacing: -0.025em;
  color: var(--tx);
  line-height: 1;
}
.module-head__sub {
  font-size: var(--text-sm);
  color: var(--t3);
  margin-top: 8px;
}
.module-head__actions {
  display: flex;
  gap: var(--s-2);
}

/* ─── Mobile bottom bar ──────────────────────────────────────────── */
.app__bottom {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--b1);
  z-index: var(--z-sticky);
  padding: 6px;
  padding-bottom: max(6px, env(safe-area-inset-bottom));
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(15, 26, 46, 0.05);
}
@media (max-width: 1024px) {
  .app__bottom {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
  }
}

.quickbtn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  color: var(--t3);
  border-radius: var(--rs);
  transition: background var(--t-fast), color var(--t-fast);
}
.quickbtn:active { background: var(--surface-2); }

.quickbtn__icon {
  font-size: 18px;
  line-height: 1;
}
.quickbtn__label {
  font-size: 10px;
  letter-spacing: 0.02em;
  font-weight: var(--w-medium);
  color: inherit;
}

.quickbtn--primary { color: var(--primary-deep); }
.quickbtn--primary .quickbtn__icon {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: var(--r-full);
  font-size: 22px;
  font-weight: var(--w-bold);
  box-shadow: var(--sh-primary);
}
