:root {
    --km-theme-bg: #f6f8fc;
    --km-theme-surface: rgba(255, 255, 255, 0.92);
    --km-theme-surface-strong: #ffffff;
    --km-theme-text: #111827;
    --km-theme-muted: #5b6475;
    --km-theme-border: rgba(148, 163, 184, 0.18);
    --km-theme-blue: #2563eb;
    --km-theme-blue-soft: rgba(37, 99, 235, 0.1);
    --km-theme-green: #0f9d58;
    --km-theme-green-soft: rgba(15, 157, 88, 0.12);
    --km-theme-shadow: 0 20px 60px rgba(15, 23, 42, 0.08);
    --km-theme-radius-xl: 28px;
    --km-theme-radius-lg: 22px;
    --km-theme-radius-md: 18px;
    --km-theme-radius-sm: 14px;
    --km-theme-shell: min(1240px, calc(100% - 32px));
    --km-theme-font: "Vazir", Tahoma, Arial, sans-serif;
}

html {
    scroll-behavior: smooth;
}

body.km-theme-body {
    margin: 0;
    direction: rtl;
    color: var(--km-theme-text);
    font-family: var(--km-theme-font);
    background:
        linear-gradient(180deg, #fbfcff 0%, var(--km-theme-bg) 42%, #eef2f8 100%);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

.km-theme-shell {
    width: var(--km-theme-shell);
    margin: 0 auto;
}

.km-theme-app {
    min-height: 100vh;
}

.km-theme-header {
    position: sticky;
    top: 0;
    z-index: 40;
    padding: 14px 0 0;
}

.km-theme-header__inner,
.km-theme-mobile-nav__inner,
.km-theme-page-hero .km-theme-shell,
.km-theme-readable,
.km-theme-post-card,
.km-theme-article,
.km-theme-empty-state,
.km-theme-footer__hero {
    background: var(--km-theme-surface);
    border: 1px solid var(--km-theme-border);
    box-shadow: var(--km-theme-shadow);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.km-theme-header__inner {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
    min-height: 78px;
    padding: 14px 18px;
    border-radius: 24px;
}

.km-theme-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    text-decoration: none;
}

.km-theme-brand__mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 18px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.18);
}

.km-theme-brand__mark img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.km-theme-brand__copy {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.km-theme-brand__copy strong {
    font-size: 15px;
    font-weight: 900;
    line-height: 1.6;
}

.km-theme-brand__copy small {
    color: var(--km-theme-muted);
    font-size: 12px;
    line-height: 1.8;
}

.km-theme-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.km-theme-nav a,
.km-theme-footer__chips a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 14px;
    border-radius: 999px;
    text-decoration: none;
    color: var(--km-theme-muted);
    background: rgba(255, 255, 255, 0.76);
    border: 1px solid var(--km-theme-border);
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease, color 180ms ease;
    font-size: 13px;
    font-weight: 800;
}

.km-theme-nav a:hover,
.km-theme-footer__chips a:hover {
    color: var(--km-theme-text);
    background: #fff;
    border-color: rgba(37, 99, 235, 0.24);
    transform: translateY(-1px);
}

.km-theme-header__actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.km-theme-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 18px;
    text-decoration: none;
    border: 0;
    font-size: 14px;
    font-weight: 900;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.km-theme-button:hover {
    transform: translateY(-1px);
}

.km-theme-button--primary {
    color: #fff;
    background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
    box-shadow: 0 14px 28px rgba(15, 23, 42, 0.18);
}

.km-theme-button--secondary {
    color: var(--km-theme-text);
    background: rgba(255, 255, 255, 0.88);
    box-shadow: inset 0 0 0 1px var(--km-theme-border);
}

.km-theme-menu-toggle {
    display: none;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: inset 0 0 0 1px var(--km-theme-border);
}

.km-theme-menu-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    margin: 4px auto;
    border-radius: 999px;
    background: var(--km-theme-text);
}

.km-theme-mobile-nav {
    padding-top: 10px;
}

.km-theme-mobile-nav__inner {
    padding: 14px;
    border-radius: 22px;
}

.km-theme-mobile-nav nav {
    display: grid;
    gap: 8px;
}

.km-theme-mobile-nav nav a {
    display: block;
    padding: 14px 16px;
    border-radius: 16px;
    text-decoration: none;
    background: rgba(244, 246, 251, 0.92);
    font-weight: 800;
}

.km-theme-mobile-nav .km-theme-button {
    width: 100%;
    margin-top: 12px;
}

.km-theme-main {
    padding-bottom: 36px;
}

.km-theme-main--front {
    padding-top: 12px;
}

.km-theme-page-hero {
    padding: 28px 0 12px;
}

.km-theme-page-hero .km-theme-shell {
    display: grid;
    gap: 14px;
    padding: 28px;
    border-radius: var(--km-theme-radius-xl);
}

.km-theme-page-hero__eyebrow,
.km-theme-footer__eyebrow {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 34px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--km-theme-blue-soft);
    color: #11478d;
    font-size: 12px;
    font-weight: 800;
}

.km-theme-page-hero h1,
.km-theme-article h1 {
    margin: 0;
    font-size: clamp(30px, 5vw, 56px);
    line-height: 1.24;
    font-weight: 900;
}

.km-theme-page-hero p,
.km-theme-empty-state p,
.km-theme-post-card__body p,
.km-theme-article__header p,
.km-theme-footer__hero p {
    margin: 0;
    color: var(--km-theme-muted);
    font-size: 15px;
    line-height: 2;
}

.km-theme-inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
}

.km-theme-page-content {
    padding: 8px 0 24px;
}

.km-theme-readable,
.km-theme-article {
    padding: 28px;
    border-radius: var(--km-theme-radius-xl);
}

.km-theme-readable > :first-child,
.km-theme-article__content > :first-child {
    margin-top: 0;
}

.km-theme-readable > :last-child,
.km-theme-article__content > :last-child {
    margin-bottom: 0;
}

.km-theme-post-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.km-theme-post-card {
    overflow: hidden;
    border-radius: var(--km-theme-radius-lg);
}

.km-theme-post-card__media {
    display: block;
    aspect-ratio: 1.5;
    overflow: hidden;
}

.km-theme-post-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.km-theme-post-card__body {
    display: grid;
    gap: 10px;
    padding: 18px;
}

.km-theme-post-card__body span {
    color: var(--km-theme-muted);
    font-size: 12px;
    font-weight: 800;
}

.km-theme-post-card__body h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.7;
}

.km-theme-post-card__body h2 a {
    text-decoration: none;
}

.km-theme-pagination {
    padding-top: 22px;
}

.km-theme-pagination .nav-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.km-theme-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 16px;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--km-theme-border);
}

.km-theme-pagination .current {
    color: #fff;
    background: linear-gradient(135deg, #0f172a 0%, #2563eb 100%);
    border-color: transparent;
}

.km-theme-article {
    display: grid;
    gap: 20px;
}

.km-theme-article__header {
    display: grid;
    gap: 14px;
}

.km-theme-article__cover {
    overflow: hidden;
    border-radius: var(--km-theme-radius-lg);
}

.km-theme-article__cover img {
    width: 100%;
    display: block;
    aspect-ratio: 1.75;
    object-fit: cover;
}

.km-theme-article__content {
    line-height: 2.1;
}

.km-theme-article__content a {
    color: var(--km-theme-blue);
}

.km-theme-empty-state {
    display: grid;
    gap: 8px;
    padding: 24px;
    border-radius: var(--km-theme-radius-xl);
}

.km-theme-empty-state strong {
    font-size: 20px;
    font-weight: 900;
    line-height: 1.7;
}

.km-theme-footer {
    padding: 18px 0 24px;
}

.km-theme-footer__hero {
    display: grid;
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.9fr);
    gap: 18px;
    padding: 24px;
    border-radius: var(--km-theme-radius-xl);
}

.km-theme-footer__hero h2 {
    margin: 14px 0 10px;
    font-size: clamp(26px, 4vw, 42px);
    line-height: 1.3;
}

.km-theme-footer__stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.km-theme-footer__stats div,
.km-theme-footer__col {
    padding: 18px;
    border-radius: var(--km-theme-radius-lg);
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--km-theme-border);
}

.km-theme-footer__stats strong {
    display: block;
    font-size: 26px;
    font-weight: 900;
    line-height: 1.3;
}

.km-theme-footer__stats span,
.km-theme-footer__meta {
    color: var(--km-theme-muted);
    font-size: 13px;
    line-height: 1.9;
}

.km-theme-footer__grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.km-theme-footer__col h3 {
    margin: 0 0 12px;
    font-size: 18px;
    line-height: 1.7;
}

.km-theme-footer__col ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.km-theme-footer__col li,
.km-theme-footer__col a {
    color: var(--km-theme-muted);
    text-decoration: none;
    line-height: 1.9;
}

.km-theme-footer__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.km-theme-footer__meta {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 2px 0;
}

.home .km-sb-showcase--home {
    padding-top: 10px;
}

.home .km-sb-container,
.km-theme-plugin-surface .km-sb-container {
    width: min(1240px, calc(100% - 32px));
}

.admin-bar .km-theme-header {
    top: 32px;
}

@media (max-width: 960px) {
    .km-theme-header__inner {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .km-theme-nav,
    .km-theme-header__actions .km-theme-button {
        display: none;
    }

    .km-theme-menu-toggle {
        display: inline-block;
    }

    .km-theme-post-grid,
    .km-theme-footer__hero,
    .km-theme-footer__grid,
    .km-theme-footer__stats {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 782px) {
    .admin-bar .km-theme-header {
        top: 46px;
    }
}

@media (max-width: 640px) {
    :root {
        --km-theme-shell: calc(100% - 20px);
    }

    .km-theme-header__inner,
    .km-theme-page-hero .km-theme-shell,
    .km-theme-readable,
    .km-theme-article,
    .km-theme-footer__hero,
    .km-theme-footer__col,
    .km-theme-footer__stats div {
        padding: 18px;
    }

    .km-theme-footer__meta {
        flex-direction: column;
        align-items: flex-start;
    }
}
