/* ===========================================================================
   App shell
   =========================================================================== */

.shell { display: flex; height: var(--vh); overflow: hidden; background: var(--page) }

.aside {
  width: var(--aside-w);
  flex: 0 0 var(--aside-w);
  background: var(--ink);
  color: var(--on-ink);
  border-right: 1px solid color-mix(in srgb, var(--on-ink) 8%, transparent);
  display: flex;
  flex-direction: column;
  padding: 0 18px 22px 17px;
  gap: 8px;
  position: sticky; top: 0; height: var(--vh); z-index: 9;
  overflow-x: hidden; overflow-y: auto; scrollbar-width: none;
  transition: width .22s ease, flex-basis .22s ease, padding .22s ease;
}
/* 17 and 16, not 18 and 18. The rail is 78px and its items are 44px, so the
   side padding has to add up to exactly 78 - 44 for an item to fill the content
   box — and it has to pay for the 1px border-right too, which border-box charges
   to the same 78: 17 + 44 + 16 + 1 = 78. Splitting it 17/17 left a 43px content
   box, so an item could not be sized by the box it was in; it needed an explicit
   width, and an explicit width is what stopped it from animating. */
.shell[data-collapsed="1"] .aside {
  width: var(--aside-w-collapsed); flex-basis: var(--aside-w-collapsed);
  padding-left: 17px; padding-right: 16px;
}
/* The class here was .aside__label, which nothing has ever had — the label
   is .navitem__label. So collapsing the sidebar narrowed it and left the text
   in place, clipped by overflow rather than hidden.

   Everything that disappears on collapse is now a flex item growing from a zero
   basis, and collapsing it means taking its flex-grow to 0 over the same .22s as
   the width. That matters. The old rules faded these out and then set
   `position: absolute` on them, which is a layout change with no in-between: the
   labels left the flow on the first frame, while the rail was still 236px wide,
   so every icon snapped to its final place and the sidebar then slid out from
   underneath it. Growing to nothing instead keeps the whole rail moving as one
   piece for the full duration. */
.navitem__label, .navitem__badge, .aside__logo, .userrow__who {
  transition: opacity .14s ease, max-width .22s ease, padding .22s ease;
}
.shell[data-collapsed="1"] .navitem__label,
.shell[data-collapsed="1"] .aside__logo,
.shell[data-collapsed="1"] .userrow__who,
.shell[data-collapsed="1"] .navitem__badge {
  opacity: 0; pointer-events: none;
}
/* grow: 1, shrink: 1, basis: 0 — and left alone in both states. These close
   because the box around them closes, not because anything animates them. The
   grow factors have to sum to exactly 1 for that to work: flex only hands out
   free space in proportion to the factors it is given, so a sum below 1 leaves
   the remainder unclaimed, and a centred row would then re-centre itself into
   the slack. That is the whole reason the icons used to swing right and come
   back — flex-grow was being animated 1 -> 0, and every value in between left a
   little more space unclaimed than the last. */
.navitem__label, .userrow__who, .aside__logo { flex: 1 1 0; min-width: 0; overflow: hidden }
/* A badge cannot grow from zero — it is sized by its own digits — so it closes
   on max-width instead. Same .22s, same result. */
.shell[data-collapsed="1"] .navitem__badge { max-width: 0; padding-left: 0; padding-right: 0 }
/* Only the gap. No width, no height, no margin, no padding and — above all — no
   justify-content: the item is already 44px tall, it fills whatever the content
   box is, and its 11px of side padding is the same number in both states. The
   icon is the first thing in a flex-start row, so 17px of aside padding plus 11px
   of item padding puts its left edge at 28px and holds it there for the whole
   .22s. Nothing downstream of it in the row can push it. */
.shell[data-collapsed="1"] .navitem { gap: 0 }

/* Red, and separate from the amber badge: a badge counts work, an alert says
   something is broken. Collapsed it becomes a dot, because a number nobody can
   read is just noise. */
.navitem__alert {
  background: #C0362C; color: #FFF; font-size: 11px; font-weight: var(--weight-strong);
  padding: 3px 9px; border-radius: var(--r-pill);
}
/* left/top, not a margin nudge. A margin is applied to wherever the flow puts
   the dot, and the flow underneath it is moving for .22s — so the dot drifted
   with the label it happened to be sitting behind. The icon it belongs to does
   not move, so neither should it: 46px and 7px is its top-right corner. */
.shell[data-collapsed="1"] .navitem__alert {
  position: absolute; left: 29px; top: 7px; margin: 0; padding: 0;
  width: 9px; height: 9px; flex: 0 0 9px; font-size: 0;
}

/* Account row and its menu */
.userrow {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px 12px 14px 14px; border-top: 1px solid color-mix(in srgb, var(--on-ink) 12%, transparent);
  cursor: pointer; background: none; border-left: none; border-right: none; border-bottom: none;
  font-family: inherit; text-align: left; color: var(--on-ink);
  transition: padding .22s ease, gap .22s ease;
}
/* Block, not inline. These are spans, and without a display the name and the
   email laid out on one line and ran into each other — and because ellipsis
   does nothing to an inline box, the overflow was clipped mid-word rather than
   truncated. The design stacks them. */
.userrow__who { display: block }
.userrow__name, .userrow__email { display: block }
.userrow__name { font-size: 13px; font-weight: var(--weight-strong); color: var(--on-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.userrow__email { font-size: 11px; color: color-mix(in srgb, var(--on-ink) 55%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.userrow .ms {
  font-size: 18px; line-height: 1; flex: 0 0 20px; width: 20px; height: 20px;
  display: grid; place-items: center; color: color-mix(in srgb, var(--on-ink) 55%, transparent);
  transition: transform .2s ease, flex-basis .22s ease, width .22s ease, opacity .14s ease;
}
.userrow[aria-expanded="true"] .ms { transform: rotate(180deg) }
/* The gap has to go to 0 alongside the two things it was separating, or the
   avatar ends up 32px to the right of the icon rail it is meant to line up
   with — the one place in the sidebar where the alignment is by eye, not by a
   shared 44px box. */
/* 6px, because the avatar in this row is 32px and 6 + 32 + 6 is the 44px rail.
   (32px is set inline by userMenu() — the sidebar row uses a smaller avatar than
   the 38px .avatar default, which is why 3px, the figure that would centre a
   38px one, left it sitting 3px to the left of the icons above it.)

   Padding is what centres it, not justify-content, and that matters twice over.
   It makes the 8px journey monotonic rather than letting the avatar be
   re-centred into slack on the way. And at 6px the content box is exactly the
   width of the avatar, so .userrow__who — flex: 1 1 0, and therefore always
   entitled to whatever is left over — is left nothing to hold on to and closes
   to zero. At 3px it kept 6px of width and pinned the avatar against the
   padding, which is the other half of why it never reached the centre. */
.shell[data-collapsed="1"] .userrow { gap: 0; padding: 14px 6px }
.shell[data-collapsed="1"] .userrow .ms { flex-basis: 0; width: 0; opacity: 0; pointer-events: none }

.aside__brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h); flex: 0 0 var(--topbar-h); margin-bottom: 12px; padding: 0 0 0 14px;
  transition: padding .22s ease, gap .22s ease;
}
/* The chevron is never moved by anything. The logo beside it is the flexible
   item, so it absorbs the entire width change, and the toggle — a fixed 44px box
   that cannot shrink — just stays pinned to the right-hand edge of a content box
   that is closing. It arrives, on its own, exactly filling the 44px rail.

   What it used to do: switch the row to `justify-content: center` at the same
   instant the logo left the flow, which teleported the chevron from the right of
   a 236px sidebar to the middle of one — and only then let the width animate,
   sliding it back out to the right. Left, then right, inside 220ms. */
/* The gap closes with the logo. A flex gap is charged between two items even
   when one of them has been grown down to nothing, so 10px of it survived the
   collapse and shunted the chevron 10px off the rail centre — the one thing this
   whole arrangement exists to line up. */
.shell[data-collapsed="1"] .aside__brand { padding: 0; gap: 0 }

/* min-width on the flex parent, max-width on the image: a wordmark at 200%
   should shrink to the sidebar rather than push the collapse toggle off it. */
/* object-fit, not a bare max-width. The height here is fixed, so clamping the
   width alone squashed the wordmark as the row closed — for the 140ms before the
   fade finished you could watch it distort. `contain` scales it down instead and
   keeps it left-aligned, so it reads as the mark shrinking away. */
.aside__logo img {
  height: calc(26px * var(--logo-scale)); width: auto; max-width: 100%;
  object-fit: contain; object-position: left center;
  display: block; filter: var(--logo-filter);
}

.topbar__title { display: flex; align-items: center; min-width: 0 }
.topbar__logo { display: none }
/* The same 44px box as a nav item, in both states — so the chevron is the same
   size and sits on the same centre line whichever way it points, and the hit
   area does not change size under the cursor mid-transition. */
.aside__toggle {
  flex: 0 0 44px; width: 44px; height: 44px;
  display: grid; place-items: center;
  color: color-mix(in srgb, var(--on-ink) 55%, transparent);
  cursor: pointer; font-size: 22px; transition: color .16s ease;
}
.aside__toggle:hover { color: var(--on-ink) }

.aside nav { display: flex; flex-direction: column; gap: 4px }
/* Between Actions and the rest of the nav. 8px either side on top of the nav's
   own 4px gap, so the block reads as separate without a heading to say so. */
.aside__rule {
  height: 1px; margin: 8px 11px;
  background: color-mix(in srgb, var(--on-ink) 14%, transparent);
}

.navitem {
  display: flex;
  align-items: center;
  gap: 12px;
  /* 44px, set rather than inferred from padding. A 22px icon with 12px above and
     below makes a 46px row, but the collapsed rail's items are 44px — so every
     icon sat 2px lower than its own collapsed self, and because the error
     accumulated down a column with 4px gaps, the last one was 9px out. The icons
     climbed the rail as it closed. One height fixes all five at once: the icon
     centres are identical in both states, so nothing moves vertically at all. */
  height: 44px;
  /* 11px, not 14px, and the same 11px when collapsed: 11 + 22 + 11 is exactly
     the 44px rail, so one number both centres the icon on the closed rail and
     pins it in place on the open one. */
  padding: 0 11px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 500;
  color: color-mix(in srgb, var(--on-ink) 70%, transparent);
  cursor: pointer;
  transition: background .18s ease, color .18s ease, gap .22s ease, padding .22s ease;
}
.navitem:hover { background: color-mix(in srgb, var(--on-ink) 7%, transparent); color: var(--on-ink) }
.navitem[aria-current="page"] { background: var(--teal); color: var(--on-teal); font-weight: var(--weight-strong) }
.navitem .ms { font-size: 22px; flex: 0 0 auto }
.navitem__label { white-space: nowrap }
.navitem__badge {
  background: var(--amber); color: var(--ink-fixed);
  font-size: 11px; font-weight: var(--weight-strong);
  padding: 3px 9px; border-radius: var(--r-pill);
  flex: 0 0 auto; max-width: 60px; overflow: hidden; white-space: nowrap;
}

.aside__foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px }

/* The inbox's state above the account row (inboxAlert in app/shell.js): red
   when there is no working inbox, so nothing sends and the calendar doesn't
   sync; the accent when setup's voice step is all that is left. A wash of its
   colour, never a solid fill, so it doesn't outshout the page that is lit.
   Collapsed, the label closes like every other and a dot marks the icon, in
   the same place as the Team alert's. */
.navitem--bad { background: color-mix(in srgb, var(--bad) 24%, transparent); color: #FFD4CF }
.navitem--bad .ms { color: #FF8A7E }
.navitem--bad:hover { background: color-mix(in srgb, var(--bad) 34%, transparent); color: #FFF }
.navitem--todo { background: color-mix(in srgb, var(--coral) 18%, transparent); color: var(--on-ink) }
.navitem--todo .ms { color: var(--coral) }
.navitem--todo:hover { background: color-mix(in srgb, var(--coral) 28%, transparent) }
.navitem--bad, .navitem--todo { position: relative; margin-bottom: 4px }
.navitem__dot { display: none }
.shell[data-collapsed="1"] .navitem__dot {
  display: block; position: absolute; left: 29px; top: 7px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--bad);
}
.shell[data-collapsed="1"] .navitem--todo .navitem__dot { background: var(--coral) }
/* On a phone the sidebar is gone: a dot on the avatar, whose menu holds the row. */
.mavatar--bad::after, .mavatar--todo::after {
  content: ""; position: absolute; top: -1px; right: -1px; pointer-events: none;
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--bad); box-shadow: 0 0 0 2px var(--card);
}
.mavatar--todo::after { background: var(--coral) }

.col { display: flex; flex-direction: column; flex: 1; min-width: 0; height: var(--vh) }

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  padding: 0 32px;
  border-bottom: 1px solid var(--hair);
  background: var(--card);
  position: sticky;
  top: 0;
  z-index: 8;
}
.topbar h1 {
  margin: 0; font-size: 20px; font-weight: var(--weight-strong); letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-right: auto;
}

/* The search field is a Soft fill field (css/forms.css) in the buttons' pill
   shape, as Pipedrive, Whop and Asana draw theirs: the same grey well and
   hairline as every other field, white with the deep-teal edge
   when you are in it (css/interaction.css, "fields"). */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--field); border: 1px solid var(--field-edge);
  border-radius: var(--r-btn); height: var(--control-h);
  padding: 0 16px; flex: 0 1 360px; min-width: 200px;
  cursor: text;
}
.search:hover:not(:focus-within) { background: var(--field-hover); border-color: var(--field-edge-hover) }
.search .ms { font-size: 18px; color: var(--muted) }
.search input {
  flex: 1; min-width: 0; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 14px; color: var(--text);
}
/* The "/" shortcut's key, at the field's right end, as Quicken, Base44 and
   Todoist mark theirs: a white keycap on the grey well, its hairline the
   field's own. The field is 36 inside its edge and the key 20, so it sits 8
   from the top and bottom, and the negative margin pulls it out of the 16px
   padding to 8 from the right too: an even gap round it, and its corner is the
   field's less that gap (floored at 8). It goes once you are in the field or
   it holds a term, and on a touch screen, where there is no key to press. */
.search__key {
  flex: 0 0 auto; display: grid; place-items: center;
  min-width: 20px; height: 20px; padding: 0 var(--sp-1); box-sizing: border-box;
  margin-right: calc(var(--sp-2) - 16px);
  background: var(--card);
  border: 1px solid var(--field-edge); border-radius: var(--r-btn-sm);
  font-family: inherit; font-size: 12px; font-weight: 500; line-height: 1; color: var(--muted);
}
.search:focus-within .search__key,
.search input:not(:placeholder-shown) ~ .search__key { display: none }
@media (hover: none) { .search__key { display: none } }

.avatar {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: var(--r-pill);
  background: var(--coral); color: var(--on-coral);
  display: grid; place-items: center;
  font-size: 13px; font-weight: var(--weight-strong);
  cursor: pointer;
}

/* The way into Settings: a gear at the far right of the bar, the place every
   app keeps it. With the bell beside it, the two are plain glyphs on the white
   bar, no outline, close together and a hairline away from the search field,
   as the header icons are in Pipedrive, Whop and Asana: ringed, each one read
   as a separate button competing with the field. Hover is the grey wash; on
   Settings the gear keeps it, so it says where you are. */
.gearbtn {
  display: grid; place-items: center; flex: 0 0 auto;
  width: var(--control-h); height: var(--control-h); box-sizing: border-box; padding: 0;
  border-radius: var(--r-btn); cursor: pointer;
  background-color: var(--card);
  border: 1px solid transparent;
  color: color-mix(in srgb, var(--text) 72%, var(--card));
}
.gearbtn .ms { font-size: 21px; color: inherit; transition: transform .3s var(--ease-out) }
.gearbtn:hover { background-color: color-mix(in srgb, var(--text) 6%, var(--card)); color: var(--text) }
.gearbtn:hover .ms { transform: rotate(45deg) }
.gearbtn[aria-current="page"] { background-color: color-mix(in srgb, var(--text) 6%, var(--card)); color: var(--text) }
@media (prefers-reduced-motion: reduce) { .gearbtn:hover .ms { transform: none } }

/* The account menu only appears in the header once the sidebar has gone. */
.mavatar { display: none; position: relative; flex: 0 0 auto }
.mavatar .avatar { width: 40px; height: 40px; flex: 0 0 40px; font-size: 13.5px }

.main {
  flex: 1; min-width: 0; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-gutter: stable;
  padding: 32px;
}

/* mobile tab bar — hidden until the sidebar goes away */
.tabbar { display: none }
