:root {
  --bg: #07080d;
  --side: #0b0d12;
  --card: rgba(22, 24, 34, 0.92);
  --card2: #14161f;
  --line: rgba(255, 255, 255, 0.06);
  --text: #f2f4f8;
  --muted: #8b93a7;
  --blue: #4d7cff;
  --blue2: #6a8bff;
  --green: #3ee07a;
  --gold: #f5d36b;
  --radius: 18px;
  font-family: "SF Pro Display", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  min-height: var(--tg-vh, 100dvh);
  background: var(--bg);
  color: var(--text);
}
body.tg {
  padding-top: calc(var(--tg-safe-area-inset-top, 0px) + var(--tg-content-safe-area-inset-top, 0px));
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
  min-height: var(--tg-vh, 100dvh);
}

.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  padding: 18px 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  padding: 8px 10px 16px;
}
.brand-icon {
  width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #3d6dff, #7a5cff);
  font-size: 14px;
}

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-sep { height: 1px; background: var(--line); margin: 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  background: transparent; border: 0; color: #c5cad6;
  padding: 10px 12px; border-radius: 12px; text-align: left;
}
.nav-item.active { background: #1a1d27; color: #fff; }
.nav-ico { width: 18px; opacity: 0.85; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 8px 6px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, #7a5cff, #4d7cff);
  display: grid; place-items: center; font-weight: 700;
}
.su-name { font-weight: 600; font-size: 0.92rem; }
.su-nick { color: var(--muted); font-size: 0.75rem; }

.stage {
  position: relative;
  padding: 22px 32px 36px;
  background:
    radial-gradient(1200px 500px at 70% -10%, rgba(90, 50, 160, 0.35), transparent 55%),
    radial-gradient(800px 400px at 20% 0%, rgba(30, 70, 160, 0.28), transparent 50%),
    linear-gradient(180deg, #0c1020 0%, #07080d 42%);
  min-height: 100vh;
  min-height: var(--tg-vh, 100dvh);
  padding-bottom: calc(36px + env(safe-area-inset-bottom, 0px));
}

.menu-btn {
  display: none;
  position: absolute; top: 12px; left: 12px;
  background: #161822; border: 1px solid var(--line);
  color: #fff; border-radius: 10px; padding: 8px 10px;
}

.page-title { margin: 0 0 12px; font-size: 1.85rem; font-weight: 700; letter-spacing: -0.03em; }

.mode-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: #12141c; border-radius: 14px; padding: 4px; max-width: 640px;
}
.mode-tab {
  border: 0; background: transparent; color: #9aa3b5;
  padding: 10px 12px; border-radius: 12px; font-weight: 600;
}
.mode-tab.active { background: #2a2e3c; color: #fff; }

.lede { color: var(--muted); margin: 10px 0 12px; }

.pack-return {
  width: min(720px, 100%);
  display: flex; align-items: center; gap: 12px;
  background: #171a24; border: 1px solid var(--line);
  border-radius: 16px; padding: 12px 14px; margin-bottom: 18px;
}
.pack-return[hidden] { display: none !important; }
.pack-ico {
  width: 40px; height: 40px; border-radius: 12px;
  background: linear-gradient(135deg, #3d6dff, #6a4dff);
  display: grid; place-items: center;
}
.pack-return strong { display: block; }
.pack-return small { color: var(--muted); }
.pack-return .chev { margin-left: auto; color: var(--muted); font-size: 22px; }

.block-label {
  text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 0.72rem; color: #7d8699; margin: 18px 0 10px;
}

.sections {
  display: flex; flex-direction: column; gap: 8px;
  max-width: 720px;
  background: rgba(16, 18, 26, 0.7);
  border: 1px solid var(--line);
  border-radius: 20px; padding: 8px;
}

.sec {
  display: grid;
  grid-template-columns: 44px 1fr auto 28px;
  gap: 12px; align-items: center;
  background: transparent; border: 0; color: inherit;
  padding: 10px 10px; border-radius: 14px; text-align: left; width: 100%;
}
.sec:hover { background: rgba(255,255,255,0.03); }
.sec.selected { background: rgba(255,255,255,0.04); }
.sec-ico {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 18px;
}
.sec-ico.sliders { background: #1f222c; }
.sec-ico.cart { background: #123d32; }
.sec-ico.gem { background: #2a2a6b; }
.sec-ico.pen { background: #5a2a1e; }
.sec-ico.moon { background: #1b1d28; }
.sec-ico.coins { background: #5a430f; }
.sec h3 { margin: 0; font-size: 0.98rem; font-weight: 650; }
.sec p { margin: 2px 0 0; color: var(--muted); font-size: 0.8rem; }
.sec-status {
  font-size: 0.72rem; color: #9aa3b5;
  background: #1c2030; border-radius: 8px; padding: 4px 8px;
}
.radio {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid #3a4154;
}
.sec.selected .radio {
  border-color: var(--blue);
  box-shadow: inset 0 0 0 4px var(--blue);
  background: #fff;
}
.cfg {
  border: 0; background: transparent; color: #9eb0ff;
  font-size: 0.8rem; padding: 0;
}

.footnote { color: #6f778a; font-size: 0.78rem; max-width: 720px; }

.qty-card {
  max-width: 720px;
  background: #14161f;
  border: 1px solid var(--line);
  border-radius: 20px; padding: 16px;
}
.qty-row {
  display: grid; grid-template-columns: 56px 1fr 56px;
  align-items: center; gap: 12px;
}
.qty-btn {
  width: 48px; height: 48px; border-radius: 50%;
  border: 0; background: #1c2030; color: #fff; font-size: 22px;
}
.qty-val { text-align: center; font-size: 2.4rem; font-weight: 700; }
.qty-presets { display: flex; gap: 8px; margin-top: 12px; }
.chip {
  border: 0; background: #1c2030; color: #c5cad6;
  border-radius: 999px; padding: 6px 14px;
}
.chip.active { background: #2a4a9c; color: #fff; }

.cta {
  margin-top: 18px; width: min(720px, 100%);
  border: 0; border-radius: 16px; padding: 16px;
  font-size: 1.05rem; font-weight: 700; color: #fff;
  background: linear-gradient(90deg, #4b6fff, #6d8bff);
  box-shadow: 0 10px 30px rgba(70, 100, 255, 0.28);
}

.search-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px;
}
.search-head h1 { margin: 0; font-size: 1.7rem; }
.search-sub { margin: 6px 0 0; color: var(--muted); }
.pill {
  border: 1px solid #2c3348; background: #151826; color: #d5dbff;
  border-radius: 999px; padding: 8px 14px;
}
.progress {
  height: 3px; background: #1b2030; border-radius: 99px;
  margin: 14px 0 18px; overflow: hidden;
}
.progress i {
  display: block; height: 100%; width: 8%;
  background: linear-gradient(90deg, #3d6dff, #7aa0ff);
  transition: width 0.3s ease;
}

.search-card {
  min-height: 420px;
  border-radius: 22px;
  background: rgba(14, 16, 24, 0.85);
  border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 40px 20px;
}
.search-card h2 { margin: 8px 0 6px; font-size: 1.7rem; }
.search-card p { margin: 0; color: var(--muted); max-width: 420px; }

.radar {
  position: relative; width: 168px; height: 168px; margin-bottom: 18px;
}
.radar-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(90, 130, 255, 0.25);
}
.radar-ring.r2 { inset: 22px; border-color: rgba(90, 130, 255, 0.45); }
.radar-sweep {
  position: absolute; inset: 10px; border-radius: 50%;
  background: conic-gradient(from 200deg, transparent 0 250deg, rgba(80,120,255,0.55) 310deg, transparent 360deg);
  animation: spin 1.4s linear infinite;
}
.radar-core {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  width: 64px; height: 64px; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #7aa0ff, #2f5bff);
  display: grid; place-items: center; font-size: 26px;
  box-shadow: 0 0 24px rgba(70,110,255,0.55);
}
@keyframes spin { to { transform: rotate(360deg); } }

.gift-card {
  position: relative;
  overflow: hidden;
  background: #14161f;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 16px;
}
.gift-card.loading > :not(.card-loader) {
  filter: blur(3px) saturate(0.6);
  opacity: 0.35;
  pointer-events: none;
  transition: opacity 0.2s, filter 0.2s;
}
.card-loader {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; text-align: center; padding: 20px;
  background: rgba(12, 14, 22, 0.55);
  animation: fadeIn 0.2s ease;
}
.card-loader.empty { background: rgba(12, 14, 22, 0.88); }
.card-loader strong { font-size: 1.05rem; }
.card-loader small { color: var(--muted); max-width: 260px; }
.loader-actions { display: flex; gap: 8px; margin-top: 10px; }
.pill.ghost { background: transparent; }
.mini-radar {
  position: relative; width: 84px; height: 84px; margin-bottom: 8px;
}
.mini-radar .r1 {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid rgba(90, 130, 255, 0.35);
}
.mini-radar .sweep {
  position: absolute; inset: 4px; border-radius: 50%;
  background: conic-gradient(from 200deg, transparent 0 250deg, rgba(80,120,255,0.6) 310deg, transparent 360deg);
  animation: spin 1.2s linear infinite;
}
.mini-radar b {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-size: 15px; font-weight: 400;
  background: radial-gradient(circle at 40% 35%, #7aa0ff, #2f5bff);
  box-shadow: 0 0 18px rgba(70,110,255,0.55);
}
.progress i.indeterminate {
  width: 35% !important;
  animation: indet 1.1s ease-in-out infinite;
}
@keyframes indet {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(310%); }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.gift-top {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 14px; align-items: start;
}
.thumb-wrap { position: relative; }
.thumb {
  width: 96px; height: 96px; border-radius: 16px; object-fit: cover;
  background: #1e2433;
}
.ext {
  position: absolute; right: 6px; bottom: 6px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #12141c; border: 0; color: #fff;
}
.g-name { margin: 0; font-size: 1.15rem; }
.g-price {
  margin: 8px 0 0; font-size: 1.7rem; font-weight: 800; color: var(--gold);
  display: flex; align-items: center; gap: 8px;
}
.g-ton { color: var(--muted); font-size: 0.95rem; font-weight: 500; }
.g-ago { color: #8b93a7; font-size: 0.8rem; margin-top: 6px; }

.attrs {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px;
  margin: 14px 0;
}
.attr {
  background: #1a1d27; border-radius: 14px; padding: 10px 12px;
}
.attr small { display: block; color: #80879a; font-size: 0.68rem; letter-spacing: 0.06em; }
.attr b { display: block; margin-top: 4px; }
.attr .r { color: var(--muted); font-size: 0.78rem; margin-top: 2px; }
.attr .fl { color: var(--gold); font-size: 0.75rem; margin-top: 4px; }

.seller-row {
  display: flex; align-items: center; gap: 10px; margin: 6px 0 14px;
}
.seller-ava {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700;
  background: #6a4dff;
}
.seller-name { font-weight: 600; }
.ls { color: var(--green); font-size: 0.82rem; margin-top: 2px; }

.nav-lot {
  display: grid; grid-template-columns: 44px 44px 1fr 44px;
  gap: 8px; align-items: center;
}
.round {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid #2a3142; background: #12141c; color: #fff;
}
.round.main { background: #fff; color: #111; border: 0; }
.write {
  border: 0; border-radius: 14px; padding: 12px;
  background: #1a1d27; color: #e8ecf4; font-weight: 700; letter-spacing: 0.04em;
}

.template-row {
  display: flex; gap: 8px; margin-top: 12px;
}
.template-row input {
  flex: 1; background: #12141c; border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; outline: none;
}
.ico-btn {
  width: 46px; border: 0; border-radius: 14px; background: #1a2744;
}

.panel {
  background: var(--card2); border: 1px solid var(--line);
  border-radius: 16px; padding: 16px; max-width: 640px; margin-bottom: 12px;
}
.panel h3 { margin: 0 0 8px; }
.panel label { display: block; margin-top: 10px; color: var(--muted); font-size: 0.85rem; }
.panel input, .panel textarea {
  width: 100%; margin-top: 6px; background: #0e1016; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; outline: none;
}
.muted { color: var(--muted); }
.credit { color: #667085; font-size: 0.78rem; margin-top: 18px; }
.stub { max-width: 640px; }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  display: grid; place-items: center; padding: 20px; z-index: 20;
}
.modal-card {
  width: min(420px, 100%); background: #161822; border-radius: 18px;
  padding: 18px; border: 1px solid var(--line);
}
.modal-card label { display: block; margin: 10px 0; color: var(--muted); font-size: 0.85rem; }
.modal-card input {
  width: 100%; margin-top: 6px; background: #0e1016; border: 1px solid var(--line);
  border-radius: 10px; padding: 10px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.btn-ghost, .btn-primary {
  border: 0; border-radius: 10px; padding: 8px 14px; font-weight: 600;
}
.btn-ghost { background: #222632; }
.btn-primary { background: var(--blue); color: #fff; }

.feed-list { display: flex; flex-direction: column; gap: 8px; }
.feed-item {
  display: flex; gap: 10px; align-items: center;
  background: #14161f; border-radius: 14px; padding: 10px;
}
.feed-item img { width: 48px; height: 48px; border-radius: 10px; object-fit: cover; }

.locked {
  min-height: var(--tg-vh, 100dvh);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 24px; gap: 6px;
}
.locked-ico { font-size: 44px; }
.locked h1 { margin: 8px 0 0; font-size: 1.5rem; }
.locked p { color: var(--muted); max-width: 340px; margin: 4px 0 0; line-height: 1.45; }

/* Адаптив: телефон → планшет → ПК. Размеры плавно растут с шириной окна. */
body.tg { overflow-x: hidden; }

.app { grid-template-columns: 1fr; }
.stage {
  min-width: 0;
  padding: clamp(12px, 2.4vw, 28px) clamp(14px, 3.2vw, 44px) calc(clamp(20px, 3vw, 40px) + env(safe-area-inset-bottom, 0px));
}
.view { width: 100%; max-width: 760px; margin: 0 auto; }
.mode-tabs, .sections, .qty-card, .cta, .pack-return, .panel, .gift-card, .search-card, .footnote, .stub {
  max-width: none;
  width: 100%;
}
.page-title { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 2rem); }
.search-head h1 { font-size: clamp(1.3rem, 1.05rem + 1.1vw, 1.85rem); }
.g-price { font-size: clamp(1.3rem, 1.05rem + 1vw, 1.8rem); }
.qty-val { font-size: clamp(1.9rem, 1.5rem + 1.4vw, 2.6rem); }
.search-card { min-height: clamp(260px, 42vh, 460px); padding: clamp(24px, 4vw, 48px) 16px; }

/* меню-шторка (телефон и планшет) */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: min(280px, 86vw);
  z-index: 20;
  transform: translateX(-105%);
  transition: transform 0.22s ease;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
}
.sidebar.open { transform: none; box-shadow: 12px 0 40px rgba(0, 0, 0, 0.45); }
.menu-btn {
  display: block;
  position: sticky;
  top: 8px;
  z-index: 5;
  margin: 0 0 10px;
}

/* телефон */
@media (max-width: 599px) {
  .sec { grid-template-columns: 40px 1fr auto 22px; gap: 8px; }
  .sec p { display: none; }
  .attrs { grid-template-columns: 1fr; }
  .gift-top { grid-template-columns: 76px 1fr; gap: 10px; }
  .thumb { width: 76px; height: 76px; }
  .nav-lot { grid-template-columns: 40px 40px 1fr 40px; gap: 6px; }
  .round { width: 40px; height: 40px; }
  .write { padding: 11px 8px; font-size: 0.92rem; }
}

/* планшет и шире */
@media (min-width: 600px) {
  .attrs { grid-template-columns: repeat(3, 1fr); }
  .gift-top { grid-template-columns: clamp(110px, 16vw, 168px) 1fr; gap: 18px; }
  .thumb { width: 100%; height: auto; aspect-ratio: 1; }
  .gift-card { padding: clamp(16px, 2.2vw, 24px); }
  .nav-lot { grid-template-columns: 48px 48px 1fr 48px; gap: 10px; }
  .round { width: 48px; height: 48px; }
  .write { padding: 14px; }
}

/* ПК: меню всегда открыто, трекер в две колонки */
@media (min-width: 900px) {
  .app { grid-template-columns: clamp(210px, 18vw, 260px) 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    height: var(--tg-vh, 100dvh);
    width: auto;
    transform: none;
    box-shadow: none;
    overflow-y: auto;
  }
  .menu-btn { display: none !important; }
  .brand { white-space: nowrap; font-size: clamp(0.88rem, 0.7rem + 0.3vw, 1rem); }
  .view { max-width: 1180px; }
  .mode-tabs { max-width: 520px; }
  #view-searching, #view-results, #view-settings, .stub { max-width: 860px; }
  .attr { padding: 12px 14px; }
}

@media (min-width: 1080px) {
  .tracker-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(300px, 28vw, 380px);
    gap: clamp(20px, 2.4vw, 36px);
    align-items: start;
  }
  .tracker-side { position: sticky; top: 16px; }
  .tracker-side .block-label:first-child { margin-top: 0; }
}

@media (min-width: 1500px) {
  .view { max-width: 1320px; }
}

@media (hover: hover) {
  .cta, .write, .round, .pill, .chip, .nav-item { transition: filter 0.15s, transform 0.15s, background 0.15s; }
  .cta:hover, .write:hover { filter: brightness(1.12); }
  .round:hover, .pill:hover, .chip:hover { filter: brightness(1.25); }
  .nav-item:hover { background: #151821; }
}
