:root {
    --bg: #0B0918;
    --bg-raise: rgba(255, 255, 255, 0.06);
    --bg-raise-2: rgba(255, 255, 255, 0.02);
    --text: #EDEAF7;
    /* Lifted for WCAG AA on the night background — muted ≈ 8:1, faint ≈ 5:1 */
    --text-muted: #B3ABD1;
    --text-faint: #8B82AC;
    --purple: #8B5CF6;
    --purple-deep: #6D28D9;
    --lavender: #C4B5FD;
    --pink: #EC4899;
    --amber: #FBBF24;
    --line: rgba(139, 92, 246, 0.22);
    --line-strong: rgba(139, 92, 246, 0.35);
}

* { box-sizing: border-box; }

/* Keyboard users always see where they are — amber ring on anything focusable */
:focus-visible {
    outline: 2px solid var(--amber);
    outline-offset: 2px;
    border-radius: 6px;
}

body {
    font-family: 'Karla', sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    /* Starry-night depth: a faint midnight-blue glow low on the horizon,
       like lying in bed looking up — fixed so the sky doesn't scroll. */
    background-image:
        radial-gradient(ellipse 90% 55% at 50% 115%, rgba(30, 27, 75, 0.5), transparent 65%),
        radial-gradient(ellipse 60% 40% at 15% -8%, rgba(76, 29, 149, 0.28), transparent 70%),
        linear-gradient(180deg, #0B0918 0%, #0D0A20 50%, #0B0918 100%);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.65;
    font-size: 17px;
    overflow-x: hidden;
}

h1, h2, h3, legend {
    font-family: 'Young Serif', serif;
    color: #fff;
    font-weight: 400;
}

a { color: var(--lavender); text-decoration: none; }
a:hover { color: #E9E4FF; }

::selection { background: var(--purple); color: #fff; }

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

@keyframes floaty-lg {
    0%, 100% { transform: translateY(0) rotate(var(--tilt, 0deg)); }
    50% { transform: translateY(-20px) rotate(var(--tilt, 0deg)); }
}

@keyframes twinkle {
    0%, 100% { opacity: 0.12; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.15); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Navigation ---------- */
header { background: transparent; }

.nav-container {
    position: sticky;
    top: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 14px 48px;
    background: rgba(11, 9, 24, 0.75);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(139, 92, 246, 0.18);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: 'Young Serif', serif;
    font-size: 22px;
    color: #fff;
    white-space: nowrap;
}

.brand:hover { color: #fff; }

.brand-mark {
    display: inline-flex;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    align-items: center;
    justify-content: center;
    font-size: 17px;
    box-shadow: 0 0 18px rgba(139, 92, 246, 0.55);
}

.nav-container nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 26px;
}

.nav-container nav ul li { position: relative; }

.nav-container nav ul li a {
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.nav-container nav ul li a:hover { color: #fff; }

.current-page { color: #fff !important; }

#auth-nav { display: flex; align-items: center; gap: 10px; }

#auth-nav .auth-handle {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

#auth-nav .auth-link {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: color 0.2s ease;
}

#auth-nav .auth-link:hover { color: #fff; }

#auth-nav .auth-google-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background-color: var(--bg-raise);
    border: 1px solid var(--line-strong);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

#auth-nav .auth-google-btn:hover { background-color: var(--line-strong); }

/* ---------- Account menu (avatar + handle, dropdown) ---------- */
.account-menu { position: relative; }

.account-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px;
    border-radius: 999px;
    background-color: var(--bg-raise);
    border: 1px solid var(--line-strong);
    color: var(--text);
    font: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.account-toggle:hover { background-color: var(--line-strong); }

.account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    border: 1px solid var(--line-strong);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.account-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 220px;
    background: #171130;
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    padding: 8px;
    z-index: 60;
    animation: fadeIn 0.15s;
}

.account-panel-header { padding: 10px 12px 8px; }

.account-panel-handle { font-weight: 700; color: #fff; font-size: 15px; }

.account-panel-email {
    color: var(--text-faint);
    font-size: 12px;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-divider { border: none; border-top: 1px solid var(--line); margin: 6px 4px; }

.account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    background: none;
    border: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    color: var(--text-muted);
    box-sizing: border-box;
}

.account-item-action {
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.account-item-action:hover { background-color: var(--bg-raise); color: #fff; }

.account-item-disabled { color: var(--text-faint); cursor: default; }

.account-soon-tag {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
    background: var(--bg-raise);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 2px 8px;
}

.account-item-danger {
    cursor: pointer;
    color: #F87171;
    transition: background-color 0.15s ease;
}

.account-item-danger:hover { background-color: rgba(248, 113, 113, 0.12); }

.nav-container select#nativeLanguage {
    width: auto;
    min-width: 130px;
    padding: 8px 34px 8px 14px;
    margin-bottom: 0;
    font-size: 14px;
    border-radius: 999px;
    background-color: var(--bg-raise);
    border: 1px solid var(--line-strong);
    color: var(--text);
}

.nav-container input#otherLanguage {
    width: 170px;
    padding: 7px 14px;
    margin: 8px 0 0 0;
    font-size: 14px;
    border-radius: 999px;
    position: absolute;
    right: 0;
    top: 100%;
    z-index: 20;
}

.title-container {
    display: flex;
    justify-content: center;
    padding: 0;
}

.hidden { display: none; }

.translation-toggle {
    display: inline-block;
    width: 38px;
    height: 38px;
    line-height: 38px;
    text-align: center;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--pink));
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.25s, box-shadow 0.25s;
}

.translation-toggle:hover { opacity: 0.85; }

.translation-toggle.active {
    opacity: 1;
    box-shadow: 0 0 14px rgba(139, 92, 246, 0.7);
}

/* ---------- Hero ---------- */
.hero {
    position: relative;
    padding: 84px 24px 96px;
    text-align: center;
    background:
        radial-gradient(ellipse 70% 55% at 50% -5%, rgba(109, 40, 217, 0.5), transparent 70%),
        radial-gradient(ellipse 40% 35% at 82% 25%, rgba(236, 72, 153, 0.14), transparent 70%);
}

.hero-inner {
    position: relative;
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    z-index: 2;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 999px;
    border: 1px solid rgba(251, 191, 36, 0.4);
    background: rgba(251, 191, 36, 0.08);
    color: var(--amber);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero h1.hero-title {
    margin: 0;
    font-size: 62px;
    line-height: 1.12;
    text-wrap: balance;
}

.gradient-text {
    background: linear-gradient(100deg, var(--lavender), var(--pink) 70%, var(--amber));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-sub {
    margin: 0;
    max-width: 540px;
    font-size: 19px;
    line-height: 1.65;
    color: var(--text-muted);
    text-wrap: pretty;
}

/* Multilingual typewriter line (cycled by script.js into #intro-header) */
#intro-header {
    min-height: 34px;
    margin: 0;
    font-family: 'Young Serif', serif;
    font-size: 21px;
    font-weight: 400;
    color: var(--lavender);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.hero-cta {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 32px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    color: #fff !important;
    font-family: 'Karla', sans-serif;
    font-weight: 700;
    font-size: 17px;
    box-shadow: 0 10px 34px rgba(139, 92, 246, 0.45);
    transition: box-shadow 0.25s, transform 0.25s;
}

.btn-primary:hover {
    box-shadow: 0 14px 44px rgba(139, 92, 246, 0.7);
    transform: translateY(-2px);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: 999px;
    border: 1px solid rgba(196, 181, 253, 0.35);
    background: transparent;
    cursor: pointer;
    color: var(--lavender);
    font-family: 'Karla', sans-serif;
    font-weight: 700;
    font-size: 16px;
    transition: background 0.25s, color 0.25s;
}

.btn-ghost:hover {
    background: rgba(139, 92, 246, 0.12);
    color: #fff;
}

.hero-float {
    position: absolute;
    width: 185px;
    border-radius: 14px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.1);
    animation: floaty-lg 6s ease-in-out infinite;
    z-index: 1;
}

.hero-float.left { --tilt: -7deg; left: 3%; top: 18%; }
.hero-float.right { --tilt: 6deg; right: 3%; top: 26%; animation-duration: 7s; animation-delay: 1s; }
.hero-float.bottom-left { --tilt: 5deg; left: 10%; top: 68%; width: 150px; animation-duration: 8s; animation-delay: 0.5s; }
.hero-float.bottom-right { --tilt: -5deg; right: 10%; top: 70%; width: 150px; animation-duration: 6.5s; animation-delay: 1.6s; }
.hero-float.mid-left { --tilt: 4deg; left: -24px; top: 44%; width: 120px; opacity: 0.55; animation-duration: 9s; animation-delay: 2.2s; }
.hero-float.mid-right { --tilt: -4deg; right: -24px; top: 48%; width: 120px; opacity: 0.55; animation-duration: 8.5s; animation-delay: 0.8s; }

.star-field {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.star-field .star {
    position: absolute;
    transition: transform 0.4s ease-out;
    will-change: transform;
}

.star-field .star i {
    font-style: normal;
    display: inline-block;
    color: var(--lavender);
    text-shadow: 0 0 6px currentColor, 0 0 16px currentColor;
    animation-name: twinkle, floaty;
    animation-iteration-count: infinite, infinite;
    animation-timing-function: ease-in-out, ease-in-out;
}

.star-field .star.gold i { color: var(--amber); }

/* On smaller screens keep two covers, faded behind the hero text */
/* On smaller screens the covers never disappear — they all slip behind the
   hero text with a much heavier fade, spread along the edges. */
@media (max-width: 1240px) {
    .hero-float {
        z-index: 0;
        opacity: 0.14;
        width: 120px;
    }

    .hero-float.left  { left: -30px; top: 10%; opacity: 0.3; width: 150px; }
    .hero-float.right { right: -30px; top: 55%; opacity: 0.3; width: 150px; }
    .hero-float.mid-left     { left: -40px; top: 38%; opacity: 0.14; }
    .hero-float.mid-right    { right: -40px; top: 80%; opacity: 0.14; }
    .hero-float.bottom-left  { left: 22%; top: 82%; }
    .hero-float.bottom-right { right: 55%; top: 3%; left: auto; }
}

/* ---------- Page header (Library / Create Story) ---------- */
.page-header {
    position: relative;
    overflow: hidden;
    /* Kept shallow so the actual content starts within the first screen */
    padding: 38px 24px 28px;
    text-align: center;
    background: radial-gradient(ellipse 60% 70% at 50% -10%, rgba(109, 40, 217, 0.45), transparent 70%);
}

.page-header-inner { position: relative; z-index: 2; }

.page-header h1 {
    margin: 0 0 10px;
    font-size: 42px;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 17px;
}

.header-float {
    position: absolute;
    width: 150px;
    border-radius: 12px;
    opacity: 0.45;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
    animation: floaty-lg 7s ease-in-out infinite;
    z-index: 1;
}

.header-float.left { --tilt: -6deg; left: 6%; top: 26%; }
.header-float.right { --tilt: 5deg; right: 6%; top: 34%; animation-duration: 8s; animation-delay: 1.2s; }

@media (max-width: 900px) {
    .header-float { width: 110px; opacity: 0.25; }
    .header-float.left { left: -24px; }
    .header-float.right { right: -24px; }
}

/* ---------- Feature cards ---------- */
.feature-grid {
    max-width: 1080px;
    margin: -34px auto 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    position: relative;
    z-index: 2;
}

.feature-card {
    border-radius: 20px;
    padding: 28px 26px;
    background: linear-gradient(160deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid var(--line);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    gap: 14px;
    transition: border-color 0.25s, transform 0.25s, box-shadow 0.25s;
}

.feature-card:hover {
    border-color: rgba(196, 181, 253, 0.5);
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.feature-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    background: rgba(139, 92, 246, 0.18);
    border: 1px solid var(--line-strong);
}

.feature-card h3 { margin: 0; font-size: 19px; }

.feature-card p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: var(--text-muted);
}

/* ---------- Main / reader layout ---------- */
main {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 20px;
}

.reader-layout {
    max-width: 1080px;
    width: 100%;
    margin: 80px auto 0;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
    align-items: start;
}

#story-container {
    font-size: 18px;
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    color: #D8D2EC;
    border: 1px solid rgba(139, 92, 246, 0.25);
    padding: 0;
    border-radius: 24px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    line-height: 1.8;
    width: 100%;
}

#story-title {
    margin: 0;
    text-align: left;
    color: #fff;
    font-size: 26px;
    padding: 22px 30px;
    border-bottom: 1px solid rgba(139, 92, 246, 0.2);
    background: rgba(139, 92, 246, 0.08);
}

#story-content {
    font-size: 18px;
    line-height: 1.8;
    color: #D8D2EC;
    margin: 0;
    display: block;
}

#story-container #story-content { padding: 26px 30px; }

#story-content .highlight {
    background: rgba(139, 92, 246, 0.25);
    border-radius: 6px;
}

/* Current word during cached-narration playback (see storyPage.js) — a
   warm amber "follow the bouncing ball", readable on the night background. */
#story-content .word-active {
    color: var(--amber);
    background: rgba(251, 191, 36, 0.14);
    border-radius: 4px;
    box-shadow: inset 0 -2px 0 rgba(251, 191, 36, 0.55);
    transition: background-color 0.1s ease, color 0.1s ease;
}

.reader-hint {
    margin: 0;
    padding: 0 30px 18px;
    font-size: 13px;
    color: var(--text-faint);
}

.reader-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 26px;
    border-top: 1px solid rgba(139, 92, 246, 0.2);
    background: rgba(11, 9, 24, 0.5);
    flex-wrap: wrap;
}

.reader-controls label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

.reader-controls select {
    width: auto;
    margin-bottom: 0;
    padding: 9px 34px 9px 12px;
    border-radius: 10px;
}

.reader-controls .button-group {
    display: flex;
    gap: 10px;
    margin-left: auto;
    flex-wrap: wrap;
}

/* ---------- Aside (recommendations) ---------- */
aside {
    border-radius: 24px;
    padding: 26px;
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid rgba(139, 92, 246, 0.25);
    display: flex;
    flex-direction: column;
    gap: 14px;
    width: 100%;
    margin-top: 0;
}

aside h3 { margin: 0; font-size: 20px; }

aside ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rec-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
    margin: -4px -10px;
    border-radius: 14px;
    transition: background 0.2s;
}

.rec-link:hover { background: rgba(139, 92, 246, 0.12); }

.rec-link img {
    width: 64px;
    height: 46px;
    object-fit: cover;
    border-radius: 9px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.rec-link .rec-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.rec-link .rec-title {
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
}

.rec-link .rec-meta {
    color: var(--text-faint);
    font-size: 12px;
}

.browse-all {
    margin-top: 6px;
    font-weight: 700;
    font-size: 14px;
}

/* ---------- Buttons (default) ---------- */
button {
    font-family: 'Karla', sans-serif;
    padding: 11px 22px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    color: white;
    border: none;
    border-radius: 999px;
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
    transition: box-shadow 0.25s, transform 0.25s;
}

button:hover {
    box-shadow: 0 8px 26px rgba(139, 92, 246, 0.65);
    transform: translateY(-1px);
}

button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button.coming-soon { position: relative; }

button.ghost {
    background: transparent;
    border: 1px solid rgba(196, 181, 253, 0.4);
    color: var(--lavender);
    box-shadow: none;
}

button.ghost:hover {
    background: rgba(139, 92, 246, 0.15);
    color: #fff;
    box-shadow: none;
}

audio {
    margin-top: 20px;
    width: 100%;
    max-width: 400px;
}

/* ---------- Inputs ---------- */
select, input, textarea {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 12px;
    background-color: rgba(11, 9, 24, 0.6);
    color: var(--text);
    font-family: 'Karla', sans-serif;
    font-size: 16px;
    margin-bottom: 10px;
}

input::placeholder, textarea::placeholder { color: var(--text-faint); }

select {
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%2724%27 height=%2724%27 viewBox=%270 0 24 24%27 fill=%27none%27 stroke=%27%23C4B5FD%27 stroke-width=%272%27 stroke-linecap=%27round%27 stroke-linejoin=%27round%27%3E%3Cpolyline points=%276 9 12 15 18 9%27%3E%3C/polyline%3E%3C/svg%3E');
    background-repeat: no-repeat;
    background-position: right 12px top 50%;
    background-size: 12px 12px;
}

select option { background: #171130; color: var(--text); }

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.25);
}

/* ---------- Forms (Create Story) ---------- */
.create-main {
    max-width: 640px;
    width: 100%;
    margin: 0 auto;
    padding: 0 24px 90px;
    display: flex;
    flex-direction: column;
    gap: 26px;
    align-items: stretch;
}

.option-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.25);
    align-self: center;
}

.option-tabs button {
    box-shadow: none;
    background: transparent;
    color: var(--text-muted);
}

.option-tabs button:hover,
.option-tabs button.selected {
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    color: #fff;
    transform: none;
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.4);
}

.story-form {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    text-align: left;
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 24px;
    padding: 34px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.form-row { margin-bottom: 18px; }

.form-row label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    color: var(--lavender);
    font-size: 14px;
    letter-spacing: 0.04em;
}

.form-row input,
.form-row select,
.form-row textarea {
    box-sizing: border-box;
    margin-bottom: 0;
}

.form-row textarea { line-height: 1.6; resize: vertical; }

fieldset.extras {
    border: 1px dashed rgba(139, 92, 246, 0.4);
    border-radius: 14px;
    margin: 0 0 20px 0;
    padding: 16px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px 24px;
}

fieldset.extras legend {
    color: var(--amber);
    font-family: 'Karla', sans-serif;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 10px;
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    white-space: nowrap;
    color: var(--text-muted);
    font-weight: 600;
}

.checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--purple);
}

.create-section {
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.create-section h2 {
    margin: 0;
    font-size: 26px;
}

.create-section .option-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Generated story card (create-story page) */
#c-story-container { width: 100%; max-width: 640px; }

.generated-story {
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid rgba(139, 92, 246, 0.25);
    border-radius: 24px;
    padding: 28px 30px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    animation: fadeIn 0.5s ease;
}

.generated-story h2 { margin-top: 0; }

.generated-image {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

#button-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    flex-wrap: wrap;
}

#button-container label {
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
}

#button-container select {
    width: auto;
    margin-bottom: 0;
    padding: 9px 34px 9px 12px;
    border-radius: 10px;
}

/* ---------- Story page ---------- */
.story-page-main {
    max-width: 800px;
    width: 100%;
    margin: 36px auto 0;
    padding: 0 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.back-link {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-muted);
    align-self: flex-start;
}

.back-link:hover { color: #fff; }

/* Non-destructive cover frame: the full artwork is letterboxed (contain,
   never cropped) inside a 16:9 frame; the empty sides are filled by a
   blurred, dimmed copy of the same image. */
.cover-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: rgba(139, 92, 246, 0.12);
}

.cover-frame-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(26px) brightness(0.7) saturate(1.1);
    transform: scale(1.2);
}

.cover-frame-fg,
#story-cover {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

#story-cover-wrap.hidden { display: none; }

/* Save button, signed out: grayed with a lock hint — still clickable, it
   opens the log-in prompt rather than doing nothing. */
button.ghost.save-locked {
    opacity: 0.65;
    border-color: rgba(196, 181, 253, 0.25);
    color: var(--text-faint);
}

button.ghost.save-locked:hover {
    opacity: 0.85;
    color: var(--lavender);
}

/* Preview block inside the "log in to save" SweetAlert2 modal — same
   blurred-copy language as .cover-frame-bg, standing in for the story
   waiting behind the login wall. */
.save-login-preview {
    position: relative;
    height: 72px;
    border-radius: 12px;
    overflow: hidden;
    background: linear-gradient(160deg, var(--purple), var(--purple-deep));
    margin-bottom: 14px;
}

.save-login-blur {
    position: absolute;
    inset: 0;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    background: rgba(11, 9, 24, 0.35);
}

.story-card-link { cursor: pointer; }

/* ---------- Library filters ---------- */
.filter-bar {
    max-width: 1140px;
    width: 100%;
    margin: 0 auto 8px;
    padding: 0 24px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.filter-bar.hidden { display: none; }

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-label {
    width: 52px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.chip {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-muted);
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s, background 0.2s;
}

.chip:hover {
    border-color: rgba(196, 181, 253, 0.5);
    color: #fff;
    transform: none;
    box-shadow: none;
}

.chip.active {
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
}

.library-empty {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-muted);
    padding: 60px 0;
    font-size: 16px;
}

@media (max-width: 768px) {
    .filter-bar { padding: 0 12px; }
    .filter-label { width: 100%; }
}

/* ---------- Library cards ---------- */
#story-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 26px;
    align-items: stretch;
    width: 100%;
    max-width: 1140px;
    margin: 10px auto 60px;
    padding: 0 24px;
    box-sizing: border-box;
}

.story-card {
    display: flex;
    flex-direction: column;
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid var(--line);
    border-radius: 20px;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.story-card:hover {
    transform: translateY(-5px);
    border-color: rgba(196, 181, 253, 0.5);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.story-card .cover-frame { flex-shrink: 0; }

.cover-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Young Serif', serif;
    font-size: 64px;
    color: #fff;
    background: linear-gradient(135deg, var(--purple-deep), var(--purple) 60%, var(--pink));
}

.story-card .card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 18px 22px 22px;
}

/* Clamped so every card keeps the same rhythm: titles two lines max,
   excerpts three — footers stay aligned across the whole grid. */
.story-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.5em;
    line-height: 1.25;
}

.story-card p {
    margin: 0 0 16px;
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.story-card button { align-self: flex-start; font-size: 14px; padding: 10px 20px; }

/* ---------- Loading states ---------- */
.loading-overlay {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 40px 20px;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 5px solid rgba(139, 92, 246, 0.2);
    border-top-color: var(--purple);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.loading-status {
    font-size: 19px;
    color: var(--text-muted);
}

.loading-hint {
    font-size: 13px;
    color: var(--text-faint);
    margin: 0;
}

.popup .def-body h4 {
    margin: 14px 0 4px;
    font-family: 'Karla', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--lavender);
}

/* ---------- Quick guide ---------- */
.key-guide {
    max-width: 1080px;
    width: 100%;
    margin: 70px auto 0;
    padding: 28px 30px;
    border-radius: 24px;
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid rgba(139, 92, 246, 0.25);
    box-sizing: border-box;
}

.key-guide h3 { margin: 0 0 18px; font-size: 20px; }

.key-guide ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px 28px;
}

.key-guide li {
    display: flex;
    align-items: baseline;
    gap: 12px;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-muted);
}

.key-chip {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 999px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid var(--line-strong);
    color: var(--lavender);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .key-guide { margin: 40px 20px 0; width: auto; }
    .key-guide ul { grid-template-columns: 1fr; }
}

/* ---------- Footer ---------- */
footer {
    margin-top: 90px;
    width: 100%;
    padding: 32px 48px;
    border-top: 1px solid rgba(139, 92, 246, 0.18);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    background: rgba(11, 9, 24, 0.6);
    color: var(--text-muted);
}

.footer-brand {
    font-family: 'Young Serif', serif;
    color: var(--text-muted);
}

.footer-links {
    display: flex;
    gap: 26px;
    align-items: center;
}

.footer-links a { color: var(--text-muted); font-size: 14px; }
.footer-links a:hover { color: #fff; }

footer button#aboutButton {
    background: transparent;
    border: none;
    box-shadow: none;
    color: var(--text-muted);
    font-size: 14px;
    padding: 0;
    font-weight: 400;
}

footer button#aboutButton:hover { color: #fff; transform: none; box-shadow: none; }

/* ---------- Modal ---------- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    padding-top: 60px;
}

.modal-content {
    background: #171130;
    color: var(--text);
    margin: 5% auto;
    padding: 24px;
    border: 1px solid var(--line-strong);
    width: 80%;
    max-width: 500px;
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.close-btn {
    color: var(--text-faint);
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close-btn:hover,
.close-btn:focus {
    color: #fff;
    text-decoration: none;
    cursor: pointer;
}

/* ---------- Tooltip & popup ---------- */
.translation-tooltip {
    position: absolute;
    background: #171130;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    padding: 7px 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    font-size: 14px;
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popup {
    position: fixed;
    top: 20%;
    left: 50%;
    transform: translate(-50%, -20%);
    max-height: 65vh;
    overflow-y: auto;
    background: #171130;
    color: var(--text);
    border: 1px solid var(--line-strong);
    border-radius: 16px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    z-index: 1000;
    max-width: 400px;
    width: 100%;
    padding: 24px;
    animation: fadeIn 0.3s;
}

.popup-content { position: relative; }

.popup .close-btn {
    position: absolute;
    top: 0;
    right: 0;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
}

.popup .phonetic {
    color: var(--lavender);
    font-style: italic;
    margin: 0 0 8px;
}

.popup .pronounce-btn {
    font-size: 14px;
    padding: 6px 14px;
    margin-bottom: 10px;
}

.popup .def-example {
    color: var(--text-muted);
    font-style: italic;
}

.mic-icon {
    width: 20px;
    height: 20px;
    cursor: pointer;
    margin-left: 10px;
}

/* ---------- SweetAlert2 dark theme ---------- */
.swal2-popup {
    background: #171130 !important;
    color: var(--text) !important;
    border: 1px solid var(--line-strong);
    border-radius: 16px !important;
    font-family: 'Karla', sans-serif;
}

.swal2-title { color: #fff !important; font-family: 'Young Serif', serif; font-weight: 400 !important; }
.swal2-html-container { color: var(--text-muted) !important; }

/* ---------- Language flags (typewriter intro) ---------- */
.us, .fr, .de, .es, .cn, .ar {
    display: inline-block;
    height: 22px;
    width: 30px;
    background-size: cover;
    background-position: center;
    vertical-align: middle;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.us { background-image: url('https://lh3.googleusercontent.com/-9BEUs3L9gVE/VhE40dddysI/AAAAAAAAkm0/YIls2k0h79w/s1600/united-states-flag-animation.gif'); }
.fr { background-image: url('https://lh3.googleusercontent.com/-Ym4VD8myqUM/VhEyjRvvWOI/AAAAAAAAjaw/zTPj6-jD9gw/s1600/france-flag-animation.gif'); }
.de { background-image: url('https://lh3.googleusercontent.com/-oPzOMIOg4mw/VhEyxoushSI/AAAAAAAAjdw/rxNagrCV45k/s1600/germany-flag-animation.gif'); }
.es { background-image: url('https://lh3.googleusercontent.com/-W24Nmtyp4sY/VhE3ut8oUdI/AAAAAAAAkZU/04Vp7Z0AEyE/s1600/spain-flag-animation.gif'); }
.cn { background-image: url('https://lh3.googleusercontent.com/-zFu9YOux_0o/VhExb8_8E8I/AAAAAAAAjLQ/Us7zTFAku-Q/s1600/china-flag-animation.gif'); }
.ar { background-image: url('https://lh3.googleusercontent.com/-0TIKrIkN5gY/VhE3K3hn3FI/AAAAAAAAkSU/31JBLnPNr_E/s1600/saudi-arabia-flag-animation.gif'); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    .feature-grid { grid-template-columns: 1fr; margin-top: 10px; }
    .reader-layout { grid-template-columns: 1fr; margin-top: 50px; }
    .hero h1.hero-title { font-size: 42px; }
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 12px;
        padding: 12px 16px;
    }

    .nav-container nav ul {
        justify-content: center;
        gap: 8px 16px;
    }

    .page-header h1 { font-size: 36px; }

    .hero { padding: 56px 20px 70px; }
    .hero h1.hero-title { font-size: 34px; }

    main { margin: 12px; }

    #story-container, aside, .story-form { max-width: 100%; }

    .story-form { padding: 20px; }

    #story-list {
        grid-template-columns: 1fr;
        padding: 0 12px;
    }

    #button-container { flex-wrap: wrap; }

    .reader-controls .button-group { margin-left: 0; }

    footer {
        flex-direction: column;
        padding: 24px 20px;
        text-align: center;
    }
}

/* ---------- Starry night: shooting stars + hero rocket ---------- */
.shooting-star {
    position: absolute;
    top: 14%;
    left: -8%;
    width: 130px;
    height: 2px;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(196, 181, 253, 0.9), #fff);
    transform: rotate(12deg);
    opacity: 0;
    pointer-events: none;
    animation: shoot 9s ease-in infinite;
    animation-delay: 3s;
    z-index: 1;
}

.shooting-star.delayed {
    top: 38%;
    animation-delay: 14s;
    animation-duration: 12s;
}

@keyframes shoot {
    0%, 91% { opacity: 0; transform: translate(0, 0) rotate(12deg); }
    93% { opacity: 1; }
    100% { opacity: 0; transform: translate(72vw, 15vw) rotate(12deg); }
}

.hero-rocket {
    position: absolute;
    width: 74px;
    right: 15%;
    top: 7%;
    z-index: 1;
    --tilt: -16deg;
    animation: floaty-lg 9s ease-in-out infinite;
    filter: drop-shadow(0 0 18px rgba(139, 92, 246, 0.45));
}

.hero-rocket .rocket-flame {
    animation: twinkle 0.7s ease-in-out infinite;
    transform-origin: 32px 78px;
}

@media (max-width: 1240px) {
    .hero-rocket { width: 50px; right: 5%; top: 4%; opacity: 0.85; }
}

@media (prefers-reduced-motion: reduce) {
    .shooting-star { display: none; }
    .hero-rocket,
    .hero-rocket .rocket-flame,
    .hero-float,
    .header-float,
    .star-field .star i { animation: none !important; }
}

/* ---------- Library search ---------- */
.library-search {
    max-width: 1140px;
    width: 100%;
    margin: 14px auto 6px;
    padding: 0 24px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.library-search.hidden { display: none; }

.library-search input {
    flex: 1;
    min-width: 200px;
    max-width: 420px;
    border-radius: 999px;
    padding: 12px 20px;
    margin-bottom: 0;
    background-color: rgba(23, 17, 48, 0.8);
}

.library-search select {
    width: auto;
    margin-bottom: 0;
    padding: 10px 34px 10px 16px;
    border-radius: 999px;
    font-size: 14px;
    background-color: rgba(23, 17, 48, 0.8);
}

.results-count {
    margin-left: auto;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-faint);
    white-space: nowrap;
}

/* ---------- Card engagement (owner tag, views, reactions, kebab) ---------- */
.story-card { position: relative; }

.card-kebab {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 3;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    background: rgba(11, 9, 24, 0.65);
    border: 1px solid var(--line-strong);
    color: var(--text);
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    box-shadow: none;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.card-kebab:hover {
    background: rgba(139, 92, 246, 0.45);
    transform: none;
    box-shadow: none;
}

.card-menu {
    position: absolute;
    top: 50px;
    right: 10px;
    z-index: 4;
    min-width: 190px;
    padding: 8px;
    background: #171130;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.15s;
}

.card-menu-item {
    width: 100%;
    padding: 9px 12px;
    border-radius: 10px;
    background: none;
    border: none;
    box-shadow: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.card-menu-item:hover {
    background-color: var(--bg-raise);
    color: #fff;
    transform: none;
    box-shadow: none;
}

.card-menu-divider { border: none; border-top: 1px solid var(--line); margin: 6px 4px; }

.card-menu-danger { color: #F87171; }
.card-menu-danger:hover { background-color: rgba(248, 113, 113, 0.12); color: #F87171; }

.visibility-chip {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    padding: 4px 10px;
    border-radius: 999px;
    background: rgba(11, 9, 24, 0.75);
    border: 1px solid var(--line-strong);
    color: var(--lavender);
    font-size: 12px;
    font-weight: 700;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0 0 10px;
}

.owner-tag {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
    min-width: 0;
}

.owner-tag-avatar {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--purple), var(--purple-deep));
    color: #fff;
    font-size: 11px;
    font-weight: 700;
}

.owner-tag-avatar.owner-tag-lisa {
    border-radius: 6px;
    box-shadow: 0 0 10px rgba(139, 92, 246, 0.55);
}

.view-count {
    flex-shrink: 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.reaction-bar { display: inline-flex; gap: 6px; }

.reaction-btn {
    padding: 6px 12px;
    border-radius: 999px;
    background: transparent;
    border: 1px solid var(--line);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 700;
    box-shadow: none;
}

.reaction-btn:hover {
    border-color: rgba(196, 181, 253, 0.5);
    color: #fff;
    transform: none;
    box-shadow: none;
}

.reaction-btn.active {
    background: rgba(251, 191, 36, 0.14);
    border-color: rgba(251, 191, 36, 0.55);
    color: var(--amber);
}

/* Views + reactions on the story reader page */
.engagement-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 30px 0;
}

/* ---------- Create page: art style picker + caption ---------- */
.style-picker {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    align-self: center;
    padding: 8px 10px 8px 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(139, 92, 246, 0.25);
}

.style-picker label {
    font-size: 14px;
    font-weight: 700;
    color: var(--lavender);
    white-space: nowrap;
}

.style-picker select {
    width: auto;
    margin-bottom: 0;
    padding: 8px 34px 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    background-color: rgba(11, 9, 24, 0.6);
}

.style-caption {
    margin: -10px 0 16px;
    font-size: 13px;
    font-style: italic;
    color: var(--text-faint);
}

/* ---------- Save-to-library dialog ---------- */
.save-dialog { width: 26em !important; }

.save-dialog-lead { margin: 0 0 14px; color: var(--text-muted); }

.save-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-align: left;
}

.save-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.save-option:hover { border-color: rgba(196, 181, 253, 0.5); }

.save-option.selected {
    border-color: var(--amber);
    background: rgba(251, 191, 36, 0.07);
    box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.save-option input { display: none; }

.save-option-icon { font-size: 20px; flex-shrink: 0; }

.save-option-text { display: flex; flex-direction: column; gap: 2px; }

.save-option-name { font-weight: 700; color: #fff; font-size: 15px; }

.save-option-desc { font-size: 13px; color: var(--text-muted); }

.save-dialog-confirm { color: #0B0918 !important; font-weight: 700 !important; }

/* ---------- My Stories ---------- */
.mystories-gate {
    max-width: 440px;
    margin: 60px auto;
    padding: 36px 32px;
    text-align: center;
    border-radius: 24px;
    background: linear-gradient(170deg, var(--bg-raise), var(--bg-raise-2));
    border: 1px solid rgba(139, 92, 246, 0.25);
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.mystories-gate.hidden { display: none; }

.mystories-gate p { margin: 0; color: var(--text-muted); }

.gate-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background-color: var(--bg-raise);
    border: 1px solid var(--line-strong);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

.gate-login:hover { background-color: var(--line-strong); color: #fff; }

.mystories-controls {
    max-width: 1140px;
    width: 100%;
    margin: 18px auto 0;
    padding: 0 24px;
    box-sizing: border-box;
    display: flex;
    justify-content: flex-end;
}

.mystories-controls.hidden { display: none; }

.show-private-toggle {
    padding: 9px 16px;
    border-radius: 999px;
    background: rgba(251, 191, 36, 0.07);
    border: 1px solid rgba(251, 191, 36, 0.35);
    color: var(--amber);
    font-size: 14px;
}

.show-private-toggle input[type="checkbox"] { accent-color: var(--amber); }

#my-story-list,
.rec-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 26px;
    align-items: stretch;
    width: 100%;
    max-width: 1140px;
    margin: 10px auto 40px;
    padding: 0 24px;
    box-sizing: border-box;
}

.recommended-section {
    max-width: 1140px;
    width: 100%;
    margin: 30px auto 0;
    padding: 0 24px;
    box-sizing: border-box;
}

.recommended-section.hidden { display: none; }

.recommended-section h2 { margin: 0 0 6px; font-size: 26px; }

.recommended-hint {
    margin: 0 0 8px;
    font-size: 14px;
    color: var(--text-faint);
}

@media (max-width: 768px) {
    #my-story-list, .rec-grid { grid-template-columns: 1fr; padding: 0 12px; }
    .mystories-controls { justify-content: center; }
    .hero-rocket { display: none; }
}
