/* ---------- Global ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; } /* prevent horiz scroll from floating bits */

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app { min-height: 100vh; } /* no grid; fixed sidebar handles layout */

/* ---------- Sidebar (fixed) ---------- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: 200px;                 /* expanded width */
  height: 100vh;
  z-index: 20;

  display: flex;
  flex-direction: column;
  gap: var(--gap);

  padding: 10px;
  border-right: 1px solid var(--border);
  background: var(--panel);

  overflow-y: auto;             /* scroll independently if tall */
  overflow-x: hidden;           /* never push a horiz scrollbar */
}

/* Collapse/expand floating button (half-in/half-out) */
/* Floating collapse/expand FAB */
.collapse-fab {
  position: fixed;
  top: 28px;
  left: calc(200px - 15px); /* starts just off the right edge of sidebar */
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 30%;
  background: var(--brand);
  border: none;
  box-shadow: 0 4px 12px #00000033;
  cursor: pointer;
  z-index: 50;
  transition:
    left 0.25s ease,
    background-color 0.25s ease,
    box-shadow 0.25s ease;
}

.collapse-fab:hover {
  background: color-mix(in srgb, var(--brand) 90%, white 10%);
  box-shadow: 0 6px 16px #00000040;
}

.collapse-fab .icon {
  width: 26px;
  height: 26px;
  color: var(--bg);
}

/* Move FAB when collapsed */
body.sidebar-collapsed .collapse-fab {
  left: calc(78px - 15px); /* keep half-overlapping collapsed sidebar */
}

/* ---------- Brand (minimal) ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  margin-bottom: 12px;
}
.brand__logo { width: 32px; height: 32px; border-radius: 6px; object-fit: contain; }
.brand__name { font: 900 32px var(--font-display); letter-spacing: .2px; color: var(--brand); }

/* ---------- Nav ---------- */
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  overflow: hidden;            /* keeps label from overflowing when collapsed */
}
.nav a:hover { background: var(--panel-2); border-color: var(--border); }
.nav a.active {
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border-color: color-mix(in srgb, var(--brand) 25%, var(--border));
  color: var(--brand)
}
.nav__icon {
  flex: 0 0 auto;
  width: 18px; height: 18px;   /* make icons a touch larger */
  color: var(--text);
}
.nav a.active .nav__icon { color: var(--brand); }
.nav__label { white-space: nowrap; }

/* ---------- Sidebar footer ---------- */
.sidebar__footer {
  margin-top: auto;
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

/* Theme toggle: blend with the sidebar (no tile) */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle .icon { width: 18px; height: 18px; color: currentColor; }
.toggle .label { font-weight: 600; font-size: 12px; color: currentColor; }
.toggle:hover { color: var(--text); }

/* ---------- Main content (offset by fixed sidebar) ---------- */
.main {
  margin-left: 230px;          /* match expanded width */
  padding: var(--pad);
  transition: margin-left .25s ease;
}

/* ---------- Collapsed state: icons only ---------- */
body.sidebar-collapsed .sidebar { width: 78px; }
body.sidebar-collapsed .main    { margin-left: 90px; }

/* Center the brand icon; fully remove the text so it doesn't reserve space */
body.sidebar-collapsed .brand { justify-content: center; }
body.sidebar-collapsed .brand__name { display: none; }

/* Icons centered; labels fully removed for true “icons-only” */
body.sidebar-collapsed .nav a { justify-content: center; padding: 10px; }
body.sidebar-collapsed .nav__label { display: none; }     /* not just opacity */
body.sidebar-collapsed .toggle .label { display: none; }  /* not just opacity */
body.sidebar-collapsed .sidebar-version { display: none;}

/* Smooth label fade when not fully removed (kept for future use) */
.brand__name, .nav__label, .toggle .label { transition: opacity .25s ease; }

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .main, .brand__name, .nav__label, .toggle .label, .collapse-toggle { transition: none !important; }
}

/* --- Floating tooltip for collapsed sidebar --- */
.sidebar-tooltip{
  position: fixed;               /* outside sidebar, never clipped */
  top: 0; left: 0;
  transform: translateY(-50%);
  padding: 6px 8px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px #00000033;
  white-space: nowrap;
  z-index: 60;
  pointer-events: none;          /* don’t steal hover */
  opacity: 0;
  transition: opacity .12s ease;
  font: 600 12px/1 var(--font-body);
}


/* ---------- Content components (cards, titles, buttons) ---------- */

/* Page header + title */
.page-header {
  margin: 0 0 16px 0;
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.page-title {
  font: 800 20px/1.2 var(--font-display);
  letter-spacing: .2px;
}

/* Card */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card + .card { margin-top: 12px; }  /* simple vertical rhythm */

/* Muted copy */
.muted { color: var(--muted); }

/* Button (primary) */
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--brand) 25%, var(--border));
  background: var(--brand);
  color: #fff;
  font: 700 13px/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: filter .15s ease, transform .02s ease;
}
.button:hover { filter: brightness(1.05); }
.button:active { transform: translateY(1px); }

/* Button (subtle / secondary) */
.button.secondary {
  background: color-mix(in srgb, var(--brand) 10%, transparent);
  color: var(--text);
  border-color: var(--border);
}

/* Simple stack utility for vertical spacing */
.stack > * + * { margin-top: 12px; }

/* Features grid */
.features-toolbar{
  display:flex; align-items:center; justify-content:flex-end; gap:8px; margin-bottom:12px;
}
.features-grid{
  display:grid; gap:12px;
  grid-template-columns: repeat(2, minmax(0,1fr));
}
@media (max-width: 720px){
  .features-grid{ grid-template-columns: 1fr; }
}

/* Feature card */
.feature-card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  position: relative;
}
.feature-card h4{ margin:0 0 6px; font: 800 16px/1.2 var(--font-display); }
.feature-meta{ color: var(--muted); font-size: 12px; margin-bottom: 8px; }

/* Card actions (top-right) */
.card-actions{
  position:absolute; top:8px; right:8px; display:flex; gap:6px;
}
.icon-btn{
  display:inline-grid; place-items:center;
  width:28px; height:28px; border-radius:8px;
  background: transparent; color: var(--muted);
  border:1px solid transparent; cursor:pointer;
}
.icon-btn:hover{ background: var(--panel-2); border-color: var(--border); color: var(--text); }
.icon-16{ width:16px; height:16px; }

/* Modal */
.modal-backdrop{
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display:none; align-items:center; justify-content:center; z-index: 90;
}
.modal{
  background: var(--panel);
  border:1px solid var(--border);
  border-radius: 12px;
  width: min(680px, 92vw);
  max-height: 90vh; overflow:auto; padding:16px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.modal-header{ display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.modal-title{ font:800 16px/1.2 var(--font-display); }
.modal-close{ border:none; background:transparent; color:var(--muted); cursor:pointer; }
.modal-close:hover{ color: var(--text); }

/* hidden utility */
.is-hidden{ display:none !important; }

/* Filter popover (for Features page) */
.filter-popover{
  position: absolute;
  right: 0;
  top: 42px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  min-width: 220px;
  z-index: 40;
}
.filter-popover label{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 2px;
  cursor: pointer;
}

