.app-shell {
  height: calc(100vh - var(--footer-height));
  min-height: calc(100vh - var(--footer-height));
  width: 100%;
  max-width: 100%;
  padding-top: var(--header-height);
  overflow: hidden;
}

.app-main {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: calc(100vh - var(--header-height) - var(--footer-height));
  overflow: hidden;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  width: 100%;
  max-width: 100%;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px 22px;
  background:
    linear-gradient(90deg, rgba(8, 127, 140, 0.12), transparent 30%),
    var(--navy-950);
  color: #ffffff;
  border-bottom: 1px solid rgba(116, 201, 209, 0.42);
  box-shadow: 0 8px 24px rgba(7, 19, 33, 0.16);
}

.topbar > * {
  min-width: 0;
}

.brand-block {
  flex: 1 1 330px;
  display: flex;
  align-items: center;
  gap: 11px;
}

.brand-mark {
  display: block;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 9px;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 780;
  overflow-wrap: anywhere;
}

.topbar p {
  margin: 3px 0 0;
  color: #9fb2c7;
  font-size: 11px;
  letter-spacing: 0.025em;
  overflow-wrap: anywhere;
}

.home-link {
  color: #ffffff;
  text-decoration: none;
}

.home-link:hover,
.home-link:focus-visible {
  color: #dffbfc;
}

.shell-context {
  display: grid;
  flex: 0 0 auto;
  gap: 1px;
  min-width: 132px;
  padding-left: 18px;
  border-left: 1px solid rgba(255, 255, 255, 0.16);
}

.shell-context-label {
  color: #8fa5bb;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.shell-context strong {
  color: #e9f0f6;
  font-size: 12px;
  font-weight: 720;
}

.main-nav {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: center;
  min-width: 0;
  gap: 6px;
}

.desktop-primary-nav {
  align-items: center;
  justify-content: flex-end;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 36px;
  gap: 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 7px 10px;
  color: #c3d0dd;
  background: transparent;
  cursor: pointer;
  font-weight: 680;
  font-size: 12px;
  transition: color 140ms ease, border-color 140ms ease, background-color 140ms ease;
}

.nav-icon {
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-link-anchor {
  text-decoration: none;
}

.nav-link:hover,
.nav-link:focus-visible {
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.09);
}

.nav-link.active {
  color: #ffffff;
  background: #087f8c;
  border-color: #27a6b1;
  box-shadow: 0 4px 12px rgba(1, 73, 82, 0.24);
}

.tutorial-launcher {
  position: relative;
}

.tutorial-menu-trigger[aria-expanded="true"] {
  color: #ffffff;
  border-color: rgba(116, 201, 209, 0.48);
  background: rgba(8, 127, 140, 0.32);
}

.tutorial-library-panel {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 1100;
  width: min(460px, calc(100vw - 32px));
  max-height: min(680px, calc(100vh - var(--header-height) - var(--footer-height) - 24px));
  overflow-y: auto;
  padding: 18px;
  border: 1px solid rgba(116, 201, 209, 0.42);
  border-radius: 12px;
  color: var(--ink);
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(7, 19, 33, 0.3);
}

.tutorial-library-panel[hidden] {
  display: none;
}

.tutorial-library-panel::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 12px 12px 0 0;
  background: linear-gradient(90deg, var(--accent), #27a6b1);
}

.tutorial-library-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tutorial-library-kicker {
  color: var(--accent-dark);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.tutorial-library-header h2 {
  margin: 3px 0 0;
  color: var(--ink);
  font-size: 20px;
  line-height: 1.2;
}

.tutorial-library-close {
  display: grid;
  width: 32px;
  min-width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #f8fafc;
  cursor: pointer;
  font-size: 21px;
  line-height: 1;
}

.tutorial-library-close:hover,
.tutorial-library-close:focus-visible {
  color: var(--ink);
  border-color: var(--accent-line);
  background: var(--accent-soft);
}

.tutorial-library-group + .tutorial-library-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.tutorial-library-group-depth-1 {
  margin: 12px 0 0 12px;
  padding-left: 12px;
  border-left: 2px solid var(--accent-line);
}

.tutorial-library-group-heading h3 {
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
}

.tutorial-library-group-heading p {
  margin: 3px 0 9px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.tutorial-library-cards {
  display: grid;
  gap: 7px;
}

.tutorial-library-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  background: #fbfcfd;
  text-decoration: none;
  transition: border-color 140ms ease, background-color 140ms ease, transform 140ms ease;
}

.tutorial-library-card:hover,
.tutorial-library-card:focus-visible {
  border-color: var(--accent-line);
  background: var(--accent-soft);
  transform: translateY(-1px);
}

.tutorial-library-card-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.tutorial-library-card-copy strong {
  color: var(--ink);
  font-size: 13px;
}

.tutorial-library-card-copy > span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.tutorial-library-duration {
  flex: 0 0 auto;
  padding: 4px 7px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: #dff7f4;
  font-size: 10px;
  font-weight: 760;
  white-space: nowrap;
}

.tutorial-library-empty {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.mobile-menu-trigger,
.mobile-menu-backdrop {
  display: none;
}

.mobile-drawer-toggle {
  min-width: 40px;
  width: 40px;
  min-height: 40px;
  height: 40px;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

.mobile-drawer-toggle:hover,
.mobile-drawer-toggle:focus-visible {
  background: rgba(255, 255, 255, 0.15);
}

.mobile-drawer-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #d9e2ef;
}

.app-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  width: 100%;
  max-width: 100%;
  z-index: 90;
  min-height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  row-gap: 4px;
  padding: 5px 18px;
  background: rgba(7, 19, 33, 0.97);
  color: #b9c8d7;
  border-top: 1px solid rgba(116, 201, 209, 0.25);
  box-shadow: 0 -4px 14px rgba(7, 19, 33, 0.1);
  font-size: 11px;
  font-weight: 560;
  overflow: hidden;
}

.app-footer > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.footer-copyright {
  flex: 0 1 auto;
  text-align: left;
}

.footer-links {
  flex: 1 1 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px 12px;
  min-width: 0;
  flex-wrap: wrap;
  line-height: 1.15;
}

.footer-links a,
.footer-links a:visited {
  min-width: 0;
  color: #b9c8d7;
  text-decoration: none;
  text-underline-offset: 3px;
}

.footer-links a:hover,
.footer-links a:focus-visible {
  color: #ffffff;
  text-decoration: underline;
}

.footer-links a.active {
  color: #bff7f9;
}

.app-version-indicator {
  flex: 0 1 auto;
  margin-left: auto;
  color: #b8c6d8;
  font-weight: 520;
  text-align: right;
}

@media (max-width: 980px) {
  body.mobile-menu-open {
    overflow: hidden;
  }

  .app-shell {
    height: calc(100vh - var(--footer-height));
    min-height: calc(100vh - var(--footer-height));
    overflow: hidden;
  }

  .mobile-menu-trigger {
    display: inline-flex;
    order: -1;
  }

  .main-nav {
    position: fixed;
    top: var(--header-height);
    left: 0;
    z-index: 950;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: min(280px, calc(100% - 40px));
    max-width: 100%;
    gap: 6px;
    padding: 12px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-bottom-right-radius: 10px;
    background: #f9fbfc;
    box-shadow: 16px 0 36px rgba(7, 19, 33, 0.24);
    transform: translateX(-104%);
    visibility: hidden;
    transition: transform 160ms ease, visibility 160ms ease;
  }

  body.mobile-menu-open .main-nav {
    transform: translateX(0);
    visibility: visible;
  }

  .main-nav .nav-link {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
    color: var(--ink);
    border-color: var(--line);
    min-height: 44px;
    border-radius: 7px;
    background: #ffffff;
  }

  .main-nav .nav-link:hover,
  .main-nav .nav-link:focus-visible {
    background: #eefdfa;
  }

  .main-nav .nav-link.active {
    color: var(--accent-dark);
    border-color: var(--accent-line);
    background: var(--accent-soft);
    box-shadow: none;
  }

  .tutorial-launcher {
    width: 100%;
  }

  .tutorial-library-panel {
    position: static;
    width: 100%;
    max-height: calc(100vh - var(--header-height) - var(--footer-height) - 92px);
    margin-top: 8px;
    padding: 14px;
    border-color: var(--line);
    border-radius: 9px;
    box-shadow: none;
  }

  .mobile-menu-backdrop:not([hidden]) {
    position: fixed;
    top: var(--header-height);
    right: 0;
    bottom: var(--footer-height);
    left: 0;
    z-index: 940;
    display: block;
    background: rgba(7, 19, 33, 0.48);
    backdrop-filter: blur(2px);
  }

  @supports (height: 100dvh) {
    .app-shell {
      height: calc(100dvh - var(--footer-height));
      min-height: calc(100dvh - var(--footer-height));
    }
  }
}

@media (max-width: 1200px) and (min-width: 981px) {
  .shell-context {
    display: none;
  }

  .brand-block {
    flex-basis: 250px;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: 70px;
    --footer-height: 52px;
  }

  .app-footer {
    justify-content: center;
    gap: 4px 8px;
    padding: 5px 10px;
    font-size: 11px;
  }

  .footer-copyright {
    display: none;
  }

  .footer-links {
    flex: 1 1 100%;
    gap: 3px 10px;
    justify-content: center;
  }

  .app-version-indicator {
    flex: 1 1 100%;
    margin-left: 0;
    text-align: center;
  }

  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    height: auto;
    padding: 9px 12px;
  }

  .brand-block {
    grid-column: 2;
    grid-row: 1;
    flex: 0 0 auto;
    width: 100%;
  }

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

  .topbar p,
  .shell-context {
    display: none;
  }

  .nav-link {
    flex: 1 1 68px;
    min-height: 40px;
    padding: 6px 10px;
  }

  .mobile-menu-trigger {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    justify-self: start;
  }
}
