html {
  box-sizing: border-box;
}

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

:root {
  --background: #ebdad8;
  --surface: #f8eeeb;
  --soft: #f2e2dd;
  --text: #25141f;
  --muted: #654b57;
  --primary: #5b103e;
  --accent: #864f22;
  --border: #bd8f76;
  --light: #fff5ef;
  color-scheme: light;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
  font-size: 18px;
  font-weight: 400;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

h1, h2, h3, p {
  margin: 0;
}

h1, h2, h3 {
  line-height: 1.2;
}

h1 {
  font-size: 52px;
  font-weight: 700;
}

h2 {
  font-size: 28px;
  font-weight: 600;
}

h3 {
  font-size: 20px;
  font-weight: 600;
}

strong, b {
  font-weight: 700;
}

cite, em, i {
  font-style: normal;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--primary);
  text-underline-offset: 0.18em;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.content-frame {
  width: calc(100% - 56px);
  max-width: 1386px;
  margin-inline: auto;
  padding-inline: 0;
}

main.content-frame {
  padding-block-start: 24px;
  scroll-margin-top: 108px;
}

.jump {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 10;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.jump:focus {
  width: auto;
  height: auto;
  max-width: calc(100% - 24px);
  padding: 10px 16px;
  clip-path: inset(0);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
}

.masthead {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-areas: "mark" "nav";
  justify-items: center;
  align-content: center;
  min-height: 96px;
  gap: 6px;
  padding-block: 6px;
  background: var(--background);
}

.site-title {
  grid-area: mark;
  display: grid;
  min-width: 54px;
  min-height: 38px;
  padding: 2px 9px;
  place-items: center;
  border-radius: 10px;
  background: var(--primary);
  color: var(--light);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.08em;
  line-height: 1;
  text-decoration: none;
  transition: background-color 400ms ease;
}

.site-title:hover {
  background: var(--accent);
}

#navigation {
  grid-area: nav;
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color 400ms ease, background-color 400ms ease;
}

.nav-item:hover {
  background: var(--surface);
  color: var(--primary);
}

.nav-item[aria-current="page"] {
  color: var(--primary);
}

.nav-group {
  position: relative;
}

.nav-group summary {
  cursor: pointer;
  list-style: none;
}

.nav-group summary::-webkit-details-marker {
  display: none;
}

.nav-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: 230px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  list-style: none;
}

.nav-list a,
.drawer-links a {
  display: flex;
}

.nav-button,
.nav-close {
  display: grid;
  width: 44px;
  min-height: 44px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--primary);
  transition: background-color 400ms ease;
}

.nav-button:hover,
.nav-close:hover {
  background: var(--soft);
}

.nav-button {
  grid-area: button;
  display: none;
  justify-self: start;
}

.site-title,
.nav-button,
.nav-close {
  align-self: center;
}

.nav-panel {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(360px, 100%);
  max-width: 100%;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 24px;
  overflow: auto;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}

.nav-panel::backdrop {
  background: rgb(37 20 31 / 62%);
}

html:has(dialog:modal) {
  overflow: hidden;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-block-end: 24px;
}

.drawer-head h2 {
  font-size: 24px;
}

.nav-close {
  flex-shrink: 0;
}

.drawer-caption {
  margin-block: 16px 4px;
  padding-inline: 12px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 600;
}

.drawer-links {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.drawer-links .nav-item {
  min-height: 44px;
}

.drawer-links .nav-item:hover,
.nav-list .nav-item:hover {
  background: var(--soft);
}

.home {
  display: grid;
  gap: 54px;
}

.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 460px);
  align-items: center;
  gap: 24px;
  min-height: 232px;
  padding: 32px 42px;
  border-radius: 24px;
  background: radial-gradient(ellipse at 80% 30%, #762354, var(--primary) 67%);
  color: var(--light);
}

.lead-art {
  display: block;
  width: 100%;
  height: auto;
  justify-self: end;
}

.feed,
.showcase {
  display: grid;
  min-width: 0;
  gap: 18px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 12px;
}

.section-title svg {
  display: block;
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  padding: 8px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--primary);
}

.story-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.story {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 152px;
  grid-template-rows: auto auto 1fr auto;
  gap: 10px 18px;
  min-width: 0;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  text-align: center;
}

.story > header {
  grid-area: 1 / 1;
  min-width: 0;
}

.story h3 {
  overflow: hidden;
  font-size: 20px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview {
  grid-area: 1 / 2 / 4 / 3;
  width: 100%;
  height: 176px;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: var(--soft);
  object-fit: cover;
}

.summary {
  grid-area: 2 / 1;
  display: -webkit-box;
  align-self: start;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
}

.story-meta {
  grid-area: 3 / 1;
  align-self: start;
}

.duration {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.story > footer {
  grid-area: 4 / 1 / 5 / 3;
  display: flex;
  justify-content: flex-end;
  align-self: end;
}

.action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  max-width: 100%;
  padding: 9px 15px;
  border-radius: 8px;
  background: var(--primary);
  color: var(--light);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: background-color 400ms ease;
}

.action:hover {
  background: var(--accent);
}

.topics {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  border-radius: 16px;
  background: var(--soft);
}

.labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.story-label {
  padding: 5px 11px;
  border-radius: 5px;
  background: var(--surface);
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
}

.slide-track {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 18px) / 2);
  gap: 18px;
  min-width: 0;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.slide-track::-webkit-scrollbar {
  display: none;
}

.slide-track.is-moving {
  scroll-snap-type: none;
}

.slide {
  min-width: 0;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.slide img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  background: var(--soft);
  object-fit: cover;
}

.slide h3 {
  padding: 14px 8px 8px;
  font-size: 22px;
}

.slide h3 a {
  color: var(--text);
  text-decoration: none;
  transition: color 400ms ease;
}

.slide h3 a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.switchers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding-block-start: 12px;
  border-block-start: 1px solid var(--border);
}

.switchers button {
  min-width: 48px;
  min-height: 44px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  transition: color 400ms ease, background-color 400ms ease, border-color 400ms ease;
}

.switchers button:hover {
  background: var(--soft);
}

.switchers button[aria-selected="true"] {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--light);
}

.story-page {
  max-width: 624px;
  margin-left: 0;
  margin-right: auto;
}

.story-head {
  display: grid;
  gap: 14px;
  padding: 28px;
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--primary);
  border-radius: 16px;
  background: var(--surface);
}

.trail {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  color: var(--muted);
  font-size: 13px;
}

.trail a:hover,
.story-page > p a:hover {
  color: var(--accent);
}

.story-page > * + * {
  margin-block-start: 18px;
}

.story-page > h2 {
  margin-block-start: 36px;
}

.story-page > h3 {
  margin-block-start: 26px;
}

.story-page blockquote {
  margin-inline: 0;
  margin-block-end: 0;
  padding: 16px 20px;
  border-inline-start: 3px solid var(--primary);
  border-radius: 0 10px 10px 0;
  background: var(--surface);
}

.story-page blockquote p + p {
  margin-block-start: 12px;
}

.story-page cite {
  display: block;
  margin-block-start: 8px;
  color: var(--accent);
  font-size: 14px;
}

.story-page ul,
.story-page ol {
  margin-block-end: 0;
  padding-inline-start: 28px;
}

.story-page li + li {
  margin-block-start: 6px;
}

.story-page li > ul,
.story-page li > ol {
  margin-block-start: 6px;
}

.story-page ol > li::marker {
  color: var(--accent);
  font-weight: 600;
}

.story-page ul.with-marks {
  padding-inline-start: 0;
  list-style: none;
}

.story-page .with-marks > li {
  position: relative;
  padding-inline-start: 30px;
}

.list-mark {
  position: absolute;
  inset-block-start: 4px;
  inset-inline-start: 0;
  border-radius: 4px;
  background: var(--surface);
}

.story-page table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.story-page th,
.story-page td {
  padding: 10px 12px;
  border-block-end: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
}

.story-page th {
  color: var(--primary);
  font-weight: 600;
}

.story-page caption {
  padding-block-end: 8px;
  color: var(--accent);
  font-weight: 500;
  text-align: start;
}

.story-page pre {
  max-width: 100%;
  white-space: pre-wrap;
}

.story-page :is(img, video, iframe) {
  max-width: 100%;
}

.colophon {
  margin-block-start: 54px;
  padding-block-end: 24px;
}

.foot-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 14px;
  background: var(--soft);
}

@keyframes enter {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.welcome,
.story,
.topics,
.showcase,
.story-page {
  animation: enter 400ms ease 0ms;
}

@media (max-width: 1260px) {
  .story-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 914px) {
  body {
    font-size: 18px;
  }

  h1 {
    font-size: 38px;
  }

  h2 {
    font-size: 24px;
  }

  main.content-frame {
    padding-block-start: 16px;
    scroll-margin-top: 80px;
  }

  .masthead {
    grid-template-areas: "button mark side";
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    min-height: 64px;
  }

  #navigation {
    display: none;
  }

  .nav-button {
    display: grid;
  }

  .home {
    gap: 42px;
  }

  .welcome {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
    min-height: 0;
    padding: 24px;
  }

  .lead-art {
    width: min(100%, 290px);
  }

  .story-list {
    grid-template-columns: minmax(0, 1fr);
  }

  .story {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto auto auto auto;
    padding: 24px;
  }

  .preview {
    grid-area: 1 / 1;
    height: auto;
  }

  .story > header {
    grid-area: 2 / 1;
  }

  .summary {
    grid-area: 3 / 1;
  }

  .story-meta {
    grid-area: 4 / 1;
  }

  .story > footer {
    grid-area: 5 / 1;
  }

  .slide-track {
    grid-auto-columns: 100%;
  }

  .story-head {
    padding: 24px;
  }

  .colophon {
    margin-block-start: 42px;
  }
}

@media (max-width: 480px) {
  .content-frame {
    width: calc(100% - 48px);
  }

  h1 {
    font-size: 32px;
  }

  .welcome,
  .story,
  .topics,
  .story-head {
    padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .welcome,
  .story,
  .topics,
  .showcase,
  .story-page {
    animation: none;
  }

  .site-title,
  .nav-item,
  .nav-button,
  .nav-close,
  .action,
  .slide h3 a,
  .switchers button {
    transition: none;
  }

  .slide-track {
    scroll-behavior: auto;
  }
}

/* Content-specific layout adjustments */
.story h3 { white-space: normal; overflow-wrap: anywhere; font-size: 17px; line-height: 1.45; }
.story h3 a { text-decoration: none; }
.story h3 a:hover { text-decoration: underline; }
.story-meta .duration span, .story-meta .duration time { display: block; }
.story-meta .story-label { display: inline-block; margin-top: 8px; font-size: 12px; }
.preview { aspect-ratio: 3 / 2; height: auto; }
.story-page .article-cover { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; border-radius: 12px; }
.story-head h1 { overflow-wrap: anywhere; }
.story-head .duration { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.medical-note { padding: 16px 18px; border-inline-start: 3px solid var(--primary); background: var(--surface); font-size: 14px; }
.copyright { text-align: center; margin-block-start: 12px; color: var(--muted); font-size: 13px; }
#mobile-navigation nav { display: grid; gap: 8px; }
.lead p { margin-top: 12px; max-width: 42ch; }
@media (min-width: 915px) and (max-width: 1100px) { .story { grid-template-columns: minmax(0, 1fr) 120px; padding: 20px; } }
