.case-study {
  width: min(1180px, calc(100% - 32px));
}

.case-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.case-header .prompt {
  margin-bottom: 0;
}

.back-link {
  color: var(--muted);
  font-size: 0.78rem;
}

.case-hero {
  padding: clamp(54px, 9vw, 112px) 0 clamp(46px, 8vw, 88px);
}

.case-kicker,
.section-label,
.readme-index {
  margin: 0 0 14px;
  color: var(--amber);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.case-hero h1 {
  max-width: 900px;
  margin: 0;
  color: var(--text);
  font-size: clamp(2.45rem, 7vw, 5.8rem);
  line-height: 0.96;
  letter-spacing: -0.075em;
}

.case-hero h1 span {
  color: var(--green);
}

.case-deck {
  max-width: 850px;
  margin: clamp(26px, 4vw, 42px) 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 2.05vw, 1.45rem);
  line-height: 1.55;
}

.case-meta {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.7fr;
  max-width: 900px;
  margin: clamp(34px, 6vw, 60px) 0 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.case-meta div {
  padding: 16px 20px 16px 0;
}

.case-meta div + div {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.case-meta dt {
  margin-bottom: 6px;
  color: var(--blue);
  font-size: 0.67rem;
}

.case-meta dt::before {
  content: "--";
  color: var(--muted);
}

.case-meta dd {
  margin: 0;
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1.45;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(155, 100, 20, 0.16);
}

.case-intro {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
  gap: clamp(34px, 8vw, 110px);
  padding: clamp(42px, 7vw, 74px) 0;
  border-top: 1px solid var(--line);
}

.case-intro h2,
.view-heading h2,
.readme-content h3 {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.55rem, 3.3vw, 2.45rem);
  line-height: 1.16;
  letter-spacing: -0.035em;
}

.case-intro h2::before,
.view-heading h2::before {
  content: none;
}

.intro-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.intro-copy p + p {
  margin-top: 20px;
}

.view-switcher {
  position: sticky;
  z-index: 5;
  top: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  padding: 1px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--line);
  box-shadow: 0 12px 34px rgba(24, 32, 42, 0.08);
}

.view-switcher button {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: center;
  min-height: 76px;
  padding: 14px 18px;
  border: 0;
  background: rgba(255, 255, 255, 0.96);
  color: var(--muted);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.view-switcher button:first-child {
  border-radius: 5px 0 0 5px;
}

.view-switcher button:last-child {
  border-radius: 0 5px 5px 0;
}

.view-switcher button > span {
  grid-row: span 2;
  color: var(--amber);
  font-size: 0.7rem;
  font-weight: 400;
}

.view-switcher button small {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 400;
}

.view-switcher button[aria-selected="true"] {
  background: var(--text);
  color: #fff;
}

.view-switcher button[aria-selected="true"] small {
  color: rgba(255, 255, 255, 0.68);
}

.view-switcher button:focus-visible {
  position: relative;
  z-index: 1;
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.case-view {
  scroll-margin-top: 112px;
  padding: clamp(58px, 9vw, 102px) 0;
}

.case-view[hidden] {
  display: none;
}

.view-heading {
  max-width: 790px;
  margin-bottom: clamp(54px, 8vw, 92px);
}

.view-heading > p:last-child {
  max-width: 650px;
  margin: 16px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.story-steps {
  display: grid;
  gap: clamp(72px, 13vw, 150px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.story-step {
  display: grid;
  grid-template-columns: minmax(240px, 0.72fr) minmax(0, 1.48fr);
  gap: clamp(32px, 6vw, 72px);
  align-items: center;
}

.story-step-reverse .step-copy {
  order: 2;
}

.story-step-reverse {
  grid-template-columns: minmax(0, 1.48fr) minmax(240px, 0.72fr);
}

.step-number {
  display: block;
  margin-bottom: 16px;
  color: var(--green);
  font-size: 0.72rem;
}

.step-copy h3 {
  margin: 0 0 16px;
  font-size: clamp(1.3rem, 2.7vw, 2rem);
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.step-copy > p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.inline-project-link {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.step-copy ul {
  display: grid;
  gap: 8px;
  margin: 22px 0 0;
  padding: 0;
  color: var(--text);
  font-size: 0.72rem;
  list-style: none;
}

.step-copy li::before {
  content: "+ ";
  color: var(--amber);
}

.step-copy .demo-note {
  margin-top: 20px;
  padding: 12px 14px;
  border-left: 2px solid var(--amber);
  background: rgba(155, 100, 20, 0.06);
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.55;
}

.demo-note strong {
  color: var(--text);
}

.product-shot {
  overflow: hidden;
  margin: 0;
  border: 1px solid #cbd4da;
  border-radius: 7px;
  background: var(--panel);
  box-shadow: 0 22px 58px rgba(24, 32, 42, 0.12);
}

.product-shot img {
  display: block;
  width: 100%;
  height: auto;
}

.video-shot video {
  display: block;
  width: 100%;
  height: auto;
  background: #eeeae2;
}

.product-shot figcaption {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.66rem;
}

.shot-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.shot-pair .product-shot {
  align-self: start;
}

.product-shot-offset {
  margin-top: 34px;
}

.product-shot-featured {
  box-shadow: 0 26px 70px rgba(20, 122, 90, 0.15);
}

.outcome-note {
  display: grid;
  grid-template-columns: 0.55fr 1.45fr;
  gap: 40px;
  margin-top: clamp(74px, 14vw, 160px);
  padding: clamp(28px, 5vw, 52px);
  border: 1px solid rgba(20, 122, 90, 0.24);
  border-radius: 7px;
  background: rgba(20, 122, 90, 0.055);
}

.outcome-note > p:last-child {
  margin: 0;
  color: var(--text);
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1.4;
  letter-spacing: -0.025em;
}

.readme-heading h2 {
  font-size: clamp(2rem, 5vw, 4.4rem);
}

.readme-layout {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: clamp(38px, 7vw, 84px);
}

.readme-nav {
  position: sticky;
  top: 118px;
  align-self: start;
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.readme-nav p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.readme-nav a {
  color: var(--text);
  font-size: 0.7rem;
}

.readme-content {
  min-width: 0;
}

.readme-content > section {
  scroll-margin-top: 120px;
  padding-bottom: clamp(50px, 8vw, 88px);
}

.readme-content > section + section {
  padding-top: clamp(50px, 8vw, 88px);
  border-top: 1px solid var(--line);
}

.readme-content h3 {
  max-width: 730px;
  margin-bottom: 24px;
}

.readme-content section > p:not(.readme-index) {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.readme-content section > p + p {
  margin-top: 20px;
}

.architecture-flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 34px 0;
}

.architecture-flow div {
  min-height: 135px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.76);
}

.architecture-flow span,
.architecture-flow small,
.architecture-flow strong {
  display: block;
}

.architecture-flow span {
  margin-bottom: 18px;
  color: var(--amber);
  font-size: 0.67rem;
}

.architecture-flow strong {
  color: var(--text);
  font-size: 0.76rem;
}

.architecture-flow small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.45;
}

.architecture-flow b {
  color: var(--green);
  font-weight: 400;
}

pre {
  overflow-x: auto;
  margin: 34px 0;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid #cfd8d4;
  border-radius: 6px;
  background: #17201e;
  color: #d9eee6;
  font: inherit;
  font-size: clamp(0.68rem, 1.3vw, 0.83rem);
  line-height: 1.75;
  box-shadow: 0 18px 44px rgba(24, 32, 42, 0.14);
}

.decision-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 30px;
}

.decision-grid article {
  min-height: 150px;
  padding: 18px;
  box-shadow: none;
}

.decision-grid span {
  display: block;
  margin-bottom: 12px;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 700;
}

.decision-grid p {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.6;
}

.stack-list {
  margin: 0;
  border-top: 1px solid var(--line);
}

.stack-list div {
  display: grid;
  grid-template-columns: minmax(150px, 0.7fr) minmax(0, 1.3fr);
  gap: 24px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.stack-list dt {
  color: var(--blue);
  font-size: 0.72rem;
}

.stack-list dd {
  margin: 0;
  color: var(--text);
  font-size: 0.76rem;
}

.case-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 30px 0 10px;
  border-top: 1px solid var(--line);
  font-size: 0.78rem;
}

@media (max-width: 820px) {
  .case-meta {
    grid-template-columns: 1fr;
  }

  .case-meta div + div {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .case-intro,
  .story-step,
  .outcome-note,
  .readme-layout {
    grid-template-columns: 1fr;
  }

  .story-step-reverse .step-copy {
    order: initial;
  }

  .readme-nav {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .readme-nav p {
    grid-column: 1 / -1;
  }
}

@media (max-width: 580px) {
  .case-study {
    width: min(100% - 24px, 1180px);
  }

  .case-header {
    display: block;
  }

  .case-header .prompt {
    margin-bottom: 14px;
    overflow-wrap: anywhere;
  }

  .case-hero h1 {
    font-size: clamp(2.25rem, 14.5vw, 4rem);
  }

  .view-switcher {
    top: 6px;
  }

  .view-switcher button {
    display: block;
    min-height: 62px;
    padding: 12px;
    font-size: 0.72rem;
    text-align: center;
  }

  .view-switcher button > span,
  .view-switcher button small {
    display: none;
  }

  .shot-pair,
  .decision-grid {
    grid-template-columns: 1fr;
  }

  .product-shot-offset {
    margin-top: 0;
  }

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

  .architecture-flow b {
    transform: rotate(90deg);
    text-align: center;
  }

  .stack-list div {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .case-footer {
    align-items: flex-start;
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
