*, *::before, *::after { box-sizing: border-box; }

:root {
  --bg: #ffffff;
  --surface: #f2f2f2;
  --surface-hover: #e8e8e8;
  --text: #000000;
  --muted: #8c8c8c;
  --tile: #3a3a3a;
  --tile-ink: #ffffff;
  --veil: 0.75;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000000;
    --surface: #161616;
    --surface-hover: #212121;
    --text: #ffffff;
    --muted: #8c8c8c;
    --tile: #3a3a3a;
    --tile-ink: #ffffff;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #000000;
  --surface: #161616;
  --surface-hover: #212121;
  --text: #ffffff;
  --muted: #8c8c8c;
  --tile: #3a3a3a;
  --tile-ink: #ffffff;
  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* Orqa fon rasmi */
body::before,
body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  height: 100lvh;
  z-index: -1;
  pointer-events: none;
}

body::before {
  background: url("bg.jpg") center / cover no-repeat;
}

body::after {
  background: var(--bg);
  opacity: var(--veil);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top, 0px) + 72px)
    calc(env(safe-area-inset-right, 0px) + 20px)
    calc(env(safe-area-inset-bottom, 0px) + 48px)
    calc(env(safe-area-inset-left, 0px) + 20px);
}

.wrap {
  width: 100%;
  max-width: 440px;
  margin: auto;
}

/* Profil */
.profile {
  text-align: center;
  margin-bottom: 36px;
}

.avatar {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: var(--surface);
  display: block;
  object-fit: cover;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.handle {
  margin: 8px 0 0;
  color: var(--muted);
}

/* Havolalar */
.links {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.link {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 10px 16px 10px 10px;
  border-radius: 18px;
  background: var(--surface);
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.tile {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--tile);
  color: var(--tile-ink);
  display: grid;
  place-items: center;
}

.ico {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.label {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.name {
  font-weight: 600;
}

.user {
  color: var(--muted);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.arrow {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--muted);
}

.link:active { transform: scale(0.98); }

@media (hover: hover) {
  .link:hover { background: var(--surface-hover); }
}

.link:focus-visible,
.theme:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
}

/* Rejim tugmasi */
.theme {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  z-index: 1;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* iPad va katta ekranlar */
@media (min-width: 768px) {
  .wrap { max-width: 480px; }
  .avatar { width: 104px; height: 104px; }
  h1 { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .link { transition: none; }
}
