/* ─────────────────────────────────────────────────────────────
   NFT Gift do'koni — retro, xira, ko'zni charchatmaydigan.
   Ranglar: eskirgan qog'oz + chang bosgan ko'k-yashil + oxra + g'isht.
   ───────────────────────────────────────────────────────────── */

:root {
  --font-display: "Bricolage Grotesque", "Golos Text", system-ui, sans-serif;
  --font-body: "Golos Text", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --gap: 10px;
  --pad: 14px;
  --safe-top: calc(env(safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px) + var(--tg-safe-area-inset-top, 0px));
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2,.7,.2,1);
}

html[data-theme="light"] {
  --bg: #f1eff8;
  --surface: #faf9fd;
  --surface-2: #e7e3f2;
  --ink: #2d2b3a;
  --muted: #6e6b80;
  --line: #d9d4e6;
  --line-strong: #bdb6cf;
  --accent: #5f63a8;
  --accent-ink: #faf9fd;
  --accent-soft: #e1def2;
  --ochre: #c9a13f;
  --ochre-ink: #2d2b3a;
  --brick: #a85a48;
  --brick-soft: #f0dcd6;
  --moss: #6f8a5e;
  --moss-soft: #e0e8d8;
  --balance-bg: #e4e0f3;
  --balance-ink: #3c3a5e;
  --shadow: 0 8px 24px rgba(45, 43, 58, .12);
  --grain-opacity: .035;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #1e2321;
  --surface: #262c2a;
  --surface-2: #2f3634;
  --ink: #dad6c8;
  --muted: #9b9e95;
  --line: #3c4441;
  --line-strong: #4f5955;
  --accent: #6fb0ab;
  --accent-ink: #1e2321;
  --accent-soft: #2c3f3d;
  --ochre: #d3b25e;
  --ochre-ink: #1e2321;
  --brick: #c7776a;
  --brick-soft: #3b2c29;
  --moss: #8da87b;
  --moss-soft: #2b3628;
  --balance-bg: #2c3f3d;
  --balance-ink: #d9efec;
  --shadow: 0 10px 28px rgba(0, 0, 0, .45);
  --grain-opacity: .07;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  min-height: 100dvh;
  overscroll-behavior-y: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
body::selection, ::selection { background: var(--accent-soft); }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic-sm { width: 18px; height: 18px; }
.ic-xl { width: 40px; height: 40px; stroke-width: 1.5; }
.ic-trail { margin-left: auto; color: var(--muted); }

/* eskirgan qog'oz teksturasi — juda yengil */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: var(--grain-opacity);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .6 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-size: 160px 160px;
}

[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
button, input, select { -webkit-appearance: none; appearance: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ───────────── to'liq ekran holatlar ───────────── */
.screen { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; padding: calc(var(--safe-top) + 32px) 24px calc(var(--safe-bottom) + 32px); }
.screen-center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; }
.boot-mark, .gate-mark {
  width: 76px; height: 76px; border-radius: 22px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line); color: var(--accent); margin-bottom: 18px;
}
.gate-mark-warn { color: var(--brick); }
.boot-mark { animation: breathe 1.6s var(--ease) infinite; }
@keyframes breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.boot-text { color: var(--muted); margin: 0; }
.gate-title { font-family: var(--font-display); font-size: 24px; font-weight: 600; line-height: 1.15; margin: 0 0 10px; max-width: 22ch; }
.gate-text { color: var(--muted); margin: 0 0 22px; max-width: 34ch; }
.gate-text b { color: var(--ink); }
.noscript { padding: 40px 20px; text-align: center; }

/* ───────────── tugmalar ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background-color .15s, border-color .15s, transform .08s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-danger { background: var(--brick); color: #f6f0ea; }
.btn-wide { width: 100%; max-width: 360px; }
.btn-block { width: 100%; }
.iconbtn {
  width: 42px; height: 42px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer;
}
.iconbtn:active { background: var(--surface-2); }
.linkbtn { background: none; border: 0; padding: 6px 4px; color: var(--accent); font-weight: 600; cursor: pointer; }

/* ───────────── ilova ───────────── */
#app { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(var(--safe-top) + 10px) var(--pad) 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.balance {
  display: inline-flex; align-items: center; gap: 6px; height: 42px; padding: 0 12px 0 10px;
  border-radius: var(--radius-sm); background: var(--balance-bg); border: 1px solid transparent;
  color: var(--balance-ink); min-width: 0;
}
.balance-value { font-family: var(--font-display); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.theme-moon { display: none; }
html[data-theme="dark"] .theme-moon { display: block; }
html[data-theme="dark"] .theme-sun { display: none; }

main { flex: 1; padding: 0 var(--pad) calc(var(--safe-bottom) + 28px); }
.view { padding-top: 14px; }

.headrow { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.page-title { font-family: var(--font-display); font-size: 26px; font-weight: 700; line-height: 1.1; margin: 0; letter-spacing: -.01em; }
.count { color: var(--muted); font-size: 14px; }

/* ───────────── filtrlar ───────────── */
.filters { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; margin: 0 calc(var(--pad) * -1); padding-left: var(--pad); padding-right: var(--pad); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; flex: none;
  border-radius: var(--radius-pill); border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color .12s, border-color .12s, color .12s;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .chip-count { color: inherit; opacity: .7; font-size: 12px; }
.filters-row { display: flex; gap: 8px; align-items: center; }
.filters-row-tight { justify-content: space-between; }
.search {
  flex: 1; display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.search:focus-within { border-color: var(--accent); color: var(--accent); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; color: var(--ink); font-size: 15px; outline: none; }
.search input::placeholder { color: var(--muted); }
.select { position: relative; display: flex; align-items: center; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.select select { height: 100%; padding: 0 30px 0 12px; border: 0; background: transparent; color: var(--ink); font-size: 14px; font-weight: 500; outline: none; max-width: 150px; }
.select .ic { position: absolute; right: 8px; pointer-events: none; }

/* ───────────── gift kartalari ───────────── */
.grid.is-loading { opacity: .55; transition: opacity .15s; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.card {
  display: flex; flex-direction: column; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); overflow: hidden; min-width: 0;
}
.card-media {
  position: relative; aspect-ratio: 1 / 1; background: var(--surface-2); display: grid; place-items: center;
  cursor: pointer; border: 0; padding: 0; width: 100%;
}
.card-media img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 8%; }
.card-media .ph { width: 40%; height: 40%; color: var(--muted); opacity: .55; }
.card-body { padding: 10px 10px 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.card-name { font-family: var(--font-display); font-weight: 600; font-size: 15px; line-height: 1.2; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-sub { color: var(--muted); font-size: 12.5px; margin: 0; }
.tag {
  align-self: flex-start; margin: 6px 0 8px; padding: 4px 9px; border-radius: 4px;
  background: var(--ochre); color: var(--ochre-ink); font-family: var(--font-display); font-weight: 700; font-size: 14px;
  font-variant-numeric: tabular-nums; transform: rotate(-2deg); transform-origin: left center; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tag small { font-weight: 600; font-size: 11px; opacity: .8; margin-left: 4px; }
.card .btn { margin-top: auto; min-height: 40px; padding: 0 10px; font-size: 14px; }

.pager { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; margin-top: 16px; }
.pager .btn { min-height: 42px; padding: 0 12px; font-size: 14px; }
.pager .btn:first-child { justify-self: start; }
.pager .btn:last-child { justify-self: end; }
.pager-info { font-family: var(--font-display); font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; }
.ic-flip { transform: scaleX(-1); }
.empty { text-align: center; padding: 40px 12px; color: var(--muted); }
.empty-title { font-family: var(--font-display); font-size: 18px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.empty-text { margin: 0; }

/* ───────────── tafsilot ───────────── */
.detail-top { display: flex; align-items: center; margin-bottom: 10px; }
.backbtn { display: inline-flex; align-items: center; gap: 4px; height: 40px; padding: 0 12px 0 6px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); font-weight: 600; cursor: pointer; }
.hero {
  position: relative; aspect-ratio: 1 / 1; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface-2); display: grid; place-items: center; overflow: hidden; margin-bottom: 14px;
}
.hero img { width: 100%; height: 100%; object-fit: contain; padding: 6%; display: block; }
.hero .anim { position: absolute; inset: 0; padding: 6%; }
.hero .anim svg { width: 100% !important; height: 100% !important; }
.detail-name { font-family: var(--font-display); font-size: 28px; font-weight: 700; line-height: 1.05; margin: 0 0 4px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.detail-sub { color: var(--muted); margin: 0 0 14px; }
.detail-sub a { color: var(--accent); text-decoration: none; font-weight: 500; }
.pricebox { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); margin-bottom: 14px; }
.pricebox .label { color: var(--muted); }
.pricebox .amount { font-family: var(--font-display); font-weight: 700; font-size: 22px; font-variant-numeric: tabular-nums; text-align: right; }
.pricebox .amount small { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.panel { padding: 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); margin-bottom: 12px; }
.panel-warn { background: var(--brick-soft); border-color: color-mix(in srgb, var(--brick) 45%, var(--line)); }
.panel-warn .panel-title { color: var(--brick); }
.panel-ok { background: var(--moss-soft); border-color: color-mix(in srgb, var(--moss) 45%, var(--line)); }
.panel-title { display: flex; align-items: center; gap: 8px; font-weight: 600; margin: 0 0 6px; }
.panel p { margin: 0 0 10px; }
.panel p:last-child { margin-bottom: 0; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field label { font-weight: 600; font-size: 14px; }
.field .hint { color: var(--muted); font-size: 12.5px; }
.input-row { display: flex; gap: 8px; }
.input { flex: 1; min-width: 0; height: 46px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 16px; outline: none; }
.input:focus { border-color: var(--accent); }
.input.invalid { border-color: var(--brick); }
.field .error { color: var(--brick); font-size: 13px; }
.small-btn { height: 46px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600; cursor: pointer; white-space: nowrap; }

/* ───────────── buyurtmalar ───────────── */
.orders { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.order { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; padding: 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); }
.order-id { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; padding-top: 2px; }
.order-name { font-family: var(--font-display); font-weight: 600; margin: 0; overflow-wrap: anywhere; }
.order-meta { grid-column: 2; display: flex; flex-wrap: wrap; gap: 2px 12px; color: var(--muted); font-size: 13px; }
.order-price { text-align: right; font-family: var(--font-display); font-weight: 700; font-variant-numeric: tabular-nums; }
.order-status { grid-column: 3; text-align: right; font-size: 12.5px; font-weight: 600; padding: 2px 8px; border-radius: 4px; justify-self: end; }
.status-done { background: var(--moss-soft); color: var(--moss); }
.status-wait { background: var(--accent-soft); color: var(--accent); }
.status-bad { background: var(--brick-soft); color: var(--brick); }
.order-note { grid-column: 1 / -1; font-size: 13px; color: var(--muted); }

/* ───────────── holat sahifasi ───────────── */
.status-card { text-align: center; padding: 28px 16px 20px; }
.status-mark { width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; margin: 0 auto 16px; background: var(--surface); border: 1px solid var(--line); color: var(--accent); }
.status-mark.ok { color: var(--moss); }
.status-mark.bad { color: var(--brick); }
.status-mark.spin .ic { animation: spin 1.4s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-title { font-family: var(--font-display); font-size: 24px; font-weight: 700; margin: 0 0 6px; }
.status-text { color: var(--muted); margin: 0 0 18px; }
.steps { display: flex; flex-direction: column; gap: 8px; text-align: left; margin: 0 auto 22px; max-width: 360px; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--surface); color: var(--muted); }
.step .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); flex: none; }
.step.active { color: var(--ink); border-color: var(--accent); }
.step.active .dot { background: var(--accent); }
.step.done { color: var(--ink); }
.step.done .dot { background: var(--moss); }
.status-actions { display: flex; flex-direction: column; gap: 8px; max-width: 360px; margin: 0 auto; }

/* ───────────── menyu ───────────── */
.backdrop { position: fixed; inset: 0; z-index: 40; background: rgba(20, 24, 22, .45); opacity: 0; transition: opacity .2s; }
.backdrop.show { opacity: 1; }
.drawer {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 50; width: min(84vw, 330px);
  background: var(--surface); border-right: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(-104%); transition: transform .24s var(--ease);
  display: flex; flex-direction: column; padding: calc(var(--safe-top) + 12px) 12px calc(var(--safe-bottom) + 12px);
}
.drawer.open { transform: translateX(0); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.drawer-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.drawer-name { font-family: var(--font-display); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-id { color: var(--muted); font-size: 12.5px; }
.drawer-balance { display: flex; align-items: center; justify-content: space-between; padding: 12px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line); margin-bottom: 10px; color: var(--muted); }
.drawer-balance strong { color: var(--ink); font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.drawer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.drawer-item { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 10px; border-radius: var(--radius-sm); border: 0; background: transparent; font-weight: 500; cursor: pointer; text-align: left; }
.drawer-item:active { background: var(--surface-2); }
.drawer-section { display: flex; flex-direction: column; min-height: 0; flex: 1; margin-top: 10px; border-top: 1px solid var(--line); padding-top: 10px; }
.drawer-section-title { font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--muted); padding: 0 10px 6px; }
.drawer-cols { overflow-y: auto; min-height: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.drawer-col { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: var(--radius-sm); border: 0; background: transparent; cursor: pointer; text-align: left; font-weight: 500; }
.drawer-col:active { background: var(--surface-2); }
.drawer-col .mark { width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--line-strong); display: grid; place-items: center; flex: none; color: var(--accent-ink); }
.drawer-col .mark .ic { width: 14px; height: 14px; stroke-width: 2.2; visibility: hidden; }
.drawer-col[aria-pressed="true"] .mark { background: var(--accent); border-color: var(--accent); }
.drawer-col[aria-pressed="true"] .mark .ic { visibility: visible; }
.drawer-col .n { margin-left: auto; color: var(--muted); font-size: 12.5px; }
.drawer-foot { margin-top: 10px; color: var(--muted); font-size: 12.5px; padding: 8px 4px 0; line-height: 1.5; }

/* ───────────── pastki oyna ───────────── */
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: var(--surface); border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 10px 16px calc(var(--safe-bottom) + 16px); box-shadow: var(--shadow);
  transform: translateY(105%); transition: transform .24s var(--ease);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 12px; }
.sheet-title { font-family: var(--font-display); font-size: 20px; font-weight: 700; margin: 0 0 12px; }
.summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0 0 12px; }
.summary dt { color: var(--muted); }
.summary dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }
.summary dd.big { font-family: var(--font-display); font-size: 18px; font-variant-numeric: tabular-nums; }
.sheet-note { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 20px); transform: translateX(-50%);
  z-index: 60; max-width: calc(100% - 32px); padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: var(--bg); font-weight: 500; box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  main { max-width: 640px; margin: 0 auto; width: 100%; }
  .topbar { padding-left: max(var(--pad), calc((100% - 640px) / 2 + var(--pad))); padding-right: max(var(--pad), calc((100% - 640px) / 2 + var(--pad))); }
  .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

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