:root {
  --app-ink: #17202a;
  --app-muted: #5f6b78;
  --app-border: #dbe2e8;
  --app-soft: #edf4f6;
  --app-accent: #164e63;
  --app-accent-light: #dff1f4;
}

body {
  color: var(--app-ink);
}

.app-brand {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  letter-spacing: -0.01em;
}

.app-brand > span {
  font-weight: 700;
}

.app-brand > small {
  color: var(--app-muted);
  font-size: 0.76rem;
  font-weight: 500;
}

.nav-tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.nav-tabs::-webkit-scrollbar {
  display: none;
}

.nav-tabs .nav-link {
  font-size: 0.94rem;
  font-weight: 600;
  padding-left: 0.72rem;
  padding-right: 0.72rem;
  white-space: nowrap;
}

.study-banner {
  border-left: 5px solid var(--app-accent);
  margin: 0.4rem 0 1rem;
  padding: 0.15rem 0 0.2rem 1rem;
}

.section-kicker,
.question-number,
.takeaway > span,
.snapshot-summary > span {
  color: var(--app-accent);
  display: block;
  font-size: 0.73rem;
  font-weight: 750;
  letter-spacing: 0.065em;
  text-transform: uppercase;
}

.study-banner h2 {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  margin: 0.18rem 0 0.35rem;
}

.study-banner p {
  color: var(--app-muted);
  margin: 0;
  max-width: 70rem;
}

.question-card {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.65rem;
  display: flex;
  flex-direction: column;
  min-height: 12.5rem;
  padding: 1.05rem 1.1rem;
}

.question-card h3 {
  font-size: 1.08rem;
  margin: 0.35rem 0;
}

.question-card p {
  color: var(--app-muted);
  flex: 1;
  line-height: 1.48;
  margin-bottom: 0.9rem;
}

.question-card .btn {
  align-self: flex-start;
}

.topology-figure {
  display: block;
  height: auto;
  margin: 0 auto;
  max-width: 100%;
}

.reading-steps {
  display: grid;
  gap: 0.9rem;
}

.reading-steps > div {
  align-items: start;
  display: grid;
  gap: 0.7rem;
  grid-template-columns: 2rem 1fr;
}

.reading-steps strong,
.data-flow > div:not(.flow-arrow) > strong {
  align-items: center;
  background: var(--app-accent);
  border-radius: 50%;
  color: #fff;
  display: inline-flex;
  height: 1.8rem;
  justify-content: center;
  width: 1.8rem;
}

.reading-steps p {
  color: var(--app-muted);
  margin: 0.15rem 0 0;
}

.interpretation-note,
.takeaway,
.snapshot-summary {
  background: var(--app-soft);
  border-left: 4px solid var(--app-accent);
  margin: 0.8rem 0 1rem;
  padding: 0.75rem 0.95rem;
}

.takeaway {
  align-items: baseline;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
}

.takeaway > span {
  display: inline;
}

.takeaway strong {
  font-weight: 650;
}

.sidebar-intro {
  color: var(--app-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  margin-bottom: 0.7rem;
}

.snapshot-summary {
  font-size: 0.85rem;
  margin: 0.65rem 0 0.9rem;
}

.snapshot-summary strong {
  display: block;
  line-height: 1.35;
  margin-top: 0.18rem;
}

.sidebar-actions {
  display: grid;
  gap: 0.5rem;
  grid-template-columns: 1fr;
}

.sidebar-actions .btn,
.download-stack .btn {
  width: 100%;
}

.sidebar-actions > .shiny-panel-conditional {
  display: grid;
  gap: 0.5rem;
}

.view-toggle {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  margin: 0 0 0.8rem;
  padding: 0.65rem 0.9rem 0.15rem;
}

.view-toggle .form-group {
  margin-bottom: 0;
}

.view-toggle .control-label {
  font-weight: 650;
  margin-right: 0.75rem;
}

.card {
  border-color: var(--app-border);
}

.guided-plot-card .card-header {
  background: #fff;
  padding-bottom: 0.65rem;
}

.plot-heading h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.plot-heading p {
  color: var(--app-muted);
  font-size: 0.88rem;
  font-weight: 400;
  margin: 0.25rem 0 0;
}

.guided-plot-card .card-body {
  overflow: visible;
  padding-top: 0.35rem;
}

.download-stack {
  display: grid;
  gap: 0.6rem;
}

.data-flow {
  align-items: center;
  display: grid;
  gap: 0.8rem;
  grid-template-columns: 1fr auto 1fr auto 1fr;
}

.data-flow > div:not(.flow-arrow) {
  min-width: 0;
}

.data-flow h3 {
  font-size: 1rem;
  margin: 0.55rem 0 0.25rem;
}

.data-flow p {
  color: var(--app-muted);
  font-size: 0.88rem;
  line-height: 1.4;
  margin: 0;
}

.flow-arrow {
  color: var(--app-accent);
  font-size: 1.5rem;
  font-weight: 700;
}

.verification-strip {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, 1fr);
  margin: 0.9rem 0;
}

.verification-strip > div {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  padding: 0.85rem;
}

.verification-strip strong,
.verification-strip span {
  display: block;
}

.verification-strip span {
  color: var(--app-muted);
  font-size: 0.86rem;
  line-height: 1.4;
  margin-top: 0.2rem;
}

.details-panel {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 0.55rem;
  margin: 0.65rem 0;
  padding: 0.8rem 0.95rem;
}

.details-panel summary {
  color: var(--app-accent);
  cursor: pointer;
  font-weight: 650;
}

.details-panel ul {
  color: var(--app-muted);
  margin: 0.8rem 0 0.15rem;
}

.provenance-record {
  background: #f8fafc;
  border: 1px solid var(--app-border);
  border-radius: 0.35rem;
  font-size: 0.76rem;
  max-height: 24rem;
  overflow: auto;
  padding: 0.9rem;
  white-space: pre-wrap;
}

@media (max-width: 900px) {
  .verification-strip {
    grid-template-columns: 1fr;
  }

  .data-flow {
    grid-template-columns: 1fr;
  }

  .flow-arrow {
    line-height: 1;
    text-align: center;
    transform: rotate(90deg);
  }
}

@media (max-width: 768px) {
  .app-brand > small {
    display: none;
  }

  .question-card {
    min-height: auto;
  }

  .study-banner {
    margin-top: 0.15rem;
  }

  .guided-plot-card .card-body {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .plot-heading p {
    font-size: 0.82rem;
  }
}
