/* DankProxies V2 — application shell.
 *
 * A persistent left sidebar plus a sticky topbar, replacing the V1 topbar +
 * second-row subnav. The old shell spent 104px of vertical space on two rows
 * of navigation and still could not show more than six sections; a rail shows
 * every destination at once, keeps the current one visible while you scroll,
 * and hands the whole viewport height back to the content.
 */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* Bare mode: no sidebar column at all. Used by the policy gate, where the
   navigation is withheld until an acceptance is recorded. */
.app.bare { grid-template-columns: minmax(0, 1fr); }

/* ============================================================== sidebar */

.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.012));
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  z-index: 40;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px 16px;
  min-height: 46px;
}
.side-brand img { height: 26px; width: auto; display: block; }
.side-brand .mark { display: none; height: 24px; width: auto; }

.side-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; margin: 0 -4px; padding: 0 4px; }
.side-scroll::-webkit-scrollbar { width: 6px; }
.side-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.09); border-radius: 3px; }

.side-group + .side-group { margin-top: 16px; }
.side-label {
  padding: 0 10px 7px;
  color: var(--dim);
  font: 700 var(--fs-2xs)/1.4 var(--font-ui);
  letter-spacing: .12em;
  text-transform: uppercase;
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--muted);
  font: 600 var(--fs-sm)/1.4 var(--font-ui);
  transition: color var(--t-fast), background var(--t-fast);
}
.side-link svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.side-link:hover { color: var(--text); background: rgba(255,255,255,.05); }

/* Active: tinted fill, accent ink, and a rail on the left edge that reads as
   a physical marker rather than a colour change. */
.side-link.active {
  color: var(--accent-hi);
  background: var(--accent-soft);
}
.side-link.active::before {
  content: "";
  position: absolute;
  left: -12px; top: 50%;
  width: 3px; height: 20px;
  transform: translateY(-50%);
  border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: var(--accent-grad);
  box-shadow: 0 0 12px var(--accent-glow);
}
.side-link .count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: #fff;
  font: 700 var(--fs-2xs)/1.6 var(--font-ui);
  font-variant-numeric: tabular-nums;
}
.side-link .count.quiet { background: rgba(255,255,255,.1); color: var(--muted); }

/* Balance chip pinned to the bottom of the rail: the number a customer checks
   most often should never require navigating anywhere. */
.side-foot { padding-top: 12px; border-top: 1px solid var(--line); margin-top: 12px; }
.side-credit {
  display: block;
  padding: 11px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: rgba(0,0,0,.3);
  transition: border-color var(--t-fast);
}
.side-credit:hover { border-color: var(--line-hot); }
.side-credit .k {
  color: var(--dim);
  font: 700 var(--fs-2xs)/1.4 var(--font-ui);
  letter-spacing: .1em;
  text-transform: uppercase;
}
.side-credit .v {
  margin-top: 3px;
  font-family: var(--font-display);
  font-size: 1.22rem;
  font-weight: 700;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}
.side-credit .a { color: var(--accent-hi); font-size: var(--fs-xs); font-weight: 600; }

/* =============================================================== topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 35;
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--topbar-h);
  padding: 0 var(--gutter);
  border-bottom: 1px solid transparent;
  transition: border-color var(--t), background var(--t), backdrop-filter var(--t);
}
/* v2.js toggles .stuck past 12px of scroll — a flat bar at rest, a defined
   one once content is passing underneath it. */
.topbar.stuck {
  border-bottom-color: var(--line);
  background: rgba(8,8,10,.72);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
}
.topbar-title { font-family: var(--font-display); font-size: var(--fs-md); font-weight: 650; letter-spacing: -.015em; }
.topbar-crumb { color: var(--dim); font-size: var(--fs-sm); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 9px; }

.nav-burger { display: none; }

/* Command-palette trigger. Real keyboard affordance, not decoration. */
.kbar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  padding: 7px 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: rgba(0,0,0,.28);
  color: var(--dim);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.kbar-btn:hover { border-color: var(--line-hot); color: var(--muted); }
.kbar-btn svg { width: 15px; height: 15px; }
.kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--line-2);
  border-radius: 5px;
  background: rgba(255,255,255,.05);
  color: var(--dim);
  font: 600 var(--fs-2xs)/1.6 var(--font-mono);
}

/* Account menu, built on <details> so it opens with zero JS and closes on
   Escape for free. */
.acct { position: relative; }
.acct > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 9px 5px 5px;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  cursor: pointer;
  list-style: none;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.acct > summary::-webkit-details-marker { display: none; }
.acct > summary:hover, .acct[open] > summary { border-color: var(--line-2); background: rgba(255,255,255,.045); }
.acct > summary > svg { width: 15px; height: 15px; flex: none; color: var(--dim); }
.acct[open] > summary > svg { transform: rotate(180deg); }
.avatar {
  display: grid; place-items: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  font: 700 var(--fs-xs)/1 var(--font-ui);
  flex: none;
}
.acct-mail { font-size: var(--fs-sm); color: var(--muted); max-width: 165px; }
.acct-menu {
  position: absolute;
  right: 0; top: calc(100% + 8px);
  min-width: 214px;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: rgba(19,19,24,.97);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: menuIn 160ms cubic-bezier(.2,1.3,.4,1);
}
@keyframes menuIn { from { opacity: 0; transform: translateY(-6px); } }
.acct-menu a, .acct-menu button {
  display: flex; align-items: center; gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--muted);
  font: 500 var(--fs-sm)/1.4 var(--font-ui);
  text-align: left;
  cursor: pointer;
}
.acct-menu a:hover, .acct-menu button:hover { background: rgba(255,255,255,.06); color: var(--text); }
.acct-menu svg { width: 15px; height: 15px; }
.acct-menu hr { height: 1px; border: 0; margin: 5px 2px; background: var(--line); }

/* ================================================================= main */

.main { display: flex; flex-direction: column; min-width: 0; }
.page { padding: 22px var(--gutter) 72px; width: 100%; max-width: var(--maxw); margin-inline: auto; }
.page > * + * { margin-top: 18px; }
.page > .page-head + * { margin-top: 0; }

/* ====================================================== command palette */

.kbar {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: start center;
  padding-top: 14vh;
  background: rgba(4,4,6,.66);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: fadeIn 140ms ease;
}
@keyframes fadeIn { from { opacity: 0; } }
.kbar-panel {
  width: min(560px, calc(100vw - 28px));
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  background: rgba(18,18,22,.98);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: kbarIn 200ms cubic-bezier(.2,1.3,.4,1);
}
@keyframes kbarIn { from { opacity: 0; transform: translateY(-12px) scale(.98); } }
.kbar-input {
  width: 100%;
  padding: 15px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  font: 400 var(--fs-md)/1.4 var(--font-ui);
}
.kbar-input:focus { outline: none; }
.kbar-list { max-height: 330px; overflow-y: auto; padding: 6px; }
.kbar-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-xs);
  color: var(--muted);
  font-size: var(--fs-sm);
  cursor: pointer;
}
.kbar-item svg { width: 16px; height: 16px; flex: none; opacity: .8; }
.kbar-item .where { margin-left: auto; color: var(--dim); font-size: var(--fs-xs); }
.kbar-item.sel { background: var(--accent-soft); color: var(--accent-hi); }
.kbar-empty { padding: 26px; text-align: center; color: var(--dim); font-size: var(--fs-sm); }

/* ========================================================== responsive */

@media (max-width: 1080px) {
  :root { --sidebar-w: 68px; }
  .side { padding: 14px 8px; align-items: stretch; }
  .side-brand { justify-content: center; padding: 6px 0 16px; }
  .side-brand img.wordmark { display: none; }
  .side-brand .mark { display: block; }
  .side-label { display: none; }
  .side-link { justify-content: center; padding: 10px 0; }
  .side-link span.txt { display: none; }
  .side-link.active::before { left: -8px; }
  .side-link .count {
    position: absolute; top: 3px; right: 8px;
    margin: 0; padding: 0;
    min-width: 7px; height: 7px;
    font-size: 0;
    border-radius: 50%;
  }
  .side-credit { padding: 9px 4px; text-align: center; }
  .side-credit .k, .side-credit .a { display: none; }
  .side-credit .v { font-size: var(--fs-sm); }
  .kbar-btn { min-width: 0; }
  .kbar-btn span, .kbar-btn .kbd { display: none; }
}

@media (max-width: 780px) {
  .app { grid-template-columns: minmax(0, 1fr); }

  /* Off-canvas drawer. Checkbox-free: v2.js toggles the class, and the
     noscript path leaves the rail visible as a static header instead. */
  .side {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    transform: translateX(-100%);
    transition: transform var(--t);
    background: rgba(11,11,14,.98);
  }
  body.nav-open .side { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open::after {
    content: "";
    position: fixed; inset: 0;
    z-index: 39;
    background: rgba(4,4,6,.6);
    mix-blend-mode: normal;
    opacity: 1;
  }
  :root { --sidebar-w: 250px; }
  .side-brand img.wordmark { display: block; }
  .side-brand .mark { display: none; }
  .side-label { display: block; }
  .side-link { justify-content: flex-start; padding: 8px 10px; }
  .side-link span.txt { display: inline; }
  .side-link .count {
    position: static; margin-left: auto;
    min-width: auto; height: auto;
    padding: 1px 7px; font-size: var(--fs-2xs);
    border-radius: var(--r-pill);
  }
  .side-credit { padding: 11px 12px; text-align: left; }
  .side-credit .k, .side-credit .a { display: block; }
  .side-credit .v { font-size: 1.22rem; }

  .nav-burger { display: inline-grid; }
  .acct-mail { display: none; }
  .page { padding: 16px var(--gutter) 64px; }
}

/* Without JS the drawer can never open, so the rail is laid out inline
   instead of hidden off-canvas. */
.no-js .side { position: static; transform: none; width: auto; height: auto; }
.no-js .nav-burger { display: none; }
