#desk {
  --bn-ink: #5e6676;
  --bn-immersive-ink: #181b22;
  --bn-immersive-on: #e5e7ec;
  --bn-split-ink: #2e55c4;
  --bn-split-on: #e8efff;
  --bn-surface: #fff;
  --bn-edge: #e0e5ee;
  --bn-shadow: 0 4px 16px #19274312, 0 1px 3px #19274309;
  --bn-floating-shadow: drop-shadow(0 6px 14px #19274321) drop-shadow(0 1px 2px #1927430a);
  --bn-ticket: linear-gradient(145deg, #4871ee, #3056d1);
}

@media (prefers-color-scheme: dark) {
  #desk {
    --bn-ink: #b2b8c6;
    --bn-immersive-ink: #fff;
    --bn-immersive-on: #30343e;
    --bn-split-ink: #b9cdff;
    --bn-split-on: #243554;
    --bn-surface: #20252e;
    --bn-edge: #343b49;
    --bn-shadow: 0 4px 16px #0004, 0 1px 3px #0003;
    --bn-floating-shadow: drop-shadow(0 6px 14px #0005) drop-shadow(0 1px 2px #0003);
  }
}

@media (max-width: 760px) {
  #desk {
    --bn-height: 50px;
    --bn-top: 4px;
    --bn-bottom: max(6px, env(safe-area-inset-bottom, 0px));
    --bn-space: calc(var(--bn-height) + var(--bn-top) + var(--bn-bottom) + var(--bn-viewport-offset, 0px));
  }

  #desk[data-bottom-nav="split"] {
    --bn-height: 58px;
    --bn-top: 0px;
    --bn-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) {
    --bn-height: 64px;
    --bn-top: 16px;
    --bn-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
    --bn-ticket-size: 48px;
  }

  #desk[data-bottom-nav="notch"] {
    --bn-top: 24px;
  }

  #desk[data-keyboard-open] {
    --bn-space: env(safe-area-inset-bottom, 0px);
  }

  #desk:is([data-standalone-page], [data-student-picker], .show-rule-workspace) {
    --bn-space: max(env(safe-area-inset-bottom, 0px), var(--bn-viewport-offset, 0px));
  }

  #desk > .mobile-nav {
    position: fixed;
    top: auto;
    right: 0;
    bottom: var(--bn-viewport-offset, 0px);
    left: 0;
    z-index: 11;
    display: block;
    padding: var(--bn-top) max(8px, env(safe-area-inset-right, 0px)) var(--bn-bottom)
      max(8px, env(safe-area-inset-left, 0px));
    background: var(--desk-page-bg, var(--bg));
  }

  #desk[data-keyboard-open] > .mobile-nav,
  #desk:is([data-standalone-page], [data-student-picker]) > .mobile-nav,
  #desk.show-rule-workspace > .mobile-nav {
    display: none;
  }

  .bn-items {
    --bn-width: 20%;
    --bn-index: 0;
    position: relative;
    isolation: isolate;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    height: var(--bn-height);
  }

  .mobile-nav[data-index="1"] .bn-items { --bn-index: 1; }
  .mobile-nav[data-index="2"] .bn-items { --bn-index: 2; }
  .mobile-nav[data-index="3"] .bn-items { --bn-index: 3; }
  .mobile-nav[data-index="4"] .bn-items { --bn-index: 4; }

  .bn-button {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    padding: 0;
    color: var(--bn-ink);
    background: none;
    border: 0;
    border-radius: 14px;
    transition: color 180ms ease, background-color 180ms ease;
    -webkit-tap-highlight-color: transparent;
  }

  .bn-button:focus-visible {
    outline-offset: -3px;
  }

  .bn-icon {
    display: grid;
    place-items: center;
    line-height: 0;
  }

  .bn-button[aria-current] {
    color: var(--bn-immersive-ink);
  }

  .bn-label,
  .bn-surface {
    display: none;
  }

  .bn-highlight {
    position: absolute;
    inset: 0 auto 0 0;
    z-index: -1;
    width: var(--bn-width);
    pointer-events: none;
    opacity: 0;
    transform: translateX(calc(var(--bn-index) * 100%));
    transition: transform 220ms cubic-bezier(.2,.7,.2,1), opacity 150ms ease;
  }

  .mobile-nav[data-index] .bn-highlight {
    opacity: 1;
  }

  .bn-highlight::after {
    content: "";
    display: block;
    width: min(52px, calc(100% - 4px));
    height: 38px;
    margin: 6px auto;
    border-radius: 13px;
    background: var(--bn-immersive-on);
  }

  #desk[data-bottom-nav="split"] > .mobile-nav {
    padding-inline: max(12px, env(safe-area-inset-left, 0px))
      max(12px, env(safe-area-inset-right, 0px));
    background: transparent;
    pointer-events: none;
  }

  #desk[data-bottom-nav="split"] .bn-items {
    --bn-gap: 8px;
    --bn-left-inset: 4px;
    --bn-width: calc((100% - var(--bn-height) - var(--bn-gap) - 2 * var(--bn-left-inset)) / 4);
    grid-template-columns: var(--bn-left-inset) repeat(4, minmax(0, 1fr))
      calc(var(--bn-gap) + var(--bn-left-inset)) var(--bn-height);
  }

  #desk[data-bottom-nav="split"] .bn-surface,
  #desk[data-bottom-nav="split"] .bn-profile {
    border: 1px solid var(--bn-edge);
    border-radius: 999px;
    background: var(--bn-surface);
    box-shadow: var(--bn-shadow);
  }

  #desk[data-bottom-nav="split"] .bn-surface {
    position: absolute;
    display: block;
    z-index: -2;
    inset: 0 calc(var(--bn-height) + var(--bn-gap)) 0 0;
    pointer-events: none;
  }

  #desk[data-bottom-nav="split"] .bn-button {
    pointer-events: auto;
    gap: 3px;
  }

  #desk[data-bottom-nav="split"] .bn-button:first-of-type {
    grid-column: 2;
  }

  #desk[data-bottom-nav="split"] .bn-label {
    display: block;
    color: inherit;
    font-size: 11px;
    font-weight: 560;
    line-height: 1.1;
    white-space: nowrap;
  }

  #desk[data-bottom-nav="split"] .bn-button[aria-current] {
    color: var(--bn-split-ink);
  }

  #desk[data-bottom-nav="split"] .bn-profile {
    grid-column: 7;
  }

  #desk[data-bottom-nav="split"] .bn-profile[aria-current] {
    background: var(--bn-split-on);
  }

  #desk[data-bottom-nav="split"] .bn-highlight {
    left: var(--bn-left-inset);
  }

  #desk[data-bottom-nav="split"] .bn-highlight::after {
    width: calc(100% - 4px);
    height: 46px;
    border-radius: 999px;
    background: var(--bn-split-on);
  }

  #desk[data-bottom-nav="split"] .mobile-nav[data-index="4"] .bn-highlight {
    --bn-index: 3;
    opacity: 0;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) > .mobile-nav {
    padding-inline: max(12px, env(safe-area-inset-left, 0px))
      max(12px, env(safe-area-inset-right, 0px));
    background: transparent;
    pointer-events: none;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-surface {
    position: absolute;
    inset: 0;
    z-index: -2;
    display: block;
    filter: var(--bn-floating-shadow);
    pointer-events: none;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-surface::before {
    position: absolute;
    inset: 0;
    border: 1px solid var(--bn-edge);
    border-radius: 26px;
    background: var(--bn-surface);
    content: "";
  }

  #desk[data-bottom-nav="notch"] .bn-surface::before {
    mask-image: radial-gradient(circle 31px at 50% 0, transparent 30px, #000 31px);
  }

  @supports (clip-path: shape(from 0 0, line to 100% 100%, close)) {
    #desk[data-bottom-nav="notch"] .bn-surface::before {
      /* A continuous curve blends the cutout into the straight top edge. */
      mask-image: none;
      clip-path: shape(
        from 0 0,
        line to calc(50% - 46px) 0,
        curve to calc(50% - 27px) 13px with calc(50% - 36px) 0 / calc(50% - 33px) 3px,
        curve to calc(50% + 27px) 13px with calc(50% - 12px) 39px / calc(50% + 12px) 39px,
        curve to calc(50% + 46px) 0 with calc(50% + 33px) 3px / calc(50% + 36px) 0,
        line to 100% 0,
        line to 100% 100%,
        line to 0 100%,
        close
      );
    }
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-button {
    justify-content: flex-end;
    gap: 4px;
    padding-bottom: 11px;
    pointer-events: auto;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-label {
    display: block;
    font-size: 11px;
    font-weight: 560;
    line-height: 13px;
    white-space: nowrap;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-button[aria-current] {
    color: var(--bn-split-ink);
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-highlight::after {
    width: min(43px, calc(100% - 4px));
    height: 32px;
    margin-top: 9px;
    border-radius: 99px;
    background: var(--bn-split-on);
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .mobile-nav[data-index="2"] .bn-highlight {
    opacity: 0;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-center .bn-icon {
    position: absolute;
    inset-inline: 0;
    top: calc(-1 * var(--bn-top));
    width: var(--bn-ticket-size);
    height: var(--bn-ticket-size);
    margin-inline: auto;
    border-radius: 50%;
    background: var(--bn-ticket);
    box-shadow: 0 3px 9px #1f49ce38;
    color: #fff;
  }

  #desk[data-bottom-nav="raised"] .bn-center .bn-icon {
    box-shadow: 0 0 0 4px var(--bn-surface), 0 6px 12px #1f49ce30;
  }

  #desk:is([data-bottom-nav="notch"], [data-bottom-nav="raised"]) .bn-center:focus-visible .bn-icon {
    outline: 2px solid currentColor;
    outline-offset: -4px;
  }
}

#desk[data-student-picker] > .desk-main {
  display: none;
}

.student-picker-workspace {
  position: fixed;
  inset: 0 0 var(--bn-viewport-offset, 0px) var(--rail);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  background: var(--desk-page-bg, var(--bg));
}

.student-picker-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px clamp(14px, 3vw, 40px);
  border-bottom: 1px solid var(--bn-edge);
  background: var(--bn-surface);
}

.student-picker-heading .icon-btn {
  flex: none;
  min-width: 44px;
  min-height: 44px;
  color: var(--bn-immersive-ink);
  background: var(--bn-surface);
  border-color: var(--bn-edge);
}
.student-picker-heading .icon-btn:hover { background: var(--bn-immersive-on); }
.student-picker-heading h1 { font-size: 22px; }
.student-picker-content { min-width: 0; overflow: hidden auto; overscroll-behavior: contain; }

@media (max-width: 760px) {
  .student-picker-workspace {
    inset: var(--bn-viewport-top, 0px) 0 var(--bn-space) 0;
    padding-top: env(safe-area-inset-top, 0px);
  }
  .student-picker-heading {
    padding: 6px max(12px, env(safe-area-inset-right, 0px)) 6px max(12px, env(safe-area-inset-left, 0px));
  }
}

.bn-preview {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  align-items: center;
  width: 100%;
  max-width: 370px;
  height: 44px;
  padding: 4px 6px;
  border-radius: 8px;
  background: var(--desk-page-bg, var(--bg));
  color: var(--bn-ink);
}

.bn-preview > span {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 1px;
  margin: 0 auto;
  width: 100%;
  max-width: 34px;
  height: 29px;
  border-radius: 9px;
}

.bn-preview > span:nth-child(2) {
  color: var(--bn-immersive-ink);
  background: var(--bn-immersive-on);
}

.bn-preview-icon {
  display: grid;
  place-items: center;
  line-height: 0;
}

.bn-preview-label {
  display: none;
}

.bn-preview[data-preview="split"] {
  grid-template-columns: repeat(4, minmax(0, 1fr)) 6px 32px;
}

.bn-preview[data-preview="split"]::before {
  position: absolute;
  z-index: -1;
  content: "";
  inset: 6px 44px 6px 6px;
  border: 1px solid var(--bn-edge);
  border-radius: 99px;
  background: var(--bn-surface);
  box-shadow: var(--bn-shadow);
}

.bn-preview[data-preview="split"] > span:nth-child(2) {
  border-radius: 99px;
  color: var(--bn-split-ink);
  background: var(--bn-split-on);
}

.bn-preview[data-preview="split"] > span:last-child {
  grid-column: 6;
  height: 32px;
  border: 1px solid var(--bn-edge);
  border-radius: 50%;
  background: var(--bn-surface);
  box-shadow: var(--bn-shadow);
}

.bn-preview[data-preview="split"] .bn-preview-label {
  display: block;
  font-size: 8px;
  line-height: 1.1;
  white-space: nowrap;
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"]) {
  height: 57px;
  align-items: end;
  padding-block: 0 7px;
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"])::before {
  position: absolute;
  inset: 17px 6px 5px;
  z-index: -1;
  border: 1px solid var(--bn-edge);
  border-radius: 14px;
  background: var(--bn-surface);
  box-shadow: var(--bn-shadow);
  content: "";
}

.bn-preview[data-preview="notch"]::before {
  mask-image: radial-gradient(circle 17px at 50% 0, transparent 16px, #000 17px);
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"]) > span:nth-child(2) {
  background: transparent;
  color: var(--bn-ink);
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"]) > span:first-child .bn-preview-icon {
  width: 25px;
  border-radius: 9px;
  background: var(--bn-split-on);
  color: var(--bn-split-ink);
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"]) .bn-preview-label {
  display: block;
  font-size: 8px;
  line-height: 1.1;
  white-space: nowrap;
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"]) .bn-preview-center {
  position: relative;
  justify-content: flex-end;
  padding-bottom: 2px;
}

.bn-preview:is([data-preview="notch"], [data-preview="raised"]) .bn-preview-center .bn-preview-icon {
  position: absolute;
  bottom: 15px;
  left: 50%;
  width: 26px;
  height: 26px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--bn-ticket);
  color: #fff;
}

.bn-preview[data-preview="notch"] .bn-preview-center .bn-preview-icon {
  bottom: 20px;
}

.bn-preview[data-preview="raised"] .bn-preview-center .bn-preview-icon {
  box-shadow: 0 0 0 2px var(--bn-surface);
}

@media (prefers-reduced-motion: reduce) {
  .bn-button,
  .bn-highlight {
    transition: none;
  }
}
