:root {
    --stories-nav-height: 68px;
    --stories-nav-bg: #ffffff;
    --stories-text: #52525b;
    --stories-active: #2563eb;
    --stories-border: #e5e7eb;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    padding-bottom: calc(
        var(--stories-nav-height) +
        env(safe-area-inset-bottom, 0px) + 12px
    );
    color: #18181b;
    background: #ffffff;
    font-family: system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
}

.stories-bottom-nav {
    position: fixed;
    z-index: 1000;
    right: 0;
    bottom: 0;
    left: 0;

    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: center;

    min-height: var(--stories-nav-height);
    padding: 6px 8px calc(
        6px + env(safe-area-inset-bottom, 0px)
    );

    background: var(--stories-nav-bg);
    border-top: 1px solid var(--stories-border);
    box-shadow: 0 -4px 18px rgb(0 0 0 / 5%);
}

.stories-nav-item {
    display: flex;
    min-width: 0;
    min-height: 48px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;

    color: var(--stories-text);
    text-decoration: none;
    font-size: 11px;
    font-weight: 500;
    -webkit-tap-highlight-color: transparent;
}

.stories-nav-item svg {
    width: 23px;
    height: 23px;
    flex: 0 0 auto;
}

.stories-nav-item.is-active {
    color: var(--stories-active);
}

.stories-nav-item:focus-visible {
    outline: 2px solid var(--stories-active);
    outline-offset: -2px;
    border-radius: 8px;
}

@media (min-width: 768px) {
    body {
        padding-bottom: 0;
    }

    .stories-bottom-nav {
        right: auto;
        left: 50%;
        bottom: 16px;
        width: min(440px, calc(100% - 32px));
        transform: translateX(-50%);
        border: 1px solid var(--stories-border);
        border-radius: 18px;
        padding-bottom: 6px;
        box-shadow: 0 8px 32px rgb(0 0 0 / 12%);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }
}

.stories-header {
    padding: 16px;
    border-bottom: 1px solid #f1f1f1;
}

.stories-brand {
    color: #18181b;
    font-size: 22px;
    font-weight: 800;
    text-decoration: none;
}

.stories-content {
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
    padding: 16px;
}

.stories-card {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}

.stories-card img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 12px;
}

.stories-card h2 {
    margin: 12px 0 8px;
    font-size: clamp(20px, 5vw, 28px);
    line-height: 1.25;
}

.stories-card h2 a {
    color: inherit;
    text-decoration: none;
}

.stories-excerpt {
    color: #52525b;
    line-height: 1.65;
}

/* Stories homepage */

.stories-home {
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
    padding: 22px 16px 32px;
}

.stories-welcome {
    margin-bottom: 24px;
}

.stories-eyebrow {
    margin: 0 0 10px;
    color: var(--stories-active);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
}

.stories-welcome h1 {
    max-width: 480px;
    margin: 0;
    font-size: clamp(30px, 8vw, 44px);
    font-weight: 800;
    letter-spacing: -1.5px;
    line-height: 1.08;
}

.stories-intro {
    max-width: 440px;
    margin: 12px 0 0;
    color: #71717a;
    font-size: 15px;
    line-height: 1.6;
}

.stories-categories {
    display: flex;
    gap: 8px;
    margin: 0 -16px 28px;
    padding: 2px 16px 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.stories-categories::-webkit-scrollbar {
    display: none;
}

.stories-category {
    flex: 0 0 auto;
    padding: 9px 15px;
    border: 1px solid #e4e4e7;
    border-radius: 999px;
    color: #3f3f46;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
}

.stories-category:first-child {
    color: #fff;
    background: #2563eb;
    border-color: #2563eb;
}

.stories-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.stories-section-heading h2 {
    margin: 0;
    font-size: 21px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.stories-feed {
    display: grid;
    gap: 22px;
}

.stories-card {
    min-width: 0;
    overflow: hidden;
}

.stories-card-image {
    display: block;
    overflow: hidden;
    border-radius: 14px;
    background: #f4f4f5;
}

.stories-card-image img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    transition: transform 200ms ease;
}

.stories-card-content {
    padding: 12px 2px 0;
}

.stories-card-meta {
    margin: 0 0 7px;
    color: #71717a;
    font-size: 12px;
    font-weight: 600;
}

.stories-card h3 {
    margin: 0;
    font-size: 19px;
    line-height: 1.35;
    letter-spacing: -0.3px;
}

.stories-card h3 a {
    color: #18181b;
    text-decoration: none;
}

.stories-card-excerpt {
    margin: 8px 0 0;
    color: #71717a;
    font-size: 14px;
    line-height: 1.6;
}

/* First story receives a larger visual treatment */

.stories-card-featured .stories-card-image img {
    aspect-ratio: 4 / 3;
}

.stories-card-featured h3 {
    font-size: 24px;
    line-height: 1.25;
}

.stories-empty {
    padding: 24px;
    border: 1px dashed #d4d4d8;
    border-radius: 14px;
}

.stories-empty h3 {
    margin-top: 0;
}

.stories-empty p {
    margin-bottom: 0;
    color: #71717a;
}

@media (min-width: 600px) {
    .stories-home {
        padding-top: 32px;
    }

    .stories-feed {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 28px 20px;
    }

    .stories-card-featured {
        grid-column: 1 / -1;
    }

    .stories-card-featured .stories-card-image img {
        aspect-ratio: 16 / 8;
    }
}

@media (prefers-reduced-motion: reduce) {
    .stories-card-image img {
        transition: none;
    }
}

/* Stories single article */

.stories-article {
    width: 100%;
    max-width: 760px;
    margin-inline: auto;
    padding: 16px 18px 36px;
    overflow-wrap: anywhere;
}

.stories-breadcrumb {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 22px;
    color: #71717a;
    font-size: 12px;
}

.stories-breadcrumb a {
    color: var(--stories-active);
    text-decoration: none;
}

.stories-article-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.stories-article-categories a {
    display: inline-flex;
    padding: 7px 11px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.stories-article-title {
    margin: 0;
    color: #18181b;
    font-size: clamp(30px, 7vw, 46px);
    font-weight: 800;
    letter-spacing: -1.4px;
    line-height: 1.12;
}

.stories-article-subtitle {
    margin: 16px 0 0;
    color: #52525b;
    font-size: 17px;
    line-height: 1.65;
}

.stories-article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    margin-top: 18px;
    color: #71717a;
    font-size: 12px;
    line-height: 1.6;
}

.stories-article-hero {
    margin: 24px 0;
}

.stories-article-featured-image {
    display: block;
    width: 100%;
    height: auto;
    max-height: 520px;
    object-fit: cover;
    border-radius: 14px;
}

.stories-article-content {
    color: #27272a;
    font-size: 17px;
    line-height: 1.85;
}

.stories-article-content > * {
    max-width: 100%;
}

.stories-article-content h2,
.stories-article-content h3 {
    margin-top: 1.8em;
    color: #18181b;
    line-height: 1.3;
    letter-spacing: -0.4px;
}

.stories-article-content h2 {
    font-size: 26px;
}

.stories-article-content h3 {
    font-size: 21px;
}

.stories-article-content p {
    margin: 0 0 1.35em;
}

.stories-article-content a {
    color: #1d4ed8;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.stories-article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
}

.stories-article-content figure {
    margin: 24px 0;
}

.stories-article-content blockquote {
    margin: 24px 0;
    padding: 4px 0 4px 18px;
    border-left: 3px solid var(--stories-active);
    color: #52525b;
}

.stories-article-content pre {
    max-width: 100%;
    overflow-x: auto;
    padding: 16px;
    border-radius: 10px;
    background: #f4f4f5;
    font-size: 14px;
}

.stories-article-footer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid #e4e4e7;
}

.stories-article-footer h2 {
    margin: 0 0 14px;
    font-size: 16px;
}

.stories-post-pagination {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid #e4e4e7;
}

.stories-post-pagination a {
    color: #27272a;
    font-size: 13px;
    line-height: 1.5;
    text-decoration: none;
}

.stories-post-next {
    text-align: right;
}

.stories-page-links {
    margin: 24px 0;
}

@media (min-width: 768px) {
    .stories-article {
        padding-top: 28px;
    }

    .stories-article-hero {
        margin-block: 30px;
    }

    .stories-article-content {
        font-size: 18px;
    }
}



/* Pageview count on story cards */

.stories-post-views {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 0 0 10px;
  color: var(--stories-muted, #64748b);
  font-size: 12px;
  line-height: 1.5;
}


/* Stories bottom navigation: keep all five items in one row */
.stories-bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
}

.stories-nav-item {
    white-space: nowrap;
    gap: 3px;
    font-size: 10px;
}

.stories-nav-item svg {
    width: 21px;
    height: 21px;
}

@media (min-width: 768px) {
    .stories-bottom-nav {
        width: min(520px, calc(100% - 32px));
    }
}


/* ========================================
   Stories Homepage Search
======================================== */

.stories-home-search {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0px 0px 10px;
    box-sizing: border-box;
}

.stories-home-search-form {
    width: 100%;
    margin: 0;
}

.stories-home-search-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.stories-home-search-row {
    display: flex;
    align-items: stretch;
    width: 100%;
    min-height: 48px;
    overflow: hidden;
    border: 1px solid #d8d8d8;
    border-radius: 9px;
    background: #fff;
}

.stories-home-search-input {
    flex: 1;
    width: 0;
    min-width: 0;
    min-height: 46px;
    margin: 0;
    padding: 10px 14px;
    border: 0;
    border-radius: 0;
    outline: none;
    background: #fff;
    color: #222;
    font-family: inherit;
    font-size: 15px;
    box-shadow: none;
}

.stories-home-search-input:focus {
    border-color: #333;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

.stories-home-search-input::placeholder {
    color: #888;
    opacity: 1;
}

.stories-home-search-button {
    display: flex;
    flex: 0 0 46px;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    min-height: 46px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #222;
    color: #fff;
    cursor: pointer;
    box-shadow: none;
}

.stories-home-search-button:hover,
.stories-home-search-button:focus-visible {
    background: #b78624;
    color: #171717;
}

.stories-home-search-button:focus-visible {
    outline: 2px solid #222;
    outline-offset: -3px;
}

.stories-home-search-button svg {
    display: block;
    width: 21px;
    height: 21px;
}

@media (min-width: 600px) {
    .stories-home-search {
        padding: 18px 24px 10px;
    }
}


/* ========================================
   Stories: Focused Search Mode
======================================== */

.stories-search-focus-overlay {
    position: fixed;
    inset: 0;
    z-index: 9990;
    background: rgba(15, 15, 15, 0.48);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

body.stories-search-focus-active .stories-search-focus-overlay {
    opacity: 1;
    visibility: visible;
}

/* Keep the search box sharp and above the overlay */
body.stories-search-focus-active .stories-home-search {
    position: relative;
    z-index: 9992;
    background: transparent;
}

body.stories-search-focus-active .stories-home-search-row {
    border: 2px solid #000000;
    border-radius: 10px;
    box-shadow: 0 0 0 4px rgba(20, 21, 22, 0.22);
    background: #fff;
}

body.stories-search-focus-active .stories-home-search-input {
    background: #fff;
}

/* Keep the bottom navigation sharp and clickable */
body.stories-search-focus-active .stories-footer {
    z-index: 9995;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .stories-search-focus-overlay {
        transition: none;
    }
}

/* Signed-in user avatar in the bottom navigation */
.stories-nav-avatar {
    display: block;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}