:root {
  --bg: var(--tg-theme-bg-color, #f5f7fb);
  --surface: var(--tg-theme-secondary-bg-color, #ffffff);
  --surface-soft: color-mix(in srgb, var(--surface) 78%, var(--bg));
  --text: var(--tg-theme-text-color, #111827);
  --muted: var(--tg-theme-hint-color, #7a8494);
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --primary: var(--tg-theme-button-color, #2f80ed);
  --primary-text: var(--tg-theme-button-text-color, #ffffff);
  --green: #16a368;
  --blue: #3b82f6;
  --orange: #f59e0b;
  --purple: #7c3aed;
  --danger: #dc2626;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --shadow: 0 12px 32px color-mix(in srgb, var(--text) 8%, transparent);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { color: inherit; cursor: pointer; border: 0; }
.app-shell { max-width: 760px; min-height: 100vh; margin: auto; padding: 20px 16px calc(98px + env(safe-area-inset-bottom)); }
.screen { display: none; animation: appear .2s ease-out; }
.screen.active { display: block; }
@keyframes appear { from { opacity: .1; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.topbar, .screen-header, .section-heading, .form-actions, .profile-card { display: flex; align-items: center; justify-content: space-between; }
.eyebrow { margin: 0 0 5px; color: var(--primary); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 28px; letter-spacing: -.04em; }
h2 { font-size: 18px; letter-spacing: -.02em; }
.avatar-button, .profile-avatar { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: linear-gradient(135deg, #527cf4, #8e5ef4); color: #fff; font-weight: 800; }
.avatar-button { font-size: 16px; }
.search-trigger { display: flex; align-items: center; gap: 10px; width: 100%; margin: 26px 0 24px; padding: 14px 15px; border-radius: var(--radius-md); background: var(--surface); color: var(--muted); box-shadow: var(--shadow); text-align: left; }
.search-trigger > span:nth-child(2) { display: grid; gap: 2px; }
.search-trigger strong { color: var(--text); font-size: 14px; }
.search-trigger small { font-size: 11px; }
.chat-trigger { border: 1px solid color-mix(in srgb, var(--primary) 18%, transparent); }
.search-icon { color: var(--primary); font-size: 22px; line-height: 1; }
.shortcut { margin-left: auto; padding: 4px 7px; border: 1px solid var(--line); border-radius: 7px; font-size: 11px; }
.section-heading { margin: 22px 0 12px; }
.section-heading h2 { margin-bottom: 0; }
.text-button { padding: 5px 0; background: transparent; color: var(--primary); font-size: 14px; font-weight: 700; }
.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.category-card { min-height: 92px; padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); text-align: left; transition: transform .15s; }
.category-card:active { transform: scale(.97); }
.category-icon { display: block; margin-bottom: 10px; font-size: 25px; }
.category-card strong { display: block; font-size: 13px; }
.category-card small { color: var(--muted); font-size: 11px; }
.hero-card { position: relative; display: flex; justify-content: space-between; min-height: 168px; margin-top: 26px; padding: 20px; overflow: hidden; border-radius: var(--radius-lg); background: linear-gradient(135deg, #1e55b7, #7148c8); color: #fff; box-shadow: var(--shadow); }
.hero-card h2 { max-width: 235px; margin: 10px 0 8px; font-size: 21px; }
.hero-card p { max-width: 240px; margin-bottom: 16px; color: rgba(255,255,255,.78); font-size: 13px; }
.hero-pill { display: inline-flex; padding: 5px 8px; border-radius: 999px; background: rgba(255,255,255,.18); font-size: 11px; font-weight: 700; }
.hero-orb { display: grid; place-items: center; width: 96px; height: 96px; margin: 28px 4px 0 10px; border-radius: 50%; background: rgba(255,255,255,.16); font-size: 42px; transform: rotate(12deg); }
.steps-card { display: grid; gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.steps-card > div { display: flex; align-items: flex-start; gap: 12px; padding: 15px; border-bottom: 1px solid var(--line); }
.steps-card > div:last-child { border-bottom: 0; }
.steps-card > div > span { display: grid; flex: 0 0 30px; place-items: center; width: 30px; height: 30px; border-radius: 10px; background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); font-size: 12px; font-weight: 800; }
.steps-card p { display: grid; gap: 3px; margin: 0; }
.steps-card strong { font-size: 13px; }
.steps-card small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.primary-button, .ghost-button { min-height: 46px; padding: 0 18px; border-radius: var(--radius-sm); font-weight: 750; }
.primary-button { background: var(--primary); color: var(--primary-text); box-shadow: 0 8px 18px color-mix(in srgb, var(--primary) 28%, transparent); }
.hero-card .primary-button { background: #fff; color: #2353ae; box-shadow: none; }
.primary-button.compact { min-height: 38px; padding: 0 13px; font-size: 13px; }
.ghost-button { background: var(--surface-soft); color: var(--text); }
.listing-stack { display: grid; gap: 12px; }
.listing-card { padding: 13px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: 0 5px 18px color-mix(in srgb, var(--text) 4%, transparent); }
.listing-main { display: flex; gap: 12px; }
.listing-photo { display: grid; flex: 0 0 82px; place-items: center; height: 82px; border-radius: 12px; background: linear-gradient(145deg, #dce8ff, #f4dcf7); font-size: 32px; }
.listing-copy { min-width: 0; flex: 1; }
.listing-topline { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.deal-badge, .tag-badge, .badge { display: inline-flex; align-items: center; width: fit-content; padding: 5px 8px; border-radius: 999px; font-size: 10px; font-weight: 800; }
.deal-badge.sell { background: color-mix(in srgb, var(--green) 12%, transparent); color: var(--green); }
.deal-badge.buy { background: color-mix(in srgb, var(--blue) 12%, transparent); color: var(--blue); }
.tag-badge { background: color-mix(in srgb, var(--orange) 15%, transparent); color: #b36e00; }
.badge.vip { background: #fff1c7; color: #ad7200; }
.listing-card h3 { margin: 0 0 5px; overflow: hidden; font-size: 16px; text-overflow: ellipsis; white-space: nowrap; }
.listing-card p { margin: 0 0 9px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.listing-bottom { display: flex; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 10px; }
.price { font-size: 15px; font-weight: 800; }
.seller { color: var(--muted); font-size: 11px; }
.screen-header { margin-bottom: 23px; }
.screen-header h1 { font-size: 26px; }
.icon-button { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--surface); color: var(--muted); font-size: 24px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-bottom: 16px; padding: 4px; border-radius: 12px; background: var(--surface-soft); }
.segment { min-height: 36px; border-radius: 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; }
.segment.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px color-mix(in srgb, var(--text) 7%, transparent); }
.filter-row { display: flex; gap: 7px; overflow-x: auto; margin-bottom: 15px; scrollbar-width: none; }
.filter-chip { flex: 0 0 auto; padding: 8px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--muted); font-size: 12px; }
.filter-chip.active { border-color: color-mix(in srgb, var(--primary) 45%, transparent); background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary); }
.progress-track { height: 5px; margin: -8px 0 26px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
.progress-track span { display: block; width: 14%; height: 100%; border-radius: inherit; background: var(--primary); transition: width .2s; }
.form-card { padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.form-card h2 { margin-bottom: 8px; font-size: 21px; }
.form-card p { color: var(--muted); font-size: 14px; line-height: 1.45; }
.choice-grid { display: grid; gap: 10px; margin-top: 18px; }
.choice { display: flex; align-items: center; gap: 12px; min-height: 58px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); text-align: left; }
.choice.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 9%, var(--surface)); }
.choice-icon { font-size: 25px; }
.choice strong { display: block; font-size: 14px; }
.choice small { color: var(--muted); font-size: 12px; }
.field { display: grid; gap: 7px; margin-top: 18px; }
.field label { font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select { width: 100%; padding: 13px; border: 1px solid var(--line); border-radius: 12px; outline: none; background: var(--surface-soft); color: var(--text); }
.field textarea { min-height: 150px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; }
.form-actions { gap: 10px; margin-top: 22px; }
.form-actions > * { flex: 1; }
.registration-submit { width: 100%; margin-top: 22px; }
.profile-card { justify-content: flex-start; gap: 13px; padding: 18px; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow); }
.profile-avatar { flex: 0 0 52px; width: 52px; height: 52px; }
.profile-card h2 { margin: 0 0 5px; font-size: 18px; }
.profile-card p { margin: 0; color: var(--muted); font-size: 13px; }
.profile-card .badge { margin-left: auto; }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; margin: 14px 0; }
.stat-grid div { padding: 14px 10px; border-radius: 14px; background: var(--surface); text-align: center; }
.stat-grid strong, .stat-grid span { display: block; }
.stat-grid strong { margin-bottom: 4px; font-size: 16px; }
.stat-grid span { color: var(--muted); font-size: 10px; line-height: 1.2; }
.settings-card { overflow: hidden; border-radius: var(--radius-md); background: var(--surface); }
.settings-card button { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 66px; padding: 11px 14px; border-bottom: 1px solid var(--line); background: transparent; text-align: left; }
.settings-card button:last-child { border-bottom: 0; }
.settings-card button > span:nth-child(2) { flex: 1; }
.settings-card strong, .settings-card small { display: block; }
.settings-card strong { margin-bottom: 3px; font-size: 13px; }
.settings-card small { color: var(--muted); font-size: 11px; }
.row-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; background: var(--surface-soft); color: var(--primary); }
.bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 5; display: flex; justify-content: center; gap: 4px; padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 90%, transparent); backdrop-filter: blur(18px); }
.nav-item { display: grid; flex: 1; place-items: center; max-width: 100px; gap: 3px; min-height: 54px; border-radius: 13px; background: transparent; color: var(--muted); }
.nav-item span { font-size: 20px; line-height: 1; }
.nav-item small { font-size: 10px; font-weight: 700; }
.nav-item.active { background: color-mix(in srgb, var(--primary) 10%, transparent); color: var(--primary); }
.create-nav span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--primary); color: var(--primary-text); }
.toast { position: fixed; right: 16px; bottom: calc(90px + env(safe-area-inset-bottom)); left: 16px; z-index: 10; padding: 13px 15px; border-radius: 13px; background: #17212b; color: #fff; font-size: 13px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s; }
.toast.show { opacity: 1; transform: none; }
.empty-state { padding: 36px 18px; border: 1px dashed var(--line); border-radius: var(--radius-md); color: var(--muted); text-align: center; }
@media (min-width: 650px) { .category-grid { grid-template-columns: repeat(6, 1fr); } .category-card { min-height: 112px; } .listing-stack { grid-template-columns: repeat(2, 1fr); } }
