:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-2: #eef4ff;
    --text: #14213d;
    --muted: #5f6b84;
    --accent: #2563eb;
    --accent-2: #0f172a;
    --border: #dfe7f3;
    --shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
    line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrapper {
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
}
.site-header__brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 48px;
    border-radius: 14px;
    background: var(--accent-2);
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
}
.brand-title { margin: 0; font-size: 1.05rem; }
.brand-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 0.92rem; }
.site-nav { display: flex; gap: 12px; flex-wrap: wrap; }
.site-nav__link {
    padding: 8px 12px;
    border-radius: 999px;
    color: var(--muted);
    font-weight: 600;
}
.site-nav__link.is-active, .site-nav__link:hover {
    background: var(--surface-2);
    color: var(--accent);
    text-decoration: none;
}
.site-header__meta { display: flex; align-items: center; }
.header-pill {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent-2);
    font-size: 0.95rem;
}

.main-grid {
    display: grid;
    grid-template-columns: 2.3fr 0.9fr;
    gap: 24px;
}
.card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 24px;
}
.hero { padding: 32px; background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%); color: white; border-radius: 24px; }
.hero h2 { font-size: 2rem; margin-top: 0; }
.hero p { color: rgba(255,255,255,0.9); max-width: 680px; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }
.btn {
    display: inline-block;
    padding: 10px 16px;
    border-radius: 999px;
    background: white;
    color: var(--accent-2);
    font-weight: 700;
}
.btn--ghost { background: transparent; color: white; border: 1px solid rgba(255,255,255,0.35); }
.section-title { margin-top: 0; }
.archive-note {
    padding: 12px 14px;
    border-left: 4px solid var(--accent);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--muted);
}
.list { padding-left: 18px; }
.joke-teasers {
    display: grid;
    gap: 10px;
}
.joke-teaser {
    display: block;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
}
.joke-teaser:hover {
    border-color: var(--accent);
    text-decoration: none;
}
.joke-teaser strong,
.joke-teaser span {
    display: block;
}
.joke-teaser strong {
    color: var(--accent-2);
}
.joke-teaser span {
    color: var(--muted);
    margin-top: 3px;
}
.list-controls {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 22px;
    color: var(--muted);
    font-weight: 700;
}
.list-controls a,
.pagination a {
    padding: 7px 11px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent-2);
    background: white;
}
.list-controls a.is-active,
.pagination a.is-active,
.list-controls a:hover,
.pagination a:hover {
    background: var(--accent-2);
    color: white;
    text-decoration: none;
}
.pagination__ellipsis {
    color: var(--muted);
    font-weight: 700;
}
.joke-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.joke-card {
    min-height: 150px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface-2);
    overflow: hidden;
}
.joke-card__button {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    height: 100%;
    padding: 15px 16px;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}
.joke-card__button:hover,
.joke-card__button:focus-visible {
    outline: 0;
    background: #f8fbff;
}
.joke-card__button:focus-visible {
    box-shadow: inset 0 0 0 3px var(--accent);
}
.joke-card__button strong {
    color: var(--accent-2);
}
.joke-card__button span {
    color: var(--muted);
}
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}
.pagination span {
    color: var(--muted);
    font-weight: 700;
}
.quote {
    background: var(--surface-2);
    border-left: 4px solid var(--accent);
    padding: 14px 16px;
    border-radius: 12px;
    margin: 12px 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}
.quote strong {
    display: block;
    width: 100%;
    color: var(--accent-2);
    margin-bottom: 4px;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.4;
    hyphens: auto;
}
.home-cartoon {
    display: block;
    color: var(--text);
}
.home-cartoon:hover {
    text-decoration: none;
}
.home-cartoon img {
    display: block;
    width: 100%;
    max-height: 260px;
    object-fit: contain;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fbff;
}
.home-cartoon span {
    display: block;
    margin-top: 10px;
    color: var(--muted);
}
.home-cartoon strong {
    display: block;
    color: var(--accent-2);
}
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 18px 0 22px;
}
.category-tabs a {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--accent-2);
    font-weight: 700;
}
.category-tabs a.is-active,
.category-tabs a:hover {
    background: var(--accent-2);
    color: white;
    text-decoration: none;
}
.cartoon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}
.cartoon-card {
    margin: 0;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}
.cartoon-card__button {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: #f8fbff;
    cursor: pointer;
}
.cartoon-card img {
    display: block;
    width: 100%;
    height: 210px;
    object-fit: contain;
}
.cartoon-card__button:hover img,
.cartoon-card__button:focus-visible img {
    transform: scale(1.02);
}
.cartoon-card__button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: -3px;
}
.cartoon-card__button img {
    transition: transform 160ms ease;
}
.cartoon-card figcaption {
    padding: 12px 14px 14px;
}
.cartoon-card strong,
.cartoon-card span {
    display: block;
}
.cartoon-card span {
    color: var(--muted);
    font-size: 0.92rem;
    margin-top: 2px;
}
body.has-lightbox {
    overflow: hidden;
}
.lightbox[hidden] {
    display: none;
}
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: grid;
    place-items: center;
    padding: 24px;
}
.lightbox__backdrop {
    position: absolute;
    inset: 0;
    border: 0;
    background: rgba(15, 23, 42, 0.76);
    cursor: zoom-out;
}
.lightbox__dialog {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 12px;
    max-width: min(980px, 96vw);
    max-height: 92vh;
}
.lightbox__image {
    display: block;
    max-width: 100%;
    max-height: calc(92vh - 92px);
    object-fit: contain;
    border-radius: 14px;
    background: white;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}
.lightbox__caption {
    color: white;
    text-align: center;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
}
.lightbox__caption strong,
.lightbox__caption span {
    display: block;
}
.lightbox__caption span {
    opacity: 0.82;
    font-size: 0.95rem;
}
.lightbox__text {
    width: min(760px, 88vw);
    max-height: calc(92vh - 70px);
    overflow: auto;
    padding: 28px;
    border-radius: 14px;
    background: white;
    color: var(--text);
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}
.lightbox__text strong {
    display: block;
    color: var(--accent-2);
    margin-bottom: 12px;
    font-size: 1.15rem;
}
.lightbox__text p {
    margin: 0;
    white-space: pre-wrap;
}
.lightbox__close {
    position: absolute;
    top: -14px;
    right: -14px;
    z-index: 2;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 999px;
    background: white;
    color: var(--accent-2);
    cursor: pointer;
    font-size: 1.7rem;
    line-height: 1;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}
.lightbox__close:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}
.lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 46px;
    height: 58px;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    color: var(--accent-2);
    cursor: pointer;
    font-size: 2.4rem;
    line-height: 1;
    transform: translateY(-50%);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}
.lightbox__nav--prev {
    left: -62px;
}
.lightbox__nav--next {
    right: -62px;
}
.lightbox__nav:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}
.site-footer {
    margin-top: 24px;
    padding: 20px 0 40px;
    color: var(--muted);
    text-align: center;
}

@media (max-width: 900px) {
    .site-header { flex-wrap: wrap; }
    .main-grid { grid-template-columns: 1fr; }
    .lightbox {
        padding: 14px;
    }
    .lightbox__close {
        top: 8px;
        right: 8px;
    }
    .lightbox__nav {
        width: 42px;
        height: 52px;
        background: rgba(255, 255, 255, 0.96);
    }
    .lightbox__nav--prev {
        left: 8px;
    }
    .lightbox__nav--next {
        right: 8px;
    }
    .lightbox__image {
        max-height: calc(92vh - 84px);
    }
    .joke-lightbox .lightbox__dialog {
        width: 100%;
        max-height: 94vh;
        padding-bottom: 64px;
    }
    .joke-lightbox .lightbox__text {
        width: 100%;
        max-height: calc(94vh - 128px);
        padding: 22px 18px;
    }
    .joke-lightbox .lightbox__nav {
        top: auto;
        bottom: 0;
        transform: none;
    }
    .joke-lightbox .lightbox__nav--prev {
        left: calc(50% - 54px);
    }
    .joke-lightbox .lightbox__nav--next {
        right: calc(50% - 54px);
    }
}
