/* Instaposter — Apple HIG uslubi (iOS Settings / macOS System Settings) */

:root {
  --bg: #f2f2f7;
  --bg-2: #ffffff;
  --bg-3: #f2f2f7;
  --fill: rgba(120, 120, 128, .12);
  --fill-2: rgba(120, 120, 128, .2);
  --sep: rgba(60, 60, 67, .18);
  --matn: #000;
  --matn-2: rgba(60, 60, 67, .6);
  --matn-3: rgba(60, 60, 67, .3);
  --blue: #007aff;
  --brand: #229ed9;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --gray: #8e8e93;
  --purple: #af52de;
  --bar: rgba(249, 249, 249, .78);
  --sidebar: rgba(236, 236, 241, .8);
  --soya: 0 10px 40px rgba(0, 0, 0, .14), 0 1px 3px rgba(0, 0, 0, .08);
  --r: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --bg-2: #1c1c1e;
    --bg-3: #2c2c2e;
    --fill: rgba(120, 120, 128, .24);
    --fill-2: rgba(120, 120, 128, .36);
    --sep: rgba(84, 84, 88, .6);
    --matn: #fff;
    --matn-2: rgba(235, 235, 245, .6);
    --matn-3: rgba(235, 235, 245, .3);
    --blue: #0a84ff;
    --brand: #2aabee;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --gray: #98989d;
    --purple: #bf5af2;
    --bar: rgba(22, 22, 24, .78);
    --sidebar: rgba(30, 30, 32, .82);
    --soya: 0 10px 40px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .08);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { min-height: 100vh; }
body {
  background: var(--bg);
  color: var(--matn);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  letter-spacing: -.41px;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--blue); text-decoration: none; }
[hidden] { display: none !important; }

/* ---------- yuklanish ---------- */
.yuklanmoqda { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--fill-2); border-top-color: var(--matn-2);
  animation: aylan .8s linear infinite;
}
@keyframes aylan { to { transform: rotate(360deg); } }

/* ---------- kirish ---------- */
.kirish {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}
.kirish-quti { width: 100%; max-width: 360px; text-align: center; }
.kirish-quti .kirish-ikon { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 10px 28px rgba(34, 158, 217, .35); }
.kirish-quti .kirish-logo { display: block; height: 54px; width: auto; max-width: 100%; margin: 0 auto 10px; }
.kirish-quti h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.kirish-quti p { color: var(--matn-2); font-size: 15px; margin: 0 0 28px; }
.kirish-quti .guruh { text-align: left; }
.kirish-quti .xato { color: var(--red); font-size: 13px; min-height: 18px; margin: 10px 4px 0; text-align: left; }
.kirish-quti .tugma-katta { margin-top: 14px; }

/* ---------- karkas ---------- */
.karkas { display: flex; min-height: 100vh; }
.yon {
  display: none;
  position: sticky; top: 0; height: 100vh; width: 260px; flex: none;
  background: var(--sidebar);
  -webkit-backdrop-filter: saturate(180%) blur(30px); backdrop-filter: saturate(180%) blur(30px);
  border-right: .5px solid var(--sep);
  padding: 22px 12px;
}
.yon-bosh { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.yon-bosh img { width: 34px; height: 34px; border-radius: 8px; }
.yon-bosh .yon-logo { width: auto; height: 22px; border-radius: 0; }
.yon-bosh b { font-size: 15px; display: block; }
.yon-bosh span { font-size: 12px; color: var(--matn-2); }
.yon nav { display: flex; flex-direction: column; gap: 2px; }
.yon nav button {
  display: flex; align-items: center; gap: 10px; text-align: left;
  padding: 7px 10px; border-radius: 8px; font-size: 14px; font-weight: 500;
}
.yon nav button:hover { background: var(--fill); }
.yon nav button.faol { background: var(--brand); color: #fff; }
.yon nav button.faol .ikon-quti { background: rgba(255, 255, 255, .25) !important; }
.ikon-quti {
  width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; flex: none; color: #fff;
}
.ikon-quti svg { width: 15px; height: 15px; }

.asosiy { flex: 1; min-width: 0; }
.sahifa {
  max-width: 760px; margin: 0 auto;
  padding: 0 16px calc(96px + env(safe-area-inset-bottom));
}

/* katta sarlavha */
.ust {
  position: sticky; top: 0; z-index: 5;
  margin: 0 -16px; padding: calc(10px + env(safe-area-inset-top)) 16px 8px;
  background: var(--bg);
  transition: background .2s, border-color .2s;
  border-bottom: .5px solid transparent;
}
.ust.suzuvchi {
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom-color: var(--sep);
}
.ust-qator { display: flex; align-items: center; justify-content: space-between; min-height: 32px; }
.ust h1 { font-size: 34px; font-weight: 700; letter-spacing: .37px; margin: 4px 0 2px; }
.ust .izoh { color: var(--matn-2); font-size: 15px; margin: 0 0 6px; }
.ust .amal { color: var(--blue); font-size: 17px; display: inline-flex; align-items: center; gap: 4px; }
.ust .amal svg { width: 20px; height: 20px; }

/* ---------- pastki tablar (iPhone) ---------- */
.tablar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(4px + env(safe-area-inset-bottom));
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: .5px solid var(--sep);
}
.tablar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; font-weight: 500; letter-spacing: .1px; color: var(--gray); padding: 2px 0;
}
.tablar button svg { width: 26px; height: 26px; }
.tablar button.faol { color: var(--brand); }

@media (min-width: 900px) {
  .yon { display: block; }
  .tablar { display: none; }
  .sahifa { padding: 0 32px 48px; }
  .ust { margin: 0 -32px; padding: 18px 32px 10px; }
}

/* ---------- guruhlangan ro'yxat (inset grouped) ---------- */
.sarlavha-kichik {
  font-size: 13px; color: var(--matn-2); text-transform: uppercase; letter-spacing: -.08px;
  margin: 26px 16px 7px;
}
.pastki-izoh { font-size: 13px; color: var(--matn-2); margin: 7px 16px 0; line-height: 1.38; letter-spacing: -.08px; }
.guruh { background: var(--bg-2); border-radius: var(--r); overflow: hidden; }
.qator {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  min-height: 44px; padding: 8px 16px; position: relative; background: var(--bg-2);
}
.qator + .qator::before {
  content: ""; position: absolute; top: 0; right: 0; left: var(--chap, 16px);
  border-top: .5px solid var(--sep);
}
button.qator:active, a.qator:active { background: var(--fill); }
.qator .ichi { flex: 1; min-width: 0; text-align: left; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.qator .nom { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qator .tag { font-size: 13px; color: var(--matn-2); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.08px; }
.qator .ong { color: var(--matn-2); font-size: 17px; display: flex; align-items: center; gap: 8px; flex: none; }
.qator .strelka { width: 8px; height: 13px; color: var(--matn-3); flex: none; }
.qator.ikonli { --chap: 60px; }
.qator.avatarli { --chap: 72px; }
.qator.xavfli .nom { color: var(--red); }
.qator.kok .nom { color: var(--blue); }

.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex: none; overflow: hidden;
  display: grid; place-items: center; font-weight: 600; font-size: 17px; color: #fff;
  background: linear-gradient(135deg, #ff9f0a, #ff375f 55%, #bf5af2);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

/* holat belgisi */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 13px; font-weight: 600; letter-spacing: -.08px;
  padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.yashil { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.pill.kok { color: var(--blue); background: color-mix(in srgb, var(--blue) 13%, transparent); }
.pill.sariq { color: var(--orange); background: color-mix(in srgb, var(--orange) 15%, transparent); }
.pill.qizil { color: var(--red); background: color-mix(in srgb, var(--red) 13%, transparent); }
.pill.kulrang { color: var(--gray); background: var(--fill); }
.son {
  min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px;
  background: var(--fill); color: var(--matn-2); font-size: 13px; font-weight: 600;
  display: inline-grid; place-items: center;
}

/* ---------- xulosa kartalari ---------- */
.kartalar { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 10px; }
@media (min-width: 640px) { .kartalar { grid-template-columns: repeat(4, 1fr); } }
.karta { background: var(--bg-2); border-radius: var(--r); padding: 12px 14px 13px; }
.karta .k-ust { display: flex; align-items: center; justify-content: space-between; }
.karta .k-ust .ikon-quti { width: 30px; height: 30px; border-radius: 50%; }
.karta .k-ust .ikon-quti svg { width: 17px; height: 17px; }
.karta .k-son { font-size: 28px; font-weight: 700; letter-spacing: .36px; font-variant-numeric: tabular-nums; }
.karta .k-nom { font-size: 15px; color: var(--matn-2); font-weight: 600; margin-top: 6px; }

.tizim {
  display: flex; align-items: center; gap: 12px; margin-top: 16px;
  background: var(--bg-2); border-radius: var(--r); padding: 12px 16px;
}
.nuqta { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--gray); }
.nuqta.yashil { background: var(--green); box-shadow: 0 0 0 4px color-mix(in srgb, var(--green) 22%, transparent); }
.nuqta.qizil { background: var(--red); box-shadow: 0 0 0 4px color-mix(in srgb, var(--red) 22%, transparent); }
.nuqta.sariq { background: var(--orange); box-shadow: 0 0 0 4px color-mix(in srgb, var(--orange) 22%, transparent); }
.tizim .ichi { flex: 1; min-width: 0; }
.tizim b { font-weight: 600; font-size: 15px; display: block; }
.tizim span { font-size: 13px; color: var(--matn-2); }

/* ---------- forma elementlari ---------- */
.maydon {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 16px; position: relative;
}
.maydon + .maydon::before, .qator + .maydon::before, .maydon + .qator::before {
  content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--sep);
}
.maydon label { flex: none; min-width: 110px; }
.maydon .ichi { flex: 1; }
.maydon input, .maydon select {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none; text-align: right;
  color: var(--matn-2); padding: 11px 0; appearance: none; -webkit-appearance: none;
}
.maydon input:focus { color: var(--matn); }
.maydon input::placeholder { color: var(--matn-3); }
.maydon.ustma { display: block; padding: 10px 16px; }
.maydon.ustma label { display: block; font-size: 13px; color: var(--matn-2); margin-bottom: 4px; }
.maydon textarea {
  width: 100%; border: 0; outline: 0; background: none; resize: vertical; min-height: 84px; padding: 0;
}
.parol-input {
  width: 100%; height: 50px; border: 0; outline: 0; border-radius: var(--r);
  background: var(--bg-2); padding: 0 16px; font-size: 17px;
}
.parol-input:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent); }

/* iOS tumbler */
.tumbler { position: relative; width: 51px; height: 31px; flex: none; }
.tumbler input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.tumbler i {
  position: absolute; inset: 0; border-radius: 16px; background: var(--fill-2); transition: background .25s;
}
.tumbler i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, .15), 0 1px 1px rgba(0, 0, 0, .16);
  transition: transform .25s cubic-bezier(.3, .7, .4, 1);
}
.tumbler input:checked + i { background: var(--green); }
.tumbler input:checked + i::after { transform: translateX(20px); }
.tumbler input:focus-visible + i { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 45%, transparent); }

/* hafta kunlari */
.kunlar { display: grid; grid-template-columns: repeat(7, minmax(0, 40px)); justify-content: space-between; gap: 4px; padding: 10px 16px 12px; }
.kunlar button {
  width: 100%; aspect-ratio: 1; border-radius: 50%; font-size: 14px; font-weight: 600;
  background: var(--fill); color: var(--matn-2); transition: background .15s, color .15s;
}
.kunlar button[aria-pressed="true"] { background: var(--brand); color: #fff; }

/* segment */
.segment {
  display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin: 12px 0 0;
}
.segment button {
  flex: 1; font-size: 13px; font-weight: 500; padding: 6px 8px; border-radius: 7px; letter-spacing: -.08px;
}
.segment button[aria-pressed="true"] { background: var(--bg-2); box-shadow: 0 3px 8px rgba(0, 0, 0, .12), 0 3px 1px rgba(0, 0, 0, .04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .segment button[aria-pressed="true"] { background: #636366; } }

/* tugmalar */
.tugma-katta {
  width: 100%; height: 50px; border-radius: var(--r); background: var(--brand); color: #fff;
  font-weight: 600; font-size: 17px; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.tugma-katta:active { opacity: .8; }
.tugma-katta:disabled { opacity: .45; cursor: default; }
.tugma-katta.ikkinchi { background: var(--bg-2); color: var(--blue); }
.tugma-katta.xavfli { background: var(--bg-2); color: var(--red); }
.tugma-katta .spinner { width: 18px; height: 18px; border-width: 2px; border-color: rgba(255, 255, 255, .35); border-top-color: #fff; }

/* bo'sh holat */
.bosh { text-align: center; padding: 56px 24px; color: var(--matn-2); }
.bosh svg { width: 54px; height: 54px; color: var(--matn-3); }
.bosh h3 { color: var(--matn); font-size: 20px; margin: 12px 0 6px; font-weight: 600; }
.bosh p { margin: 0 auto; max-width: 340px; font-size: 15px; }

/* ---------- pastdan chiqadigan oyna (sheet) ---------- */
.parda {
  position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .32);
  opacity: 0; transition: opacity .3s;
}
.parda.ochiq { opacity: 1; }
.varaq {
  position: fixed; z-index: 41; left: 0; right: 0; bottom: 0;
  max-height: calc(100vh - 44px - env(safe-area-inset-top)); overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 12px 12px 0 0;
  transform: translateY(100%); transition: transform .38s cubic-bezier(.32, .72, 0, 1);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
  min-height: calc(100vh - 54px - env(safe-area-inset-top));
}
.varaq.amal-varaq { min-height: 0; background: none; }
.varaq.ochiq { transform: none; }
@media (min-width: 900px) {
  .varaq {
    left: 50%; top: 50%; bottom: auto; width: 560px; max-height: 86vh; border-radius: 14px;
    min-height: 0;
    transform: translate(-50%, -46%) scale(.96); opacity: 0;
    transition: transform .3s cubic-bezier(.32, .72, 0, 1), opacity .2s; box-shadow: var(--soya);
  }
  .varaq.ochiq { transform: translate(-50%, -50%); opacity: 1; }
}
.varaq-ust {
  position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 14px 16px; background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: .5px solid var(--sep);
}
.varaq-ust b { font-size: 17px; font-weight: 600; text-align: center; }
.varaq-ust button { color: var(--blue); font-size: 17px; }
.varaq-ust button:last-child { justify-self: end; font-weight: 600; }
.varaq-ust button:first-child { justify-self: start; }
.varaq-ust button:disabled { color: var(--matn-3); }
.varaq-ichi { padding: 0 16px; }
@media (min-width: 900px) { .varaq-ichi { padding: 0 20px; } }

/* tasdiqlash oynasi (action sheet) */
.amal-varaq { padding: 8px; }
.amal-varaq .guruh { border-radius: 14px; }
.amal-varaq .sarlavha { text-align: center; padding: 14px 16px; font-size: 13px; color: var(--matn-2); }
.amal-varaq .sarlavha b { display: block; font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.amal-varaq button.qator { justify-content: center; font-size: 20px; color: var(--blue); min-height: 57px; --chap: 0; }
.amal-varaq button.qator.xavfli { color: var(--red); }
.amal-varaq .bekor { margin-top: 8px; }
.amal-varaq .bekor button { font-weight: 600; }

/* ---------- toast ---------- */
#toast {
  position: fixed; z-index: 60; left: 50%; top: calc(12px + env(safe-area-inset-top));
  transform: translate(-50%, -150%);
  background: var(--bg-2); color: var(--matn); box-shadow: var(--soya);
  border-radius: 999px; padding: 10px 18px; font-size: 15px; font-weight: 500;
  max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 8px;
  visibility: hidden; opacity: 0; transition: transform .4s cubic-bezier(.32, .72, 0, 1), opacity .25s, visibility 0s .4s;
}
#toast.ochiq { transform: translate(-50%, 0); visibility: visible; opacity: 1; transition: transform .4s cubic-bezier(.32, .72, 0, 1), opacity .25s; }
#toast svg { width: 20px; height: 20px; flex: none; }
#toast.yaxshi svg { color: var(--green); }
#toast.yomon svg { color: var(--red); }

/* jurnal */
.havola-tugma { color: var(--blue); font-size: 15px; display: inline-flex; align-items: center; gap: 3px; }
.havola-tugma svg { width: 14px; height: 14px; }

/* qidiruv ro'yxati (IG akkaunt tanlash) */
.qidiruv {
  margin: 12px 0 0; display: flex; align-items: center; gap: 6px;
  background: var(--fill); border-radius: 10px; padding: 0 8px; height: 36px;
}
.qidiruv svg { width: 16px; height: 16px; color: var(--matn-2); flex: none; }
.qidiruv input { flex: 1; border: 0; outline: 0; background: none; font-size: 17px; min-width: 0; }
.qator .belgi { width: 18px; height: 18px; color: var(--blue); flex: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; }
}

/* aylantirganda katta sarlavha iOS kabi kichrayadi */
.ust h1 { transition: font-size .2s, margin .2s; }
.ust.suzuvchi h1 {
  font-size: 17px; font-weight: 600; letter-spacing: -.41px; text-align: center;
  margin: -28px 72px 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ust.suzuvchi .izoh { display: none; }

/* logo: yorug' / qorong'i mavzu uchun */
img.qorongida { display: none !important; }
@media (prefers-color-scheme: dark) {
  img.yorugda { display: none !important; }
  img.qorongida { display: block !important; }
}
.avatar { background: linear-gradient(135deg, #5bc4f5, var(--brand)); }

.kirish-guruh .parol-input { border-radius: 0; }
.kirish-guruh .parol-input + .parol-input { border-top: .5px solid var(--sep); }
