/* ---------- Kunduzgi mavzu (oq) ---------- */
:root {
  --bg: #ffffff;
  --glow: rgba(59, 130, 246, .07);
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --soft: #94a3b8;
  --line: #e5e7eb;
  --chip: #f1f5f9;
  --input: #f8fafc;
  --shadow: rgba(15, 23, 42, .05);
  --overlay: rgba(15, 23, 42, .35);
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

/* ---------- Kechki mavzu (qora) ---------- */
:root[data-theme="dark"] {
  --bg: #0b1120;
  --glow: rgba(99, 102, 241, .14);
  --card: #111a2e;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --soft: #64748b;
  --line: #1e293b;
  --chip: #1a2540;
  --input: #0d1526;
  --shadow: rgba(0, 0, 0, .35);
  --overlay: rgba(2, 6, 23, .65);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background:
    radial-gradient(ellipse 90% 55% at 50% 0%, var(--glow), transparent 70%),
    var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  transition: background-color .6s, color .6s;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

/* ---------- Yuqori panel: soat va sozlamalar ---------- */
.topbar {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 28px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.clock {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px var(--shadow);
  font-size: 14px;
}
.clock i { color: #f59e0b; font-size: 15px; }
:root[data-theme="dark"] .clock i { color: #a5b4fc; }
.clock-time { font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.clock-date { color: var(--muted); padding-left: 10px; border-left: 1px solid var(--line); }

.top-actions { display: flex; gap: 10px; }

.icon-btn {
  position: relative;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px var(--shadow);
  color: var(--muted);
  font-size: 17px;
  transition: color .2s, border-color .2s, transform .5s var(--ease);
}
.icon-btn:hover { color: var(--text); border-color: var(--soft); }
#openSettings:hover i { transform: rotate(90deg); }
#openSettings i { transition: transform .5s var(--ease); }
.icon-btn:focus-visible { outline: 2px solid #3b82f6; outline-offset: 2px; }
/* login saqlangan bo'lsa — kichik yashil nuqta */
.icon-btn.has-dot::after {
  content: "";
  position: absolute; top: 9px; right: 9px;
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 2px var(--card);
}
.icon-btn.small { width: 36px; height: 36px; font-size: 15px; box-shadow: none; }

/* ---------- Asosiy qism: ekran markazida ---------- */
.hub {
  flex: 1;
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 28px calc(24px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 48px;
}

.head {
  display: flex; flex-direction: column; align-items: center; gap: 20px;
  text-align: center;
  animation: rise .6s var(--ease) both;
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  font-size: 16px;
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, .6);
}
.word { font-size: 18px; font-weight: 500; letter-spacing: -.02em; }
.word b { font-weight: 700; }
.head h1 {
  font-size: clamp(28px, 3.4vw, 40px);
  font-weight: 700;
  letter-spacing: -.035em;
  line-height: 1.1;
}

/* ---------- Kartalar: kompyuterda 5 ta bir qatorda ---------- */
.panels {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
}
.card {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "icon icon"
    "name go";
  align-items: end;
  row-gap: 44px;
  padding: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 1px 2px var(--shadow), 0 2px 8px -2px var(--shadow);
  overflow: hidden;
  transition: transform .35s var(--ease), box-shadow .35s var(--ease), border-color .25s, background-color .6s;
  animation: rise .6s var(--ease) both;
  animation-delay: calc(.06s + var(--d) * .05s);
}
.card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--c), var(--c2));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .45s var(--ease);
}
.card:hover {
  transform: translateY(-4px);
  border-color: transparent;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 30%, transparent), 0 18px 36px -16px color-mix(in srgb, var(--c) 50%, transparent);
}
.card:hover::before { transform: scaleX(1); }
.card:focus-visible { outline: 2px solid var(--c); outline-offset: 3px; }
.card:active { transform: translateY(-1px) scale(.99); }

.icon {
  grid-area: icon;
  width: 52px; height: 52px;
  display: grid; place-items: center;
  border-radius: 14px;
  font-size: 21px;
  color: #fff;
  background: linear-gradient(135deg, var(--c2), var(--c));
  box-shadow: 0 8px 18px -8px var(--c), inset 0 1px 0 rgba(255,255,255,.25);
  transition: transform .4s var(--ease);
}
.card:hover .icon { transform: scale(1.06); }
.name {
  grid-area: name;
  min-height: 32px;
  display: flex;
  align-items: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
}
.go {
  grid-area: go;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--chip);
  color: var(--muted);
  font-size: 12px;
  transition: background .3s, color .3s, transform .35s var(--ease);
}
.card:hover .go { background: var(--c); color: #fff; transform: translateX(2px); }

/* Avtomatik kirish ketayotganda: strelka o'rnida aylanuvchi halqa */
.card.loading { pointer-events: none; }
.card.loading::before { transform: scaleX(1); }
.card.loading .go { background: var(--c); color: #fff; }
.card.loading .go i { display: none; }
.card.loading .go::after {
  content: "";
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.foot { text-align: center; font-size: 13px; color: var(--soft); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  grid-template-columns: minmax(0, 1fr);
  padding: 16px;
  visibility: hidden;
  transition: visibility 0s .3s;
}
.modal.open { visibility: visible; transition: none; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .3s;
}
.modal.open .modal-backdrop { opacity: 1; }
.modal-box {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  border-radius: 22px;
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -20px rgba(15, 23, 42, .45);
  display: flex; flex-direction: column; gap: 18px;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  transition: opacity .25s, transform .35s var(--ease);
}
.modal.open .modal-box { opacity: 1; transform: none; }

.modal-head { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.modal-head > div { flex: 1; min-width: 0; }
.modal-icon {
  width: 44px; height: 44px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, #3b82f6, #4f46e5);
  color: #fff; font-size: 17px;
}
.modal-head h2 { font-size: 18px; font-weight: 700; letter-spacing: -.02em; }
.modal-head p { font-size: 13px; color: var(--muted); margin-top: 2px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field-box {
  display: flex; align-items: center; gap: 4px;
  height: 50px;
  padding: 0 6px 0 16px;
  border-radius: 14px;
  background: var(--input);
  border: 1px solid var(--line);
  transition: border-color .2s, box-shadow .2s;
}
.field-box:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 4px rgba(59, 130, 246, .15); }
.field-box > i { color: var(--soft); font-size: 15px; width: 18px; text-align: center; }
.field-box input {
  flex: 1; min-width: 0;
  height: 100%;
  padding: 0 8px;
  border: 0; outline: 0; background: transparent;
  font: inherit; font-size: 16px; /* iOS kattalashtirmasligi uchun */
  color: var(--text);
}
.field-box input::placeholder { color: var(--soft); }
.field-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--soft);
  font-size: 15px;
  transition: background .2s, color .2s;
}
.field-btn:hover { background: var(--chip); color: var(--text); }

/* Mavzu tanlovi: Avto / Kunduz / Kecha */
.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 4px;
  border-radius: 14px;
  background: var(--input);
  border: 1px solid var(--line);
}
.segment button {
  height: 40px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 10px;
  font-size: 14px; font-weight: 600;
  color: var(--muted);
  transition: background .2s, color .2s, box-shadow .2s;
}
.segment button i { font-size: 13px; }
.segment button:hover { color: var(--text); }
.segment button.active {
  background: var(--card);
  color: var(--text);
  box-shadow: 0 1px 3px var(--shadow), 0 0 0 1px var(--line);
}
.segment button.active i { color: #3b82f6; }

.modal-actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1;
  height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 14px;
  font-size: 15px; font-weight: 600;
  transition: background .2s, transform .15s, box-shadow .2s;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  color: #fff;
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, .7);
}
.btn.primary:hover { box-shadow: 0 12px 24px -8px rgba(37, 99, 235, .8); }
.btn.ghost { background: var(--chip); color: var(--muted); }
.btn.ghost:hover { color: #ef4444; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 16px);
  padding: 12px 18px;
  border-radius: 12px;
  background: #0f172a;
  color: #fff;
  font-size: 14px; font-weight: 500;
  width: max-content;
  max-width: calc(100vw - 32px);
  text-align: center;
  box-shadow: 0 14px 30px -10px rgba(15, 23, 42, .45);
  opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .35s var(--ease);
  z-index: 30;
}
:root[data-theme="dark"] .toast { background: #f1f5f9; color: #0f172a; }
.toast i { color: #3b82f6; margin-right: 8px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Planshet: 3 + 2 ---------- */
@media (max-width: 960px) {
  .panels { grid-template-columns: repeat(6, 1fr); }
  .card { grid-column: span 2; }
  .card:nth-child(4) { grid-column: 2 / span 2; }
}

/* ---------- Telefon: toza ro'yxat ---------- */
@media (max-width: 640px) {
  .topbar { padding: 14px 16px 0; }
  .clock { height: 40px; padding: 0 14px; }
  .clock-date { display: none; }
  .icon-btn { width: 40px; height: 40px; font-size: 16px; }
  .icon-btn.has-dot::after { top: 7px; right: 7px; }

  .hub { padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); gap: 26px; }
  .head { gap: 14px; }
  .logo { width: 36px; height: 36px; font-size: 14px; border-radius: 11px; }
  .word { font-size: 17px; }

  .panels { grid-template-columns: 1fr; gap: 10px; }
  .card, .card:nth-child(4) {
    grid-column: auto;
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto;
    grid-template-areas: "icon name go";
    align-items: center;
    column-gap: 14px;
    row-gap: 0;
    padding: 12px 14px 12px 12px;
    border-radius: 16px;
  }
  .card::before { top: 0; bottom: 0; right: auto; width: 3px; height: auto; transform: scaleY(0); transform-origin: top; }
  .card:active::before { transform: scaleY(1); }
  .card.loading::before { transform: scaleY(1); }
  .card:hover { transform: none; }
  .card:active { transform: scale(.985); }
  .icon { width: 46px; height: 46px; border-radius: 13px; font-size: 18px; }
  .name { font-size: 16px; }
  .go { background: transparent; color: var(--soft); font-size: 13px; }

  /* modal pastdan chiqadi */
  .modal { place-items: end center; padding: 0; }
  .modal-box {
    max-width: none;
    border-radius: 24px 24px 0 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
    transform: translateY(100%);
  }
}

/* Past ekranlar (telefon yotiq holatda) */
@media (max-height: 520px) and (min-width: 641px) {
  .topbar { padding-top: 12px; }
  .hub { gap: 20px; padding-top: 8px; padding-bottom: 16px; }
  .brand, .foot { display: none; }
  .panels { grid-template-columns: repeat(5, 1fr); gap: 12px; }
  .card, .card:nth-child(4) { grid-column: auto; padding: 16px; row-gap: 28px; }
  .icon { width: 44px; height: 44px; font-size: 18px; }
  .name { font-size: 15px; }
  .go { display: none; }
}

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