:root {
    --bg: #121212;
    --text: #e0e0e0;
    --text-muted: #a0a0a0;
    --border: #333333;
    --primary: #4da3ff;
    --primary-hover: #3388ee;
    --card-bg: #1e1e1e;
    --radius: 8px;
    --font: 'Inter', 'Cairo', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 16px;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s ease; }

.wrap {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    padding: 0 16px;
}

.icon {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
    flex-shrink: 0;
    margin-right: 8px;
    display: inline-block;
    vertical-align: middle;
}
[dir="rtl"] .icon {
    margin-right: 0;
    margin-left: 8px;
}

header.site {
    border-bottom: 1px solid var(--border);
    background: var(--bg);
    position: sticky;
    top: 0;
    z-index: 100;
}

.brandbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.brandbar img { width: 40px; height: 40px; border-radius: var(--radius); }
.brandname { font-weight: 700; font-size: 1.2rem; letter-spacing: -0.5px; }
.brandsub { font-size: 0.8rem; color: var(--text-muted); }

form.lang { display: flex; align-items: center; gap: 4px; }

form.lang label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
form.lang .icon { color: var(--text-muted); margin: 0; }

select {
    padding: 8px 12px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    cursor: pointer;
    min-height: 44px;
}

nav.main {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    position: relative;
}

nav.main ul {
    display: flex;
    list-style: none;
    padding: 0 16px;
    gap: 20px;
}

nav.main a, nav.main summary {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    color: var(--text-muted);
    font-weight: 500;
    position: relative;
}

nav.main a[aria-current="page"]::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: var(--primary);
    border-radius: 3px 3px 0 0;
}

nav.main details {
    position: static;
}

nav.main summary {
    cursor: pointer;
    list-style: none;
}

nav.main summary::-webkit-details-marker { display: none; }
nav.main details[open] summary { color: var(--primary); }

nav.main .nav-drop-list {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 10px 15px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    padding: 8px 16px;
    z-index: 1000;
}

nav.main .nav-drop-list a {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    width: 100%;
    display: flex;
    align-items: center;
}

nav.main .nav-drop-list a:last-child { border-bottom: none; }
nav.main .nav-drop-list a[aria-current="page"] { color: var(--primary); font-weight: 700; }
nav.main .nav-drop-list a[aria-current="page"]::after { display: none; }

main { padding: 32px 0; }
h1 { font-size: 2rem; margin-bottom: 16px; line-height: 1.2; letter-spacing: -0.5px; }
h2 { font-size: 1.4rem; margin: 32px 0 16px; display: flex; align-items: center; }
.lead { font-size: 1.1rem; color: var(--text-muted); margin-bottom: 24px; }

.topic-heading {
    margin-top: 48px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    color: var(--primary);
    text-transform: capitalize;
}

.tag {
    display: inline-block;
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary);
}

.crumbs { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 16px; }
.crumbs span { margin: 0 8px; }
.meta { display: flex; align-items: center; font-size: 0.9rem; color: var(--text-muted); margin-top: 24px; gap: 6px; }

.services { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.services li {
    display: flex; gap: 12px; align-items: flex-start; padding: 16px;
    background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
}
.services .n { font-weight: 700; color: var(--primary); }
.services strong { display: flex; align-items: center; }

.cardlist { list-style: none; display: grid; grid-template-columns: 1fr; gap: 16px; margin: 24px 0; }
.cardlist li {
    padding: 20px; background: var(--card-bg); border: 1px solid var(--border);
    border-radius: var(--radius); transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.cardlist li a { font-size: 1.2rem; font-weight: 700; display: block; margin-bottom: 8px; }
.cardlist li p { color: var(--text-muted); font-size: 0.95rem; }

.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 24px; }
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border-radius: var(--radius); font-weight: 600;
    font-family: var(--font); cursor: pointer; border: none; min-height: 48px; font-size: 1rem;
}
.btn.primary { background: var(--primary); color: #121212; font-weight: 700; }
.btn.secondary { background: transparent; border: 1px solid var(--border); color: var(--text); }

.cardlist li:active, .btn:active, nav.main a:active, nav.main summary:active {
    transform: scale(0.97); opacity: 0.8;
}

footer.site { border-top: 1px solid var(--border); padding: 32px 0; margin-top: 48px; font-size: 0.9rem; color: var(--text-muted); }
.cols { display: grid; grid-template-columns: 1fr; gap: 24px; margin-bottom: 32px; }
footer nav h2 { font-size: 1rem; margin: 0 0 12px; color: var(--text); display: block; }
footer nav ul { list-style: none; }
footer nav li { margin-bottom: 8px; }
footer nav a { color: var(--text-muted); display: inline-flex; align-items: center; }
.bottom { text-align: center; border-top: 1px solid var(--border); padding-top: 24px; display: flex; justify-content: center; align-items: center; gap: 6px; }
.bottom .icon { width: 16px !important; height: 16px !important; min-width: 16px !important; min-height: 16px !important; }

body::before {
    content: ""; position: fixed; top: env(safe-area-inset-top, 0); left: 0;
    width: 0%; height: 3px; background: var(--primary); z-index: 9999;
    transition: width 0s, opacity 0.3s ease; opacity: 0;
}
body.htmx-request::before { width: 80%; transition: width 1.5s cubic-bezier(0.1, 0.4, 1, 1), opacity 0s; opacity: 1; }
body.htmx-settling::before { width: 100%; opacity: 0; }

.htmx-swapping main { opacity: 0; transition: opacity 150ms ease-out; }
.htmx-settling main { opacity: 0; }
main { animation: slideUp 0.3s ease-out forwards; will-change: transform, opacity; }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 768px) {
    .wrap { padding: 0 24px; }
    
    form.lang label {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        overflow: visible;
        clip: auto;
        white-space: normal;
        display: inline-flex;
        align-items: center;
    }

    @media (hover: hover) {
        nav.main a:hover, nav.main summary:hover { color: var(--primary); }
        .cardlist li:hover { transform: translateY(-4px); box-shadow: 0 12px 24px rgba(0,0,0,0.08); border-color: var(--primary); }
        .btn.primary:hover { background: var(--primary-hover); }
        .btn.secondary:hover { border-color: var(--primary); color: var(--primary); }
        footer a:hover { color: var(--primary); }
    }

    .cardlist { grid-template-columns: 1fr 1fr; }
    .cols { grid-template-columns: 2fr 1fr 1fr; }
    .brandbar { flex-wrap: nowrap; }
    h1 { font-size: 2.5rem; }
}