:root {
  --bg: #F4F5F7; --surface: #FFFFFF; --surface-2: #EEF0F3; --line: #E2E5EA;
  --text: #0E1116; --muted: #5B6472; --accent: #FF5A1F; --accent-soft: #FFE7DD; --accent-ink: #FFFFFF;
  --good: #15803D; --good-soft: #DCFCE7; --warn: #B45309; --warn-soft: #FEF3C7; --bad: #B91C1C; --bad-soft: #FEE2E2;
  --radius: 16px; --shadow: 0 1px 2px rgba(14,17,22,.06), 0 4px 16px rgba(14,17,22,.05);
  --nav-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1116; --surface: #171B22; --surface-2: #20262F; --line: #2A313C;
    --text: #F5F7FA; --muted: #98A2B3; --accent-soft: #3A1F14;
    --good: #4ADE80; --good-soft: #12301F; --warn: #FBBF24; --warn-soft: #33270C; --bad: #F87171; --bad-soft: #3A1717;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Noto Sans Arabic", sans-serif;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { font-size: 20px; letter-spacing: -0.01em; }
h3 { font-size: 17px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- Layout ---------- */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: calc(env(safe-area-inset-top) + 12px) 16px 10px; display: flex; align-items: center; gap: 10px;
}
.top h1 { flex: 1; font-size: 24px; }
.top .back { font-size: 22px; color: var(--text); padding: 4px 8px 4px 0; }
main { max-width: 600px; margin: 0 auto; padding: 4px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }
.top-inner { max-width: 600px; margin: 0 auto; width: 100%; display: flex; align-items: center; gap: 10px; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  background: var(--surface); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { display: flex; max-width: 600px; width: 100%; }
.nav a {
  flex: 1; height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 11px; color: var(--muted); position: relative; font-weight: 500;
}
.nav a svg { width: 24px; height: 24px; }
.nav a.on { color: var(--accent); }
.nav .dot {
  position: absolute; top: 8px; left: calc(50% + 6px); min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; display: grid; place-items: center;
}
.section { margin: 22px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section h2 { font-size: 17px; }
.row { display: flex; align-items: center; }
.gap { gap: 10px; } .grow { flex: 1; } .wrap { flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.loading, .empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.empty .btn { margin-top: 14px; }

/* ---------- Cards ---------- */
.card {
  display: block; background: var(--surface); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 10px;
}
.card h3 { margin: 4px 0 4px; }
.card.row { display: flex; }
.meta { color: var(--muted); font-size: 14px; }
.ev-top { display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.ev-top .sport { color: var(--accent); }
.ev-foot { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.card.featured { border: 2px solid var(--accent); position: relative; }
.tag.feat { position: absolute; top: 12px; right: 12px; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 3px 8px; border-radius: 999px; }
.day { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 18px 2px 8px; }

.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.pill.hot { background: var(--accent-soft); color: var(--accent); }
.pill.ok { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- Avatars & people ---------- */
.av {
  --h: 20; width: 44px; height: 44px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  font-weight: 700; font-size: 15px; color: hsl(var(--h) 70% 30%); background: hsl(var(--h) 80% 88%);
}
@media (prefers-color-scheme: dark) { .av { color: hsl(var(--h) 80% 85%); background: hsl(var(--h) 35% 25%); } }
.av.lg { width: 72px; height: 72px; font-size: 24px; }
.av.sm { width: 30px; height: 30px; font-size: 12px; }
.person { display: flex; align-items: center; gap: 12px; }
.person .info { flex: 1; min-width: 0; }
.person .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.match { text-align: center; min-width: 52px; }
.match b { display: block; font-size: 18px; color: var(--accent); }
.match span { font-size: 11px; color: var(--muted); }
.reasons { font-size: 13px; color: var(--muted); margin-top: 6px; }
.chips-line { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.faces { display: flex; }
.faces .av { margin-left: -8px; border: 2px solid var(--surface); }
.faces .av:first-child { margin-left: 0; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; font-size: 15px; padding: 11px 16px; border-radius: 12px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.dark { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.ghost { background: transparent; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ok { background: var(--good-soft); border-color: transparent; color: var(--good); }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.icon-btn { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 600; padding: 8px 6px; cursor: pointer; display: inline-flex; gap: 5px; align-items: center; }
.icon-btn.on { color: var(--accent); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.actions .btn { flex: 1; }

/* ---------- Filters ---------- */
.seg { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg select {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; padding: 7px 13px; border-radius: 999px; white-space: nowrap; cursor: pointer;
}
.seg button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.seg select { padding-right: 28px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 4px 2px; }

/* ---------- Forms ---------- */
form .field { margin-bottom: 14px; }
label.lbl { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], input[type=datetime-local], select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- Auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 48px) 20px 40px; }
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.brand img { width: 44px; height: 44px; border-radius: 12px; }
.brand b { font-size: 22px; letter-spacing: -0.02em; }
.auth h1 { font-size: 30px; margin-bottom: 8px; }
.auth .lead { color: var(--muted); margin-bottom: 26px; }
.linklike { appearance: none; background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; padding: 6px 0; }

/* ---------- Profile ---------- */
.hero { display: flex; gap: 14px; align-items: center; margin: 6px 0 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }
.rel { display: flex; gap: 14px; align-items: center; }
.rel .ring { --p: 0; width: 64px; height: 64px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: conic-gradient(var(--good) calc(var(--p) * 1%), var(--surface-2) 0); }
.rel .ring b { width: 50px; height: 50px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 15px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- Feed ---------- */
.post .head { display: flex; align-items: center; gap: 10px; }
.post .head .info { flex: 1; min-width: 0; }
.trophy { display: flex; align-items: center; gap: 14px; margin: 12px 0 8px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.trophy .medal { font-size: 34px; line-height: 1; }
.trophy .pos { font-size: 22px; font-weight: 800; }
.trophy.podium { background: linear-gradient(135deg, var(--accent-soft), var(--surface-2)); }
.post .bar { display: flex; gap: 6px; border-top: 1px solid var(--line); margin-top: 10px; padding-top: 4px; }
.post .bar .spacer { flex: 1; }
.comment { display: flex; gap: 10px; padding: 8px 0; }
.comment .body { flex: 1; font-size: 14px; }

/* ---------- Sheet & toast ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow: auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px);
  transform: translateY(100%); transition: transform .25s ease; max-width: 600px; margin: 0 auto;
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet h3 { margin: 8px 0 10px; font-size: 19px; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px); z-index: 60;
  transform: translate(-50%, 20px); opacity: 0; transition: all .25s; background: var(--text); color: var(--bg);
  padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.bad { background: var(--bad); color: #fff; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Add to Home Screen ---------- */
.install-banner { display: flex; align-items: center; gap: 12px; border-color: var(--accent); }
.install-banner img { width: 40px; height: 40px; border-radius: 10px; flex: none; }
.install-banner .meta { font-size: 13px; }
.sheet h4 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 8px; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 0 0 8px; }
.steps li { counter-increment: step; position: relative; padding: 4px 0 12px 40px; min-height: 30px; }
.steps li::before {
  content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; display: grid; place-items: center;
}
.steps .hint { margin-top: 4px; }
.ico { width: 20px; height: 20px; vertical-align: -4px; color: #0A84FF; }
.key { display: inline-block; min-width: 22px; padding: 0 5px; border-radius: 6px; background: var(--surface-2); text-align: center; font-weight: 700; }

/* ---------- privacy notice & terms ---------- */
.doc { line-height: 1.55; }
.doc h2 { font-size: 17px; margin: 22px 0 8px; }
.doc ul { padding-left: 20px; margin: 0 0 12px; }
.doc li { margin-bottom: 6px; }
.doc p { margin: 0 0 12px; }
.consent { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--muted); margin: 4px 0 16px; }
.consent input { width: 20px; height: 20px; flex: none; margin-top: 1px; accent-color: var(--accent); }
.consent a { color: var(--accent); font-weight: 600; }

/* ---------- in-app alert ---------- */
.alert-bar {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); z-index: 70; transform: translate(-50%, -16px); opacity: 0; transition: all .25s;
  width: min(440px, calc(100% - 24px)); display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--accent); border-radius: 14px; box-shadow: var(--shadow);
}
.alert-bar.show { transform: translate(-50%, 0); opacity: 1; }
.alert-bar .grow { font-weight: 600; font-size: 14px; }
