:root {
    --bg: #f7f4ee;
    --surface: #ffffff;
    --surface-soft: #fbfaf7;
    --text: #202124;
    --muted: #6c675f;
    --line: #e7e0d5;
    --primary: #1f6f5b;
    --primary-dark: #155344;
    --accent: #b64e37;
    --shadow: 0 18px 45px rgba(43, 37, 29, .08);
    --radius: 8px;
    font-family: "Tajawal", Tahoma, Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    line-height: 1.8;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
textarea,
select {
    font: inherit;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 16px clamp(16px, 5vw, 72px);
    background: rgba(247, 244, 238, .92);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--primary-dark);
    font-weight: 800;
    font-size: 20px;
}

.brand-mark {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    background:
        linear-gradient(rgba(255, 253, 247, .72), rgba(251, 243, 229, .82)),
        url("../images/paper-texture.jpg") center / cover,
        #fbf3e5;
    color: var(--primary-dark);
    border: 2px solid rgba(31, 111, 91, .34);
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(31, 111, 91, .10);
    font-size: 23px;
    line-height: 1;
}

.site-nav,
.admin-sidebar nav {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.site-nav a,
.admin-sidebar nav a {
    padding: 8px 12px;
    color: var(--muted);
    border-radius: 8px;
}

.site-nav a:hover,
.admin-sidebar nav a:hover {
    color: var(--primary-dark);
    background: #edf5f1;
}

main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
}

.hero {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(280px, .9fr);
    align-items: end;
    gap: 32px;
    padding: clamp(42px, 8vw, 86px) 0 28px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--accent);
    font-weight: 700;
}

.hero h1,
.page-title h1,
.admin-top h1 {
    margin: 0;
    font-size: clamp(34px, 6vw, 64px);
    line-height: 1.25;
    letter-spacing: 0;
}

.hero p,
.page-title p,
.admin-top p,
.section-head p {
    margin: 8px 0 0;
    color: var(--muted);
}

.search-box,
.quote-card,
.directory-item,
.admin-panel,
.stats-grid div,
.login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.search-box {
    padding: 22px;
}

.search-box label,
.admin-form label,
.login-card label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

.search-box div {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 11px 12px;
    background: var(--surface-soft);
    color: var(--text);
    outline: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(31, 111, 91, .12);
}

button,
.button,
.quote-actions a,
.quote-actions button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 16px;
    border: 0;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

button:hover,
.button:hover,
.quote-actions a:hover,
.quote-actions button:hover {
    background: var(--primary-dark);
}

.secondary-button {
    background: #eef6f2;
    color: var(--primary-dark);
}

.secondary-button:hover {
    color: #fff;
}

.chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    padding: 4px 0 26px;
}

.chips a,
.topic-pill {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 5px 12px;
    background: #fff7ed;
    color: #7a3d23;
    border: 1px solid #f0d8c3;
    border-radius: 999px;
    font-size: 14px;
}

.section-head,
.page-title,
.admin-top {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    padding: 30px 0 18px;
}

.section-head h2,
.admin-panel h2 {
    margin: 0;
    font-size: 26px;
}

.quote-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    padding-bottom: 34px;
}

.quote-card {
    position: relative;
    overflow: hidden;
    display: flex;
    min-height: 260px;
    flex-direction: column;
    gap: 18px;
    padding: 22px;
    background:
        linear-gradient(rgba(255, 253, 247, .80), rgba(251, 243, 229, .86)),
        url("../images/paper-texture.jpg") center / cover,
        radial-gradient(circle at 18% 16%, rgba(255, 255, 255, .78), transparent 24%),
        radial-gradient(circle at 88% 10%, rgba(255, 247, 221, .62), transparent 28%),
        linear-gradient(135deg, #fffdf7 0%, #fbf3e5 100%);
}

.quote-card::before,
.single-quote-card::before {
    content: "”";
    position: absolute;
    left: 20px;
    top: 6px;
    color: rgba(31, 111, 91, .08);
    font-size: 118px;
    font-weight: 800;
    line-height: 1;
    pointer-events: none;
}

.quote-card > * {
    position: relative;
    z-index: 1;
}

.quote-card-link {
    display: block;
    flex: 1;
}

.quote-text {
    margin: 0;
    flex: 1;
    font-size: 20px;
    color: #28231d;
}

.single-quote {
    display: grid;
    place-items: center;
    padding: clamp(36px, 8vw, 78px) 0 24px;
}

.single-quote-card {
    position: relative;
    overflow: hidden;
    width: min(820px, 100%);
    padding: clamp(24px, 5vw, 46px);
    background:
        linear-gradient(rgba(255, 253, 247, .76), rgba(251, 243, 229, .84)),
        url("../images/paper-texture.jpg") center / cover,
        radial-gradient(circle at 12% 12%, rgba(255, 255, 255, .82), transparent 26%),
        radial-gradient(circle at 92% 8%, rgba(255, 247, 221, .68), transparent 30%),
        linear-gradient(135deg, #fffdf7 0%, #fbf3e5 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.single-quote-card > * {
    position: relative;
    z-index: 1;
}

.single-quote-card .quote-text {
    font-size: clamp(28px, 5vw, 44px);
    line-height: 1.7;
}

.quote-meta,
.quote-actions {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    flex-wrap: wrap;
}

.quote-meta a:first-child {
    color: var(--primary-dark);
    font-weight: 800;
}

.quote-author {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.quote-author .mini-avatar {
    width: 34px;
    height: 34px;
    font-size: 15px;
}

.quote-actions button,
.quote-actions a {
    min-height: 36px;
    padding: 7px 12px;
    background: #eef6f2;
    color: var(--primary-dark);
    font-size: 14px;
}

.quote-actions [data-image-quote] {
    background: #fff7ed;
    color: #7a3d23;
}

.share-menu {
    display: flex;
    width: 100%;
    gap: 8px;
    flex-wrap: wrap;
    direction: ltr;
    padding-top: 2px;
}

.share-menu[hidden] {
    display: none;
}

.share-menu.is-open {
    display: flex;
}

.share-menu a {
    min-height: 34px;
    padding: 0;
    background: #fff7ed;
    color: #7a3d23;
    border: 1px solid #f0d8c3;
}

.share-menu .share-icon {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    font-weight: 800;
    line-height: 1;
}

.share-icon svg {
    width: 17px;
    height: 17px;
    fill: currentColor;
}

.share-x {
    background: #111 !important;
    color: #fff !important;
    border-color: #111 !important;
}

.share-facebook {
    background: #eaf1ff !important;
    color: #1877f2 !important;
    border-color: #cfe0ff !important;
}

.share-whatsapp {
    background: #e9fbf0 !important;
    color: #128c4a !important;
    border-color: #c8efd8 !important;
}

.share-telegram {
    background: #e9f7ff !important;
    color: #218acb !important;
    border-color: #c9eaff !important;
}

.directory-grid,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    padding-bottom: 40px;
}

.directory-item,
.stats-grid div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px;
}

.directory-author {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.mini-avatar,
.author-avatar {
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    overflow: hidden;
    background: #edf5f1;
    color: var(--primary-dark);
    font-weight: 800;
}

.mini-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
}

.mini-avatar img,
.author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.author-profile {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 22px;
}

.author-avatar {
    width: 108px;
    height: 108px;
    border-radius: 50%;
    border: 1px solid var(--line);
    font-size: 44px;
}

.author-bio {
    max-width: 760px;
    color: var(--text) !important;
}

.directory-item span,
.stats-grid strong {
    font-weight: 800;
    font-size: 22px;
}

.directory-item small,
.stats-grid span,
.muted {
    color: var(--muted);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 6px 0 42px;
}

.pagination a {
    display: grid;
    width: 40px;
    height: 40px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.pagination a.active {
    background: var(--primary);
    color: #fff;
}

.empty-state,
.alert {
    padding: 16px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
}

.alert.success {
    border-color: #b9dfc9;
    background: #eefaf2;
    color: #21613b;
}

.alert.error {
    border-color: #f0b6aa;
    background: #fff1ed;
    color: #8a2d20;
}

.site-footer {
    width: min(1180px, calc(100% - 32px));
    margin: 20px auto 0;
    padding: 24px 0 36px;
    color: var(--muted);
    border-top: 1px solid var(--line);
}

.footer-links {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.footer-links a {
    color: var(--primary-dark);
    font-weight: 700;
}

.content-page {
    max-width: 840px;
    margin-bottom: 46px;
    padding: 26px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.content-page h2 {
    margin: 24px 0 8px;
    font-size: 22px;
}

.content-page p {
    margin: 0 0 14px;
    color: #332d25;
}

.content-page a {
    color: var(--primary-dark);
    font-weight: 800;
}

.admin-body {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    min-height: 100vh;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 20px;
    background: #fff;
    border-left: 1px solid var(--line);
}

.admin-sidebar nav {
    align-items: stretch;
    flex-direction: column;
    margin-top: 26px;
}

.admin-main {
    width: min(1100px, calc(100% - 32px));
    padding-bottom: 40px;
}

.admin-panel {
    margin-bottom: 18px;
    padding: 22px;
}

.admin-form {
    display: grid;
    gap: 16px;
}

.admin-filters {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(160px, 1fr)) auto;
    gap: 12px;
    align-items: end;
    margin: 16px 0;
}

.admin-filters label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.compact-filters {
    grid-template-columns: minmax(220px, 1.5fr) repeat(3, minmax(150px, 1fr)) auto;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.field-stack {
    display: grid;
    gap: 12px;
    align-content: start;
}

.checkbox {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
}

.checkbox input {
    width: auto;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: 14px;
}

.actions-cell {
    display: flex;
    gap: 8px;
    align-items: center;
}

.actions-cell button,
.actions-cell a {
    min-height: 34px;
    padding: 6px 10px;
    border-radius: 8px;
    background: #f3f0ea;
    color: var(--text);
}

.login-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 18px;
}

.login-card {
    display: grid;
    width: min(420px, 100%);
    gap: 14px;
    padding: 26px;
}

.login-card h1 {
    margin: 0;
}

.import-details {
    color: var(--accent);
}

@media (max-width: 900px) {
    .hero,
    .quote-grid,
    .directory-grid,
    .stats-grid,
    .form-grid,
    .admin-filters,
    .admin-body {
        grid-template-columns: 1fr;
    }

    .admin-sidebar {
        position: static;
        height: auto;
        border-left: 0;
        border-bottom: 1px solid var(--line);
    }

    .admin-sidebar nav {
        flex-direction: row;
    }
}

@media (max-width: 620px) {
    .site-header,
    .section-head,
    .page-title,
    .admin-top {
        align-items: stretch;
        flex-direction: column;
    }

    .site-nav {
        width: 100%;
    }

    .site-nav a {
        flex: 1;
        text-align: center;
    }

    .search-box div,
    .quote-meta,
    .quote-actions,
    .directory-item,
    .author-profile {
        align-items: stretch;
        flex-direction: column;
    }

    .author-profile {
        display: flex;
    }

    .hero h1,
    .page-title h1,
    .admin-top h1 {
        font-size: 34px;
    }

    .quote-card {
        min-height: 220px;
    }
}
