/* Shared signed-in shell. Public pages retain their own header and layout. */
:root {
  --sidebar-width: 248px;
  --shell-header-height: 76px;
  --shell-ink: #312344;
  --shell-muted: #70647f;
  --shell-border: #e9e2f1;
  --shell-active: #eee6fb;
  --shell-purple: #5933af;
  --workspace-max-width: 1680px;
  --z-sidebar: 20;
  --z-sidebar-backdrop: 30;
  --z-sidebar-drawer: 35;
}

.app-sidebar {
  display: none;
}

.sidebar-toggle,
.sidebar-close {
  display: none;
}

.sidebar-backdrop[hidden] {
  display: none;
}

.has-app-nav .app-sidebar {
  position: fixed;
  z-index: var(--z-sidebar);
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100dvh;
  padding: 0 16px;
  background: radial-gradient(ellipse at 0 0, #6e42aa55, transparent 55%), linear-gradient(165deg, #302049, #1c122e 75%);
  border-right: 1px solid #4d3763;
  color: #f5edff;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #6b537f transparent;
}

.sidebar-brand-row {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 8px;
  min-height: 100px;
  padding: 20px 6px 24px;
  margin-bottom: 16px;
  border-bottom: 1px solid #ffffff12;
}

.sidebar-brand {
  gap: 10px;
  min-width: 0;
}

.sidebar-brand .brand-mark {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-width: 1px;
  border-radius: 13px;
  box-shadow: 0 4px 12px #5933af1c;
}

.sidebar-brand strong {
  font-size: 22px;
  white-space: nowrap;
  color: #fff;
}

.sidebar-brand strong em {
  color: #edcf94;
}

.sidebar-brand small {
  display: block;
  margin-top: 5px;
  color: #c4b0d8;
  font-size: 11px;
  letter-spacing: 0;
  white-space: nowrap;
}

.has-app-nav .app-sidebar .app-nav {
  position: static;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-shrink: 0;
  width: 100%;
  min-width: 0;
  gap: 5px;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.sidebar-section-label {
  margin: 26px 14px 9px;
  color: #c0acd5;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .16em;
}

.sidebar-section-label:first-child {
  margin-top: 8px;
}

.has-app-nav .app-sidebar .app-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-direction: row;
  gap: 11px;
  min-width: 0;
  min-height: 52px;
  padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: transparent;
  color: #e0d4ed;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  text-align: left;
  text-decoration: none;
  box-shadow: none;
  transition: color 180ms ease, background-color 180ms ease, border-color 180ms ease;
}

.has-app-nav .app-sidebar .app-nav-item svg {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 10px;
  background: #ffffff09;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.has-app-nav .app-sidebar .app-nav-item:hover {
  background: #ffffff0e;
  color: #fff;
  border-color: #ffffff12;
}

.has-app-nav .app-sidebar .app-nav-item.active {
  background: #f4edff;
  color: #4c2a8b;
  border-color: #f8f3ff;
  font-weight: 700;
  box-shadow: 0 7px 20px #10062230;
}

.has-app-nav .app-sidebar .app-nav-item.active svg {
  background: #e5d7f8;
}

.has-app-nav .app-sidebar .app-nav-item.active::after {
  content: '';
  position: absolute;
  right: 13px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--shell-purple);
}

.has-app-nav .app-sidebar .app-nav-item.active svg {
  stroke-width: 2;
}

.app-sidebar .sidebar-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 15px;
  margin-top: auto;
  padding: 32px 0 24px;
}

.sidebar-footer-note {
  padding: 0 14px;
  color: #baa7ce;
  font-size: 12.5px;
}

.has-app-nav .sidebar-footer .header-logout {
  display: flex;
  grid-column: auto;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid #ffffff21;
  border-radius: 12px;
  background: #ffffff06;
  color: #e0d3ec;
  box-shadow: none;
  font-size: 15px;
}

.has-app-nav .sidebar-footer .header-logout:hover {
  color: #fff;
  background: #ffffff0e;
  border-color: #ffffff40;
}

.sidebar-footer .header-logout svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.has-app-nav .app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  height: var(--shell-header-height);
  min-height: var(--shell-header-height);
  margin-left: var(--sidebar-width);
  padding: 0 clamp(24px, 3vw, 44px);
  border-bottom: 1px solid var(--shell-border);
  background: #fbf9fff5;
  backdrop-filter: none;
  box-shadow: none;
}

.has-app-nav .app-header>.brand {
  display: none;
}

.shell-breadcrumb {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
  color: var(--shell-muted);
  font-size: 14px;
}

.shell-breadcrumb strong {
  color: var(--shell-ink);
  font-weight: 600;
}

.shell-breadcrumb>span:nth-child(2) {
  color: #b9abc8;
}

.has-app-nav .header-actions-group {
  margin-left: auto;
  gap: 14px;
}

.has-app-nav .notif-bell {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border-color: var(--shell-border);
  color: var(--shell-muted);
}

.shell-profile-link {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  min-height: 46px;
  gap: 10px;
  color: var(--shell-ink);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid #e6dcee;
  border-radius: 14px;
  background: #fff;
  padding: 5px 10px 5px 6px;
  box-shadow: 0 3px 8px #32204404;
}

.shell-profile-link:hover {
  border-color: #cdb4e7;
  background: #faf7ff;
}

.shell-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #d9c5ed;
  border-radius: 10px;
  background: linear-gradient(145deg, #f1e8fc, #e4d4f5);
  color: var(--shell-purple);
}

.shell-avatar svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
}

.shell-user-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.shell-user-copy small {
  color: var(--shell-muted);
  font-size: 11px;
  font-weight: 500;
}

#shellUserName {
  display: block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.shell-points-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid #eed7a7;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff6de, #fffaf0);
  color: #765013;
  text-decoration: none;
  box-shadow: 0 3px 10px #b9892009;
}

.shell-points-link:hover {
  border-color: #d9b365;
  background: #ffefc7;
}

.shell-points-icon {
  display: inline-flex;
  color: #9b6915;
}

.shell-points-icon svg {
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

#shellPoints {
  font: 700 19px/1 var(--font-display);
  font-variant-numeric: tabular-nums;
}

.shell-points-link small {
  color: #866022;
  font-size: 12px;
}

.shell-profile-link>svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: #9888a7;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.has-app-nav main {
  width: auto;
  max-width: none;
  margin: 0 0 0 var(--sidebar-width);
  padding: 20px clamp(20px, 2.6vw, 38px) 40px;
}

body.has-app-nav #mainContent {
  scroll-margin-top: var(--shell-header-height);
}

.has-app-nav #dashboard {
  width: 100%;
  max-width: var(--workspace-max-width);
  margin-inline: auto;
}

.has-app-nav #learningScreen {
  width: 100%;
  max-width: var(--workspace-max-width);
  margin-inline: auto;
  transform: none;
}

/* Give each kind of content a useful measure within the wider workspace. */
.has-app-nav :is(#libraryView, #profileView) {
  max-width: 1440px;
  margin-inline: auto;
}

.has-app-nav :is(#createView, #quickFactsView) {
  max-width: 1200px;
  margin-inline: auto;
}

@media (min-width: 1280px) {
  .has-app-nav .learning-layout {
    grid-template-columns: 320px minmax(0, 1fr);
  }
}

.has-app-nav .topic-tree,
.has-app-nav .lesson-audio-card {
  top: calc(var(--shell-header-height) + 16px);
}

.course-banner-back {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  margin-bottom: 12px;
  padding: 10px 16px;
  border: 1px solid #fff;
  border-radius: 12px;
  background: #fff;
  color: #35176d;
  font-size: .875rem;
  font-weight: 750;
  text-decoration: none;
  box-shadow: 0 4px 12px rgb(25 10 58 / .18);
}

.course-banner-back:hover {
  background: #f1eaff;
  border-color: #f1eaff;
}

.course-banner-back:active {
  background: #e4d7ff;
}

.course-banner-back:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 4px;
}

.tree-list:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.has-app-nav .tree-list {
  grid-auto-rows: max-content;
  align-content: start;
  min-width: 0;
}

.has-app-nav .tree-item {
  min-width: 0;
  max-width: 100%;
  height: auto;
}

.has-app-nav .tree-item-copy {
  overflow-wrap: anywhere;
}

@media (min-width: 1024px) {
  .has-app-nav .topic-tree {
    position: sticky;
    display: flex;
    flex-direction: column;
    top: calc(var(--shell-header-height) + 12px);
    height: calc(100dvh - var(--shell-header-height) - 24px);
    max-height: calc(100dvh - var(--shell-header-height) - 24px);
    overflow: hidden;
  }

  .has-app-nav .tree-list {
    min-height: 0;
    flex: 1 1 auto;
    overflow-x: hidden;
    overflow-y: auto;
    scrollbar-gutter: stable;
    padding: 3px 5px 3px 3px;
  }

  .has-app-nav .topic-tree > :not(.tree-list) {
    flex-shrink: 0;
  }

  .has-app-nav .tree-course {
    padding-bottom: 12px;
  }

  .has-app-nav .tree-course h1 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .has-app-nav .tree-progress {
    padding-block: 12px;
  }

  .has-app-nav .tree-footer {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .has-app-nav .tree-footer button {
    padding: 10px 8px;
    font-size: 12px;
  }
}


.has-app-nav .tree-list .tree-item {
  grid-template-columns: 28px minmax(0, 1fr);
  min-height: 54px;
  padding: 10px;
  gap: 10px;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  border-radius: 10px;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.has-app-nav .tree-list .tree-item:hover {
  transform: none;
  background: var(--color-primary-soft);
}

.has-app-nav .tree-list .tree-item.active {
  background: var(--color-primary-soft);
  border-color: var(--color-border);
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.has-app-nav .tree-list .tree-index {
  width: 28px;
  height: 28px;
  font-size: 11px;
  border-radius: 9px;
}

.has-app-nav .tree-list .tree-item-copy small {
  display: none;
}

.has-app-nav .tree-list .tree-item-copy strong {
  font-size: 13px;
  line-height: 1.45;
}

.has-app-nav .tree-list .tree-section-label {
  padding: 14px 10px 6px;
  font-size: 10px;
  letter-spacing: .04em;
}

.has-app-nav .lesson-pane {
  scroll-margin-top: calc(var(--shell-header-height) + 16px);
}

@media (prefers-reduced-motion: reduce) {
  .has-app-nav .tree-list .tree-item {
    transition: none;
  }
}

.has-app-nav :is(.app-sidebar, .app-header) :focus-visible {
  outline: 3px solid #8d6bc6;
  outline-offset: 3px;
}

.has-app-nav .app-sidebar :focus-visible {
  outline-color: #efc77c;
}

.has-app-nav {
  scroll-padding-top: calc(var(--shell-header-height) + 16px);
}

@media (min-width: 1024px) and (max-width: 1279px) {
  :root {
    --sidebar-width: 224px;
  }

  .sidebar-brand strong {
    font-size: 20px;
  }

  .sidebar-brand .brand-mark {
    flex-basis: 36px;
    width: 44px;
    height: 36px;
  }

  .sidebar-brand small {
    font-size: 10px;
  }

  .has-app-nav #libraryView .home-action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .has-app-nav #libraryView .home-action-grid button:last-child {
    grid-column: 1/-1;
    min-height: 150px;
  }

  .has-app-nav #libraryView .home-overview-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .has-app-nav #libraryView .home-action-copy {
    width: calc(100% - 105px);
  }

  .has-app-nav #libraryView .continue-hero {
    grid-template-columns: minmax(0, 1.5fr) minmax(180px, .7fr);
  }

  .has-app-nav #libraryView .continue-hero-mascot {
    width: 210px;
  }

  .has-app-nav #libraryView .continue-hero-mascot img {
    height: 245px;
  }

  .has-app-nav .learning-layout {
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 22px;
  }

  .has-app-nav .topic-tree {
    position: sticky;
  }

  .has-app-nav .tree-list {
    display: grid;
    max-height: none;
    margin-inline: 0;
    padding: 3px 5px 3px 3px;
    overflow-y: auto;
    scrollbar-gutter: stable;
    scroll-snap-type: none;
  }

  .has-app-nav .tree-item {
    min-width: 0;
  }
}

@media (max-width: 1023px) {
  :root {
    --shell-header-height: 68px;
  }

  .has-app-nav .app-header {
    margin-left: 0;
    padding-inline: 22px;
    gap: 12px;
  }

  .has-app-nav .app-header>.brand {
    display: flex;
    margin-right: auto;
  }

  .has-app-nav .app-header>.brand .brand-mark {
    width: 35px;
    height: 35px;
  }

  .has-app-nav .app-header>.brand small {
    display: none;
  }

  .has-app-nav .app-header>.brand strong {
    font-size: 20px;
  }

  .has-app-nav .shell-breadcrumb {
    display: none;
  }

  .has-app-nav .sidebar-toggle {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    background: #fff;
    color: var(--shell-purple);
    box-shadow: none;
  }

  .sidebar-toggle svg,
  .sidebar-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .has-app-nav .app-sidebar {
    z-index: var(--z-sidebar-drawer);
    width: min(292px, calc(100vw - 36px));
    padding: 0 18px;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    border-right: 0;
    box-shadow: 14px 0 60px #25154120;
    transition: transform 240ms cubic-bezier(.22, 1, .36, 1), visibility 0s 240ms;
  }

  .has-app-nav.sidebar-open .app-sidebar {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    transition-delay: 0s;
  }

  .sidebar-brand-row {
    padding-top: max(20px, env(safe-area-inset-top));
    min-height: 90px;
  }

  .sidebar-brand {
    flex: 1;
  }

  .sidebar-brand strong {
    font-size: 22px;
  }

  .sidebar-brand small {
    font-size: 11px;
  }

  .sidebar-close {
    display: grid;
    place-items: center;
    width: 40px;
    height: 44px;
    padding: 10px;
    border-radius: 10px;
    border: 0;
    background: transparent;
    color: #d8c6e9;
    box-shadow: none;
  }

  .sidebar-close:hover {
    color: #fff;
    background: #ffffff12;
  }

  .sidebar-backdrop {
    position: fixed;
    z-index: var(--z-sidebar-backdrop);
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #21133575;
    box-shadow: none;
    cursor: default;
  }

  .sidebar-backdrop:hover {
    background: #21133575;
    box-shadow: none;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.has-app-nav main {
    margin-left: 0;
    padding: 28px 24px 40px;
  }

  .app-sidebar .sidebar-footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 600px) {
  .has-app-nav .app-header {
    padding-inline: 16px;
    gap: 10px;
  }

  .has-app-nav .app-header>.brand {
    display: none;
  }

  .has-app-nav .app-header>.brand .brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 10px;
  }

  .has-app-nav .app-header>.brand strong {
    font-size: 18px;
  }

  .has-app-nav .header-actions-group {
    gap: 8px;
  }

  .has-app-nav .notif-dropdown {
    position: fixed;
    top: calc(var(--shell-header-height) + 8px);
    left: 16px;
    right: 16px;
    width: auto;
    max-height: calc(100dvh - var(--shell-header-height) - 32px);
  }

  .shell-profile-link {
    padding: 5px;
    gap: 7px;
  }

  .shell-profile-link>svg,
  .shell-user-copy small {
    display: none;
  }

  #shellUserName {
    max-width: 90px;
    font-size: 12.5px;
  }

  .shell-points-link {
    padding: 8px;
    gap: 5px;
  }

  .shell-points-link small {
    display: none;
  }

  body.has-app-nav main {
    padding: 24px 16px 36px;
  }
}

@media (min-width: 1024px) {
  .has-app-nav.sidebar-collapsed {
    --sidebar-width: 0px;
  }

  .has-app-nav.sidebar-collapsed .app-sidebar {
    display: none;
  }

  .has-app-nav .sidebar-toggle,
  .has-app-nav .sidebar-close {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: 1px solid var(--shell-border);
    border-radius: 12px;
    background: #fff;
    color: var(--shell-purple);
    box-shadow: none;
  }

  .has-app-nav .sidebar-close {
    width: 36px;
    padding: 7px;
    margin-left: auto;
    border-color: #ffffff24;
    background: transparent;
    color: #f5edff;
  }

  .sidebar-toggle svg,
  .sidebar-close svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
  }

  .sidebar-brand small {
    white-space: normal;
  }

  .sidebar-brand strong {
    font-size: 18px;
  }

  .sidebar-brand .brand-mark {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
  }
}

@media (prefers-reduced-motion: reduce) {

  .has-app-nav .app-sidebar,
  .has-app-nav .app-sidebar .app-nav-item {
    transition: none;
  }
}
