.app-shell {
  --app-topbar-height: 61px;
  --app-tab-height: 61px;
  --app-top-inset: env(safe-area-inset-top, 0px);
  --app-bottom-inset: env(safe-area-inset-bottom, 0px);
  min-height: 100vh;
  padding-bottom: 0;
}
.app-topbar {
  position: sticky;
  z-index: 4;
  inset-block-start: 0;
  padding-top: var(--app-top-inset);
  border-bottom: 1px solid #324056;
  background: var(--night);
  color: var(--white);
}
.app-topbar-inner {
  display: flex;
  min-height: var(--app-topbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.app-heading, .app-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}
.app-identity .brand-mark { flex: 0 0 auto; }
.app-name { color: #c9d5e4; font-size: .75rem; line-height: 1.15; }
#app-title {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 1.1875rem;
  font-weight: 800;
  line-height: 1.17;
  letter-spacing: 0;
}
.app-back {
  display: inline-flex;
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  gap: 1px;
  padding: 4px 8px 4px 4px;
  border: 1px solid #566478;
  border-radius: 8px;
  background: transparent;
  color: var(--white);
  font-size: .875rem;
  font-weight: 700;
}
.app-back:hover { background: #29384d; }
.app-back:not([hidden]) + .app-identity .brand-mark { display: none; }
.app-back svg, .app-tab-icon svg {
  width: 21px;
  height: 21px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
}
.app-nav a {
  --app-icon-field: var(--night);
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: #e0e8f1;
  text-decoration: none;
  font-size: .875rem;
  font-weight: 700;
}
.app-nav a:hover, .app-nav a[aria-current] {
  --app-icon-field: #2b394f;
  background: var(--app-icon-field);
}
.app-nav a[aria-current] {
  border-color: #55637a;
  color: #ffb499;
  font-weight: 800;
}
.app-nav a:focus-visible, .app-back:focus-visible { outline-color: #ff956f; outline-offset: 2px; }
.app-tab-icon {
  display: grid;
  min-width: 23px;
  min-height: 23px;
  place-items: center;
}
.app-tab-icon circle { fill: var(--app-icon-field); }

.app-main {
  min-height: calc(100vh - var(--app-topbar-height) - var(--app-top-inset));
  padding-bottom: 28px;
}
.app-main:focus:not(:focus-visible) { outline: none; }
.app-view {
  padding-top: clamp(20px, 3vw, 36px);
  scroll-margin-top: calc(var(--app-topbar-height) + var(--app-top-inset) + 16px);
}
.app-view[hidden] { display: none; }
.app-main :is(button, a, input, select, textarea, #workout) {
  scroll-margin-top: calc(var(--app-topbar-height) + var(--app-top-inset) + 10px);
  scroll-margin-bottom: calc(var(--app-tab-height) + var(--app-bottom-inset) + 10px);
}
.app-plan-stats {
  display: grid;
  grid-template-columns: minmax(0, 1.16fr) minmax(0, .8fr) minmax(0, 1fr);
  margin-bottom: 20px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--night);
  color: var(--white);
}
.app-plan-stats > div { min-width: 0; padding-inline: 16px; }
.app-plan-stats > div:first-child { padding-inline-start: 0; }
.app-plan-stats > div:last-child { padding-inline-end: 0; }
.app-plan-stats > div + div { border-inline-start: 1px solid #546378; }
.app-plan-stats dt { color: #c9d5e4; font-size: .8125rem; font-weight: 650; }
.app-plan-stats dd {
  margin-top: 1px;
  color: #fff;
  font-size: clamp(1.125rem, 2.2vw, 1.6rem);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.app-plan-stats small { color: #d5e0eb; font-size: .8125rem; font-weight: 650; }
.app-plan-stats #summary-plan { color: #ffb699; }

.exercise-view { width: min(100%, 820px); margin-inline: auto; }
.exercise-view .dialog-body {
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--white);
}
.exercise-view .dialog-body :focus-visible {
  scroll-margin-top: calc(var(--app-topbar-height) + var(--app-top-inset) + 10px);
}

@media (max-width: 700px) {
  .app-shell .app-topbar-inner, .app-shell .app-main { width: calc(100% - 24px); }
  .app-topbar-inner { justify-content: start; }
  .app-nav {
    position: fixed;
    z-index: 5;
    inset: auto 0 0;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    padding-bottom: var(--app-bottom-inset);
    padding-inline: max(3px, env(safe-area-inset-left, 0px)) max(3px, env(safe-area-inset-right, 0px));
    border-block-start: 1px solid #bdc9d7;
    background: var(--white);
  }
  .app-nav a {
    --app-icon-field: var(--white);
    min-width: 0;
    min-height: var(--app-tab-height);
    flex-direction: column;
    gap: 3px;
    padding: 4px 2px;
    border: 0;
    border-radius: 0;
    color: #42536a;
    font-size: .8125rem;
    line-height: 1.1;
    white-space: nowrap;
  }
  .app-tab-icon { width: min(44px, 100%); min-height: 28px; border-radius: 10px; }
  .app-nav a:hover { --app-icon-field: #edf1f6; }
  .app-nav a:hover .app-tab-icon { background: var(--app-icon-field); }
  .app-nav a[aria-current] { --app-icon-field: #ffede6; color: #8f3220; }
  .app-nav a:hover, .app-nav a[aria-current] { background: var(--white); }
  .app-nav a[aria-current] .app-tab-icon { background: var(--app-icon-field); }
  .app-nav a:focus-visible { outline-color: #a83c22; outline-offset: -3px; }
  .app-main { padding-bottom: calc(var(--app-tab-height) + var(--app-bottom-inset) + 22px); }
  .app-view { padding-top: 16px; }
  .app-plan-stats { padding: 10px 11px; margin-bottom: 17px; }
  .app-plan-stats > div { padding-inline: 9px; }
  .app-plan-stats dd { font-size: 1.0625rem; }
  .app-plan-stats small { font-size: .75rem; }
  .app-view .plan-settings {
    display: grid;
    width: 100%;
    grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr);
    gap: 10px;
  }
  .app-view .plan-settings .week-select { display: grid; min-width: 0; gap: 3px; }
  .app-view .plan-settings :is(select, input) { width: 100%; }
  .exercise-view .dialog-body { padding: 13px 11px 17px; border-radius: 10px; }
}
