@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@600;700;800&display=swap');

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --secondary: #0f172a; 
  --accent: #0ea5e9;
  --bg: #f8fafc; 
  --surface: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  
  --shadow-sm: 0 4px 12px rgba(15, 23, 42, 0.03);
  --shadow-md: 0 10px 30px -10px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 20px 40px -15px rgba(15, 23, 42, 0.1);
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;
  --radius-3xl: 2rem;
  
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2rem;
  --space-5: 2.5rem;
  --space-6: 3rem;
  --max-width: 1000px; 
  --header-height: 84px;
}

/* Updated Dark Mode Variables */
[data-theme="dark"] {
  --primary: #60a5fa;
  --primary-dark: #3b82f6;
  --primary-light: #1e3a8a;
  --secondary: #f8fafc; 
  --accent: #38bdf8;
  --bg: #020617; 
  --surface: #0f172a; 
  --text: #cbd5e1;
  --text-muted: #94a3b8;
  --border: #1e293b;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 10px 30px -10px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 40px -15px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Outfit', sans-serif;
  font-weight: 700;
  color: var(--secondary);
  line-height: 1.2;
}

a {
  text-decoration: none;
  color: inherit;
  transition: all 0.25s ease;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

/* --- Layout --- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

.section-padding {
  padding: 4rem var(--space-3);
  border-bottom: none !important;
}

.section-padding h2 {
  margin-bottom: 2rem;
}

/* --- The "Floating Island" Navbar --- */
.navbar {
  width: 100%;
  min-height: 72px;
  margin: 0;
  border-radius: 0;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
}

.navbar .container {
  width: 100%;
  max-width: 1200px;
  padding: 0 1.5rem;
}

.nav-inner {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  flex-wrap: nowrap;
  gap: 1.25rem;
  width: 100%;
  min-height: 72px;
  padding: 0;
}

.logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  letter-spacing: -0.02em;
  margin-right: auto;
  flex-shrink: 0;
}

.logo span {
  color: var(--secondary);
}

.nav-search-wrapper {
  position: relative;
  display: flex;
  order: initial;
  flex: 0 1 460px;
  max-width: 460px;
  margin-bottom: 0;
}

.nav-search-icon {
  position: absolute;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  color: #64748b;
  width: 20px;
  height: 20px;
  display: inline-flex;
}

.nav-search-icon svg {
  width: 100%;
  height: 100%;
}

.nav-search-input {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 0 1rem 0 2.8rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
}

.nav-search-input:focus {
  background: var(--surface);
  border-color: var(--primary-dark);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.3);
}

.nav-links {
  display: none;
}

@media (min-width: 768px) {
  .nav-links {
    display: flex;
    gap: var(--space-4);
    align-items: center;
    margin-left: 0.25rem;
  }
}

.nav-link {
  position: relative;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text-muted);
  padding: 0.375rem 0;
}

.nav-link::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 100%;
  height: 2px;
  border-radius: 999px;
  background: var(--secondary);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.25s ease;
}

.nav-link:hover,
.nav-link.active {
  color: var(--secondary);
}

.nav-link:hover::after,
.nav-link.active::after {
  transform: scaleX(1);
}

.nav-story-filters {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  padding: 0.5rem 0 0.9rem;
  border-top: 1px solid var(--border);
}

.navbar.has-filters {
  border-radius: 0;
}

@media (max-width: 767px) {
  .nav-inner {
    min-height: 64px;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 0.5rem 0;
    justify-content: space-between;
  }

  .logo {
    margin-right: auto;
  }

  .nav-search-wrapper {
    order: 3;
    flex: 1 0 100%;
    max-width: 100%;
  }

  .nav-story-filters {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 0.8rem;
  }

  .mobile-menu-btn {
    align-self: center;
    margin-top: 4px;
  }
}

/* Theme Toggle Button */
.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--secondary);
  background: transparent;
  transition: background 0.2s, color 0.2s;
  cursor: pointer;
  z-index: 110;
}

.theme-toggle-btn:hover {
  background: var(--border);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Mobile Menu */
.mobile-menu-btn {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 30px;
  z-index: 110;
}

@media (min-width: 768px) {
  .mobile-menu-btn {
    display: none;
  }
}

.mobile-menu-btn span {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--secondary);
  transition: all 0.3s ease;
}

.mobile-menu-btn.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mobile-menu-btn.open span:nth-child(2) {
  opacity: 0;
}
.mobile-menu-btn.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: -100%;
  width: 80%;
  height: 100vh;
  background: var(--surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 105;
  padding: 7rem 2rem;
  transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 40px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.mobile-drawer.open {
  right: 0;
}

/* --- Modern Dribbble Parallelogram Hero Section --- */
.hero {
  position: relative;
  overflow: hidden;
  padding: calc(var(--space-6) * 3) 0 calc(var(--space-6) * 2.5);
  background: transparent;
}

.hero::before {
  content: '';
  position: absolute;
  top: -20%;
  left: -10%;
  width: 60vw;
  height: 60vw;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, rgba(14, 165, 233, 0.05) 50%, transparent 70%);
  filter: blur(80px);
  z-index: -1;
  pointer-events: none;
}

.hero::after {
  content: '';
  position: absolute;
  bottom: -10%;
  right: -5%;
  width: 50vw;
  height: 50vw;
  background: radial-gradient(circle, rgba(14, 165, 233, 0.12) 0%, transparent 60%);
  filter: blur(60px);
  z-index: -1;
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  align-items: start;
  gap: var(--space-6);
}

.hero-text {
  text-align: left;
}

.hero-title {
  font-size: clamp(3rem, 5vw, 4.2rem);
  margin-bottom: var(--space-2);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--secondary);
  line-height: 1.05;
  max-width: 800px;
}

.hero-subtitle {
  font-size: 1.25rem;
  color: var(--text-muted);
  max-width: 600px;
  margin: 0 0 var(--space-5) 0;
  line-height: 1.6;
}

.cta-button {
  background: var(--secondary);
  color: var(--bg);
  padding: 1rem 2.5rem;
  border-radius: 9999px;
  font-weight: 600;
  letter-spacing: 0.01em;
  font-size: 1.05rem;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cta-button:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 14px 30px rgba(15, 23, 42, 0.3);
  background: var(--text);
  color: var(--bg);
}

.hero-visual {
  display: flex;
  height: 500px;
  position: relative;
  gap: 15px; 
  margin-left: 0;
  width: 100%;
}

.visual-card {
  flex: 1;
  position: relative;
  height: 100%;
  overflow: hidden;
  clip-path: polygon(25% 0, 100% 0, 75% 100%, 0% 100%);
  background: var(--surface);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), filter 0.4s ease;
  border-radius: 0; 
}

.visual-card:nth-child(even) {
  transform: translateY(15px);
}
.visual-card:nth-child(odd) {
  transform: translateY(-15px);
}

.visual-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.3); 
  transition: transform 0.6s ease;
  filter: grayscale(10%);
}

.visual-card:hover {
  z-index: 10;
}

.visual-card:hover img {
  transform: scale(1.4);
  filter: grayscale(0%);
}

@media (max-width: 992px) {
  .hero-grid {
    grid-template-columns: 1fr;
    text-align: center;
  }
  
  .hero-text {
    text-align: center;
    order: 2;
  }
  
  .hero-subtitle {
    margin: 0 auto var(--space-5);
  }
  
  .hero-visual {
    order: 1;
    height: 350px;
    margin: var(--space-4) auto;
    width: 100%;
    max-width: 600px;
  }
}

/* --- Search & Filter --- */
.filter-bar {
  position: sticky;
  top: 6rem;
  z-index: 90;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border);
}

.filter-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  padding: 0.75rem;
}

@media (min-width: 768px) {
  .filter-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
  }
}

.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem 0.75rem 2.75rem;
  border: 1px solid transparent;
  border-radius: var(--radius-xl);
  background: var(--bg);
  color: var(--text);
  font-size: 0.96rem;
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  background: var(--surface);
  border-color: var(--primary-light);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

.search-icon {
  position: absolute;
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.categories {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.categories::-webkit-scrollbar {
  display: none;
}

.category-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 9999px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.category-btn:hover {
  color: var(--secondary);
  background: var(--bg);
}

.category-btn.active {
  background: var(--secondary);
  color: var(--bg);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

/* --- How It Works --- */
.how-it-works-section {
  background: var(--surface);
  transition: background 0.3s ease;
}

.how-it-works-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--space-4);
  margin-top: 2rem;
}

.step-card {
  background: var(--surface);
  backdrop-filter: blur(10px);
  padding: var(--space-5);
  border-radius: var(--radius-3xl);
  border: 1px solid var(--border);
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}

.step-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  background: var(--primary);
}

.step-icon {
  width: 64px;
  height: 64px;
  background: var(--bg);
  color: var(--primary);
  border-radius: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  font-size: 1.5rem;
  transition: background 0.3s ease, color 0.3s ease;
}

.step-title {
  color: var(--secondary);
  transition: color 0.3s ease;
}

.step-desc {
  color: var(--text-muted);
  transition: color 0.3s ease;
}

.step-card:hover .step-icon {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.step-card:hover .step-title,
.step-card:hover .step-desc {
  color: #ffffff;
}

/* --- The Bento Grid Feed --- */
.feed {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  grid-auto-rows: 400px;
  grid-auto-flow: dense;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.card {
  height: 100%;
  background: var(--surface);
  border-radius: var(--radius-3xl);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.3s ease, border-color 0.3s ease;
  display: flex;
  flex-direction: column;
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-dark);
}

.card-image-wrap {
  position: relative;
  height: 180px;
  flex-shrink: 0;
  width: 100%;
  overflow: hidden;
  border-bottom: 1px solid rgba(0,0,0,0.03);
}

.card-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.card:hover .card-image {
  transform: scale(1.06);
}

.card-badge {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0.375rem 1rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.card-body {
  padding: var(--space-3) var(--space-4);
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-meta {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.card-title {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.card-excerpt {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-footer {
  margin-top: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.read-more {
  color: var(--secondary);
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.read-more i {
  transition: transform 0.25s ease;
}

.read-more:hover {
  color: var(--primary);
}

.read-more:hover i {
  transform: translateX(4px);
}

@media (min-width: 768px) {
  .card:nth-child(4n + 1) {
    grid-column: span 2;
    grid-row: span 2;
  }
  
  .card:nth-child(4n + 1) .card-image-wrap {
    height: 55%;
  }

  .card:nth-child(4n + 1) .card-body {
    padding: var(--space-4) var(--space-5);
  }

  .card:nth-child(4n + 1) .card-title {
    font-size: 2.25rem;
    margin-bottom: var(--space-2);
  }

  .card:nth-child(4n + 1) .card-excerpt {
    font-size: 1.1rem;
    -webkit-line-clamp: 4;
  }
}

/* --- Audio UI --- */
.card-audio-controls {
  padding: 0.75rem var(--space-4);
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

.audio-btn {
  min-width: 38px;
  height: 38px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  color: var(--secondary);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.audio-btn:hover:not(:disabled) {
  background: var(--secondary);
  color: var(--bg);
  transform: translateY(-1px);
  border-color: var(--secondary);
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
}

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

.card .speech-content {
  display: none;
  padding: 1.5rem var(--space-4);
  background: var(--secondary);
  color: var(--bg);
  font-size: 0.95rem;
  max-height: 180px;
  overflow-y: auto;
}

.card.is-speaking .speech-content {
  display: block;
}

.post-content.speech-content {
  display: block;
}

.sentence {
  transition: all 0.2s;
  padding: 0 2px;
  border-radius: 4px;
}

.sentence.active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--bg);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* --- Post Page --- */
.post-header {
  padding: 4rem 0 2rem;
  text-align: center;
}

.post-hero-image {
  width: 100%;
  height: 60vh;
  min-height: 400px;
  object-fit: cover;
  border-radius: var(--radius-3xl);
  margin-bottom: 3rem;
  box-shadow: var(--shadow-md);
}

.post-meta {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-weight: 500;
}

.post-title {
  font-size: clamp(2.5rem, 5vw, 4rem);
  margin-bottom: 2rem;
  letter-spacing: -0.02em;
}

.post-content {
  font-size: 1.2rem;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 3rem;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}

.post-audio-sticky {
  position: sticky;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--secondary);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  display: flex;
  gap: 1rem;
  align-items: center;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
  z-index: 100;
  width: fit-content;
  max-width: 90%;
  border: 1px solid var(--border);
}

.post-audio-sticky .audio-btn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--bg);
  border: none;
}

.post-audio-sticky .audio-btn:hover:not(:disabled) {
  background: var(--bg);
  color: var(--secondary);
}

/* --- Static Pages --- */
.content-page {
  background: var(--surface);
  padding: 4rem;
  border-radius: var(--radius-3xl);
  box-shadow: var(--shadow-sm);
  margin-top: 2rem;
  border: 1px solid var(--border);
}

.content-page h1 {
  margin-bottom: 2rem;
  font-size: 3rem;
  letter-spacing: -0.02em;
}

.content-page h2 {
  margin: 3rem 0 1rem;
  font-size: 1.8rem;
}

.content-page p {
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  font-size: 1.15rem;
  line-height: 1.8;
}

@media (max-width: 640px) {
  .content-page {
    padding: 2rem;
  }
  .content-page h1 {
    font-size: 2.2rem;
  }
}

/* --- Footer --- */
.footer {
  background: var(--surface);
  color: var(--secondary);
  margin-top: 2rem; 
  padding: 3rem 0 2rem;
}

.footer-inner {
  gap: 1rem;
  text-align: center;
}

.footer-logo {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: var(--space-3);
  display: flex;
  justify-content: center;
  align-items: center;
  letter-spacing: -0.02em;
}

.footer-logo span {
  color: var(--secondary);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.footer-link {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 600;
}

.footer-link:hover {
  color: var(--primary);
}

.copyright {
  color: var(--text-muted);
  font-size: 0.875rem;
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
  margin-top: var(--space-2);
}

/* --- Stories Page Cleanup --- */
body[data-page="stories"] .filter-bar {
  position: relative;
  top: 0;
  background: transparent;
  border-bottom: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  padding: var(--space-2) 0;
}

body[data-page="stories"] .section-padding {
  padding-top: var(--space-2);
}

body[data-page="stories"] .feed {
  grid-template-columns: 1fr;
  grid-auto-rows: auto;
  grid-auto-flow: row;
  gap: var(--space-3);
  margin-top: 0;
}

@media (min-width: 900px) {
  body[data-page="stories"] .feed {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

body[data-page="stories"] .card {
  height: auto;
}

body[data-page="stories"] .card-image-wrap,
body[data-page="stories"] .card:nth-child(4n + 1) .card-image-wrap {
  height: 220px;
}

body[data-page="stories"] .card:nth-child(4n + 1) {
  grid-column: span 1;
  grid-row: span 1;
}

body[data-page="stories"] .card:nth-child(4n + 1) .card-body {
  padding: var(--space-3) var(--space-4);
}

body[data-page="stories"] .card:nth-child(4n + 1) .card-title {
  font-size: 1.4rem;
  margin-bottom: 0.75rem;
}

body[data-page="stories"] .card:nth-child(4n + 1) .card-excerpt {
  font-size: 0.95rem;
  -webkit-line-clamp: 2;
}

/* --- Animations --- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  animation: fadeIn 0.7s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Skeleton Shimmer */
.skeleton {
  background: var(--surface);
  position: relative;
  overflow: hidden;
  border-color: transparent;
}

.skeleton::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  transform: translateX(-100%);
  background-image: linear-gradient(
    90deg,
    transparent 0,
    rgba(255, 255, 255, 0.05) 20%,
    rgba(255, 255, 255, 0.1) 60%,
    transparent
  );
  animation: shimmer 2s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* Structured story chapters and expressive narration controls */
.post-subtitle {
  margin: 0.75rem auto 0;
  max-width: 720px;
  color: var(--text-muted);
  font-size: 1.15rem;
  text-align: center;
}
.post-synopsis {
  max-width: 760px;
  margin: 1rem auto 0;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.75;
}
.story-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.45rem;
  margin: 1.25rem 0;
}
.story-tag {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 999px;
  padding: 0.3rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.narration-panel {
  margin: 1.75rem auto 2.5rem;
  max-width: 850px;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.narration-panel-heading {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.narration-panel-heading strong, .narration-panel-heading small { display: block; }
.narration-panel-heading small { color: var(--text-muted); font-size: 0.82rem; margin-top: 0.15rem; }
.narration-pulse {
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary); box-shadow: 0 0 0 5px var(--primary-light);
}
.narration-settings {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(130px, 0.8fr);
  gap: 0.9rem;
}
.narration-settings label {
  display: flex; flex-direction: column; gap: 0.4rem;
  color: var(--text-muted); font-size: 0.82rem; font-weight: 600;
}
.narration-settings select {
  width: 100%; min-width: 0; border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 0.65rem 0.7rem;
  background: var(--bg); color: var(--text); font: inherit; font-weight: 500;
}
.narration-speed { position: relative; }
.narration-speed input { width: 100%; accent-color: var(--primary); }
.narration-rate-value { color: var(--primary); }
.narration-note { color: var(--text-muted); font-size: 0.78rem; line-height: 1.5; margin-top: 0.9rem; }
.post-audio-sticky {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem;
  margin-top: 1rem;
}
.post-audio-sticky .audio-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.65rem 0.9rem; border: 1px solid var(--border); border-radius: 999px;
  color: var(--text); background: var(--bg); font-weight: 600;
}
.post-audio-sticky .play-btn { color: white; background: var(--primary); border-color: var(--primary); }
.post-audio-sticky .audio-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.narration-progress { color: var(--text-muted); font-size: 0.82rem; margin-left: auto; }
.structured-story { max-width: 760px; margin-left: auto; margin-right: auto; }
.story-scene { margin: 0 0 3.25rem; }
.scene-heading {
  margin: 2.5rem 0 1.25rem;
  font-size: clamp(1.45rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}
.story-scene p { margin: 0 0 1.25rem; line-height: 1.95; font-size: 1.08rem; }
.scene-illustration { margin: 1.7rem 0 2rem; }
.scene-illustration img {
  display: block; width: 100%; max-height: 540px; object-fit: cover;
  border-radius: var(--radius-xl); border: 1px solid var(--border);
}
.scene-image .image-placeholder {
  border: 1px dashed var(--border);
  border-radius: 0.9rem;
  padding: 1rem;
  background: var(--surface);
  color: var(--text-muted);
}
.image-missing-note {
  display: none; color: var(--text-muted); background: var(--bg);
  border: 1px dashed var(--border); padding: 1rem; border-radius: var(--radius-lg);
  font-size: 0.85rem; line-height: 1.6;
}
.image-missing .image-missing-note, .image-prompt-only .image-missing-note { display: block; }
.image-missing-note details { margin-top: 0.5rem; }
.image-missing-note summary { cursor: pointer; color: var(--primary); font-weight: 600; }
.image-missing-note p { font-size: 0.82rem; margin: 0.5rem 0 0; overflow-wrap: anywhere; }
.speech-content .sentence.active {
  background: #fff0a8; color: #332800; border-radius: 0.2rem;
  box-decoration-break: clone; -webkit-box-decoration-break: clone;
  box-shadow: 0 0 0 2px #fff0a8; transition: background-color 0.15s ease;
}
[data-theme="dark"] .speech-content .sentence.active {
  background: #66531a; color: #fff5cc; box-shadow: 0 0 0 2px #66531a;
}
@media (max-width: 640px) {
  .narration-settings { grid-template-columns: 1fr; }
  .narration-panel { padding: 1rem; }
  .post-audio-sticky { gap: 0.4rem; }
  .narration-progress { width: 100%; margin-left: 0; }
  .story-scene p { font-size: 1rem; line-height: 1.85; }
}

/* --- Homepage landing layout --- */
.home-page .hero {
  min-height: 555px;
  display: flex;
  align-items: center;
  padding: 4rem 0;
  background: linear-gradient(115deg, #edf5ff 0%, #f6fbff 100%);
}

.home-page .hero::before,
.home-page .hero::after {
  display: none;
}

.home-page .hero .container,
.home-page .how-it-works-section .container {
  width: 100%;
  max-width: 840px;
}

.home-page .hero-grid {
  grid-template-columns: 0.95fr 1.05fr;
  align-items: center;
  gap: 3rem;
}

.home-page .hero-title {
  max-width: 350px;
  margin-bottom: 1rem;
  font-size: clamp(2.8rem, 4.2vw, 3.5rem);
  line-height: 1.05;
}

.home-page .hero-subtitle {
  max-width: 370px;
  margin: 0 0 1.75rem;
  font-size: 1.05rem;
  line-height: 1.65;
}

.home-page .cta-button {
  padding: 0.9rem 2rem;
  font-size: 0.95rem;
}

.home-page .hero-visual {
  height: 420px;
  gap: 0.7rem;
  margin: 0;
}

.home-page .visual-card img {
  filter: none;
}

.home-page .how-it-works-section {
  padding: 3.25rem 0 4.5rem;
}

.home-page .how-it-works-section h2 {
  margin-bottom: 2.25rem;
  text-align: center;
  font-size: 1.35rem;
}

.home-page .how-it-works-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.5rem;
  margin-top: 0;
}

.home-page .step-card {
  min-height: 230px;
  padding: 2rem 1.5rem;
  border-radius: 1.75rem;
}

.home-page .step-card:hover {
  background: var(--surface);
  box-shadow: var(--shadow-md);
}

.home-page .step-icon {
  width: 56px;
  height: 56px;
  margin-bottom: 1.25rem;
  border-radius: 1.15rem;
  background: var(--bg);
}

.home-page .step-icon svg {
  width: 22px;
  height: 22px;
}

.home-page .step-card:hover .step-icon {
  background: var(--bg);
  color: var(--primary);
}

.home-page .step-card:hover .step-title {
  color: var(--secondary);
}

.home-page .step-card:hover .step-desc {
  color: var(--text-muted);
}

.home-page .step-title {
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.home-page .step-desc {
  font-size: 0.9rem;
  line-height: 1.55;
}

.home-featured {
  max-width: 900px;
}

.home-featured-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.home-featured-heading h2 {
  margin-bottom: 0;
}

@media (max-width: 992px) {
  .home-page .hero {
    min-height: 0;
  }

  .home-page .hero-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .home-page .hero-text {
    order: 0;
    text-align: left;
  }

  .home-page .hero-title,
  .home-page .hero-subtitle {
    margin-right: auto;
    margin-left: 0;
  }

  .home-page .hero-visual {
    order: 1;
    width: 100%;
    max-width: 520px;
    height: 340px;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .home-page .hero {
    padding: 3rem 0;
  }

  .section-padding {
    padding: 2.75rem 1rem;
  }

  .home-page .hero-title {
    font-size: clamp(2.5rem, 12vw, 3.25rem);
  }

  .home-page .hero-visual {
    height: 280px;
    gap: 0.25rem;
  }

  .home-page .how-it-works-section {
    padding: 2.75rem 0 3rem;
  }

  .home-page .how-it-works-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .home-page .step-card {
    min-height: 0;
  }
}

/* --- Shared page spacing, story cards, and theme control --- */
body {
  min-width: 320px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sf-nav-inner {
  gap: 1rem;
}

.sf-theme-toggle {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.sf-theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.sf-theme-toggle:focus-visible {
  outline: 3px solid var(--primary-light);
  outline-offset: 2px;
}

.theme-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.theme-icon[hidden] {
  display: none;
}

.stories-page h1 {
  margin-bottom: 0.8rem;
  font-size: clamp(2.2rem, 5vw, 3.5rem);
}

.stories-intro {
  margin-bottom: 2rem;
  color: var(--text-muted);
}

.story-card-image {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin-bottom: 0.35rem;
  overflow: hidden;
  border-radius: 0.75rem;
  background: var(--bg);
}

.story-card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.35s ease;
}

.story-card-image:hover img {
  transform: scale(1.04);
}

.sf-footer {
  background: var(--surface);
  color: var(--text-muted);
}

.copyright-notice {
  max-width: 760px;
  margin: 0.65rem auto 0;
  font-size: 0.82rem;
  line-height: 1.6;
}

[data-theme="dark"] .home-page .hero {
  background: linear-gradient(115deg, var(--bg), var(--surface));
}

[data-theme="dark"] .flash.success {
  background: #14532d;
  color: #dcfce7;
}

[data-theme="dark"] .flash.error {
  background: #7f1d1d;
  color: #fee2e2;
}

@media (max-width: 640px) {
  .sf-nav-inner {
    gap: 0.6rem;
    padding: 0 1rem;
  }

  .sf-links {
    gap: 0.75rem;
    font-size: 0.85rem;
  }

  .sf-theme-toggle {
    width: 38px;
    min-height: 38px;
    padding: 0;
  }

  .theme-toggle-label {
    display: none;
  }

}
