:root {
    --camel: #d4a76a;
    --sand: #e6b17a;
    --cream: #fdf5e6;
    --paper: #fffef9;
    --ink: #3e2723;
    --text: #4a4a4a;
    --heading: #8b4513;
    --line: rgba(62, 39, 35, 0.14);
    --ok: #2e7d32;
    --danger: #c62828;
    --muted: #6b5b4f;
    --tap: 44px;
    --space: 1rem;
    --wrap: 1100px;
}

@font-face {
    font-family: Poppins;
    src: url("../fonts/poppins-400.woff2") format("woff2");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: Poppins;
    src: url("../fonts/poppins-600.woff2") format("woff2");
    font-weight: 600;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: Poppins;
    src: url("../fonts/poppins-700.woff2") format("woff2");
    font-weight: 700;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: "Kanz al Lulu";
    src: url("../KanzalLulu-Regular.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
    unicode-range: U+0600-06FF, U+0750-077F, U+0870-089F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}

* { box-sizing: border-box; }

html, body { overflow-x: clip; }

body {
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(900px 420px at 0% -10%, rgba(212, 167, 106, 0.45), transparent 55%),
        var(--cream);
    font-family: Poppins, "Kanz al Lulu", sans-serif;
    font-size: 1rem;
    line-height: 1.5;
    min-height: 100vh;
}

img, audio, video { max-width: 100%; height: auto; }
audio { width: 100%; display: block; }

a { color: var(--heading); }
a:hover { color: var(--ink); }

h1, h2, h3 { color: var(--heading); font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
h1 { font-size: 1.45rem; margin: 0 0 0.4rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.35rem; }

.ar {
    font-family: "Kanz al Lulu", Poppins, "Traditional Arabic", "Noto Naskh Arabic", "Scheherazade New", serif;
    font-size: 1.15em;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(90deg, var(--camel), var(--sand));
    color: var(--ink);
    border-bottom: 1px solid rgba(62, 39, 35, 0.12);
    padding-top: env(safe-area-inset-top, 0px);
}

.topbar-in {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 0.45rem 0.85rem;
    display: flex;
    gap: 0.5rem 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.brand {
    color: var(--ink);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.04em;
    font-size: 1.15rem;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    margin-right: auto;
}

.menu-btn {
    min-height: var(--tap);
    min-width: var(--tap);
    border: 1px solid rgba(62, 39, 35, 0.25);
    background: rgba(255, 255, 255, 0.45);
    color: var(--ink);
    border-radius: 0.45rem;
    font: inherit;
    font-weight: 700;
    padding: 0 0.85rem;
    cursor: pointer;
}

.nav {
    display: none;
    flex: 1 0 100%;
    flex-direction: column;
    gap: 0.15rem;
    padding-bottom: 0.4rem;
}
.nav.is-open { display: flex; }
.nav a, .subnav a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0 0.15rem;
    border-bottom: 2px solid transparent;
}
.nav a.is-on, .subnav a.is-on { border-bottom-color: var(--ink); }

.who {
    display: flex;
    flex-wrap: wrap;
    gap: 0.15rem 0.7rem;
    align-items: center;
    justify-content: flex-end;
    min-width: 0;
}
.who a, .who .linkish {
    color: var(--ink);
    font-weight: 600;
    min-height: var(--tap);
    display: inline-flex;
    align-items: center;
}
.who-name {
    max-width: 7.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.2rem;
    min-height: 1.2rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    background: var(--ink);
    color: #fff;
    font-size: 0.75rem;
}

.wrap {
    max-width: var(--wrap);
    margin: 0 auto;
    padding: 1rem 0.85rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
    min-width: 0;
}
.page-head { margin-bottom: 1rem; }
.page-head p, .lead { margin: 0; color: var(--muted); }
.measure { max-width: 40rem; }
.section { margin-top: 1.6rem; }

.foot {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    padding: 0 1rem calc(1.25rem + env(safe-area-inset-bottom, 0px));
}

.flash {
    padding: 0.7rem 0.9rem;
    border-radius: 0.5rem;
    margin: 0 0 1rem;
}
.flash-ok { background: #e8f5e9; color: var(--ok); }
.flash-err { background: #fdecea; color: var(--danger); }

.btn, button.btn, a.btn, .icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    border-radius: 0.45rem;
    padding: 0.45rem 0.8rem;
    min-height: var(--tap);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    text-align: center;
}
.btn-primary { background: var(--camel); border-color: transparent; }
.btn-danger { background: var(--danger); border-color: transparent; color: #fff; }
.btn.is-on, .icon-btn.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
button.linkish {
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.login-card, .card, .filters, .stack, .queue-card, .empty {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0.7rem;
}

.is-bare {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 1rem;
}
.is-bare .wrap { width: min(440px, 100%); min-width: 0; padding: 0; }
.login-card {
    width: 100%;
    margin: 0 auto;
    padding: 1.35rem 1.1rem 1.4rem;
}
.login-card .btn-primary { width: 100%; margin-top: 0.9rem; }
.eyebrow { margin: 0; letter-spacing: 0.08em; text-transform: uppercase; font-size: 0.75rem; color: var(--muted); }

label { display: block; font-weight: 600; margin: 0.75rem 0 0.3rem; color: var(--ink); }
.sr {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
input, select, textarea {
    width: 100%;
    max-width: 100%;
    border: 1px solid rgba(62, 39, 35, 0.18);
    background: #fff;
    color: var(--ink);
    border-radius: 0.7rem;
    padding: 0.55rem 0.8rem;
    min-height: var(--tap);
    font: inherit;
    font-size: 16px;
}
input:focus-visible, textarea:focus-visible, select:focus-visible {
    outline: none;
    border-color: var(--heading);
    box-shadow: 0 0 0 3px rgba(212, 167, 106, 0.45);
}
textarea { min-height: 6rem; resize: vertical; }
select[multiple] { min-height: 9rem; }
.stack { padding: 1rem; max-width: 720px; min-width: 0; }
.stack > .btn, .stack > button.btn { margin-top: 0.9rem; }

.field-row { display: grid; grid-template-columns: 1fr; gap: 0; }

.finder { display: contents; }
.finder-bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    grid-column: 1 / -1;
    margin: 0 0 1rem;
    padding: 0.28rem 0.28rem 0.28rem 0.95rem;
    background:
        linear-gradient(180deg, #fffef9, #fbf3e4);
    border: 1px solid rgba(62, 39, 35, 0.2);
    border-radius: 999px;
    box-shadow: 0 14px 34px rgba(62, 39, 35, 0.08);
}
.finder-bar:focus-within {
    border-color: var(--heading);
    box-shadow: 0 0 0 3px rgba(212, 167, 106, 0.45);
}
.finder-mark {
    width: 0.62rem;
    height: 0.62rem;
    flex: 0 0 auto;
    background: var(--heading);
    transform: rotate(45deg);
}
.finder-bar input {
    flex: 1 1 auto;
    width: auto;
    min-width: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    padding-left: 0.35rem;
}
.finder-bar input:focus-visible { outline: none; box-shadow: none; border-color: transparent; }
.finder-bar .btn { border-radius: 999px; padding-inline: 1.15rem; white-space: nowrap; }

.combo { position: relative; }
select.combo-native {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
.combo::after {
    content: "";
    position: absolute;
    right: 1rem;
    top: 0.95rem;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--heading);
    border-bottom: 2px solid var(--heading);
    transform: rotate(45deg);
    pointer-events: none;
}
.combo.is-multi::after { content: none; }
.combo-input { padding-right: 2rem; }
.combo.is-multi .combo-input { padding-right: 0.8rem; }
.combo-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.4rem; }
.combo-chips:empty { display: none; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 100%;
    min-height: 2rem;
    padding: 0.15rem 0.35rem 0.15rem 0.65rem;
    border-radius: 999px;
    background: rgba(212, 167, 106, 0.35);
    color: var(--ink);
    font-size: 0.92rem;
}
.chip span { overflow-wrap: anywhere; }
.chip button {
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    min-width: 1.8rem;
    min-height: 1.8rem;
    border-radius: 999px;
    cursor: pointer;
}
.combo-list {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 0.3rem);
    max-height: min(16rem, 50vh);
    overflow: auto;
    margin: 0;
    padding: 0.3rem;
    list-style: none;
    background: var(--paper);
    border: 1px solid rgba(62, 39, 35, 0.18);
    border-radius: 0.8rem;
    box-shadow: 0 16px 36px rgba(62, 39, 35, 0.14);
}
.combo-list button {
    width: 100%;
    text-align: start;
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    min-height: var(--tap);
    border-radius: 0.5rem;
    padding: 0.35rem 0.7rem;
    cursor: pointer;
}
.combo-list button.is-active,
.combo-list button[aria-selected="true"] { background: rgba(212, 167, 106, 0.38); }
.combo-list .combo-empty { padding: 0.6rem 0.7rem; color: var(--muted); }
.combo.is-invalid .combo-input { border-color: var(--danger); }

.filters-panel { margin-bottom: 0.85rem; }
.filters-panel > summary {
    min-height: var(--tap);
    display: flex;
    align-items: center;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    list-style: none;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0 0.9rem;
}
.filters-panel > summary::-webkit-details-marker { display: none; }
.filters-panel[open] > summary { border-radius: 0.7rem 0.7rem 0 0; border-bottom: 0; }
.filters-panel[open] > .filters { border-top: 0; border-radius: 0 0 0.7rem 0.7rem; }
.filters { padding: 0.35rem 0.9rem 0.9rem; }
.filters-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.8rem; }
.filters-actions .btn { width: 100%; }

.browse { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; min-width: 0; }
.results { min-width: 0; }

.cards { display: grid; grid-template-columns: 1fr; gap: 0.85rem; }
.card, .queue-card {
    padding: 0.9rem 0.9rem 1rem;
    min-width: 0;
    box-shadow: 0 10px 28px rgba(62, 39, 35, 0.05);
    border-top: 3px solid var(--camel);
}
.card h2 { font-size: 1.05rem; }
.card h2 a, .queue-card h2 a { text-decoration: none; }
.card-top, .row-actions, .share-row, .subnav { display: flex; gap: 0.45rem; flex-wrap: wrap; align-items: center; }
.card-top { margin-bottom: 0.35rem; }
.cat, .pill, .level, .status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    min-height: 1.6rem;
    font-size: 0.78rem;
    font-weight: 700;
}
.cat, .pill { background: rgba(212, 167, 106, 0.28); color: var(--ink); }
.level { background: var(--ink); color: #fff; }
.star { color: var(--heading); font-weight: 700; font-size: 0.8rem; }
.status-pending { background: #fff3e0; color: #8a4b08; }
.status-approved { background: #e8f5e9; color: var(--ok); }
.status-rejected { background: #fdecea; color: var(--danger); }
.by, .meta, .hint { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.by { margin: 0.2rem 0; }
.pills { display: flex; flex-wrap: wrap; gap: 0.3rem; margin: 0.45rem 0; }

.engage { display: flex; flex-wrap: nowrap; gap: 0.35rem; margin-top: 0.7rem; min-width: 0; }
.engage form { display: contents; }
.engage .icon-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.3rem 0.3rem;
    font-size: 0.78rem;
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
}
.net { font-weight: 700; color: var(--ink); min-height: var(--tap); display: inline-flex; align-items: center; padding: 0 0.2rem; flex: 0 0 auto; }

.detail { max-width: 760px; min-width: 0; }
.prose { margin: 0.8rem 0; overflow-wrap: anywhere; }
.preview img, .lazy-img img { width: 100%; max-height: 70vh; object-fit: contain; border-radius: 0.5rem; border: 1px solid var(--line); background: #fff; }
.files { display: grid; gap: 0.8rem; margin: 0.8rem 0; }
.feed { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.lazy-slot { min-width: 0; }
.lazy-img, .lazy-pdf { min-height: 16rem; border-radius: 0.7rem; background: linear-gradient(180deg, rgba(212, 167, 106, 0.2), rgba(255, 254, 249, 0.95)); }
.lazy-audio { min-height: var(--tap); }
.pdf-frame, .lazy-pdf iframe {
    width: 100%;
    height: min(70vh, 40rem);
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: #fff;
}
.file-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.recommend { margin-top: 1rem; }
.moderation { margin-top: 1.4rem; }
.guidelines { padding-left: 1.1rem; }
.empty {
    color: var(--muted);
    padding: 1rem;
    border-style: dashed;
    margin: 0.4rem 0 0.8rem;
}
.plain { padding-left: 1.1rem; }
.plain li { margin: 0.45rem 0; }
.check { display: flex; gap: 0.45rem; align-items: flex-start; font-weight: 600; min-height: var(--tap); }
.check input { width: 1.15rem; min-height: 1.15rem; margin-top: 0.2rem; flex: 0 0 auto; }
#location-fields.is-off { opacity: 0.45; }

.split { display: grid; grid-template-columns: 1fr; gap: 1rem; align-items: start; min-width: 0; }
.thread-list { display: grid; gap: 0.4rem; min-width: 0; }
.thread {
    display: block;
    padding: 0.65rem 0.75rem;
    min-height: var(--tap);
    border: 1px solid var(--line);
    border-radius: 0.5rem;
    background: var(--paper);
    text-decoration: none;
    color: var(--text);
    overflow-wrap: anywhere;
}
.thread.is-on { border-color: var(--camel); background: #fff8ee; }
.inbox-back { margin: 0 0 0.6rem; }
.msgs { display: grid; gap: 0.55rem; margin-bottom: 1rem; min-width: 0; }
.bubble {
    max-width: min(36rem, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    padding: 0.55rem 0.75rem;
    overflow-wrap: anywhere;
}
.bubble.mine { margin-left: auto; background: #fff6e8; }
.bubble p { margin: 0; }
.bubble time { color: var(--muted); font-size: 0.8rem; }

.subnav { margin: 0.4rem 0 1rem; }
.subnav a { padding: 0 0.35rem; }

.table-wrap { overflow-x: auto; background: var(--paper); border: 1px solid var(--line); border-radius: 0.7rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--heading); font-size: 0.85rem; }

.inline, .fulfill-row, .reject-row, .cat-row, .search-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    min-width: 0;
}
.inline input, .fulfill-row input, .reject-row input, .cat-row input, .search-row input {
    flex: 1 1 10rem;
    width: auto;
    min-width: 0;
}
.pager { display: flex; gap: 0.8rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.pager a { min-height: var(--tap); display: inline-flex; align-items: center; }
.queue-card { margin-bottom: 0.75rem; }
.note-line { overflow-wrap: anywhere; }

:focus-visible { outline: 2px solid var(--heading); outline-offset: 2px; }

@media (max-width: 640px) {
    .split.is-open-thread .thread-list { display: none; }
    .table-wrap { overflow-x: visible; }
    .inline, .fulfill-row, .reject-row, .cat-row, .search-row {
        flex-direction: column;
        align-items: stretch;
    }
    .inline input, .fulfill-row input, .reject-row input, .cat-row input, .search-row input,
    .inline .btn, .fulfill-row .btn, .reject-row .btn, .cat-row .btn, .search-row .btn,
    .stack > .btn, .stack > button.btn, .file-actions .btn, .share-row .btn, .row-actions .btn {
        width: 100%;
        flex: 0 0 auto;
    }
    .share-row, .row-actions { align-items: stretch; }
    .share-row form, .row-actions form { width: 100%; }
    table, thead, tbody, tr, th, td { display: block; width: 100%; }
    thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    tr { border-bottom: 1px solid var(--line); padding: 0.35rem 0; }
    td { border-bottom: 0; padding: 0.35rem 0.75rem; }
    td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        color: var(--heading);
        font-size: 0.78rem;
    }
    td:empty::before, td.row-actions::before { content: none; }
}

@media (min-width: 641px) {
    h1 { font-size: 1.8rem; }
    .wrap { padding: 1.25rem 1rem calc(3rem + env(safe-area-inset-bottom, 0px)); }
    .field-row { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split { grid-template-columns: minmax(200px, 260px) minmax(0, 1fr); }
    .inbox-back { display: none; }
    .engage { flex-wrap: wrap; }
    .engage .icon-btn { flex: 0 1 auto; font-size: 1rem; padding: 0.45rem 0.8rem; }
    .finder-bar.search-row,
    form.finder-bar { flex-direction: row; align-items: center; }
    form.finder-bar .btn { width: auto; }
    .filters-actions { flex-direction: row; }
    .filters-actions .btn { width: auto; flex: 1; }
    .who-name { max-width: 12rem; }
}

@media (min-width: 1025px) {
    .menu-btn { display: none; }
    .topbar-in { flex-wrap: nowrap; padding: 0.35rem 1rem; }
    .brand { margin-right: 0.25rem; }
    .nav {
        display: flex;
        order: 1;
        flex: 1 1 auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.15rem 0.85rem;
        padding: 0;
    }
    .who { order: 2; margin-left: auto; flex-wrap: nowrap; }
    .browse { grid-template-columns: 280px minmax(0, 1fr); }
    .filters-panel { grid-column: 1; }
    .results { grid-column: 2; }
    .filters-panel { margin: 0; }
    .filters-panel > summary { display: none; }
    .filters-panel[open] > .filters { border-top: 1px solid var(--line); border-radius: 0.7rem; }
    .filters {
        position: sticky;
        top: calc(4.6rem + env(safe-area-inset-top, 0px));
        padding: 0.9rem;
    }
    .cards { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
}
