/* ============================================================
   Base — reset, typography, app shell, sidebar, topbar.
   Colors reference tokens.css only.
   ============================================================ */

* { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  background: hsl(var(--bg-100));
  color: hsl(var(--text-100));
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: hsl(var(--text-100)); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code {
  font-family: var(--font-mono);
  background: hsl(var(--bg-300));
  padding: 1px 6px; border-radius: 6px; font-size: 13px;
  color: hsl(var(--text-200));
}
h1, h2, h3 { font-family: var(--font-serif); font-weight: 500; letter-spacing: -0.01em; }
::placeholder { color: hsl(var(--text-400)); }
::selection { background: hsl(var(--accent-100) / 0.25); }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.content { flex: 1; min-width: 0; display: flex; flex-direction: column; background: hsl(var(--bg-100)); }
.container { width: 100%; max-width: 1140px; margin: 0 auto; padding: 32px 40px 0; }
.footer {
  max-width: 1140px; margin: auto auto 0; width: 100%;
  padding: 40px 40px 24px; color: hsl(var(--text-400)); font-size: 12px;
}

/* ---------- Sidebar (captured: ~275px, bg-100 surface, full-hide collapse,
   hover flyout overlay card) ---------- */
.sidebar {
  width: 275px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: hsl(var(--bg-200));
  border-right: 1px solid hsl(var(--border) / 0.1);
  padding: 12px;
  position: sticky; top: 0; height: 100vh;
  z-index: 60;
}

.sidebar-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 4px 14px 10px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { width: 29px; height: 20px; display: block; }
.brand-name {
  font-family: "Outfit", var(--font-sans);
  font-size: 1.52rem; font-weight: 650; letter-spacing: 0.01em;
  text-transform: uppercase;
  color: hsl(var(--text-100));
}
.brand:hover { text-decoration: none; }

.icon-btn {
  width: 32px; height: 32px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: var(--radius-sm);
  color: hsl(var(--text-400)); cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: hsl(var(--border) / 0.08); color: hsl(var(--text-100)); }

.side-nav { display: flex; flex-direction: column; gap: 1px; flex: 1; padding: 0 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: hsl(var(--text-200)); font-size: 14px;
}
.side-nav a .ic { font-size: 17px; color: hsl(var(--text-400)); }
.side-nav a:hover { background: hsl(var(--border) / 0.08); text-decoration: none; color: hsl(var(--text-100)); }
.side-nav a:hover .ic { color: hsl(var(--text-200)); }
.side-nav a.active { background: hsl(var(--border) / 0.1); color: hsl(var(--text-100)); font-weight: 500; }
.side-nav a.active .ic { color: hsl(var(--text-100)); }
.side-nav .nav-cta { color: hsl(var(--accent-100)); font-weight: 500; }
.side-nav .nav-cta .ic { color: hsl(var(--accent-100)); }
.side-nav .nav-cta:hover { color: hsl(var(--accent-100)); background: hsl(var(--accent-100) / 0.1); }

/* ---------- Topbar (visible only when sidebar collapsed, desktop) ---------- */
.topbar {
  display: none;
  position: fixed; top: 0; left: 0; z-index: 65;
  padding: 10px 0 0 12px;
}
html.sb-collapsed .topbar { display: block; }

/* Collapsed sidebar → floating flyout card (captured behavior: overlay below
   the panel icon, no reflow; the icon stays clickable to re-pin) */
html.sb-collapsed .sidebar {
  position: fixed; top: 50px; bottom: 8px; left: 8px; height: auto;
  border: 1px solid hsl(var(--border) / 0.15);
  border-radius: 16px;
  box-shadow: var(--shadow-flyout);
  transform: translateX(calc(-100% - 16px));
  transition: transform 0.18s ease;
  visibility: hidden;
}
html.sb-collapsed.sb-peek .sidebar {
  transform: translateX(0);
  visibility: visible;
}

/* ---------- Account pill + menu ---------- */
.avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
  background: hsl(var(--border) / 0.12); color: hsl(var(--text-100));
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; letter-spacing: 0.02em;
}

.account {
  position: relative;
  border-top: 1px solid hsl(var(--border) / 0.1);
  margin: 12px -12px 0; padding: 10px 8px 4px;
}
.account-btn {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; background: none; border: none;
  border-radius: var(--radius-sm); color: hsl(var(--text-100));
  font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.account-btn:hover, .account.open .account-btn { background: hsl(var(--border) / 0.08); }
.account-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.account-role { color: hsl(var(--text-400)); font-size: 13px; }
.account .ic-chev-down { font-size: 14px; color: hsl(var(--text-400)); opacity: 0; transition: opacity 0.15s; }
.account-btn:hover .ic-chev-down, .account.open .ic-chev-down { opacity: 1; }

.account-menu {
  position: absolute; bottom: calc(100% + 6px); left: 8px; right: 8px;
  min-width: 244px;
  background: hsl(var(--bg-000)); border: 1px solid hsl(var(--border) / 0.15);
  border-radius: var(--radius); box-shadow: var(--shadow-menu);
  padding: 6px; z-index: 70;
}
.account-menu[hidden] { display: none; }
.menu-email {
  padding: 8px 10px 6px; font-size: 12.5px; color: hsl(var(--text-400));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: hsl(var(--text-100)); font: inherit; font-size: 13.5px;
  background: none; border: none; cursor: pointer; text-align: left;
}
.menu-item:hover { background: hsl(var(--border) / 0.08); text-decoration: none; }
.menu-item .ic { font-size: 17px; color: hsl(var(--text-400)); }
.menu-kbd { margin-left: auto; display: flex; gap: 2px; color: hsl(var(--text-400)); font-size: 12px; }
.menu-divider { height: 1px; background: hsl(var(--border) / 0.1); margin: 6px 4px; }
.menu-form { margin: 0; }
.menu-sub-root { position: relative; }
.menu-sub-root .ic-chev-right { margin-left: auto; font-size: 14px; }
.submenu {
  display: none; position: absolute; left: calc(100% + 10px); bottom: -6px;
  min-width: 212px;
  background: hsl(var(--bg-000)); border: 1px solid hsl(var(--border) / 0.15);
  border-radius: var(--radius); box-shadow: var(--shadow-menu);
  padding: 6px;
}
.menu-sub-root:hover .submenu, .menu-sub-root:focus-within .submenu { display: block; }
.submenu .menu-item { white-space: nowrap; }
.menu-checked { cursor: default; }
.menu-checked .ic-check { margin-left: auto; color: hsl(var(--accent-100)); }

/* Appearance switcher row (System / Light / Dark radiogroup) */
.appearance-row { cursor: default; }
.appearance-row:hover { background: none; }
.seg-mini {
  margin-left: auto; display: inline-flex; gap: 2px;
  background: hsl(var(--bg-200)); border: 1px solid hsl(var(--border) / 0.1);
  border-radius: var(--radius-full); padding: 2px;
}
.seg-mini .icon-btn { width: 26px; height: 26px; border-radius: var(--radius-full); }
.seg-mini .icon-btn .ic { font-size: 14px; }
.seg-mini .icon-btn[aria-checked="true"] {
  background: hsl(var(--bg-000));
  color: hsl(var(--text-100));
  box-shadow: 0 1px 3px hsl(0 0% 0% / 0.12);
}

/* ---------- Auth (logged-out) shell ---------- */
.app-auth { flex-direction: column; }
.auth-brand { padding: 20px 32px; }
.auth-brand .brand { padding: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar,
  html.sb-collapsed .sidebar {
    display: flex; visibility: visible; transform: none; transition: none;
    width: 100%; height: auto; position: static;
    flex-direction: row; align-items: center; flex-wrap: wrap; gap: 4px 12px;
    border: none; border-bottom: 1px solid hsl(var(--border) / 0.1);
    border-radius: 0; box-shadow: none;
    padding: 10px 16px;
  }
  .topbar, html.sb-collapsed .topbar { display: none; }
  .sidebar-toggle { display: none; }
  .sidebar-head { padding: 0; }
  .brand-name { font-size: 1.35rem; }
  .side-nav { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .side-nav a { padding: 6px 10px; }
  .side-nav a .ic { display: none; }
  .account { border-top: none; margin: 0 0 0 auto; padding: 0; }
  .account-menu {
    bottom: auto; top: calc(100% + 6px); left: auto; right: 0; width: 260px;
  }
  .submenu { left: auto; right: calc(100% + 10px); bottom: auto; top: -6px; }
  .container { padding: 24px 20px 0; }
  .footer { padding: 32px 20px 20px; }
}
