/* Reset, app shell and the few controls the shell itself needs. Screen parts come with the UI kit (components.css). */

*,
*::before,
*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 20px;
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, p, ul { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
svg.icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.focus-ring:focus-visible,
a:focus-visible,
button:focus-visible { outline: none; box-shadow: 0 0 0 1px var(--accent); }

/* Skip link */
.skip-link { position: absolute; left: -9999px; z-index: 50; }
.skip-link:focus {
  position: fixed;
  top: 8px;
  left: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-control);
  background: var(--accent);
  color: var(--on-accent);
}

/* Sidebar: hidden on phones, a 64 px icon rail from 768 px, the full 240 px from 1280 px. */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  display: none;
  width: var(--sidebar-rail);
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--bg);
}
.sidebar-brand {
  display: flex;
  height: var(--topbar);
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
}
.brand-dot {
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 9999px;
  background: var(--accent);
}
.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  padding: 16px 8px;
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group h2 {
  display: none;
  margin-bottom: 4px;
  padding: 0 12px;
  color: var(--muted);
}
.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 8px;
  border-top: 1px solid var(--line);
}
.nav-link {
  position: relative;
  display: flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 12px;
  border-radius: var(--radius-control);
  color: var(--muted);
  font-size: 14px;
  transition: color var(--duration-fast) var(--ease-out), background-color var(--duration-fast) var(--ease-out);
}
.nav-link:hover { background: var(--surface); color: var(--fg); }
.nav-link[aria-current="page"] { background: var(--raised); color: var(--fg); }
/* Until the sliding marker is measured, the current link draws its own bar. */
.sidebar.has-marker .nav-link[aria-current="page"]::before { display: none; }
.nav-marker { z-index: 1; width: 2px; height: 24px; margin-top: 6px; border-radius: 9999px; background: var(--accent); }
.nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 2px;
  border-radius: 9999px;
  background: var(--accent);
}
.nav-label,
.sidebar-brand .brand-name { display: none; }
.nav-count {
  position: absolute;
  top: 4px;
  right: 4px;
  padding: 0 4px;
  border-radius: var(--radius-badge);
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 16px;
}

/* Main column, top bar and content */
.shell-main { display: flex; min-height: 100vh; flex-direction: column; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  height: var(--topbar);
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.main {
  width: 100%;
  max-width: var(--content);
  flex: 1;
  margin: 0 auto;
  padding: 20px 16px 96px;
}
.main:focus { outline: none; }
.shell-footer {
  margin-top: 32px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

/* Bottom nav (phones only): four sections and More. */
.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav ul { position: relative; display: flex; }
.bottom-nav li { display: flex; flex: 1; }
.bottom-slot {
  position: relative;
  display: flex;
  min-height: 56px;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 16px;
  transition: color var(--duration-fast) var(--ease-out);
}
.bottom-slot svg.icon { width: 20px; height: 20px; }
.bottom-slot[aria-current="page"],
.bottom-slot.is-active { color: var(--accent); }
/* One marker for five equal slots: it slides by its own width per index. */
.bottom-nav .bottom-marker {
  position: absolute;
  top: -1px;
  left: 0;
  display: flex;
  width: 20%;
  justify-content: center;
  pointer-events: none;
  transform: translateX(calc(var(--nav-index, 0) * 100%));
  transition: transform var(--duration-base) var(--ease-out);
}
.bottom-nav .bottom-marker[hidden] { display: none; }
.bottom-marker::before { content: ""; width: 32px; height: 2px; border-radius: 9999px; background: var(--accent); }
.bottom-icon { position: relative; display: inline-flex; }
.bottom-icon .nav-count { top: -6px; right: -12px; }

@media (min-width: 768px) {
  .sidebar { display: flex; }
  .shell-main { padding-left: var(--sidebar-rail); }
  .topbar { padding: 0 var(--page); }
  .topbar-title,
  .bottom-nav { display: none; }
  .main { padding: 20px var(--page) 32px; }
}
@media (min-width: 1280px) {
  .sidebar { width: var(--sidebar); }
  .shell-main { padding-left: var(--sidebar); }
  .sidebar-nav,
  .sidebar-foot { padding-left: 12px; padding-right: 12px; }
  .nav-group h2,
  .sidebar-brand .brand-name { display: block; }
  .nav-link { justify-content: flex-start; }
  .nav-label { display: inline; flex: 1; }
  .nav-link .nav-count { position: static; font-size: 12px; }
}

/* Phones: the top bar holds the demo badge and five icon buttons at 44 px, so the app name gives way below 480 px. */
@media (max-width: 767px) {
  .topbar-actions { gap: 4px; }
}
@media (max-width: 479px) {
  .topbar-title { display: none; }
}
