/* =========================================================
   layout.css — app shell, sidebar, topbar, bottom nav.
========================================================= */

#app-root { position: relative; z-index: 1; }

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh; min-height: 100dvh;
}

/* ── Sidebar ─────────────────────────────────────────── */
.shell-side {
  display: flex; flex-direction: column;
  gap: 4px;
  padding: 18px 14px;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg-1) 92%, transparent),
    color-mix(in srgb, var(--bg-2) 92%, transparent));
  border-right: 1px solid var(--border);
  position: sticky; top: 0;
  height: 100vh; height: 100dvh;
}
.shell-logo {
  display: flex; align-items: center; justify-content: center;
  padding: 6px 0 14px;
}
.shell-logo img { width: 44px; height: 44px; border-radius: 12px; }

.shell-nav {
  display: flex; flex-direction: column; gap: 2px;
}
.shell-nav {
  overflow-y: auto;
  min-height: 0;
}
.shell-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.shell-nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-align: left;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.shell-nav-item:hover {
  background: var(--accent-soft);
  color: var(--text-1);
}
.shell-nav-item.active {
  background: var(--accent);
  color: var(--accent-fg);
}
.shell-nav-ico {
  width: 22px; text-align: center;
  font-size: 16px;
}

/* ── Main ─────────────────────────────────────────────── */
.shell-main {
  display: flex; flex-direction: column;
  min-width: 0;
  background: transparent;
}

.shell-topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 16px var(--pad-page);
  border-bottom: 1px solid var(--border);
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--bg-1) 65%, transparent) 0%,
      color-mix(in srgb, var(--bg-1) 0%, transparent) 100%);
  backdrop-filter: blur(6px);
  position: sticky; top: 0;
  z-index: 10;
}
.shell-topbar-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-1);
}
.shell-topbar-actions { display: flex; align-items: center; gap: 8px; }

.shell-route {
  padding: var(--pad-page);
  flex: 1;
  display: block;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Bottom mobile nav ────────────────────────────────── */
.shell-bottom {
  display: none;
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 6px 6px max(6px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg-1) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  z-index: 20;
}
.shell-bottom-item {
  flex: 1;
  min-width: 40px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 0;
  font-size: 11px;
  color: var(--text-2);
  text-decoration: none;
}
.shell-bottom-item.active {
  color: var(--accent);
}
.shell-bottom-ico { font-size: 18px; }

@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .shell-side { display: none; }
  .shell-bottom { display: flex; }
  .shell-route {
    padding: var(--pad-page) var(--pad-page) calc(64px + var(--pad-page));
  }
  .shell-topbar { padding: 12px var(--pad-page); }
  .shell-topbar-title { font-size: 18px; }
}

/* ── Toast ────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text-1);
  color: var(--bg-1);
  padding: 10px 18px;
  border-radius: var(--r-pill);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur), transform var(--dur);
  z-index: 100;
}
.toast.show {
  opacity: 0.95;
  transform: translateX(-50%) translateY(0);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 18px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: var(--r-sm);
  font-weight: 600;
  font-size: 14px;
  transition: background var(--dur-fast), transform var(--dur-fast);
}
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 85%, black); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary[disabled] { opacity: 0.6; cursor: not-allowed; }

.btn-soft {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  background: var(--accent-soft);
  color: var(--text-1);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--dur-fast);
}
.btn-soft:hover { background: color-mix(in srgb, var(--accent-soft) 60%, var(--accent) 40%); }

.field {
  display: flex; flex-direction: column; gap: 6px;
}
.field span { font-size: 13px; color: var(--text-2); font-weight: 500; }

/* ── Bare shell (unauthed: no sidebar/topbar/bottom-nav) ── */
.bare-shell {
  min-height: 100vh; min-height: 100dvh;
  position: relative;
}
.bare-route { min-height: 100vh; min-height: 100dvh; }

.shell-account {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-2) 84%, transparent);
}
.shell-account-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 4px;
  border-radius: var(--r-sm);
  color: var(--text-1);
  text-decoration: none;
}
.shell-account-main:hover,
.shell-account-main.active {
  background: var(--accent-soft);
}
.shell-account-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  background: var(--accent-soft);
  color: var(--text-1);
  font-family: var(--font-serif);
  font-weight: 600;
  overflow: hidden;
}
.shell-account-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.shell-account-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.shell-account-copy b,
.shell-account-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shell-account-copy b {
  font-size: 13px;
  font-weight: 600;
}
.shell-account-copy small {
  color: var(--text-3);
  font-size: 11px;
}
.shell-account-action {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: var(--r-sm);
  color: var(--text-2);
  background: var(--bg-1);
  border: 1px solid var(--border);
  text-decoration: none;
  transition: color var(--dur-fast), border-color var(--dur-fast), background var(--dur-fast);
}
.shell-account-action:hover,
.shell-account-action.active {
  color: var(--text-1);
  border-color: var(--border-accent);
  background: var(--accent-soft);
}
