/* App shell: top bar, sidebar nav, bottom bar (mobile), main area, focus timer, login screen. */
.app { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); grid-template-rows: var(--topbar-h) 1fr; grid-template-areas: "brand top" "nav main"; }
.app.is-bare { display: block; }

.brand { grid-area: brand; display: flex; align-items: center; gap: var(--s2); padding: 0 var(--s5); background: var(--bg-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); font-weight: 900; font-size: 1.15rem; letter-spacing: -.01em; position: sticky; top: 0; z-index: 60; }
.brand-logo { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; font-size: 1.3rem; background: linear-gradient(135deg, var(--primary), var(--cyan)); box-shadow: 0 3px 0 rgba(0, 0, 0, .3); }
.brand-name span { color: var(--xp); }

.topbar { grid-area: top; position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s5); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.topbar-menu { display: none; }
#hud-slot { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: var(--s3); overflow: hidden; }
.topbar-actions { display: flex; align-items: center; gap: var(--s2); flex: none; }
.avatar { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; color: #fff; background: linear-gradient(135deg, var(--primary), #ec4899); border: 2px solid var(--border-strong); cursor: pointer; padding: 0; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 210px; padding: var(--s2); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 70; animation: pop-in .2s var(--ease-bounce); }
.menu-item { display: flex; align-items: center; gap: var(--s2); width: 100%; padding: 10px 12px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 700; cursor: pointer; text-align: left; }
.menu-item:hover, .menu-item:focus-visible { background: var(--surface-2); }
.menu-head { padding: 8px 12px; font-size: var(--fs-sm); color: var(--text-muted); border-bottom: 1px solid var(--border); margin-bottom: var(--s1); }
.rel { position: relative; }

.sidenav { grid-area: nav; position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: var(--s4) var(--s3); background: var(--bg-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.nav-group { margin: var(--s4) var(--s3) var(--s1); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.nav-link { --accent: var(--primary); display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; font-weight: 800; transition: background var(--dur), color var(--dur), transform var(--dur); }
.nav-link .emoji { font-size: 1.25rem; width: 28px; text-align: center; transition: transform var(--dur) var(--ease-bounce); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .emoji { transform: scale(1.18) rotate(-6deg); }
.nav-link.is-active { background: linear-gradient(90deg, color-mix(in srgb, var(--primary) 30%, transparent), transparent); color: var(--text); box-shadow: inset 4px 0 0 var(--primary); }
.sidenav-foot { margin-top: auto; padding: var(--s3); font-size: var(--fs-xs); color: var(--text-faint); }

.main { grid-area: main; padding: var(--s6) var(--s6) var(--s8); min-width: 0; outline: none; }
.main.is-loading { opacity: .6; }
.task-banner { max-width: var(--content-max); margin: 0 auto var(--s4); }

.bottombar { display: none; }
.drawer-backdrop { display: none; }

/* ── focus timer ── */
.timer-btn { font-variant-numeric: tabular-nums; }
.timer-btn.is-running { --btn-bg: color-mix(in srgb, #ef4444 30%, var(--surface-2)); }
.timer-btn.is-break { --btn-bg: color-mix(in srgb, #22c55e 30%, var(--surface-2)); }
.timer-pop { width: 260px; padding: var(--s4); }
.timer-face { font-size: 2.6rem; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; margin: var(--s2) 0; }
.timer-modes { display: flex; gap: var(--s2); justify-content: center; }

/* ── login ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s5) var(--s4); position: relative; overflow: hidden; }
.login-stars { position: absolute; inset: 0; pointer-events: none; background-image:
  radial-gradient(2px 2px at 20% 30%, #fff8, transparent), radial-gradient(1.5px 1.5px at 70% 20%, #fff6, transparent),
  radial-gradient(2px 2px at 40% 80%, #fff5, transparent), radial-gradient(1px 1px at 85% 60%, #fff8, transparent),
  radial-gradient(1.5px 1.5px at 10% 70%, #fff6, transparent), radial-gradient(1px 1px at 55% 45%, #fff7, transparent),
  radial-gradient(2px 2px at 92% 88%, #fff5, transparent), radial-gradient(1px 1px at 30% 10%, #fff8, transparent); }
:root[data-theme="light"] .login-stars { opacity: .0; }
.login-card { width: min(440px, 100%); position: relative; z-index: 1; padding: var(--s7) var(--s6); }
.login-rocket { font-size: 4rem; text-align: center; animation: float 3.2s ease-in-out infinite; filter: drop-shadow(0 10px 18px rgba(124, 108, 255, .45)); }
.login-title { text-align: center; font-size: var(--fs-3xl); margin: var(--s2) 0 var(--s1); }
.login-title span { background: linear-gradient(90deg, var(--xp), #fb7185); -webkit-background-clip: text; background-clip: text; color: transparent; }
.login-sub { text-align: center; color: var(--text-muted); margin-bottom: var(--s6); }
.login-planets { position: absolute; font-size: 3rem; opacity: .5; pointer-events: none; }

/* ── building / error page cards ── */
.building { max-width: 560px; margin: var(--s8) auto; text-align: center; }
.building .empty-icon { font-size: 4rem; }

/* ── responsive ── */
@media (max-width: 900px) {
  :root { --topbar-h: 58px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-areas: "top" "main"; }
  .brand { display: none; }
  .topbar { padding: 0 var(--s3); gap: var(--s2); }
  .topbar-menu { display: inline-flex; }
  .sidenav { position: fixed; z-index: 200; top: 0; left: 0; bottom: 0; height: 100vh; width: min(300px, 84vw); transform: translateX(-105%); transition: transform .25s ease; box-shadow: var(--shadow-lg); padding-top: var(--s5); }
  .app.drawer-open .sidenav { transform: none; }
  .app.drawer-open .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(4, 7, 22, .6); }
  .main { padding: var(--s4) var(--s4) calc(96px + env(safe-area-inset-bottom)); }
  .bottombar { display: flex; position: fixed; z-index: 100; left: 0; right: 0; bottom: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg-2) 94%, transparent); backdrop-filter: blur(10px); border-top: 1px solid var(--border); justify-content: space-around; }
  .bottom-link { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px; min-height: 54px; border: 0; background: none; border-radius: var(--radius-sm); color: var(--text-muted); text-decoration: none; font-size: 11px; font-weight: 800; cursor: pointer; }
  .bottom-link .emoji { font-size: 1.35rem; }
  .bottom-link.is-active { color: var(--text); background: color-mix(in srgb, var(--primary) 22%, transparent); }
  .hide-mobile { display: none !important; }
}
@media (min-width: 901px) { .show-mobile { display: none !important; } }
@media (max-width: 420px) { .timer-btn .timer-text { display: none; } } /* phones: the HUD streak pill needs the room */
@media (max-width: 420px) {
  .card { padding: var(--s4); border-radius: var(--radius); }
}
@media print {
  .topbar, .sidenav, .bottombar, .brand, .toast-stack { display: none !important; }
  .app { display: block; }
  body { background: #fff; color: #000; }
}
