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

/* CSS Variables */
:root {
    /* Brand Colors */
    --brand-primary: #35769A;
    --brand-primary-hover: #13577c;
    --brand-primary-dark: #1A3A4C;
    --brand-primary-light: #91d6fc;
    
    /* Background Colors */
    --background-color: #F7ECE1;
    
    /* Story Element Colors */
    --character-primary: #ef4444;
    --character-light: #fedcdc;
    --setting-primary: #10b981;
    --setting-light: #dbfde5;
    --tone-primary: #f59e0b;
    --tone-light: #fbf2cd;
    
    /* Neutral Colors */
    --white: #ffffff;
    --gray-50: #fafaf9;
    --gray-100: #f5f5f4;
    --gray-200: #e7e5e4;
    --gray-300: #d6d3d1;
    --gray-400: #a8a29e;
    --gray-500: #78716c;
    --gray-600: #57534e;
    --gray-700: #44403c;
    --gray-800: #292524;
    --gray-900: #1c1917;
    
    /* Spacing Scale */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;
    --space-20: 5rem;
    --space-24: 6rem;
    
    /* Typography */
    --font-family: 'Quicksand', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --font-size-xs: 0.75rem;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.125rem;
    --font-size-xl: 1.25rem;
    --font-size-2xl: 1.5rem;
    --font-size-3xl: 1.875rem;
    --font-size-4xl: 2.25rem;
    --font-size-5xl: 3rem;
    --font-size-6xl: 3.75rem;
    
    /* Line Heights */
    --leading-tight: 1.25;
    --leading-snug: 1.375;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    
    /* Border Radius */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem;
    --radius-lg: 0.5rem;
    --radius-xl: 0.75rem;
    --radius-2xl: 1rem;
    --radius-3xl: 1.5rem;
    --radius-full: 9999px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    
    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset and Base Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: var(--font-family);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Preferences  */
@view-transition {
    navigation: auto;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--gray-700);
    background-color: var(--background-color);
    line-height: var(--leading-normal);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-family) !important;
    font-weight: 700;
    line-height: var(--leading-tight);
    color: var(--gray-900);
}

p, span, div, a, button, input, select, textarea, label {
    font-family: var(--font-family) !important;
}

.container {
    max-width: 980px;
    margin: 0 auto;
    padding: 0 var(--space-4);
    width: 100%;
}

/* Header */
.header {
    background: var(--white);
    padding: var(--space-6) 0;
    box-shadow: var(--shadow-sm);
    border-bottom: 1px solid transparent;
    position: sticky;
    top: 0;
    z-index: 50;
    transition: border-color var(--transition-normal);
    max-height: 85px;
}

.header.scrolled {
    border-bottom-color: var(--gray-300);
}

.header .container {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: var(--space-4);
    position: relative;
}

/* The logo takes the slack, so the links, the account menu and the mobile
   menu button all sit against the right edge at every width. */
.header .container > .logo {
    margin-right: auto;
}

.logo h1 {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-2xl);
    font-weight: 800;
    color: var(--brand-primary);
    letter-spacing: -0.025em;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    text-decoration: none;
}

.logo-icon {
    width: 2rem;
    height: 2rem;
    filter: drop-shadow(0 2px 4px rgb(0 0 0 / 0.1));
}

.nav {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.nav-link {
    font-family: var(--font-family) !important;
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 500;
    font-size: var(--font-size-sm);
    padding: var(--space-2) var(--space-1);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    letter-spacing: -0.01em;
}

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

/* The active page gets a rounded bar under it, in the same blue as the
   Sign In button's border. */
.nav-link.active {
    position: relative;
    color: var(--brand-primary);
    font-weight: 600;
}

.nav-link.active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    border-radius: var(--radius-full);
    background: var(--brand-primary);
}

.mobile-nav-link.active {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    font-weight: 600;
}

.nav-link.primary-btn {
    font-family: var(--font-family) !important;
    background: var(--brand-primary);
    color: var(--white);
    padding: var(--space-3) var(--space-6);
    border-radius: 12px;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease-out;
}

.header.show-header-cta .nav-link.primary-btn {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-link.primary-btn:hover {
    background: var(--brand-primary-hover);
    color: var(--white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    background: var(--white);
    border: 2px solid var(--gray-300);
    cursor: pointer;
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-lg);
    position: relative;
    z-index: 1001;
    transition: all var(--transition-fast);
    font-family: var(--font-family) !important;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-700);
    min-width: 60px;
    text-align: center;
}

.mobile-menu-btn:hover {
    background: var(--gray-50);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.mobile-menu-btn.active {
    background: var(--brand-primary);
    border-color: var(--brand-primary);
    color: var(--white);
    box-shadow: var(--shadow-md);
}

.mobile-menu-btn span {
    display: none;
}

/* Mobile Menu Popover */
.mobile-menu-popover {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--gray-200);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all var(--transition-normal);
    z-index: 1000;
    min-width: 200px;
    margin-top: var(--space-2);
}

.mobile-menu-popover.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.mobile-menu-content {
    padding: var(--space-4);
}

.mobile-nav-link {
    display: block;
    padding: var(--space-3) var(--space-4);
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    font-size: var(--font-size-base);
    border-radius: var(--radius-lg);
    transition: all var(--transition-fast);
    margin-bottom: var(--space-1);
}

.mobile-nav-link:hover {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
    transform: translateX(4px);
}

.mobile-nav-link:last-child {
    margin-bottom: 0;
}

/* Hero Section */
.hero {
    height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--background-color) 0%, var(--background-color) 100%);
    padding: 40px 0 80px;
    position: relative;
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-16);
    align-items: center;
    direction: rtl;
}

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

.hero-text a.primary-btn {
    width: 100%;
    max-width: 330px;
}

.hero-image {
    direction: ltr;
    width: 100%;
}

.hero-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-3xl);
    font-weight: 800;
    color: var(--gray-700);
    margin-bottom: var(--space-12);
    line-height: var(--leading-tight);
    letter-spacing: -0.025em;
    text-align: center;
}

.mascot-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mascot-image {
    width: 100%;
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 8px 16px rgb(0 0 0 / 0.1));
    z-index: 2;
    position: relative;
}

.idea-bubbles {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
}

.idea-bubble {
    position: absolute;
    width: 60px;
    opacity: 0.8;
    filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.1));
    animation: float 3s ease-in-out infinite;
}

.bubble-1 {
    top: -4%;
    left: 40%;
    transform: translateX(-50%);
    animation-delay: 0s;
}

.bubble-2 {
    top: 7%;
    left: 20%;
    animation-delay: 0.5s;
}

.bubble-3 {
    top: 3%;
    right: 25%;
    animation-delay: 1s;
}

.bubble-4 {
    top: 30%;
    left: 10%;
    animation-delay: 1.5s;
}

.bubble-5 {
    top: 25%;
    right: 10%;
    animation-delay: 2s;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    25% {
        transform: translateY(-10px) rotate(5deg);
    }
    50% {
        transform: translateY(-5px) rotate(-3deg);
    }
    75% {
        transform: translateY(-15px) rotate(3deg);
    }
}

/* Marketing Section Reveal Animations */
.section {
    height: 50vh;
    display: flex;
    align-items: center;
    background: var(--background-color);
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.section.revealed {
    opacity: 1;
    transform: translateY(0);
}

.section:nth-child(even) {
    background: var(--background-color);
}

/* Stagger the animations for different elements within sections */
.section-text {
    max-width: 480px;
    opacity: 0;
    transform: translateX(-20px);
    transition: opacity 0.6s ease-out 0.2s, transform 0.6s ease-out 0.2s;
}

.section.revealed .section-text {
    opacity: 1;
    transform: translateX(0);
}

.section-image {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 0.6s ease-out 0.4s, transform 0.6s ease-out 0.4s;
}

.section.revealed .section-image {
    opacity: 1;
    transform: translateX(0);
}

/* Reverse sections have opposite slide directions */
.section.reverse .section-text {
    transform: translateX(20px);
}

.section.reverse .section-image {
    transform: translateX(-20px);
}

.section.reverse.revealed .section-text {
    transform: translateX(0);
}

.section.reverse.revealed .section-image {
    transform: translateX(0);
}

.section-text h2 {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-5xl);
    font-weight: 800;
    color: var(--brand-primary);
    margin-bottom: var(--space-6);
    letter-spacing: -0.025em;
}

.section-text p {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    color: var(--gray-600);
    line-height: var(--leading-relaxed);
    text-align: justify;
    hyphens: auto;
}

.devices-svg, .backpack-svg {
    width: 100%;
    max-width: 400px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.05));
}

.phone-svg {
    width: 100%;
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.05));
}

.books-svg {
    width: 100%;
    max-width: 300px;
    height: auto;
    filter: drop-shadow(0 4px 6px rgb(0 0 0 / 0.05));
}

/* Buttons */
.btn {
    font-family: var(--font-family) !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-3) var(--space-12);
    border-radius: var(--radius-xl);
    font-weight: 700;
    font-size: var(--font-size-base);
    text-decoration: none;
    cursor: pointer;
    transition: all var(--transition-normal);
    letter-spacing: -0.01em;
    box-shadow: var(--shadow-sm);
    text-transform: uppercase;
}

.primary-btn {
    background: var(--brand-primary);
    color: var(--white);
    border-color: var(--brand-primary);
    border-bottom: 4px solid var(--brand-primary-hover);
}

.primary-btn:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.secondary-btn {
    background: var(--white);
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.secondary-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    transform: translateY(-1px);
}

.outline-btn {
    background: transparent;
    color: var(--white);
    border: 2px solid var(--white);
    box-shadow: none;
    transition: all var(--transition-normal);
}

.outline-btn:hover {
    background: var(--white);
    color: var(--brand-primary-dark);
    border-color: var(--white);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* Widget Section - Removed, keeping only modal version */
.widget-container {
    position: relative;
    min-height: calc(100vh - 85px);
    padding-block: var(--space-12);
}

.widget-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('/assets/img/bgs/site-background-1.webp');
    background-size: cover;
    background-position: center;
    opacity: 0.3;
}

/* Shorty Chat Interface */
.shorty-chat {
    display: flex;
    align-items: center;
    gap: var(--space-6);
    margin-bottom: var(--space-6);
    justify-content: center;
}

.shorty-avatar {
    width: 80px;
    filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.2));
    flex-shrink: 0;
    animation: float-gentle 3s ease-in-out infinite;
}

@keyframes float-gentle {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

.chat-bubble {
    background: var(--white);
    border-radius: var(--radius-2xl);
    padding: var(--space-6) var(--space-8);
    max-width: 520px;
    box-shadow: var(--shadow-lg);
    position: relative;
    transition: transform var(--transition-fast);
}

.chat-bubble strong {
    color: var(--brand-primary);
}

.chat-bubble::after {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 12px solid #ffffff;
}

.chat-bubble p {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    color: var(--gray-800);
    font-weight: 600;
    line-height: var(--leading-relaxed);
    margin: 0;
}

h2.widget-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-4xl);
    font-weight: 800;
    text-align: center;
    margin-bottom: var(--space-12);
    letter-spacing: -0.025em;
    color: var(--white);
}

.story-generator {
    z-index: 5;
    position: relative;
}

.story-elements {
    background: white;
    position: relative;
    height: 520px;
    overflow-y: auto;
    overflow-x: clip;
    border-top: 0;
    padding: var(--space-6);
    border-top-right-radius: 0;
    border-top-left-radius: 0;
    scrollbar-width: none;
    border-bottom: 2px solid var(--brand-primary);
    padding-bottom: 130px;
}

.story-elements::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.story-elements-header {
    background: var(--brand-primary);
    color: var(--white);
    padding: var(--space-3) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--brand-primary-hover);
}

.story-elements-content {
    padding: var(--space-4);
}

.story-elements-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--white);
    margin: 0;
}

.story-status {
    font-family: var(--font-family) !important;
    padding: var(--space-4) var(--space-8);
    background: var(--brand-primary-light);
    border-bottom: 1px solid var(--brand-primary);
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--brand-primary);
    text-align: center;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-normal);
}

.story-status:empty {
    display: none;
}

.generator-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    min-height: 600px;
    gap: var(--space-6);
}

.story-inputs {
    margin-block: var(--space-6);
    min-height: 570px;
    background-color: #fff;
    border-radius: 12px;
    border: 2px solid var(--brand-primary);
    border-bottom: 4px solid var(--brand-primary);
    position: relative;
    overflow: hidden;
}

.input-group {
    margin-bottom: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    position: relative;
}

.input-label {
    font-family: var(--font-family) !important;
    font-weight: 600;
    color: #000;
    font-size: var(--font-size-ls);
    letter-spacing: -0.01em;
    flex-shrink: 0;
    margin-bottom: 0;
    opacity: 0.7;
}

.story-input, .story-select {
    font-family: var(--font-family) !important;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-xl);
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
    background: var(--white);
    color: var(--gray-700);
}

.story-input:focus, .story-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 3px var(--brand-primary-light);
}

.story-input:disabled, .story-select:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
    opacity: 0.7;
    border-color: var(--gray-200);
}

.story-input::placeholder {
    color: var(--gray-600);
    font-weight: 500;
}

/* Color-coded input groups */
.character-group {
    background: var(--character-light);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--character-primary);
    border-bottom: 4px solid var(--character-primary);
}

.character-group .story-input {
    border-color: var(--character-primary);
}

.character-group .story-input:focus {
    box-shadow: 0 0 0 3px var(--character-light);
}

.setting-group {
    background: var(--setting-light);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--setting-primary);
    border-bottom: 4px solid var(--setting-primary);
}

.setting-group .story-input {
    border-color: var(--setting-primary);
}

.setting-group .story-input:focus {
    box-shadow: 0 0 0 3px var(--setting-light);
}

.situation-group {
    background: var(--tone-light);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--tone-primary);
    border-bottom: 4px solid var(--tone-primary);
}

.situation-group .story-input {
    border-color: var(--tone-primary);
}

.situation-group .story-input:focus {
    box-shadow: 0 0 0 3px var(--tone-light);
}

.tone-group {
    background: var(--gray-200);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-500);
    border-bottom: 4px solid var(--gray-500);
    position: relative;
    display: none; /* Hidden by default */
}

.tone-group .story-input {
    border-color: var(--gray-500);
    margin-right: var(--space-10);
}

.tone-group .story-input:focus {
    box-shadow: 0 0 0 3px var(--gray-200);
}

/* Optional Input Groups */
.theme-group {
    background: var(--gray-200);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-500);
    border-bottom: 4px solid var(--gray-500);
    position: relative;
    display: none; /* Hidden by default */
}

.theme-group .story-input {
    border-color: var(--gray-500);
    margin-right: var(--space-10); /* Space for remove button */
}

.challenge-group {
    background: var(--gray-200);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-500);
    border-bottom: 4px solid var(--gray-500);
    position: relative;
    display: none; /* Hidden by default */
}

.challenge-group .story-input {
    border-color: var(--gray-500);
    margin-right: var(--space-10);
}

.words-group {
    background: var(--gray-200);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-500);
    border-bottom: 4px solid var(--gray-500);
    position: relative;
    display: none; /* Hidden by default */
}

.words-group .story-input {
    border-color: var(--gray-500);
    margin-right: var(--space-10);
}

.reading-group {
    background: var(--gray-200);
    padding: var(--space-3);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-500);
    border-bottom: 4px solid var(--gray-500);
    position: relative;
    display: none; /* Hidden by default */
}

.reading-group .story-input {
    border-color: var(--gray-500);
    margin-right: var(--space-10);
}

/* Show optional input groups when active */
.tone-group.active,
.theme-group.active,
.challenge-group.active,
.words-group.active,
.reading-group.active {
    display: flex;
}

/* Remove Button Styling */
.remove-btn {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--space-1);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    margin-left: var(--space-2);
}

.remove-btn:hover {
    background: var(--gray-500);
    transform: translateY(-50%) scale(1.1);
}

.remove-btn svg {
    width: 18px;
    height: 18px;
    fill: var(--gray-500);
    transition: fill var(--transition-fast);
}

.remove-btn:hover svg {
    fill: var(--white);
}

/* Optional Section Styling */
.optional-section {
    margin-top: var(--space-6);
    padding: var(--space-4);
    background: var(--white);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-200);
}

.optional-section-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-4);
    text-align: center;
}

/* Pill Group */
.pill-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: absolute;
    width: 100%;
    background: #e2f2fb;
    bottom: 0;
    padding: 12px;
    border-bottom-left-radius: 12px;
    border-bottom-right-radius: 12px;
    border-top: 2px solid var(--brand-primary);
    z-index: 10;
}

.pill-group-title {
    color: var(--brand-primary);
    font-weight: bold;
}

.pill-group-buttons {
    display: flex;
    align-content: center;
    justify-content: start;
    flex-wrap: wrap;
    gap: 5px;
}

/* Pill Button Styling */
.pill-btn {
    font-family: var(--font-family) !important;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--gray-200);
    color: var(--gray-700);
    border: 2px solid var(--gray-500);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    letter-spacing: 0.025em;
    border-bottom: 3px solid var(--gray-500);
}

.pill-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pill-btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.pill-btn svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
    transition: transform var(--transition-fast);
}

.pill-btn:hover svg {
    transform: rotate(90deg);
}

/* Hidden state for pills when input group is active */
.pill-btn.hidden {
    display: none;
}

/* Optional Section Styling */
.optional-section {
    margin-top: var(--space-6);
    padding: var(--space-4);
    background: var(--white);
    border-radius: var(--radius-2xl);
    border: 2px solid var(--gray-200);
}

.optional-section-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: var(--space-4);
    text-align: center;
}

.optional-summary, .advanced-summary {
    font-family: var(--font-family) !important;
    padding: var(--space-4);
    background: #cde3fb;
    border-radius: var(--radius-xl);
    cursor: pointer;
    font-weight: 600;
    color: var(--gray-800);
    border: 2px solid var(--brand-primary);
    transition: all var(--transition-fast);
    font-size: var(--font-size-sm);
}

.optional-summary:hover, .advanced-summary:hover {
    background: var(--brand-primary);
    color: var(--white);
    border-color: var(--brand-primary);
}

.optional-inputs, .advanced-inputs {
    padding: var(--space-4);
    background: #cde3fb;
    border-radius: var(--radius-xl);
    margin-top: var(--space-3);
    border: 2px solid var(--brand-primary);
}

.button-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    margin-top: var(--space-6);
}

/* Enhanced button styling for better visibility against light blue background */
.button-group .btn {
    box-shadow: var(--shadow-md);
    border: 3px solid var(--brand-primary);
    font-weight: 700;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.button-group .primary-btn {
    background: var(--brand-primary);
    border-color: var(--brand-primary-hover);
    border-bottom: 5px solid var(--brand-primary-dark);
    box-shadow: 0 6px 12px rgba(53, 118, 154, 0.3);
}

.button-group .primary-btn:hover {
    background: var(--brand-primary-hover);
    border-color: var(--brand-primary-dark);
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(53, 118, 154, 0.4);
}

.button-group .secondary-btn,
.button-group .outline-btn {
    background: var(--white);
    border-color: var(--brand-primary);
    border-bottom: 5px solid var(--brand-primary);
    color: var(--brand-primary);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.button-group .secondary-btn:hover,
.button-group .outline-btn:hover {
    background: var(--brand-primary);
    color: var(--white);
    border-color: var(--brand-primary-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 16px rgba(53, 118, 154, 0.3);
}

.story-output {
    grid-column: 2;
    grid-row: 1;
    margin-block: var(--space-6);
    position: relative;
    border-radius: 12px;
}

.story-output-header {
    background: var(--brand-primary);
    color: var(--white);
    padding: var(--space-3) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 12px 12px 0 0;
    border-bottom: 2px solid var(--brand-primary-hover);
    flex-wrap: wrap;
    gap: 5px;
}

.story-output-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
    color: var(--white);
}

.story-actions {
    display: flex;
    gap: var(--space-2);
}

.story-action-btn {
    background: transparent;
    border: 1px solid var(--white);
    color: var(--white);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-lg);
    font-family: var(--font-family) !important;
    font-size: var(--font-size-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.story-action-btn:hover {
    background: var(--white);
    color: var(--brand-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.story-action-btn:active {
    transform: translateY(0);
    box-shadow: none;
}

.story-action-btn.copied {
    background-color: var(--setting-primary);
    border-color: var(--setting-primary);
    color: var(--white);
}

.story-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.5);
}

.story-action-btn:disabled:hover {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.5);
    color: rgba(255, 255, 255, 0.5);
    transform: none;
    box-shadow: none;
}

/* Fullscreen mode for story output */
.story-output.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    background: var(--white);
    border-radius: 0;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.story-output.fullscreen .story-output-header {
    border-radius: 0;
    flex-shrink: 0;
}

.story-output.fullscreen .story-content {
    border-radius: 0;
    border: none;
    border-bottom: none;
    max-height: none;
    height: 100%;
    flex: 1;
    overflow-y: auto;
}

/* Fullscreen Story Modal */
.story-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.story-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.story-modal-content {
    background: var(--white);
    width: 95%;
    height: 95%;
    max-width: 1200px;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalSlideIn 0.3s ease-out;
    position: relative;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.story-modal-header {
    background: var(--brand-primary);
    color: var(--white);
    padding: var(--space-4) var(--space-6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    border-bottom: 2px solid var(--brand-primary-hover);
    flex-shrink: 0;
}

.story-modal-title {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin: 0;
    color: var(--white);
}

.story-modal-actions {
    display: flex;
    gap: var(--space-3);
}

.story-modal-body {
    flex: 1;
    padding: var(--space-6);
    overflow-y: auto;
    font-family: var(--font-family) !important;
    line-height: 1.8;
    color: var(--gray-700);
    font-size: var(--font-size-lg);
    text-align: justify;
    hyphens: auto;
    scrollbar-width: none; /* Firefox */
    max-width: 65ch;
    margin: 0 auto;
}

.story-modal-body::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.story-modal-body h2 {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-3xl);
    font-weight: 700;
    color: var(--gray-900);
    margin-block: var(--space-8);
    text-align: center;
}

.story-modal-body p {
    font-family: var(--font-family) !important;
    margin-bottom: var(--space-5);
    line-height: 1.8;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
}

.story-modal-body .story-character {
    color: var(--character-primary);
    font-weight: 600;
}

.story-content {
    font-family: var(--font-family) !important;
    line-height: 1.8;
    background: var(--white);
    color: var(--gray-700);
    font-size: var(--font-size-base);
    text-align: justify;
    hyphens: auto;
    border: 2px solid var(--brand-primary);
    border-radius: 0 0 12px 12px;
    padding: var(--space-5);
    padding-bottom: 75px;
    font-weight: 500;
    height: 100%;
    height: 520px;
    overflow-y: auto;
    scrollbar-width: none; /* Firefox */
    border-bottom: 4px solid var(--brand-primary);
    position: relative; /* Required for absolutely positioned loading overlay */
    border-top: 0;
}

.story-content::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

.story-content h2 {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: var(--space-6);
    text-align: left;
}

.story-content p {
    font-family: var(--font-family) !important;
    margin-bottom: var(--space-4);
    line-height: 1.8;
    text-align: justify;
    hyphens: auto;
    -webkit-hyphens: auto;
    -ms-hyphens: auto;
}

.story-placeholder {
    font-family: var(--font-family) !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 400px;
    text-align: center;
    color: var(--gray-500);
}

.story-placeholder h4 {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-xl);
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: var(--gray-700);
}

.story-placeholder p {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-base);
    color: var(--gray-500);
}

.loading-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    min-height: 520px;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(4px);
    border: 2px solid var(--brand-primary);
    border-bottom: 4px solid var(--brand-primary);
    border-top: none;
    border-radius: 12px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

.loading-hourglass {
    margin-bottom: var(--space-4);
    animation: hourglassFloat 2s ease-in-out infinite;
}

.hourglass-icon {
    width: 48px;
    height: 48px;
    animation: hourglassRotate 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1));
}

.loading-overlay p {
    font-family: var(--font-family) !important;
    color: var(--gray-600);
    font-weight: 500;
    animation: textPulse 1.5s ease-in-out infinite;
}

/* Hourglass Animations */
@keyframes hourglassRotate {
    0% { 
        transform: rotate(0deg) scale(1);
        opacity: 0.8;
    }
    25% { 
        transform: rotate(5deg) scale(1.05);
        opacity: 1;
    }
    50% { 
        transform: rotate(0deg) scale(1);
        opacity: 0.9;
    }
    75% { 
        transform: rotate(-5deg) scale(1.05);
        opacity: 1;
    }
    100% { 
        transform: rotate(0deg) scale(1);
        opacity: 0.8;
    }
}

@keyframes hourglassFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-8px);
    }
}

@keyframes textPulse {
    0%, 100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

/* Print Styles for Stories */
@media print {
    * {
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
    
    body {
        font-family: 'Georgia', 'Times New Roman', serif !important;
        line-height: 1.6 !important;
        color: #2d3748 !important;
        background: white !important;
        margin: 0.75in !important;
        padding: 0 !important;
        font-size: 14pt !important;
    }
    
    .print-story-container {
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .print-story-header {
        text-align: center !important;
        margin-bottom: 1.5in !important;
        padding-bottom: 0.5in !important;
        border-bottom: 3px solid #35769A !important;
    }
    
    .print-story-title {
        font-family: 'Georgia', serif !important;
        font-size: 24pt !important;
        font-weight: bold !important;
        color: #35769A !important;
        margin: 0 !important;
        text-shadow: none !important;
        line-height: 1.2 !important;
    }
    
    .print-story-subtitle {
        font-family: 'Georgia', serif !important;
        font-size: 14pt !important;
        color: #4a5568 !important;
        margin: 0.25in 0 0 0 !important;
        font-style: italic !important;
    }
    
    .print-story-content {
        margin-top: 0.5in !important;
        column-count: 1 !important;
        column-gap: 0 !important;
    }
    
    .print-story-content h2 {
        display: none !important;
    }
    
    .print-story-content p {
        font-family: 'Georgia', serif !important;
        font-size: 13pt !important;
        line-height: 1.8 !important;
        margin-bottom: 0.25in !important;
        text-align: justify !important;
        text-indent: 0.25in !important;
        orphans: 3 !important;
        widows: 3 !important;
        color: #2d3748 !important;
    }
    
    .print-story-content p:first-of-type {
        text-indent: 0 !important;
        margin-top: 0 !important;
    }
    
    .print-story-content .story-character {
        color: #e53e3e !important;
        font-weight: bold !important;
        background: none !important;
    }
    
    .print-story-content .story-setting {
        color: #38a169 !important;
        font-weight: 600 !important;
    }
    
    .print-story-content .story-situation {
        color: #3182ce !important;
        font-weight: 600 !important;
    }
    
    .print-story-content .story-theme {
        color: #805ad5 !important;
        font-weight: 600 !important;
        font-style: italic !important;
    }
    
    .print-story-content .story-antagonist {
        color: #d69e2e !important;
        font-weight: 600 !important;
    }
    
    .print-story-content .story-tone {
        color: #718096 !important;
        font-style: italic !important;
    }
    
    .print-footer {
        position: fixed !important;
        bottom: 0.5in !important;
        left: 0.75in !important;
        right: 0.75in !important;
        text-align: center !important;
        font-size: 10pt !important;
        color: #718096 !important;
        border-top: 1px solid #e2e8f0 !important;
        padding-top: 0.25in !important;
    }
    
    /* Hide all non-story elements when printing */
    .header, .nav, .mobile-menu-btn, .mobile-menu-popover,
    .button-group, .story-output-header, .loading-overlay,
    .widget-container, .footer, .story-modal {
        display: none !important;
    }
    
    /* Force page breaks */
    .print-page-break {
        page-break-before: always !important;
    }
    
    .print-no-break {
        page-break-inside: avoid !important;
    }
}

/* Story element highlighting */
.story-character {
    font-family: var(--font-family) !important;
    color: var(--character-primary);
    font-weight: 600;
}

.story-antagonist {
    font-family: var(--font-family) !important;
    color: var(--antagonist-primary);
    font-weight: 600;
}

/* .story-character:hover {
    background-color: var(--character-primary);
    color: var(--white);
    transform: scale(1.05);
} */

.story-setting {
    font-family: var(--font-family) !important;
    color: var(--setting-primary);
    font-weight: 600;
}

.story-situation {
    font-family: var(--font-family) !important;
    color: var(--tone-primary);
    font-weight: 600;
}

.story-tone {
    font-family: var(--font-family) !important;
    color: var(--tone-primary);
    font-weight: 600;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    margin-bottom: var(--space-8);
}

.form-input, .form-select {
    font-family: var(--font-family) !important;
    padding: var(--space-5);
    border: 2px solid var(--gray-300);
    border-bottom: 4px solid var(--gray-400);
    border-radius: 12px;
    font-size: var(--font-size-base);
    transition: all var(--transition-fast);
    background: var(--white);
    color: var(--gray-700);
    font-weight: 500;
}

.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--brand-primary);
    border-bottom-color: var(--brand-primary-hover);
    box-shadow: 0 4px 8px rgba(53, 118, 154, 0.15);
}

.form-input::placeholder {
    color: var(--gray-500);
    font-weight: 400;
}

.hidden {
    display: none;
}

/* Footer */
.footer {
    background: var(--brand-primary);
    color: var(--white)#ffffff;
    padding: 100px 0 var(--space-8);
    position: relative;
}

.footer:before {
    content: "";
    position: absolute;
    left: 0;
    bottom: 100%;
    width: 100%;
    height: 85px;
    background: var(--brand-primary);
    mask-image: url(/assets/img/mask-2.png);
    mask-size: cover;
    mask-repeat: no-repeat;
    mask-position: center;
}

.footer-content {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: var(--space-12);
    margin-bottom: var(--space-12);
}

.footer-brand h3 {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-xl);
    font-weight: 700;
    margin-bottom: var(--space-3);
    color: var(--white);
}

.footer-brand p {
    font-family: var(--font-family) !important;
    color: var(--brand-primary-light);
    line-height: var(--leading-relaxed);
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.footer-links a {
    font-family: var(--font-family) !important;
    color: var(--brand-primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
    font-size: var(--font-size-sm);
}

.footer-links a:hover {
    color: var(--white);
}

.footer-contact p {
    font-family: var(--font-family) !important;
    color: var(--brand-primary-light);
    font-size: var(--font-size-sm);
}

.footer-bottom {
    text-align: center;
    padding-top: var(--space-8);
    border-top: 1px solid var(--brand-primary-light);
    color: var(--brand-primary-light);
}

.footer-bottom p {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-sm);
}

/* Animations */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.scroll-down-btn {
    position: absolute;
    bottom: 110px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    color: var(--gray-400);
    border: none;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.scroll-down-btn:hover {
    color: var(--gray-700);
    transform: translateX(-50%) translateY(-2px);
}

#perfect-for-schools .section-content, #fun-characters .section-content {
    grid-template-columns: 1fr 2fr;
}

.character-bubbles {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 300px;
    margin: 0 auto;
}

.character-bubble {
    position: absolute;
    width: 70px;
    /* height: 70px; */
    opacity: 0.9;
    filter: drop-shadow(0 4px 8px rgb(0 0 0 / 0.1));
    animation: float 4s ease-in-out infinite;
}

.character-bubbles .bubble-1 {
    top: 5%;
    left: 40%;
    transform: translateX(-50%);
    animation-delay: 0s;
}

.character-bubbles .bubble-2 {
    top: 15%;
    left: 15%;
    animation-delay: 0.7s;
}

.character-bubbles .bubble-3 {
    top: 20%;
    right: 10%;
    animation-delay: 1.4s;
}

.character-bubbles .bubble-4 {
    top: 45%;
    left: 5%;
    animation-delay: 2.1s;
}

.character-bubbles .bubble-5 {
    top: 50%;
    right: 5%;
    animation-delay: 2.8s;
}

.character-bubbles .bubble-6 {
    top: 70%;
    left: 40%;
    transform: translateX(-50%);
    animation-delay: 3.5s;
}

.section-content {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-16);
    align-items: center;
}

.section.reverse .section-content {
    direction: rtl;
}

.section.reverse .section-text,
.section.reverse .section-image {
    direction: ltr;
}

/* Policy Pages Styles */
.main {
    min-height: calc(100vh - 200px);
    padding: var(--space-16) 0;
}

.content-section {
    max-width: 800px;
    margin: 0 auto 80px;
    padding: 0 var(--space-6);
}

.content-section h1 {
    font-size: var(--font-size-4xl);
    color: var(--brand-primary);
    margin-bottom: var(--space-3);
    text-align: center;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.content-section .subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-12);
    font-weight: 500;
}

.policy-content {
    background: var(--white);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    padding: var(--space-12);
    border: 1px solid var(--gray-200);
}

.policy-section {
    margin-bottom: var(--space-10);
    padding-bottom: var(--space-8);
    border-bottom: 1px solid var(--gray-100);
}

.policy-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.policy-section h2 {
    font-size: var(--font-size-2xl);
    color: var(--brand-primary);
    margin-bottom: var(--space-6);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.policy-section h3 {
    font-size: var(--font-size-lg);
    color: var(--gray-800);
    margin-bottom: var(--space-4);
    margin-top: var(--space-6);
    font-weight: 600;
}

.policy-section p {
    color: var(--gray-700);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-4);
    font-size: var(--font-size-base);
}

.policy-section p:last-child {
    margin-bottom: 0;
}

.policy-section ul {
    margin: var(--space-4) 0;
    padding-left: var(--space-6);
}

.policy-section li {
    color: var(--gray-700);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-3);
    font-size: var(--font-size-base);
}

.policy-section li:last-child {
    margin-bottom: 0;
}

.policy-section li strong {
    color: var(--gray-900);
    font-weight: 600;
}

.contact-info {
    background: var(--gray-50);
    padding: var(--space-6);
    border-radius: var(--radius-xl);
    border: 1px solid var(--gray-200);
    margin-top: var(--space-4);
}

.contact-info p {
    margin-bottom: var(--space-3);
    color: var(--gray-800);
}

.contact-info p:last-child {
    margin-bottom: 0;
}

.contact-info strong {
    color: var(--brand-primary);
    font-weight: 600;
}

/* Responsive Design for Policy Pages */
@media (max-width: 768px) {
    .main {
        padding: var(--space-8) 0;
    }
    
    .content-section {
        padding: 0 var(--space-4);
    }
    
    .content-section h1 {
        font-size: var(--font-size-3xl);
    }
    
    .policy-content {
        padding: var(--space-8);
        border-radius: var(--radius-xl);
    }
    
    .policy-section {
        margin-bottom: var(--space-8);
        padding-bottom: var(--space-6);
    }
    
    .policy-section h2 {
        font-size: var(--font-size-xl);
    }
    
    .policy-section ul {
        padding-left: var(--space-4);
    }
}

/* Responsive Design */
@media (max-width: 1024px) {
    .generator-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 0;
    }
    
    .story-inputs {
        grid-column: 1;
        grid-row: 1;
    }
    
    /* Fixed bottom button group on tablet and mobile */
    .button-group {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: white;
        border-top: 2px solid var(--brand-primary);
        box-shadow: 0 -8px 16px rgba(0, 0, 0, 0.15);
        padding: var(--space-3) var(--space-4);
        gap: var(--space-3);
        z-index: 40;
        grid-column: 1;
        grid-row: 2;
        margin-top: 0;
        display: flex;
        flex-direction: row;
        justify-content: center;
    }
    
    /* Make buttons take up equal space side by side */
    .button-group .btn {
        flex: 1;
        padding: var(--space-3) var(--space-4);
        font-size: var(--font-size-sm);
        text-align: center;
    }

    .outline-btn {
        border-color: var(--brand-primary);
        color: var(--brand-primary);
    }
    
    /* Add bottom padding to story generator content to account for fixed button group */
    .generator-content {
        padding-bottom: 80px; /* Space for fixed button group */
    }
    
    .story-output {
        grid-column: 1;
        grid-row: 3;
        margin-block: 0 var(--space-4);
    }

    .story-modal-content {
        border-radius: 0;
        height: 100%;
        width: 100%;
    }

    .story-modal-header {
        border-radius: 0;
    }

    .story-modal-content .loading-overlay {
        border-radius: 0;
    }
}

@media (max-width: 768px) {
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-8);
    }
    
    /* Reverse hero content order on mobile - image first, then text */
    .hero-content {
        display: flex;
        flex-direction: column-reverse;
    }
    
    /* Make all sections show image above text on mobile */
    .section-content {
        display: flex !important;
        flex-direction: column;
    }
    
    /* Ensure section images come first */
    .section-image {
        order: 1;
        margin-bottom: var(--space-4);
    }

    .section-image > img {
        width: 100%;
        max-width: 150px;
    }

    /* Constrain image sizes to prevent overflow */
    .section-image img, .section-image svg, .devices-svg, .backpack-svg, .phone-svg, .books-svg {
        max-width: 100%;
        width: auto;
        height: auto;
        max-height: 300px;
    }

    .character-bubbles {
        max-width: 100%;
        height: auto;
        max-height: 250px;
    }

    .mascot-container {
        max-width: 100%;
        height: auto;
        max-height: 300px;
    }
    
    .section-text {
        order: 2;
        text-align: center;
    }
    .section-text p {
        text-align: center;
    }

    .section.reverse .section-content {
        direction: ltr;
        display: flex !important;
        flex-direction: column;
    }
    
    .section.reverse .section-image {
        order: 1;
    }
    
    .section.reverse .section-text {
        order: 2;
    }
    
    .hero-title {
        font-size: var(--font-size-4xl);
    }
    
    .section-text h2, .widget-title {
        font-size: var(--font-size-3xl);
    }
    
    .nav {
        display: none;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
    
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: var(--space-6);
    }
    
    .hero {
        padding: var(--space-12) 0 var(--space-8);
    }
    
    .section {
        padding: var(--space-12) 0;
    }
    
    .shorty-chat {
        flex-direction: column;
        gap: var(--space-3);
        text-align: center;
        margin-bottom: 0;
    }
    
    .shorty-avatar {
        width: 60px;
    }
    
    .chat-bubble {
        max-width: 100%;
        margin: 0 var(--space-3);
        padding: var(--space-4) var(--space-5);
    }
    
    .chat-bubble::before,
    .chat-bubble::after {
        display: none;
    }
    
    /* Story generator mobile optimizations */
    .generator-content {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        gap: 0;
        min-height: auto;
    }
    
    .story-inputs {
        grid-row: 1;
    }
    
    .story-output {
        grid-row: 3;
        margin-block: var(--space-4);
    }
    
    .input-group {
        margin-bottom: var(--space-2);
        gap: var(--space-3);
    }
    
    .input-label {
        font-size: var(--font-size-sm);
    }
    
    .character-group, .setting-group, .situation-group, .tone-group {
        padding: var(--space-2);
    }
    
    .theme-group, .challenge-group, .words-group, .reading-group {
        padding: var(--space-2);
    }
    
    .optional-section {
        margin-top: var(--space-3);
        padding: var(--space-2);
    }
    
    .pill-btn {
        padding: var(--space-1) var(--space-2);
        font-size: var(--font-size-xs);
        gap: var(--space-1);
    }
    
    .optional-inputs, .advanced-inputs {
        padding: var(--space-2);
    }
    
    .story-content {
        min-height: 300px;
        max-height: 520px;
        padding: var(--space-4);
    }
    
    /* Widget container mobile improvements */
    .widget-container {
        padding: var(--space-4) 0;
    }
    
    .widget-content {
        margin: 0;
    }
    
    .widget-body {
        padding: 0;
    }
    
    /* Header mobile improvements */
    .header {
        padding: var(--space-4) 0;
    }
    
    .logo h1 {
        font-size: var(--font-size-xl);
    }
    
    .logo-icon {
        width: 1.75rem;
        height: 1.75rem;
    }

    .widget-container::before {
        background-image: url('/assets/img/bgs/book-stack.webp');
        background-position: bottom;
        opacity: 0.15;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-3);
    }
    
    .button-group {
        padding: var(--space-3);
        gap: var(--space-2);
    }
    
    .hero-title {
        font-size: var(--font-size-3xl);
    }
    
    .section-text h2, .widget-title {
        font-size: var(--font-size-2xl);
    }
    
    /* Extra tight spacing for small screens */
    .input-group {
        margin-bottom: var(--space-1);
        gap: var(--space-2);
    }
    
    .input-label {
        font-size: var(--font-size-xs);
    }
    
    .character-group, .setting-group, .situation-group, .tone-group {
        padding: var(--space-2);
    }
    
    .optional-inputs, .advanced-inputs {
        padding: var(--space-2);
    }
    
    .story-content {
        padding: var(--space-3);
        min-height: 250px;
        max-height: 400px;
    }
    
    .chat-bubble {
        margin: 0 var(--space-2);
        padding: var(--space-3) var(--space-4);
    }
}

/* Audio Player Styles */
.audio-player-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(4px);
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--gray-200);
    border-radius: 0 0 12px 12px;
    z-index: 20;
    transition: all var(--transition-normal);
}

.player-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--space-2);
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-600);
    transition: all var(--transition-fast);
}

.player-btn:hover {
    background: var(--gray-200);
    color: var(--brand-primary);
}

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

.play-icon { display: block; }
.pause-icon { display: none; }
.player-btn.playing .play-icon { display: none; }
.player-btn.playing .pause-icon { display: block; }

.seek-slider {
    flex-grow: 1;
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: var(--gray-300);
    border-radius: var(--radius-full);
    outline: none;
    transition: opacity 0.2s;
}

.seek-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 16px;
    height: 16px;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.seek-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
    background: var(--brand-primary);
    border-radius: var(--radius-full);
    cursor: pointer;
}

.audio-time {
    font-size: var(--font-size-xs);
    color: var(--gray-600);
    font-weight: 500;
    min-width: 70px;
    text-align: center;
}

.story-content.playing .audio-player-container {
    opacity: 1;
    visibility: visible;
}

/* Make sure modal player is correctly styled */
.story-modal-content .audio-player-container {
    position: relative;
    border-radius: 0 0 var(--radius-2xl) var(--radius-2xl);
}

/* Modal-specific loading overlay */
.story-modal-content .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    z-index: 30;
    border-radius: var(--radius-2xl);
}

.story-content .story-character {
    color: #e53e3e !important;
    font-weight: bold !important;
}

/* Blog Post Styles */
.blog-post h1 {
    font-size: var(--font-size-4xl);
    margin-bottom: var(--space-3);
    text-align: left;
}

.blog-post p {
    margin-bottom: var(--space-4);
}

.blog-post .subtitle {
    text-align: left;
    margin-bottom: var(--space-8);
}

.blog-list {
    margin-top: var(--space-12);
}

.blog-list-item {
    background: var(--white);
    padding: var(--space-8);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-lg);
    margin-bottom: var(--space-8);
    border: 1px solid var(--gray-200);
}

.blog-list-item h2 {
    font-size: var(--font-size-3xl);
    margin-bottom: var(--space-4);
}

.blog-list-item h2 a {
    text-decoration: none;
    color: var(--brand-primary);
    transition: color var(--transition-fast);
}

.blog-list-item h2 a:hover {
    color: var(--brand-primary-hover);
}

.blog-excerpt {
    color: var(--gray-600);
    line-height: var(--leading-relaxed);
    margin-bottom: var(--space-6);
}

.read-more {
    color: var(--brand-primary);
    font-weight: 600;
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

.story-modal-body .story-character {
    color: var(--character-primary);
    font-weight: 600;
}
/* ==========================================================================
   Accounts: header menu, sign-in dialog and the saved story library
   ========================================================================== */

.account-nav {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}


.account-btn {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    background: var(--white);
    border: 2px solid var(--brand-primary);
    color: var(--brand-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition-fast);
}

.account-btn:hover {
    background: var(--brand-primary);
    color: var(--white);
}

.account-btn-quiet {
    border-color: var(--gray-300);
    color: var(--gray-600);
}

.account-btn-quiet:hover {
    background: var(--gray-200);
    color: var(--gray-800);
}

/* Account avatar and its dropdown */
.account-menu {
    position: relative;
    display: flex;
    align-items: center;
}

.account-avatar {
    width: 38px;
    height: 38px;
    border: none;
    border-radius: var(--radius-full);
    color: var(--white);
    font-family: var(--font-family) !important;
    font-size: var(--font-size-base);
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-sm);
}

.account-avatar:hover {
    filter: brightness(1.1);
    box-shadow: var(--shadow-md);
}

.account-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    min-width: 200px;
    padding: var(--space-2);
    background: var(--white);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    /* Never transition "all" here: visibility would be transitioned too, and
       the children inherit it, so they arrive after the panel does. */
    transition: opacity var(--transition-fast), transform var(--transition-fast);
    z-index: 1050;
}

.account-menu.open .account-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.account-dropdown-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: var(--space-2);
}

.account-dropdown-name strong {
    font-size: var(--font-size-sm);
    color: var(--gray-800);
}

.account-dropdown-name span {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-dropdown-item {
    display: block;
    width: 100%;
    text-decoration: none;
    padding: var(--space-3) var(--space-4);
    background: none;
    border: none;
    border-radius: var(--radius-lg);
    text-align: left;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    transition: background-color var(--transition-fast), color var(--transition-fast);
}

.account-dropdown-item:hover {
    background: var(--brand-primary-light);
    color: var(--brand-primary);
}

/* Settings */
.settings-saved {
    color: var(--setting-primary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-align: center;
    margin-bottom: var(--space-2);
}

.settings-danger {
    margin-top: var(--space-8);
    padding-top: var(--space-5);
    border-top: 1px solid var(--gray-200);
    text-align: center;
}

.settings-danger h4 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-2);
}

.settings-danger p {
    font-size: var(--font-size-sm);
    color: var(--gray-500);
    margin-bottom: var(--space-4);
}

.settings-danger .btn {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
    font-size: var(--font-size-sm);
}

/* Shared dialog shell for sign-in and the story library */
.app-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1100;
    padding: var(--space-4);
    overflow-y: auto;
}

.app-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-modal-content {
    background: var(--white);
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-xl);
    padding: var(--space-8);
    position: relative;
    animation: modalSlideIn 0.3s ease-out;
}

.app-modal-wide {
    max-width: 640px;
}

.app-modal-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-4);
    background: none;
    border: none;
    font-size: var(--font-size-3xl);
    line-height: 1;
    color: var(--gray-400);
    cursor: pointer;
    transition: color var(--transition-fast);
}

.app-modal-close:hover {
    color: var(--gray-700);
}

.app-modal-avatar {
    width: 64px;
    height: 64px;
    display: block;
    margin: 0 auto var(--space-3);
}

.app-modal-title {
    font-size: var(--font-size-2xl);
    text-align: center;
    margin-bottom: var(--space-2);
}

.app-modal-subtitle {
    text-align: center;
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    margin-bottom: var(--space-6);
}

/* Password field with its show/hide eye */
.password-field {
    position: relative;
    display: flex;
    align-items: center;
}

.password-field .story-input {
    width: 100%;
    padding-right: var(--space-12);
}

.password-toggle {
    position: absolute;
    right: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2);
    background: none;
    border: none;
    border-radius: var(--radius-full);
    color: var(--gray-400);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.password-toggle:hover {
    color: var(--brand-primary);
    background: var(--gray-100);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
    display: block;
}

.password-toggle .eye-off,
.password-toggle.revealed .eye-on {
    display: none;
}

.password-toggle.revealed .eye-off {
    display: block;
}

/* Continue with Google */
.google-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--white);
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-full);
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-700);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.google-btn:hover:not(:disabled) {
    border-color: var(--gray-400);
    background: var(--gray-50);
}

.google-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: var(--space-5) 0;
    color: var(--gray-400);
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.auth-divider::before,
.auth-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--gray-200);
}

/* [hidden] has to beat the flex layout below it. */
.google-btn[hidden],
.auth-divider[hidden],
.auth-form .form-group[hidden],
.auth-error[hidden],
.library-status[hidden] {
    display: none;
}

.auth-form .form-group {
    margin-bottom: var(--space-4);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.auth-form .input-label {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--gray-600);
}

.auth-form .story-input {
    width: 100%;
}

.auth-form .primary-btn {
    width: 100%;
    margin-top: var(--space-2);
}

.auth-error {
    background: var(--character-light);
    color: #9b1c1c;
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-align: center;
    margin-bottom: var(--space-2);
}

.auth-switch {
    text-align: center;
    margin-top: var(--space-5);
}

.auth-switch button {
    background: none;
    border: none;
    color: var(--brand-primary);
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}

/* Saved story library */
.library-actions {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-5);
}

.library-actions .btn {
    width: 100%;
}

.app-modal-narrow {
    max-width: 400px;
    text-align: center;
}

.confirm-actions {
    display: flex;
    gap: var(--space-3);
    margin-top: var(--space-6);
}

/* .btn carries 3rem of side padding, which two buttons cannot afford in a
   narrow dialog: trim it and let them shrink. */
.confirm-actions .btn {
    flex: 1;
    min-width: 0;
    padding-left: var(--space-4);
    padding-right: var(--space-4);
    white-space: nowrap;
}

.danger-btn,
.danger-btn:hover {
    background: var(--character-primary);
    border-color: var(--character-primary);
    color: var(--white);
}

.danger-btn:hover {
    filter: brightness(0.94);
}

.library-status {
    text-align: center;
    color: var(--gray-500);
    font-size: var(--font-size-sm);
    padding: var(--space-4) 0;
}

.library-list {
    list-style: none;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.library-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-4);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-xl);
    background: var(--gray-50);
}

.library-item-details h4 {
    font-size: var(--font-size-base);
    margin-bottom: var(--space-1);
}

.library-item-meta {
    font-size: var(--font-size-xs);
    color: var(--gray-500);
}

.library-item-actions {
    display: flex;
    gap: var(--space-2);
    flex-shrink: 0;
}

/* The library sits on a light panel, so the story action buttons invert */
.library-btn {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.library-btn:hover:not(:disabled) {
    background: var(--brand-primary);
    color: var(--white);
}

.library-btn-danger {
    border-color: var(--character-primary);
    color: var(--character-primary);
}

.library-btn-danger:hover:not(:disabled) {
    background: var(--character-primary);
    color: var(--white);
}

/* On phones the account controls move into the mobile menu popover. */
.account-nav-mobile {
    display: none;
}

@media (max-width: 768px) {
    .header .container > .account-nav {
        display: none;
    }

    .account-nav-mobile {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-2);
        margin-top: var(--space-2);
        padding-top: var(--space-3);
        border-top: 1px solid var(--gray-200);
    }

    .account-nav-mobile .account-menu {
        flex-direction: column;
        align-items: stretch;
    }

    .account-nav-mobile .account-avatar {
        display: none;
    }

    .account-nav-mobile .account-dropdown {
        position: static;
        opacity: 1;
        visibility: visible;
        transform: none;
        border: none;
        box-shadow: none;
        padding: 0;
        min-width: 0;
    }

    .app-modal-content {
        padding: var(--space-6);
    }

    .library-item {
        flex-direction: column;
        align-items: flex-start;
    }
}
