:root {
    --bg: #edf3fb;
    --bg-soft: #f7faff;
    --surface: #ffffff;
    --surface-soft: #f4f8ff;
    --text: #0f172a;
    --muted: #5c6d87;
    --primary: #1d4ed8;
    --primary-2: #0ea5e9;
    --accent: #f59e0b;
    --success: #16a34a;
    --danger: #dc2626;
    --border: #d5e1f2;
    --border-strong: #b9cdec;
    --shadow-sm: 0 6px 18px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 14px 36px rgba(15, 23, 42, 0.1);
    --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.12);
    --radius-sm: 12px;
    --radius: 18px;
    --radius-lg: 26px;
    --container: 1240px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 12% -4%, rgba(29, 78, 216, 0.19), transparent 32%),
        radial-gradient(circle at 88% 0%, rgba(14, 165, 233, 0.16), transparent 30%),
        linear-gradient(180deg, #f9fbff 0%, var(--bg) 38%, #e8effa 100%);
    font-family: "IBM Plex Sans Arabic", "Lexend", sans-serif;
}

body.admin-body {
    background:
        radial-gradient(circle at 90% -5%, rgba(29, 78, 216, 0.2), transparent 36%),
        radial-gradient(circle at 8% 8%, rgba(14, 165, 233, 0.15), transparent 28%),
        linear-gradient(180deg, #f7faff 0%, #e9f0fb 100%);
}

a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease, background-color 0.2s ease, transform 0.2s ease;
}

img {
    display: block;
    max-width: 100%;
    width: 100%;
}

.container {
    width: min(calc(100% - 1.5rem), var(--container));
    margin: 0 auto;
}

.page-main {
    min-height: 65vh;
    padding: 1.2rem 0 3rem;
}

.admin-page-main {
    padding-top: 1rem;
}

.section {
    padding: 1.25rem 0;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.section-head.compact {
    margin-top: 0.75rem;
}

.section-head h1,
.section-head h2 {
    margin: 0;
    font-size: clamp(1.4rem, 3vw, 2rem);
    line-height: 1.25;
    letter-spacing: -0.02em;
}

.section-head h1::before,
.section-head h2::before {
    content: "";
    display: inline-block;
    width: 34px;
    height: 7px;
    border-radius: 999px;
    margin-left: 10px;
    margin-bottom: 6px;
    vertical-align: middle;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 70;
    backdrop-filter: blur(12px);
    background: rgba(255, 255, 255, 0.82);
    border-bottom: 1px solid rgba(185, 205, 236, 0.7);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.04);
}

.site-header::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, #1d4ed8, #0ea5e9, #22c55e);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    padding: 0.85rem 0;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.8rem;
}

.brand-dot {
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 0.75rem;
    background: linear-gradient(140deg, var(--primary), var(--primary-2));
    color: #fff;
    font-weight: 700;
    font-size: 1.2rem;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 18px rgba(29, 78, 216, 0.32);
}

.brand strong {
    display: block;
    line-height: 1.2;
    font-size: 1.12rem;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 0.83rem;
}

.menu-toggle {
    display: none;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 10px;
    padding: 0.52rem 0.68rem;
    color: #334155;
}

.main-nav {
    display: flex;
    gap: 0.45rem;
}

.main-nav a {
    font-weight: 500;
    padding: 0.54rem 0.88rem;
    border-radius: 999px;
    color: #1f2f46;
}

.main-nav a.active,
.main-nav a[aria-current="page"] {
    background: linear-gradient(135deg, #d8e7ff, #e9f2ff);
    color: #0f3b97;
    box-shadow: inset 0 0 0 1px #c2d6f5;
}

.main-nav a:hover {
    background: linear-gradient(135deg, #e3edff, #f2f8ff);
    color: #153a97;
    transform: translateY(-1px);
}

.grade-stage-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.55rem;
    padding: 0.16rem 0 0.78rem;
}

.stage-dropdown {
    position: relative;
}

.stage-dropdown > summary {
    cursor: pointer;
    list-style: none;
    border: 1px solid #c8d8f3;
    background: linear-gradient(135deg, #f6faff, #ebf3ff);
    color: #1b429f;
    border-radius: 999px;
    font-size: 0.9rem;
    padding: 0.45rem 0.92rem;
    font-weight: 600;
    user-select: none;
}

.stage-dropdown > summary::-webkit-details-marker {
    display: none;
}

.stage-dropdown.active > summary,
.stage-dropdown[open] > summary {
    border-color: #a8c4ef;
    background: linear-gradient(135deg, #dbe9ff, #e8f2ff);
    color: #0f3d99;
}

.stage-dropdown-menu {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    min-width: min(88vw, 320px);
    max-height: 310px;
    overflow: auto;
    z-index: 30;
    display: grid;
    gap: 0.36rem;
    padding: 0.5rem;
    border: 1px solid #c8dbf3;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.14);
}

.stage-dropdown-menu a {
    display: block;
    border: 1px solid #c8d8f3;
    background: linear-gradient(135deg, #f6faff, #ebf3ff);
    color: #1b429f;
    border-radius: 999px;
    font-size: 0.9rem;
    padding: 0.42rem 0.82rem;
    font-weight: 500;
}

.stage-dropdown-menu a.active,
.stage-dropdown-menu a[aria-current="page"] {
    border-color: #a8c4ef;
    background: linear-gradient(135deg, #dbe9ff, #e8f2ff);
    color: #0f3d99;
}

.stage-dropdown-menu a:hover {
    background: linear-gradient(135deg, #dce9ff, #eaf4ff);
}

.grade-strip {
    display: flex;
    gap: 0.48rem;
    overflow-x: auto;
    scrollbar-width: thin;
    padding: 0.12rem 0 0.75rem;
}

.grade-strip a {
    flex-shrink: 0;
    border: 1px solid #c8d8f3;
    background: linear-gradient(135deg, #f6faff, #ebf3ff);
    color: #1b429f;
    border-radius: 999px;
    font-size: 0.9rem;
    padding: 0.42rem 0.86rem;
    font-weight: 500;
}

.grade-strip a.active,
.grade-strip a[aria-current="page"] {
    border-color: #a8c4ef;
    background: linear-gradient(135deg, #dbe9ff, #e8f2ff);
    color: #0f3d99;
}

.grade-strip a:hover {
    background: linear-gradient(135deg, #dce9ff, #eaf4ff);
}

.hero-section {
    padding: 1.2rem 0 1.65rem;
}

.hero-grid {
    display: grid;
    grid-template-columns: 1.25fr 0.75fr;
    gap: 1rem;
    padding: 1.45rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 10% 5%, rgba(14, 165, 233, 0.1), transparent 40%),
        linear-gradient(135deg, #ffffff 0%, #f5f9ff 52%, #ecf3ff 100%);
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.hero-grid::after {
    content: "";
    position: absolute;
    width: 280px;
    height: 280px;
    left: -84px;
    bottom: -132px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(29, 78, 216, 0.18) 0%, transparent 70%);
    pointer-events: none;
}

.hero-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: linear-gradient(135deg, #dce9ff, #eaf4ff);
    color: #17409f;
    padding: 0.38rem 0.85rem;
    border-radius: 999px;
    border: 1px solid #bfd2f2;
    font-size: 0.88rem;
    font-weight: 500;
}

.hero-grid h1 {
    margin: 0.72rem 0 0.45rem;
    font-size: clamp(2rem, 5.2vw, 3.95rem);
    line-height: 1.13;
    letter-spacing: -0.02em;
}

.hero-grid p {
    margin: 0 0 1.05rem;
    color: var(--muted);
    line-height: 1.85;
    font-size: 1.04rem;
}

.hero-search {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.5rem;
    margin-bottom: 0.85rem;
}

.hero-search input,
.hero-search button,
input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea,
.hero-search input,
.hero-search button {
    border: 1px solid var(--border);
    background: #fff;
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
    outline: none;
    border-color: #9ab6ea;
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.14);
}

.hero-search input {
    height: 3.25rem;
    font-size: 1rem;
}

button,
.hero-search button,
.btn.primary,
.button-primary {
    border: 0;
    color: #fff;
    font-weight: 600;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
    box-shadow: 0 12px 24px rgba(29, 78, 216, 0.25);
}

button:hover,
.btn.primary:hover,
.button-primary:hover,
.hero-search button:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

.hero-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.55rem;
}

.hero-stats div {
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.88);
    border-radius: var(--radius-sm);
    padding: 0.62rem 0.7rem;
}

.hero-stats strong {
    display: block;
    font-size: 1.25rem;
    color: #1d4ed8;
    line-height: 1.2;
}

.hero-stats span {
    color: var(--muted);
    font-size: 0.84rem;
}

.ad-slot {
    border: 1px dashed #b9cdef;
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, #f7faff, #eef5ff),
        repeating-linear-gradient(
            135deg,
            rgba(29, 78, 216, 0.06) 0,
            rgba(29, 78, 216, 0.06) 10px,
            transparent 10px,
            transparent 20px
        );
    padding: 0.92rem;
    min-height: 140px;
}

.ad-slot p {
    margin: 0 0 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    color: #61708a;
}

.ad-box {
    min-height: 96px;
    border: 1px solid #cadbf3;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.85);
    color: #5f6f8d;
    display: grid;
    place-items: center;
    text-align: center;
}

.ad-slot.inline {
    margin: 0.9rem 0 1.1rem;
}

.grade-grid,
.cards-grid,
.catalog-grid {
    display: grid;
    gap: 0.9rem;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.grade-card,
.content-card,
.detail-card,
.admin-card,
.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}

.grade-card {
    padding: 0.95rem;
    position: relative;
    overflow: hidden;
}

.grade-card::before {
    content: "";
    position: absolute;
    inset: 0 auto auto 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--primary-2));
}

.grade-card h3 {
    margin: 0.28rem 0 0.25rem;
    font-size: 1.15rem;
}

.grade-card small {
    color: var(--muted);
}

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

.content-card {
    overflow: hidden;
}

.content-card a {
    display: grid;
    grid-template-rows: auto 1fr;
    height: 100%;
}

.content-card .thumb {
    aspect-ratio: 16 / 11;
    background: linear-gradient(135deg, #d9e7ff, #ebf3ff);
    overflow: hidden;
}

.content-card .thumb img {
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.content-card:hover .thumb img {
    transform: scale(1.05);
}

.content-card .body {
    padding: 0.86rem;
    background: linear-gradient(180deg, #ffffff, #fbfdff);
}

.meta-top,
.stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.45rem;
}

.type {
    display: inline-flex;
    align-items: center;
    padding: 0.26rem 0.64rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #deebff, #eef5ff);
    color: #1d3f9c;
    border: 1px solid #cadbf4;
    font-size: 0.79rem;
    font-weight: 600;
}

.year {
    color: #425777;
    font-size: 0.83rem;
    font-weight: 600;
}

.content-card h3 {
    margin: 0.58rem 0 0.36rem;
    font-size: 1.08rem;
    line-height: 1.45;
}

.meta-line {
    margin: 0 0 0.3rem;
    color: #4f6381;
    font-size: 0.84rem;
    line-height: 1.55;
}

.content-card .body > p {
    margin: 0;
    color: var(--muted);
    line-height: 1.72;
    font-size: 0.92rem;
}

.stats {
    margin-top: 0.72rem;
    color: #4e6280;
    font-size: 0.84rem;
    border-top: 1px dashed #d7e3f3;
    padding-top: 0.56rem;
}

.stats bdi {
    font-weight: 700;
    color: #1f457f;
}

.subject-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.subject-chips a {
    border-radius: 999px;
    border: 1px solid #c7d9f2;
    background: linear-gradient(135deg, #f6faff, #edf4ff);
    color: #20459e;
    padding: 0.42rem 0.78rem;
    font-size: 0.88rem;
}

.subject-chips a:hover {
    background: linear-gradient(135deg, #e3edff, #edf5ff);
}

.sort-form {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.sort-form label {
    color: #4f6280;
    font-size: 0.88rem;
}

.filter-row,
.search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.62rem;
    margin-bottom: 1rem;
}

.search-filters {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    padding: 0.7rem;
    box-shadow: var(--shadow-sm);
}

.search-filters button,
.filter-row button {
    border: 0;
    border-radius: 12px;
    color: #fff;
    font-weight: 600;
    background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

.detail-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1rem;
    align-items: start;
}

.detail-main {
    display: grid;
    gap: 0.92rem;
}

.detail-side {
    display: grid;
    gap: 0.85rem;
    position: sticky;
    top: 110px;
}

.detail-card {
    padding: 1rem;
    border-radius: var(--radius-lg);
    background:
        radial-gradient(circle at 95% 10%, rgba(14, 165, 233, 0.08), transparent 30%),
        linear-gradient(180deg, #ffffff, #f8fbff);
}

.detail-card h1 {
    margin: 0.72rem 0 0.48rem;
    font-size: clamp(1.8rem, 4vw, 3rem);
    line-height: 1.22;
}

.detail-card p {
    margin: 0 0 1rem;
    color: #32445f;
    line-height: 1.9;
}

.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.95rem;
}

.detail-meta div {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.62rem 0.66rem;
}

.detail-meta strong {
    display: block;
    margin-bottom: 0.16rem;
    font-size: 0.84rem;
    color: #486089;
}

.detail-thumb {
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.download-row,
.action-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.share-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.82rem;
    color: #314564;
    font-size: 0.92rem;
}

.share-row a {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    padding: 0.36rem 0.72rem;
    font-size: 0.84rem;
}

.share-row a:hover {
    border-color: #9eb8e2;
    background: #f5f9ff;
}

.rating-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    padding: 0.72rem;
    margin-top: 0.78rem;
}

.rating-actions {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin: 0.46rem 0 0.38rem;
}

.star-btn {
    width: 2.05rem;
    height: 2.05rem;
    border: 1px solid #d7e2f3;
    border-radius: 10px;
    background: #fff;
    color: #9aa7bc;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
}

.star-btn:hover {
    border-color: #f4be2e;
    color: #f2ab00;
    background: #fff9e9;
}

.star-btn.active {
    border-color: #f2b005;
    color: #f0a500;
    background: #fff5d8;
}

.rating-box small {
    color: #526684;
    font-size: 0.85rem;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.76rem;
    color: #5d6e88;
    font-size: 0.9rem;
}

.breadcrumbs a:hover {
    color: #1d4ed8;
}

.breadcrumbs .sep {
    color: #98aac5;
}

.btn,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fff;
    padding: 0.6rem 0.9rem;
    font-weight: 500;
}

.button-secondary {
    background: #fff;
    color: #243b63;
}

.button-danger {
    background: #fff6f6;
    border-color: #f1c1c1;
    color: #b12020;
}

.empty {
    border: 1px dashed #c6d5eb;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    border-radius: var(--radius);
    padding: 1.18rem;
    text-align: center;
    grid-column: 1 / -1;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 0.42rem;
    margin-top: 1rem;
}

.pagination a,
.pagination span {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #fff;
    min-width: 2.1rem;
    text-align: center;
    padding: 0.44rem 0.68rem;
}

.pagination .active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(135deg, var(--primary), #2563eb);
}

.pagination .dots {
    border-style: dashed;
    color: #63779a;
}

.flash {
    margin: 0.6rem 0;
    border-radius: 12px;
    padding: 0.66rem 0.84rem;
    border: 1px solid;
    background: #fff;
}

.flash.success {
    border-color: #a9dfbd;
    color: #0e6b34;
}

.flash.error {
    border-color: #efbaba;
    color: #9f2020;
}

.site-footer {
    margin-top: 2rem;
    border-top: 1px solid rgba(197, 215, 240, 0.8);
    background:
        radial-gradient(circle at 12% -30%, rgba(29, 78, 216, 0.25), transparent 50%),
        linear-gradient(180deg, #11264c 0%, #0f2347 100%);
    color: #e8f0ff;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1.4fr 1fr 1fr;
    gap: 1rem;
    padding: 1.4rem 0 1.6rem;
}

.footer-grid h3 {
    margin: 0 0 0.55rem;
    font-size: 1.35rem;
}

.footer-grid p,
.footer-grid li {
    margin: 0;
    line-height: 1.75;
    color: #c5d5f2;
}

.footer-grid ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.36rem;
}

.footer-grid a:hover {
    color: #fff;
}

.admin-shell {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0.9rem;
    min-height: 0;
}

.admin-sidebar {
    border: 1px solid rgba(159, 183, 226, 0.5);
    border-radius: 16px;
    background:
        radial-gradient(circle at 12% 12%, rgba(255, 255, 255, 0.16), transparent 30%),
        linear-gradient(180deg, #15367b 0%, #0f2e6b 100%);
    color: #d7e7ff;
    padding: 1rem;
    box-shadow: var(--shadow-md);
}

.admin-sidebar h2 {
    margin: 0.28rem 0 0.95rem;
    font-size: 1.12rem;
    color: #fff;
}

.admin-sidebar nav {
    display: grid;
    gap: 0.46rem;
}

.admin-sidebar nav a {
    padding: 0.58rem 0.74rem;
    border: 1px solid rgba(163, 189, 235, 0.35);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: #dbe8ff;
    font-weight: 500;
}

.admin-sidebar nav a:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(191, 213, 246, 0.6);
    color: #fff;
}

.admin-sidebar nav a.active,
.admin-sidebar nav a[aria-current="page"] {
    background: rgba(255, 255, 255, 0.24);
    border-color: rgba(210, 227, 255, 0.8);
    color: #fff;
}

.admin-main {
    padding: 1rem;
    border: 1px solid rgba(182, 203, 235, 0.6);
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-sm);
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, #ffffff, #f6faff);
    border-radius: 12px;
    padding: 0.66rem 0.84rem;
    margin-bottom: 0.86rem;
}

.admin-topbar h1 {
    margin: 0;
    font-size: 1.03rem;
}

.admin-grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.62rem;
    margin-bottom: 0.9rem;
}

.admin-grid-stats article {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    padding: 0.72rem 0.82rem;
    position: relative;
    overflow: hidden;
}

.admin-grid-stats article::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 5px;
    background: linear-gradient(180deg, var(--primary), var(--primary-2));
}

.admin-grid-stats article:nth-child(2)::before {
    background: linear-gradient(180deg, #0ea5e9, #22c55e);
}

.admin-grid-stats article:nth-child(3)::before {
    background: linear-gradient(180deg, #4f46e5, #0ea5e9);
}

.admin-grid-stats article:nth-child(4)::before {
    background: linear-gradient(180deg, #f59e0b, #ef4444);
}

.admin-grid-stats article:nth-child(5)::before {
    background: linear-gradient(180deg, #16a34a, #0ea5e9);
}

.admin-grid-stats h3 {
    margin: 0;
    color: #5c6e87;
    font-size: 0.86rem;
    font-weight: 500;
}

.admin-grid-stats strong {
    display: block;
    margin-top: 0.2rem;
    color: #1d4ed8;
    font-size: 1.25rem;
}

.admin-card,
.panel {
    padding: 0.9rem;
    margin-bottom: 0.92rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    border-radius: 12px;
    overflow: hidden;
}

.admin-table th {
    background: #f3f7ff;
    color: #334866;
    font-size: 0.86rem;
    font-weight: 600;
}

.admin-table th,
.admin-table td {
    padding: 0.58rem;
    border-bottom: 1px solid #dbe6f7;
    text-align: right;
    vertical-align: top;
    font-size: 0.92rem;
}

.admin-table tbody tr:nth-child(even) {
    background: #fbfdff;
}

.admin-table tbody tr:hover {
    background: #f4f8ff;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap .admin-table {
    min-width: 700px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.34rem;
}

.table-actions a {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 0.26rem 0.52rem;
    font-size: 0.84rem;
}

.table-actions a:hover {
    border-color: #b5caeb;
    background: #f5f9ff;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.62rem;
}

label {
    display: grid;
    gap: 0.34rem;
    font-size: 0.9rem;
    color: #1c2d49;
}

textarea {
    min-height: 130px;
    resize: vertical;
}

.inline-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 0.82rem 0;
}

.inline-check {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.thumb-preview img {
    max-width: 200px;
    border-radius: 12px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.84rem;
}

.muted-note {
    margin: 0.24rem 0 0.72rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.muted-note a {
    color: #1d4ed8;
    text-decoration: underline;
}

.auth-wrap {
    padding: 2rem 0;
}

.auth-card {
    width: min(100%, 500px);
    margin: 0 auto;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
    padding: 1.1rem;
    box-shadow: var(--shadow-md);
}

.auth-card h1 {
    margin-top: 0.2rem;
}

.admin-footer {
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    color: var(--muted);
    padding: 0.74rem 0.86rem;
}

/* Legacy class compatibility */
.page-section {
    padding: 1.2rem 0;
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.section-heading h1,
.section-heading h2 {
    margin: 0;
}

.section-heading p {
    margin: 0.36rem 0 0;
    color: var(--muted);
}

.panel h2 {
    margin: 0 0 0.45rem;
}

.muted {
    color: var(--muted);
}

.footer-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 0.38rem;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 0.6rem;
    margin-bottom: 0.8rem;
}

/* Phase 2 visual refinement */
body {
    line-height: 1.75;
}

.page-main {
    padding-top: 1.55rem;
}

.section {
    padding: 1.65rem 0;
}

.section-head {
    gap: 1rem;
    margin-bottom: 1.15rem;
    align-items: flex-start;
}

.section-head h1::before,
.section-head h2::before {
    width: 38px;
    height: 6px;
    margin-bottom: 5px;
}

.section-title {
    display: grid;
    gap: 0.28rem;
}

.section-title p {
    margin: 0;
    color: #587099;
    font-size: 0.93rem;
    line-height: 1.75;
    max-width: 62ch;
}

.hero-section {
    padding-top: 0.8rem;
}

.hero-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(240px, 0.55fr);
    gap: 1.1rem;
    padding: 1.8rem;
    border-radius: 28px;
    border-color: #c4d8f5;
    background:
        radial-gradient(circle at 12% 8%, rgba(14, 165, 233, 0.14), transparent 44%),
        radial-gradient(circle at 90% 0%, rgba(29, 78, 216, 0.12), transparent 36%),
        linear-gradient(160deg, #ffffff 0%, #f3f8ff 55%, #ecf4ff 100%);
}

.hero-grid h1 {
    margin-top: 0.82rem;
    font-size: clamp(2rem, 4.6vw, 3.45rem);
    line-height: 1.18;
}

.hero-grid p {
    max-width: 64ch;
    margin-bottom: 1.2rem;
    color: #425777;
}

.hero-chip {
    border-color: #b5cef2;
    background: linear-gradient(135deg, #e5efff, #f0f7ff);
    color: #114193;
    font-weight: 600;
}

.hero-search {
    gap: 0.62rem;
    margin-bottom: 1rem;
}

.hero-search input {
    height: 3.4rem;
    border-radius: 14px;
    border-color: #bfd3f1;
    background: rgba(255, 255, 255, 0.96);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.hero-search button {
    min-width: 128px;
    border-radius: 14px;
}

.hero-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.65rem;
}

.hero-stats div {
    padding: 0.75rem 0.82rem;
    border-color: #cadaf3;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(247, 251, 255, 0.92));
}

.hero-stats strong {
    color: #123f97;
    font-size: 1.36rem;
}

.hero-stats span {
    color: #536783;
}

.ad-slot {
    border-color: #c8d9f2;
    border-style: solid;
    background:
        linear-gradient(180deg, #f8fbff, #eef4ff),
        repeating-linear-gradient(
            135deg,
            rgba(29, 78, 216, 0.04) 0,
            rgba(29, 78, 216, 0.04) 10px,
            transparent 10px,
            transparent 20px
        );
}

.ad-box {
    min-height: 124px;
}

.grade-grid {
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 0.85rem;
}

.cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(262px, 1fr));
    gap: 1rem;
}

.grade-card {
    padding: 1.02rem 0.95rem 0.94rem;
    border-radius: 16px;
    background:
        radial-gradient(circle at 100% 0, rgba(29, 78, 216, 0.09), transparent 36%),
        linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.grade-card h3 {
    margin-top: 0.36rem;
    font-size: 1.08rem;
}

.grade-card small {
    font-size: 0.85rem;
}

.content-card {
    border-radius: 16px;
    border-color: #c9dbf3;
    background: linear-gradient(180deg, #ffffff 0%, #fafdff 100%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.08);
}

.content-card a {
    grid-template-rows: auto 1fr;
}

.content-card .thumb {
    aspect-ratio: 16 / 10;
}

.content-card .body {
    padding: 0.95rem;
    display: grid;
    gap: 0.55rem;
}

.meta-top {
    align-items: flex-start;
}

.type {
    font-size: 0.76rem;
    letter-spacing: 0.01em;
}

.year {
    font-size: 0.8rem;
    color: #4a607e;
}

.content-card h3 {
    margin: 0;
    font-size: 1.07rem;
}

.meta-line {
    margin: 0;
}

.content-card .excerpt {
    margin: 0;
    color: #526784;
    font-size: 0.9rem;
    line-height: 1.72;
    min-height: 3.1em;
}

.card-foot {
    margin-top: auto;
    display: grid;
    gap: 0.48rem;
}

.stats {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
    justify-content: flex-start;
    gap: 0.75rem;
}

.stats span {
    display: inline-flex;
    align-items: center;
    gap: 0.24rem;
    border: 1px solid #d6e3f5;
    border-radius: 999px;
    background: #f7fbff;
    padding: 0.2rem 0.56rem;
    color: #4f6586;
    font-size: 0.8rem;
}

.card-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 0.24rem 0.62rem;
    border-radius: 999px;
    border: 1px solid #bdd2f3;
    background: linear-gradient(135deg, #edf5ff, #f5f9ff);
    color: #1a468f;
    font-size: 0.78rem;
    font-weight: 600;
}

.content-card:hover .card-cta {
    border-color: #9fbdf0;
    color: #103d95;
}

.catalog-intro {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 16px;
    border: 1px solid #c9dbf3;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.catalog-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(280px, 0.33fr);
    gap: 1rem;
    align-items: start;
}

.catalog-feed {
    min-width: 0;
}

.catalog-side {
    position: sticky;
    top: 108px;
}

.catalog-side .ad-slot.inline {
    margin: 0;
}

.subject-chips {
    gap: 0.55rem;
}

.subject-chips a {
    padding: 0.45rem 0.84rem;
    border-color: #bcd1f0;
    background: linear-gradient(135deg, #f2f8ff, #ebf3ff);
    font-weight: 500;
}

.sort-form select,
.filter-row select,
.search-filters select {
    min-height: 2.8rem;
}

.filter-row,
.search-filters {
    gap: 0.72rem;
    margin-bottom: 1.1rem;
}

.search-filters {
    padding: 0.84rem;
    border-radius: 16px;
    border-color: #c8dbf3;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.search-filters input {
    min-height: 2.8rem;
}

.detail-grid {
    gap: 1.2rem;
    grid-template-columns: minmax(0, 1.28fr) minmax(260px, 0.72fr);
}

.detail-card {
    padding: 1.2rem;
    border-color: #c6d9f3;
}

.detail-card h1 {
    font-size: clamp(1.75rem, 3.9vw, 2.7rem);
}

.detail-meta {
    gap: 0.64rem;
}

.detail-meta div {
    padding: 0.68rem 0.72rem;
    border-color: #d0e1f5;
}

.action-grid .btn {
    min-height: 2.8rem;
    border-radius: 12px;
}

.share-row {
    margin-top: 0.95rem;
}

.breadcrumbs {
    margin-bottom: 0.9rem;
    font-size: 0.88rem;
}

.admin-shell {
    gap: 1rem;
}

.admin-main {
    padding: 1.1rem;
    border-color: rgba(173, 196, 232, 0.7);
}

.admin-topbar {
    margin-bottom: 1rem;
    padding: 0.72rem 0.9rem;
}

.admin-grid-stats {
    gap: 0.75rem;
}

.admin-grid-stats article {
    padding: 0.82rem 0.88rem;
}

.admin-card,
.panel {
    border-radius: 16px;
    padding: 1rem;
}

.admin-table th,
.admin-table td {
    padding: 0.66rem 0.62rem;
}

.pagination {
    gap: 0.38rem;
    margin-top: 1.1rem;
}

.pagination a,
.pagination span {
    min-width: 2.05rem;
    padding: 0.42rem 0.62rem;
    font-size: 0.86rem;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid #7ba2e8;
    outline-offset: 1px;
}

/* Phase 2.1 typography and RTL readability tuning */
body {
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: "kern" 1;
}

h1,
h2,
h3,
.section-head h1,
.section-head h2,
.detail-card h1,
.content-card h3 {
    letter-spacing: 0;
    text-wrap: balance;
}

p,
.meta-line,
.content-card .excerpt,
.detail-card p,
.section-title p,
label {
    text-wrap: pretty;
}

.hero-grid p,
.section-title p,
.detail-card p {
    max-width: 66ch;
}

.hero-stats strong,
.stats bdi,
.detail-meta span,
.pagination a,
.pagination span {
    font-variant-numeric: tabular-nums;
}

.main-nav a,
.grade-strip a,
.stage-dropdown > summary,
.stage-dropdown-menu a,
.subject-chips a,
.btn,
button,
select,
input {
    line-height: 1.35;
}

.content-card .body {
    gap: 0.5rem;
}

.content-card h3 {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.meta-line {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.content-card .excerpt {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    min-height: 3.25em;
}

.card-foot {
    margin-top: auto;
    padding-top: 0.48rem;
    border-top: 1px dashed #dbe6f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.stats {
    flex-wrap: wrap;
    gap: 0.45rem;
}

.card-cta {
    flex-shrink: 0;
    white-space: nowrap;
}

.catalog-intro {
    padding: 1.05rem;
}

.catalog-intro .section-head {
    margin-bottom: 0.8rem;
}

.sort-form {
    padding: 0.34rem 0.42rem;
    border: 1px solid #cfdef4;
    border-radius: 12px;
    background: linear-gradient(180deg, #ffffff, #f7fbff);
}

.sort-form label {
    font-weight: 600;
}

.sort-form select {
    min-width: 152px;
    border-color: #bfd3f2;
    background: #ffffff;
}

.search-filters {
    align-items: end;
}

.search-filters button {
    min-height: 2.8rem;
    padding-inline: 1.2rem;
    white-space: nowrap;
}

.breadcrumbs {
    padding: 0.36rem 0.62rem;
    border: 1px solid #d5e2f5;
    border-radius: 999px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    width: fit-content;
    max-width: 100%;
}

.breadcrumbs .sep {
    margin-inline: 0.15rem;
}

.breadcrumbs .crumb {
    color: #425a7e;
}

.breadcrumbs .crumb.current {
    color: #172d54;
    font-weight: 600;
}

.detail-card p {
    margin-bottom: 1.08rem;
}

.detail-meta span {
    color: #213554;
    font-weight: 600;
}

.rating-box small {
    line-height: 1.6;
}

@media (min-width: 981px) {
    .search-filters {
        grid-template-columns: minmax(260px, 1.9fr) repeat(4, minmax(140px, 1fr)) auto;
    }
}

/* Subtle entrance motion */
@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero-grid,
.grade-card,
.content-card,
.detail-card,
.admin-card,
.admin-grid-stats article {
    animation: fade-up 0.45s ease both;
}

.content-card:nth-child(2),
.grade-card:nth-child(2),
.admin-grid-stats article:nth-child(2) {
    animation-delay: 0.04s;
}

.content-card:nth-child(3),
.grade-card:nth-child(3),
.admin-grid-stats article:nth-child(3) {
    animation-delay: 0.08s;
}

.content-card:nth-child(4),
.grade-card:nth-child(4),
.admin-grid-stats article:nth-child(4) {
    animation-delay: 0.12s;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 1120px) {
    .hero-grid {
        grid-template-columns: 1fr;
    }

    .catalog-stage {
        grid-template-columns: 1fr;
    }

    .catalog-side {
        position: static;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-side {
        position: static;
    }
}

@media (max-width: 980px) {
    .footer-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .admin-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .menu-toggle {
        display: inline-flex;
    }

    .main-nav {
        display: none;
        position: absolute;
        top: 100%;
        right: 0.75rem;
        left: 0.75rem;
        flex-direction: column;
        gap: 0.3rem;
        background: #fff;
        border: 1px solid var(--border);
        border-radius: 12px;
        padding: 0.52rem;
        box-shadow: var(--shadow-md);
    }

    .main-nav.open {
        display: flex;
    }

    .main-nav a {
        border-radius: 10px;
    }

    .section-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .sort-form {
        justify-content: space-between;
        width: 100%;
    }

    .sort-form select {
        flex: 1;
    }

    .hero-grid {
        padding: 1rem;
    }

    .hero-search {
        grid-template-columns: 1fr;
    }

    .hero-search button {
        width: 100%;
    }

    .hero-stats {
        grid-template-columns: 1fr;
    }

    .grade-stage-nav {
        display: grid;
        grid-template-columns: 1fr;
    }

    .stage-dropdown {
        width: 100%;
    }

    .stage-dropdown > summary {
        border-radius: 12px;
        width: 100%;
    }

    .stage-dropdown-menu {
        position: static;
        margin-top: 0.45rem;
        min-width: 100%;
    }

    .breadcrumbs {
        width: 100%;
        border-radius: 12px;
    }

    .card-foot {
        flex-direction: column;
        align-items: flex-start;
    }

    .card-cta {
        align-self: flex-end;
    }
}

@media (max-width: 560px) {
    .container {
        width: min(calc(100% - 1rem), var(--container));
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .section-head h1,
    .section-head h2 {
        font-size: 1.38rem;
    }

    .content-card h3 {
        font-size: 1rem;
    }

    .detail-card h1 {
        font-size: 1.8rem;
    }

    .action-grid .btn {
        width: 100%;
    }

    .share-row {
        gap: 0.34rem;
    }

    .share-row a {
        padding: 0.32rem 0.58rem;
    }
}
