[hidden] { display: none !important; }

:root {
    --ground: #f4efec;
    --surface: #ffffff;
    --ink: #251f21;
    --ink-2: #585254;
    --ink-3: #8a8486;
    --line: #eae9ea;
    --teal: #73a89a;
    --teal-wash: rgba(115, 168, 154, 0.12);
    --red: #ed313e;
    --radius: 14px;
    --font: -apple-system, "SF Arabic", "Geeza Pro", "Segoe UI", "Noto Naskh Arabic", Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--ground);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.6;
}

body { padding-bottom: env(safe-area-inset-bottom); }

/* auth */
.auth { display: flex; justify-content: center; padding: 24px 16px 40px; }
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border-radius: 20px;
    padding: 22px 18px;
    box-shadow: 0 1px 2px rgba(77, 53, 51, 0.06);
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 24px; font-weight: 700; }
.brand-mark {
    width: 34px; height: 34px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--ink); color: #fff; font-size: 17px;
}
.auth-intro { margin: 10px 0 16px; color: var(--ink-2); font-size: 13.5px; }

.tabs { display: flex; gap: 6px; background: var(--ground); padding: 4px; border-radius: 12px; margin-bottom: 14px; }
.tab {
    flex: 1; min-height: 40px; border: 0; border-radius: 9px; background: none;
    font: inherit; font-size: 14px; color: var(--ink-2); cursor: pointer;
}
.tab.is-on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(77, 53, 51, 0.08); }

.form { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; color: var(--ink-2); margin-top: 6px; }
.input {
    width: 100%; min-height: 46px; padding: 10px 12px;
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: 15px;
}
.input:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row > div { display: flex; flex-direction: column; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.chip {
    min-height: 38px; padding: 0 14px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink); font: inherit; font-size: 13.5px; cursor: pointer;
}
.chip.is-on { border-color: var(--teal); background: var(--teal-wash); color: var(--teal); font-weight: 600; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); margin: 8px 0; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }

.btn {
    min-height: 46px; padding: 0 18px; border: 1px solid transparent; border-radius: 10px;
    font: inherit; font-size: 15px; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-quiet { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn:disabled { opacity: 0.5; }
.link { background: none; border: 0; font: inherit; font-size: 13px; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 8px; }
.fine { font-size: 12px; color: var(--ink-3); margin: 8px 0 0; }
.error { color: var(--red); font-size: 13px; margin: 6px 0 0; }

/* app shell */
#app { max-width: 720px; margin: 0 auto; padding: 0 0 24px; }
.topbar {
    position: sticky; top: 0; z-index: 5;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; background: var(--ground);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; font-size: 18px; font-weight: 700; }
.topbar-actions { display: flex; gap: 2px; }

.view { padding: 14px 16px; }
.statuses { display: flex; gap: 12px; overflow-x: auto; padding: 2px 0 10px; }
.status-item { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 5px; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.status-ring {
    width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    border: 2px solid var(--teal); background: var(--surface); font-size: 16px; font-weight: 600;
}
.status-item.is-add .status-ring { border-style: dashed; border-color: #c0bebf; color: var(--ink-2); font-size: 20px; }
.status-label { max-width: 64px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; color: var(--ink-2); }

.rooms { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.room {
    width: 100%; text-align: start; display: flex; flex-direction: column; gap: 5px;
    padding: 14px; border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); font: inherit; color: inherit; cursor: pointer;
}
.room-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.room-name { font-size: 16px; font-weight: 600; }
.room-meta { font-size: 11.5px; color: var(--ink-3); }
.room-last { font-size: 13px; color: var(--ink-2); }
.room-sim { font-size: 12px; font-weight: 600; color: var(--teal); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }
.chat-head { display: flex; align-items: center; gap: 8px; }
.chat-title { font-size: 16px; font-weight: 600; }
.thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-height: 240px; }
.msg {
    position: relative; align-self: flex-start; max-width: 88%;
    display: flex; flex-direction: column; gap: 3px;
    padding: 9px 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line);
    font-size: 14px;
}
.msg.is-mine { align-self: flex-end; background: var(--teal-wash); border-color: transparent; }
.msg.is-anon { border-style: dashed; border-color: #c0bebf; }
.msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.msg-name { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.badge { font-size: 11px; font-weight: 600; color: var(--teal); background: var(--teal-wash); border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.msg-profile { font-size: 11px; color: var(--ink-3); }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-foot { display: flex; justify-content: flex-end; gap: 4px; }
.more { border: 0; background: none; color: var(--ink-3); font: inherit; font-size: 17px; line-height: 1; cursor: pointer; padding: 2px 6px; opacity: .55; }
.more:hover, .more:focus-visible { opacity: 1; }
.msg-menu { display: flex; gap: 8px; margin-top: 6px; }
.msg-menu button {
    min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 8px;
    background: var(--surface); font: inherit; font-size: 12.5px; cursor: pointer; color: var(--ink);
}
.msg-menu .danger { color: var(--red); }
.reported { font-size: 11px; color: var(--teal); }
.empty { color: var(--ink-3); font-size: 13px; text-align: center; padding: 10px 0; }

.composer {
    position: sticky; bottom: 0; display: flex; align-items: center; gap: 6px;
    padding: 8px 0 10px; background: var(--ground);
}
.composer .input { flex: 1; min-width: 0; }
.btn-send { padding: 0 14px; }

/* matches */
.matches { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.match { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.match-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.match-name { font-size: 15px; font-weight: 600; }
.match-detail { font-size: 12px; color: var(--ink-2); }
.track { height: 4px; border-radius: 999px; background: var(--ground); overflow: hidden; }
.track > span { display: block; height: 100%; background: var(--teal); }

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(37, 31, 33, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-card { width: 100%; max-width: 440px; background: var(--surface); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.progress { height: 3px; border-radius: 999px; background: var(--ground); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--teal); }
.status-text { margin: 0; font-size: 19px; line-height: 1.7; min-height: 72px; }
.status-meta { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--ink-2); }
.modal-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.toast {
    position: fixed; inset-inline: 16px; bottom: 18px; z-index: 40;
    margin: 0 auto; max-width: 420px;
    background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px;
    font-size: 13.5px; text-align: center;
}

/* سؤال اليوم */
.question {
    display: grid;
    gap: 6px;
    width: 100%;
    text-align: right;
    border: 1px solid rgba(115, 168, 154, 0.45);
    background: var(--teal-wash);
    border-radius: 18px;
    padding: 14px 16px;
    font: inherit;
    color: var(--ink);
    cursor: pointer;
}
.question-tag { font-size: 12px; font-weight: 700; color: var(--teal); letter-spacing: 0; }
.question-text { font-size: 16px; line-height: 1.6; font-weight: 600; }
.question-cta { font-size: 12px; color: var(--ink-2); }

/* شروط الاستخدام */
.check-terms { align-items: flex-start; line-height: 1.6; font-size: 12.5px; color: var(--ink-2); }
.check-terms input { margin-top: 3px; flex: none; }

/* الأقرب ليك + الرسايل الخاصة */
.section-title { font-size: 15px; margin: 4px 0 0; }
.chats { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.chat-row {
    width: 100%;
    display: grid;
    gap: 4px;
    text-align: right;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    color: var(--ink);
    cursor: pointer;
}
.chat-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.chat-row-name { font-weight: 600; }
.chat-row-time { font-size: 11px; color: var(--ink-3); }
.chat-row-last { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match-actions { display: flex; gap: 8px; margin-top: 2px; }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.chat-sub { font-size: 12px; color: var(--ink-3); }
.app.is-chat .topbar-title, #app.is-chat .topbar-title { visibility: hidden; }
.chat-head { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 4px 12px; }
.chat-head .chat-title { text-align: left; }
.chat-head .chat-sub { grid-column: 2; text-align: left; }
