:root {
  --bg: #f5f4fc;
  --bg-grad: radial-gradient(1200px 600px at 10% -10%, #e9e3ff 0%, transparent 55%),
             radial-gradient(900px 500px at 110% 10%, #ffe6ef 0%, transparent 50%);
  --card: #ffffff;
  --card-soft: #fbfaff;
  --text: #1c1930;
  --muted: #8a86a0;
  --line: #e9e6f5;
  --primary: #7c5cff;
  --primary-2: #ff5c8a;
  --primary-dark: #6547e8;
  --soft: #efebff;
  --danger: #e3556b;
  --ok: #2fb37a;
  --radius: 20px;
  --shadow: 0 8px 30px rgba(48, 32, 110, .08);
  --accent: var(--primary);
}

html.dark {
  --bg: #12111c;
  --bg-grad: radial-gradient(900px 500px at 0% 0%, #241d4d 0%, transparent 55%),
             radial-gradient(700px 400px at 100% 5%, #3a1a2c 0%, transparent 50%);
  --card: #1e1c2c;
  --card-soft: #242135;
  --text: #f2f0fb;
  --muted: #9c98b4;
  --line: #322e48;
  --soft: #2b2745;
  --primary-dark: #5a45d6;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
html.dark input, html.dark select, html.dark textarea { background: #262238; color: var(--text); }
html.dark input:focus, html.dark select:focus, html.dark textarea:focus { background: #2d2942; }
html.dark .pill, html.dark .avatar-option, html.dark .chip-option { background: #262238; }
html.dark .pill.selected, html.dark .avatar-option.selected, html.dark .chip-option.selected { background: var(--soft); }
html.dark .badge.banned { background: #4a2530; }
html.dark .person-card { background: linear-gradient(180deg, #241f3f 0%, var(--card) 60%); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
}

#app {
  max-width: 480px; min-height: 100dvh; margin: 0 auto; position: relative;
  display: flex; flex-direction: column;
}

.screen { display: none; flex: 1; flex-direction: column; min-height: 0; }
.screen.active { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.content { flex: 1; overflow-y: auto; padding: 14px 16px 24px; }

/* ── Topbar ───────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 12px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar h2 { margin: 0; font-size: 20px; flex: 1; font-weight: 800; letter-spacing: -.3px; }
.icon-btn {
  border: 0; background: var(--soft); color: var(--primary);
  width: 38px; height: 38px; border-radius: 12px; font-size: 17px; cursor: pointer;
  display: grid; place-items: center; transition: .15s;
}
.icon-btn:active { transform: scale(.94); }

/* ── Kirish ekrani ────────────────────────────────────── */
.login-hero {
  text-align: center;
  padding: calc(env(safe-area-inset-top) + 54px) 24px 22px;
}
.brand-mark {
  width: 92px; height: 92px; margin: 0 auto 16px;
  display: grid; place-items: center; font-size: 46px;
  background: linear-gradient(145deg, #fff 0%, #f3eeff 100%);
  border-radius: 30px;
  box-shadow: 0 18px 44px rgba(124, 92, 255, .28);
  animation: float 5s ease-in-out infinite;
}
html.dark .brand-mark { background: linear-gradient(145deg, #2a2547, #241f3f); }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
.login-hero h1 {
  margin: 0; font-size: 40px; letter-spacing: -1px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  font-weight: 900;
}
.tagline { color: var(--muted); margin: 8px 0 14px; font-size: 16px; }
.brand-chips { display: flex; justify-content: center; gap: 8px; }
.brand-chips span {
  background: var(--soft); color: var(--primary); font-size: 12px; font-weight: 700;
  padding: 5px 12px; border-radius: 20px;
}
.login-card { margin: 6px 18px 14px; }
.btn.telegram {
  width: 100%; margin-top: 10px; background: #2aabee; color: #fff;
}
.btn.telegram:active { background: #2196d6; }
.login-code { margin-top: 14px; text-align: center; }
.code-box {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 26px; letter-spacing: 6px; font-weight: 800;
  background: var(--soft); color: var(--primary);
  border-radius: 14px; padding: 14px; margin: 8px 0;
}
.code-box.waiting { opacity: .6; }
.login-code .btn { margin-top: 8px; width: 100%; }
.login-code .btn.small { width: auto; }
.hint.waiting { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .45; } }
.fine { text-align: center; color: var(--muted); font-size: 11.5px; margin: 14px 0 0; }
.socials {
  display: flex; justify-content: center; gap: 10px; padding: 4px 18px calc(env(safe-area-inset-bottom) + 24px);
  flex-wrap: wrap;
}
.socials a {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 600;
  background: var(--card); padding: 9px 14px; border-radius: 12px; box-shadow: var(--shadow);
}

/* ── Kartalar ─────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 18px; margin: 0 16px 14px; box-shadow: var(--shadow);
}
#s-login .card { margin-top: 12px; }
#s-onboarding .card, #s-profile .card { margin-left: 16px; margin-right: 16px; }
.content > .card { margin-left: 0; margin-right: 0; }

label { display: block; font-size: 13px; font-weight: 700; margin: 14px 0 6px; color: var(--text); }
label:first-child { margin-top: 0; }
.muted { color: var(--muted); font-weight: 500; font-size: 12px; }
h2 { font-weight: 800; }

input, select, textarea {
  width: 100%; padding: 13px 14px; font: inherit; font-size: 15px;
  border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--card-soft); color: var(--text); outline: none; resize: vertical;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: var(--card); }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 14px; line-height: 1.5; }
.footnote { text-align: center; color: var(--muted); font-size: 12px; padding: 8px 20px calc(env(safe-area-inset-bottom) + 18px); }
.row { display: flex; gap: 10px; }
.row > div { flex: 1; }

/* ── Tugmalar ─────────────────────────────────────────── */
.btn {
  border: 0; border-radius: 14px; padding: 14px 18px; font: inherit;
  font-weight: 700; font-size: 15px; cursor: pointer; transition: .15s;
}
.btn.primary { background: linear-gradient(135deg, var(--primary), #9a6bff); color: #fff; width: 100%; margin-top: 16px; box-shadow: 0 8px 22px rgba(124,92,255,.28); }
.btn.primary:active { transform: scale(.99); background: var(--primary-dark); }
.btn.ghost { background: var(--soft); color: var(--primary); }
.btn.small { padding: 10px 14px; font-size: 13px; width: auto; margin: 0 8px 8px 0; }
.btn.danger { color: var(--danger); }
.btn.round { width: 64px; height: 64px; border-radius: 50%; padding: 0; font-size: 25px; box-shadow: var(--shadow); }
.btn[disabled] { opacity: .5; pointer-events: none; }

/* ── Tanlov ───────────────────────────────────────────── */
.pills { display: flex; gap: 10px; }
.pill {
  flex: 1; padding: 13px; border: 1.5px solid var(--line); border-radius: 13px;
  background: var(--card-soft); color: var(--text); font: inherit; font-weight: 700; cursor: pointer;
  transition: .15s;
}
.pill.selected { background: var(--soft); border-color: var(--primary); color: var(--primary); }

.chip-picker { display: flex; flex-wrap: wrap; gap: 7px; }
.chip-option {
  border: 1.5px solid var(--line); background: var(--card-soft); color: var(--text);
  border-radius: 20px; padding: 8px 13px; font: inherit; font-size: 13px; cursor: pointer; transition: .15s;
}
.chip-option.selected { background: var(--soft); border-color: var(--primary); color: var(--primary); font-weight: 700; }

.avatar-picker { display: block; }
.avatar-group-label {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); margin: 10px 0 8px;
}
.avatar-group-label:first-child { margin-top: 0; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-grid.image-grid { grid-template-columns: repeat(5, 1fr); gap: 9px; }
.avatar-option {
  width: 100%; aspect-ratio: 1; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--card-soft); font-size: 22px; cursor: pointer;
  display: grid; place-items: center; transition: transform .15s, border-color .15s, box-shadow .15s;
  overflow: hidden; padding: 0;
}
.avatar-option:active { transform: scale(.94); }
.avatar-option.selected {
  border-color: var(--primary); background: var(--soft);
  box-shadow: inset 0 0 0 2px var(--primary), 0 3px 10px rgba(123,75,255,.18);
}
.avatar-option.avatar-img { border-radius: 16px; }
.avatar-img img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.avatar.avatar-img { overflow: hidden; }
.avatar.big.avatar-img { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--primary), var(--shadow); }

/* ── Progress ─────────────────────────────────────────── */
.progress-pill { font-size: 12px; font-weight: 800; color: var(--primary); background: var(--soft); padding: 5px 10px; border-radius: 20px; }
.progress-track { height: 4px; background: var(--line); position: sticky; top: 65px; z-index: 4; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, var(--primary), var(--primary-2)); transition: width .3s; }

/* ── Nomzod kartasi ───────────────────────────────────── */
.actions { display: flex; justify-content: center; gap: 26px; padding: 6px 16px calc(env(safe-area-inset-bottom) + 18px); }

.person-card {
  position: relative; overflow: hidden;
  background:
    radial-gradient(circle at 88% -10%, rgba(255,182,193,.35), transparent 42%),
    radial-gradient(circle at -5% 20%, rgba(139,111,255,.18), transparent 38%),
    linear-gradient(180deg, #fbf7ff 0%, var(--card) 46%);
  border: 1px solid rgba(123,75,255,.08);
  border-radius: 26px; padding: 22px; box-shadow: var(--shadow); margin-bottom: 14px;
  animation: rise .3s ease;
}
html.dark .person-card {
  background:
    radial-gradient(circle at 88% -10%, rgba(255,182,193,.12), transparent 42%),
    radial-gradient(circle at -5% 20%, rgba(139,111,255,.16), transparent 38%),
    linear-gradient(180deg, #2a2340 0%, var(--card) 46%);
}
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.person-top { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.avatar {
  width: 54px; height: 54px; border-radius: 17px; flex: 0 0 auto;
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 21px;
}
.avatar.big { width: 64px; height: 64px; font-size: 26px; }
.person-id { font-weight: 800; font-size: 18px; letter-spacing: -.3px; }
.person-bio { margin: 14px 0 0; font-size: 14.5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { background: var(--soft); color: var(--primary); border-radius: 20px; padding: 5px 11px; font-size: 12px; font-weight: 600; }
.mini-avatar { width: 20px; height: 20px; display: inline-grid; place-items: center; overflow: hidden; border-radius: 6px; vertical-align: middle; }
.mini-avatar img { width: 100%; height: 100%; object-fit: cover; }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; }
.empty .big-emoji { font-size: 50px; display: block; margin-bottom: 12px; }

.filter-match { border-left: 3px solid var(--primary); padding-left: 11px; margin-top: 12px; font-size: 13px; color: var(--text); }
.match-item {
  display: flex; gap: 12px; align-items: center; background: var(--card);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px; cursor: pointer;
  box-shadow: var(--shadow); transition: .15s;
}
.match-item:active { transform: scale(.99); }
.match-item .meta { min-width: 0; flex: 1; }
.match-item .name { font-weight: 800; }
.match-item .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Chat ─────────────────────────────────────────────── */
.chat-head { gap: 8px; }
.chat-head #chat-person { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 0; }
.chat-head #chat-person .avatar { width: 36px; height: 36px; border-radius: 11px; font-size: 15px; }
.chat-head #chat-person .name { font-weight: 800; font-size: 15px; }
.messages { padding: 14px 16px 20px; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 17px; margin-bottom: 8px; word-break: break-word; font-size: 14.5px; }
.bubble.them { background: var(--card); border-bottom-left-radius: 5px; box-shadow: 0 2px 8px rgba(40,30,90,.05); }
.bubble.mine { background: linear-gradient(135deg, var(--primary), #9a6bff); color: #fff; margin-left: auto; border-bottom-right-radius: 5px; }
.bubble-time { display: block; font-size: 10px; opacity: .65; margin-top: 3px; }
.composer {
  display: flex; gap: 8px; padding: 10px 12px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--card); border-top: 1px solid var(--line);
}
.composer input { flex: 1; }
.composer .btn { width: auto; margin: 0; padding: 12px 18px; }

/* ── Profil ───────────────────────────────────────────── */
.profile-head { display: flex; gap: 14px; align-items: center; }
.public-id { font-weight: 800; font-size: 19px; color: var(--primary); }
.mini-badge { display: inline-block; margin-top: 4px; font-size: 11px; color: var(--ok); background: rgba(47,179,122,.12); padding: 3px 8px; border-radius: 20px; font-weight: 700; }
.mini-badge.off { color: var(--danger); background: rgba(227,85,107,.12); }
.admin-status { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.admin-status .mini-badge { margin: 0; }
.chart-box { margin-bottom: 10px; }
.chart-title { font-size: 11.5px; color: var(--muted); font-weight: 700; margin-bottom: 8px; }
.chart { display: flex; align-items: flex-end; gap: 6px; height: 84px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 3px; }
.bar { width: 100%; max-width: 30px; background: linear-gradient(180deg, var(--primary), #b18cff); border-radius: 6px 6px 3px 3px; position: relative; min-height: 4px; }
.bar span { position: absolute; top: -15px; left: 0; right: 0; text-align: center; font-size: 9.5px; font-weight: 700; color: var(--primary); }
.bar-col small { font-size: 9.5px; color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { text-align: right; font-weight: 600; }

/* ── Navigatsiya ──────────────────────────────────────── */
.bottom-nav {
  display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); position: sticky; bottom: 0; z-index: 5;
}
.bottom-nav button {
  flex: 1; border: 0; background: none; padding: 9px 0 8px; color: var(--muted);
  font: inherit; font-size: 10.5px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; align-items: center;
  transition: .15s;
}
.bottom-nav button span { font-size: 20px; }
.bottom-nav button.active { color: var(--primary); font-weight: 800; }

/* ── Tablar ───────────────────────────────────────────── */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 10px; }
.tab {
  flex: 1; border: 0; background: none; padding: 9px 4px; font: inherit; font-size: 13px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 800; }
.tabs.scroll { overflow-x: auto; scrollbar-width: none; }
.tabs.scroll::-webkit-scrollbar { display: none; }
.tabs.scroll .tab { flex: 0 0 auto; padding: 9px 12px; }

/* ── Statistika ───────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--soft); border-radius: 13px; padding: 11px 4px; text-align: center; }
.stat b { display: block; font-size: 19px; color: var(--primary); }
.stat span { font-size: 10px; color: var(--muted); }
.extra-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px; }
.extra-grid .stat b { font-size: 16px; }
.city-row { display: flex; justify-content: space-between; font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.city-row:last-child { border: 0; }

/* ── Admin ────────────────────────────────────────────── */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.search-row input { flex: 1; padding: 10px 12px; }
.search-row select { width: 130px; padding: 10px; }
.admin-row {
  display: flex; gap: 8px; align-items: center; padding: 10px 0;
  border-bottom: 1px solid var(--line); font-size: 13px;
}
.admin-row:last-child { border: 0; }
.admin-row .meta { flex: 1; min-width: 0; }
.admin-row .id { color: var(--muted); font-size: 11.5px; }
.admin-row .btn { margin: 0; padding: 7px 9px; font-size: 11px; border-radius: 9px; }
.badge { font-size: 10px; padding: 2px 6px; border-radius: 8px; background: var(--soft); color: var(--primary); font-weight: 700; }
.badge.banned { background: #fdecee; color: var(--danger); }
.admin-divider { height: 1px; background: var(--line); margin: 16px 0; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.setting-row b { font-size: 14px; }
.switch { position: relative; width: 48px; height: 28px; flex: 0 0 auto; margin: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 2; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 20px; transition: .2s; }
.switch span::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ── Boshqalar ────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 84px);
  transform: translate(-50%, 20px); background: #26223d; color: #fff;
  padding: 12px 18px; border-radius: 14px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: 88%; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.proposal-row {
  display: flex; flex-direction: column; gap: 6px; padding: 13px;
  background: var(--card); border-radius: var(--radius); margin-bottom: 10px; box-shadow: var(--shadow);
}
.proposal-row .subject { font-weight: 800; font-size: 16px; }
.proposal-row .note { font-size: 13px; color: var(--muted); }
.proposal-row .actions { display: flex; gap: 8px; padding: 0; }
.proposal-row .actions .btn { flex: 1; margin: 0; }

code { background: var(--soft); padding: 1px 5px; border-radius: 5px; font-size: 11px; }

[hidden] { display: none !important; }
