*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--page-bg);
  color: var(--ink);
  min-height: 100vh;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
}

a {
  color: inherit;
}

.app-main {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 20px calc(var(--nav-height) + 24px + env(safe-area-inset-bottom, 0px));
}

.tab-panel[hidden] {
  display: none !important;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
}

.title-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px 20px;
  background: var(--chrome-bg);
  color: var(--title-ink);
  padding: 8px 20px 10px;
  /* Mobile: yellow header shelves over blue content (nav is fixed at bottom). */
  border-bottom: 1px solid var(--chrome-edge);
  box-shadow: var(--chrome-shelf-down);
}

.header-portrait {
  line-height: 0;
  flex-shrink: 0;
  /* Mirror mobile: 0 flat / 1 medium / 2 strong (override via --portrait-depth). */
  --pd: var(--portrait-depth, 1);
}

.header-portrait img {
  display: block;
  width: auto;
  height: 72px;
  max-width: 88px;
  object-fit: contain;
  /* Soft silhouette shadow; scales with --portrait-depth (2 ≈ +50% vs prior strong). */
  filter: drop-shadow(
      0
      calc(3.75px * var(--pd))
      calc(9.5px * var(--pd) + 2px)
      rgba(0, 0, 0, calc(0.12 + 0.18 * var(--pd)))
    );
}

.header-portrait[data-depth="0"] {
  --pd: 0;
}
.header-portrait[data-depth="1"] {
  --pd: 1;
}
.header-portrait[data-depth="2"] {
  --pd: 2;
}

.header-portrait[data-depth="0"] img {
  filter: none;
}

.header-text {
  text-align: center;
  min-width: 0;
}

.header-text h1 {
  margin: 0;
  color: var(--title-ink);
  font-size: 2.05em;
  line-height: 1.1;
}

.header-text p {
  margin: 4px 0 0;
  color: var(--muted-ink);
  font-size: 1.425em;
}

.header-course-link {
  color: var(--ink);
  font-size: 1.35em;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  justify-self: end;
}

.header-course-link:hover {
  text-decoration: underline;
}

.main-nav {
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  gap: 4px;
  padding: 6px 8px env(safe-area-inset-bottom, 0px);
  background: var(--nav-bg);
  /* Mobile: yellow nav shelves up over blue content. */
  border-top: 1px solid var(--chrome-edge);
  box-shadow: var(--chrome-shelf-up);
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
}

/* Soft fade just above the yellow bar (reads over opaque page content). */
.main-nav::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -10px;
  height: 10px;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(19, 59, 91, 0.11)
  );
}

.main-nav a {
  flex: 1;
  text-align: center;
  text-decoration: none;
  color: var(--muted-ink);
  font-weight: 700;
  font-size: 14px;
  padding: 10px 8px;
  border-radius: 10px;
}

.main-nav a.active {
  background: var(--selected-bg);
  color: var(--selected-fg);
  font-weight: 800;
}

.more-section {
  max-width: 640px;
  margin: 0 auto;
}

.more-details {
  background: var(--surface);
  border: 1px solid var(--mist);
  border-radius: 18px;
  overflow: hidden;
}

.more-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.more-details > summary::-webkit-details-marker {
  display: none;
}

.more-details > summary::after {
  content: "";
  flex-shrink: 0;
  width: 0.55em;
  height: 0.55em;
  border-right: 2.5px solid var(--ink);
  border-bottom: 2.5px solid var(--ink);
  transform: rotate(45deg);
  opacity: 0.55;
  transition: transform 0.15s ease;
  margin-top: -0.15em;
}

.more-details[open] > summary::after {
  transform: rotate(-135deg);
  margin-top: 0.2em;
}

.more-summary-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

.more-summary-sub {
  font-size: 0.95rem;
}

.more-details-body {
  padding: 0 16px 16px;
}

.more-guidance {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(
    165deg,
    rgba(240, 247, 252, 0.95) 0%,
    rgba(217, 236, 248, 0.88) 100%
  );
  border: 1px solid rgba(165, 199, 223, 0.32);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 4px 10px rgba(19, 59, 91, 0.1),
    0 1px 3px rgba(19, 59, 91, 0.06);
  color: var(--ink);
  line-height: 1.45;
  font-size: 0.95rem;
  font-weight: 400;
}

.more-card-host {
  margin: 0;
}

.panel-status {
  text-align: center;
  padding: 32px 16px;
  color: var(--ink);
}

.panel-status p {
  white-space: pre-line;
  text-align: center;
}

.panel-status .spinner {
  margin: 0 auto 16px;
}

.explore-idle {
  padding: 40px 24px;
}

.explore-idle-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  font-size: 18px;
  color: rgba(19, 59, 91, 0.45);
  background: rgba(19, 59, 91, 0.06);
}

.explore-idle-title {
  margin: 0;
  font-size: 1.15em;
  font-weight: 800;
  color: rgba(19, 59, 91, 0.88);
}

.explore-idle-subtitle {
  margin: 8px auto 0;
  max-width: 28rem;
  font-size: 0.95em;
  line-height: 1.4;
  color: var(--muted-ink);
}

.muted {
  color: var(--muted-ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  padding: 12px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: 1.6px solid var(--ink);
  background: var(--ink);
  color: #fff;
}

.btn.secondary {
  background: transparent;
  color: var(--ink);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.error-banner,
.empty-card,
.surface-card {
  background: var(--surface);
  border: 1px solid var(--mist);
  border-radius: 24px;
  padding: 18px 20px;
}

.error-banner {
  margin-bottom: 16px;
}

.section-heading {
  margin: 28px 0 6px;
  font-size: 1.4rem;
  color: var(--ink);
}

.section-sub {
  margin: 0 0 14px;
  color: var(--muted-ink);
}

@media (max-width: 767px) {
  .title-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 10px;
    padding: 8px 12px;
  }

  .header-portrait img {
    height: 72px;
    max-width: 84px;
  }

  .header-text {
    text-align: center;
    min-width: 0;
  }

  .header-text h1 {
    font-size: 1.2em;
  }

  .header-text p {
    font-size: 0.8em;
  }

  .header-course-link {
    font-size: 0.72em;
    white-space: normal;
    text-align: right;
    max-width: 7.2em;
    line-height: 1.25;
  }
}

@media (min-width: 768px) {
  .site-header {
    position: sticky;
  }

  /* Desktop: title sits above nav; move the content ledge to the nav bottom. */
  .title-bar {
    border-bottom: 1px solid rgba(19, 59, 91, 0.08);
    box-shadow: none;
  }

  .main-nav {
    position: static;
    justify-content: center;
    gap: 8px;
    padding: 8px 20px 10px;
    max-width: none;
    border-top: none;
    border-bottom: 1px solid var(--chrome-edge);
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.7),
      var(--chrome-shelf-down);
  }

  .main-nav::before {
    display: none;
  }

  .main-nav a {
    flex: 0 0 auto;
    min-width: 120px;
    padding: 10px 18px;
  }

  .header-portrait img {
    height: 96px;
    max-width: 120px;
  }

  .app-main {
    padding: 20px 24px 40px;
  }
}
