/* Threads-inspired app shell: left rail + feed column */

.app-shell {
  --shell-rail-width: 4.5rem;
  --shell-feed-max: 40rem;
  --shell-gap: 1.5rem;
}

.app-rail {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--shell-rail-width);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.25rem 0 1.5rem;
  border-right: 1px solid var(--border-subtle);
  background: rgba(16, 16, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.app-rail-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  margin-bottom: 0.5rem;
  color: var(--ink);
  text-decoration: none;
}

.app-rail-mark {
  font-size: var(--text-xl);
  line-height: 1;
}

.app-rail-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  width: 100%;
  margin-top: 0.5rem;
}

.app-rail-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  width: 3.5rem;
  min-height: 3.5rem;
  padding: 0.5rem 0.25rem;
  border-radius: 0.875rem;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.15s ease, background 0.15s ease;
}

.app-rail-link svg {
  width: 1.5rem;
  height: 1.5rem;
}

.app-rail-link:hover,
.app-rail-link:focus {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.app-rail-link.is-active {
  color: var(--ink);
}

.app-rail-label {
  font-size: var(--text-2xs);
  line-height: var(--leading-tight);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.app-shell .app-main {
  min-height: 100vh;
  margin-left: var(--shell-rail-width);
  display: flex;
  justify-content: center;
  padding: 0 var(--shell-gap) 3rem;
  transform: translateX(calc(var(--shell-rail-width) / -2));
}

.app-shell .page.feed-layout {
  width: 100%;
  max-width: var(--shell-feed-max);
  margin: 1.5rem 0;
}

.feed-layout .wordmark,
.feed-layout .back {
  display: none;
}

.feed-header {
  margin: 0 0 var(--space-5);
}

.feed-header-row {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.feed-avatar {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-md);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
}

.feed-header-text {
  flex: 1 1 auto;
  min-width: 0;
}

.feed-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.375rem 0.625rem;
}

.feed-name {
  font-size: var(--text-body);
  font-weight: 600;
  line-height: var(--leading-body);
  color: var(--ink);
}

.feed-meta {
  font-size: var(--text-meta);
  line-height: var(--leading-body);
  color: var(--ink-muted);
}

.feed-subtitle {
  margin: 0.125rem 0 0;
  font-size: var(--text-meta);
  line-height: var(--leading-body);
  color: var(--ink-muted);
}

.feed-layout h1 {
  margin: 0 0 var(--space-3);
  font-family: var(--font-ui);
  font-size: var(--text-heading);
  font-weight: 700;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  background: none;
  -webkit-text-fill-color: initial;
  color: var(--ink);
}

.feed-layout .meta {
  margin: 0 0 var(--space-4);
  font-size: var(--text-meta);
  line-height: var(--leading-body);
  color: var(--ink-muted);
}

.feed-layout .lead,
.feed-layout .lead.subtle {
  margin: 0 0 var(--space-5);
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--ink);
}

.feed-layout .link-save {
  margin: 0 0 var(--space-5);
  align-items: flex-start;
  text-align: left;
}

.feed-layout .card,
.feed-layout .scope-box,
.feed-layout .synthesis,
.feed-layout .notice,
.feed-layout .paywall,
.feed-layout .methodology,
.feed-layout .feedback {
  border-radius: var(--radius-card);
  border-color: var(--border-subtle);
  background: rgba(255, 255, 255, 0.02);
}

.feed-layout .cards {
  gap: var(--space-4);
  margin: var(--space-5) 0;
}

.feed-layout .full-section {
  margin: var(--space-6) 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
}

.feed-layout .full-section:first-of-type {
  border-top: none;
  padding-top: 0;
}

.feed-layout .full-toc {
  justify-content: flex-start;
  margin: 0 0 var(--space-5);
}

.feed-layout .full-toc a,
.feed-layout .full-toc a:link,
.feed-layout .full-toc a:visited {
  font-size: var(--text-meta);
  letter-spacing: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border-color: var(--border-subtle);
}

.feed-layout .life-domain-nav a,
.feed-layout .life-domain-nav a:link,
.feed-layout .life-domain-nav a:visited {
  color: var(--ink-dim);
  text-decoration: none;
}

.feed-layout .life-domain-nav a:hover,
.feed-layout .life-domain-nav a:focus {
  color: var(--gold);
}

.feed-layout button.cta-secondary,
.feed-layout .cta-secondary {
  font-size: var(--text-body);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  border-color: var(--border-strong);
  color: var(--ink);
}

.feed-layout button.cta-secondary:hover,
.feed-layout .cta-secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: var(--ink);
}

.feed-layout .cta {
  font-size: var(--text-body);
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 999px;
  box-shadow: none;
}

.feed-layout .card p + p,
.feed-layout .scope-item-text + .scope-item-text,
.feed-layout .synthesis p + p {
  margin-top: 0.85em;
}

.feed-layout .card h3,
.feed-layout .card h2,
.feed-layout .scope-box h2,
.feed-layout .scope-box h3,
.feed-layout .scope-item-head {
  font-size: var(--text-body);
  font-weight: 600;
  line-height: var(--leading-body);
}

.feed-layout .scope-box,
.feed-layout .scope-box ul,
.feed-layout .scope-item-text,
.feed-layout .notice,
.feed-layout .notice p,
.feed-layout .methodology,
.feed-layout .methodology .method-list,
.feed-layout .paywall,
.feed-layout .paywall ul,
.feed-layout .paywall p,
.feed-layout .method-list,
.feed-layout .full-page .method-list,
.feed-layout .full-page .full-questions {
  font-size: var(--text-body);
  font-weight: 400;
  line-height: var(--leading-body);
  color: var(--ink);
}

.feed-layout .notice h2,
.feed-layout .methodology h2,
.feed-layout .paywall h2,
.feed-layout .feedback h2,
.feed-layout .synthesis h2 {
  font-size: var(--text-body);
  font-weight: 600;
  line-height: var(--leading-body);
  letter-spacing: 0;
}

.feed-layout .theme,
.feed-layout .reflection,
.feed-layout .fact-line,
.feed-layout .hint,
.feed-layout .note,
.feed-layout .muted {
  font-size: var(--text-meta);
  line-height: var(--leading-body);
}

.result-page .card .interp-label,
.full-page .card .interp-label,
.feed-layout .card .interp-label,
.result-page .synthesis .interp-label,
.full-page .synthesis .interp-label,
.feed-layout .synthesis .interp-label {
  margin: 0 0 6px;
  font-family: var(--font-ui);
  font-size: var(--text-caption);
  font-weight: 400;
  line-height: var(--leading-caption);
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--ink-muted);
}

@media (max-width: 768px) {
  .app-shell {
    --shell-gap: 1rem;
  }

  .app-shell .scroll-top {
    bottom: calc(84px + env(safe-area-inset-bottom));
  }

  .app-rail {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: auto;
    flex-direction: row;
    justify-content: space-around;
    padding: 0.5rem 0.625rem calc(0.5rem + env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--border-subtle);
  }

  .app-rail-brand {
    display: none;
  }

  .app-rail-links {
    flex-direction: row;
    justify-content: space-around;
    width: 100%;
    margin: 0;
    gap: 0;
  }

  .app-rail-link {
    width: auto;
    min-width: 4rem;
    min-height: 3rem;
    flex: 1 1 0;
  }

  .app-shell .app-main {
    margin-left: 0;
    margin-bottom: 4.5rem;
    padding: 0 1rem 1.5rem;
    transform: none;
  }

  .app-shell .page.feed-layout {
    padding-top: 1.25rem;
  }
}
