:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-2: #eef3f0;
  --text: #17201c;
  --muted: #66736d;
  --border: #dde5e0;
  --accent: #0d7d62;
  --accent-dark: #075c49;
  --danger: #b13b3b;
  --shadow: 0 12px 30px rgba(30, 49, 42, 0.12);
  font-family: Inter, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

input.input-error,
select.input-error,
textarea.input-error {
  border-color: var(--danger);
  background: #fff7f7;
}

.field-error {
  display: block;
  margin-top: 5px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.3;
}

.visually-hidden-file {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-trigger {
  width: 100%;
  margin-top: 6px;
}

.file-status {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.submit-photo-preview {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.submit-photo-preview img {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: fixed;
  inset: 0 0 auto;
  z-index: 20;
  height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px 72px;
  gap: 8px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: rgba(247, 248, 250, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.country-button,
.icon-button,
.language-select,
.tab-button,
.text-button,
.back-button,
.nav-button {
  border: 0;
  background: transparent;
  color: var(--text);
}

.country-button {
  min-width: 0;
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-self: start;
  max-width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 700;
}

.country-flag {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgba(23, 32, 28, 0.08);
}

.country-button span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 20px;
}

.filter-icon-button {
  font-size: 0;
}

.filter-equalizer {
  width: 22px;
  height: 20px;
  display: grid;
  align-content: space-between;
}

.filter-line {
  position: relative;
  display: block;
  width: 22px;
  height: 2px;
  border-radius: 999px;
  background: var(--accent-dark);
}

.filter-line::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-dark);
  transform: translateY(-50%);
}

.filter-line-1::after {
  left: 3px;
}

.filter-line-2::after {
  left: 12px;
}

.filter-line-3::after {
  left: 7px;
}

.language-select {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 8px;
  font-weight: 700;
}

.main-view {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: calc(70px + env(safe-area-inset-top)) 14px calc(92px + env(safe-area-inset-bottom));
}

.screen {
  display: none;
}

.screen-active {
  display: block;
}

.search-row {
  margin: 0 0 12px;
}

.home-category-row {
  position: sticky;
  top: calc(58px + env(safe-area-inset-top));
  z-index: 15;
  margin: 0 0 10px;
  padding: 8px 0 10px;
  background: rgba(247, 248, 250, 0.96);
  backdrop-filter: blur(14px);
}

.search-input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 14px;
  color: var(--text);
  outline: none;
}

.home-category-select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 0 14px;
  color: var(--text);
  outline: none;
  font-weight: 700;
}

.category-page-head {
  margin: 0 0 10px;
}

.category-page-head h2 {
  font-size: 22px;
}

.search-input:focus,
select:focus,
input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 125, 98, 0.12);
}

.city-picker-field {
  position: relative;
  min-width: 0;
}

.city-search-input {
  padding-right: 34px;
}

.city-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 230px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 14px 36px rgba(15, 23, 42, 0.14);
}

.city-suggestion {
  width: 100%;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 10px 11px;
  color: var(--text);
  text-align: left;
}

.city-suggestion:hover,
.city-suggestion.active {
  background: #eef7f4;
}

.city-suggestion.muted {
  color: var(--muted);
  cursor: default;
}

.city-suggestion small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.detected-note {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #cfe2d9;
  border-radius: 8px;
  background: #eef7f3;
  color: var(--accent-dark);
  font-size: 14px;
}

.section-block {
  margin: 18px 0 0;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 10px;
}

h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.category-scroller {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 100%;
  align-items: start;
  max-height: calc((96px * 2) + 8px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.category-scroller::-webkit-scrollbar,
.experts-row::-webkit-scrollbar {
  display: none;
}

.category-page {
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-auto-rows: 96px;
  align-content: start;
  gap: 8px;
  padding-right: 2px;
}

.category-card {
  min-height: 0;
  height: 96px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
  text-align: left;
  overflow: hidden;
}

.category-card.active {
  border-color: var(--accent);
  background: #eff8f4;
}

.category-card img {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
}

.category-card span {
  min-width: 0;
  max-height: calc(13px * 1.18 * 3);
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.18;
  overflow-wrap: anywhere;
  word-break: normal;
}

.page-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}

.page-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #b9c6c0;
}

.page-dots span.active {
  width: 18px;
  border-radius: 999px;
  background: var(--accent);
}

.experts-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(232px, 78%);
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding-bottom: 2px;
}

.experts-grid {
  display: grid;
  gap: 10px;
}

.expert-card {
  scroll-snap-align: start;
  display: grid;
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.expert-card img {
  width: 68px;
  height: 68px;
  border-radius: 8px;
  object-fit: cover;
}

.expert-card h3,
.ad-card h3,
.ad-detail h1 {
  margin: 0;
}

.expert-card h3 {
  font-size: 15px;
}

.expert-card p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}

.small-button {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent-dark);
  padding: 7px 9px;
  font-size: 13px;
  font-weight: 700;
}

.expert-detail {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.expert-hero {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.expert-hero img {
  width: 96px;
  height: 96px;
  border-radius: 8px;
  object-fit: cover;
}

.expert-hero h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.18;
}

.expert-hero p,
.expert-detail p {
  margin: 6px 0;
  color: var(--muted);
  line-height: 1.45;
}

.expert-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.expert-meta-grid div,
.expert-contact-result {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 10px;
}

.expert-meta-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.expert-meta-grid strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

.expert-contact-result {
  margin-top: 12px;
  color: var(--accent-dark);
  font-size: 13px;
  line-height: 1.4;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.tab-button {
  height: 42px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-weight: 700;
}

.tab-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.ads-list {
  display: grid;
  gap: 10px;
}

.ad-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 9px;
  text-align: left;
}

.ad-card img {
  width: 112px;
  height: 104px;
  border-radius: 8px;
  object-fit: cover;
}

.ad-card h3 {
  padding-right: 28px;
  font-size: 16px;
  line-height: 1.25;
}

.ad-card p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.price {
  color: var(--text);
  font-weight: 800;
}

.favorite {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--danger);
  font-size: 18px;
}

.empty-state {
  border: 1px dashed #bfcac5;
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
  color: var(--muted);
  text-align: center;
}

.bottom-nav {
  position: fixed;
  inset: auto 0 0;
  z-index: 22;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  align-items: end;
  padding: 6px 14px calc(6px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 24px rgba(30, 49, 42, 0.08);
}

.nav-button {
  min-height: 38px;
  display: grid;
  place-items: center;
  gap: 2px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.nav-icon {
  width: 24px;
  height: 24px;
  display: block;
  opacity: 0.72;
  background: currentColor;
  -webkit-mask: var(--nav-icon) center / contain no-repeat;
  mask: var(--nav-icon) center / contain no-repeat;
  pointer-events: none;
}

.nav-icon-listings {
  --nav-icon: url("/assets/app-visuals/icons/nav_listings_mono.png");
}

.nav-icon-post-ad {
  --nav-icon: url("/assets/app-visuals/icons/nav_post_ad_mono.png");
}

.nav-icon-profile {
  --nav-icon: url("/assets/app-visuals/icons/nav_profile_mono.png");
}

.nav-label {
  line-height: 1.1;
}

.nav-button.active {
  color: var(--accent-dark);
}

.nav-button.active .nav-icon {
  opacity: 1;
}

.submit-nav {
  min-height: 38px;
}

.submit-nav.active {
  color: var(--accent-dark);
}

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  align-items: end;
  background: rgba(15, 24, 21, 0.34);
}

.sheet {
  max-height: calc(100vh - 70px);
  overflow: auto;
  border-radius: 14px 14px 0 0;
  background: var(--surface);
  padding: 14px 14px calc(16px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}

.compact-sheet {
  max-height: 70vh;
}

.sheet-head {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

.sheet-head h2 {
  text-align: center;
}

.text-button {
  color: var(--accent-dark);
  font-weight: 700;
}

.filter-fields,
.form-card {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
}

.checkbox-field {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 11px;
}

.checkbox-field input {
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  accent-color: var(--accent);
}

.checkbox-field strong,
.checkbox-field small {
  display: block;
}

.checkbox-field small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.primary-button {
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  padding: 12px 14px;
  font-weight: 800;
}

.publication-action {
  display: grid;
  gap: 8px;
}

.publication-action small {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.sheet-submit {
  position: sticky;
  bottom: 0;
  width: 100%;
  margin-top: 12px;
}

.sheet-list {
  display: grid;
  gap: 8px;
}

.sheet-list button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  text-align: left;
}

.country-option-label {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-list button.active {
  border-color: var(--accent);
  background: #eef7f3;
  color: var(--accent-dark);
  font-weight: 800;
}

.back-button {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-weight: 800;
}

.ad-detail,
.form-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.ad-photo-gallery {
  display: grid;
  gap: 8px;
}

.ad-photo-gallery img,
.ad-detail > img {
  width: 100%;
  max-height: 320px;
  border-radius: 8px;
  object-fit: cover;
}

.ad-photo-gallery.multi {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ad-photo-gallery.multi img {
  aspect-ratio: 1 / 1;
}

.ad-detail h1 {
  margin-top: 12px;
  font-size: 23px;
  line-height: 1.18;
}

.meta-line {
  color: var(--muted);
  font-size: 14px;
}

.text-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.text-panel h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.ad-action-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.ad-action-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.secondary-button {
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #fff;
  color: var(--accent-dark);
  padding: 11px 12px;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.telegram-login-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: #229ed9;
  color: #fff;
  padding: 13px 14px;
  text-align: center;
  font-weight: 900;
  box-shadow: 0 10px 22px rgba(34, 158, 217, 0.24);
}

#profileScreen .telegram-login-button,
#profileScreen .primary-button,
#profileScreen .secondary-button {
  width: 100%;
  margin-top: 10px;
}

#profileScreen #saveProfileButton {
  background: var(--accent);
}

.danger-button {
  border: 1px solid #e5b8b8;
  border-radius: 8px;
  background: #fff7f7;
  color: var(--danger);
  padding: 11px 12px;
  text-align: center;
  text-decoration: none;
  font-weight: 800;
}

.profile-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.profile-head p {
  margin: 5px 0 0;
  color: var(--muted);
}

.profile-id {
  color: var(--muted);
  font-size: 12px;
}

.admin-entry-button {
  width: 100%;
}

.profile-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.profile-stats div,
.profile-stat-button {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 12px;
  text-align: left;
}

.profile-stats strong,
.profile-stat-button strong {
  display: block;
  font-size: 22px;
}

.profile-stats span,
.profile-stat-button span {
  color: var(--muted);
  font-size: 13px;
}

.submit-action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.submit-action-row .secondary-button {
  text-align: center;
  text-decoration: none;
}

.my-ads-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 0 0 12px;
}

.my-ads-tabs .tab-button {
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 800;
}

.my-ads-tabs .tab-button.active {
  border-color: var(--accent);
  background: #eef7f4;
  color: var(--accent-dark);
}

.preview-block,
.my-ads-list {
  display: grid;
  gap: 10px;
}

.preview-card,
.payment-card,
.my-ad-row {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfcfb;
  padding: 12px;
}

.preview-card h3,
.payment-card h3,
.my-ad-row h3 {
  margin: 0 0 6px;
  font-size: 15px;
}

.preview-card p,
.payment-card p,
.my-ad-row p {
  margin: 5px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.my-ad-row ul {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.35;
}

.my-ad-row .action-row {
  margin-top: 10px;
}

.preview-photo-grid {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.preview-photo-grid.multi {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.preview-photo {
  width: 100%;
  max-height: 180px;
  border-radius: 8px;
  object-fit: cover;
}

.preview-photo-grid.multi .preview-photo {
  aspect-ratio: 1 / 1;
}

.profile-prompt {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(78px + env(safe-area-inset-bottom));
  z-index: 35;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid #cfe2d9;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  box-shadow: var(--shadow);
}

.profile-prompt p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.hidden {
  display: none !important;
}

@media (min-width: 760px) {
  .topbar,
  .bottom-nav {
    left: calc((100% - 760px) / 2);
    right: calc((100% - 760px) / 2);
  }

  .profile-prompt {
    left: calc((100% - 732px) / 2);
    right: calc((100% - 732px) / 2);
  }
}
